1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-18 03:30:45 +00:00

rocm-related: move all relevant ROCm derivations to rocmPackages

clr: init at 5.7.0 (hipamd, opencl, rocclr merged)
This commit is contained in:
Madoura 2023-10-01 20:05:32 -05:00
parent 12e7fc6923
commit 575ce47fa4
No known key found for this signature in database
GPG key ID: 1B9BB76A2B71922D
62 changed files with 518 additions and 1399 deletions

View file

@ -1,129 +0,0 @@
diff --git a/bin/hipcc.pl b/bin/hipcc.pl
index da9559b..7aaa540 100755
--- a/bin/hipcc.pl
+++ b/bin/hipcc.pl
@@ -185,7 +185,7 @@ if ($HIP_PLATFORM eq "amd") {
chomp($HIP_CLANG_TARGET);
if (! defined $HIP_CLANG_INCLUDE_PATH) {
- $HIP_CLANG_INCLUDE_PATH = abs_path("$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION/include");
+ $HIP_CLANG_INCLUDE_PATH = abs_path("@clang@/resource-root/include");
}
if (! defined $HIP_INCLUDE_PATH) {
$HIP_INCLUDE_PATH = "$HIP_PATH/include";
@@ -206,8 +206,8 @@ if ($HIP_PLATFORM eq "amd") {
print ("HIP_CLANG_TARGET=$HIP_CLANG_TARGET\n");
}
- $HIPCXXFLAGS .= " -isystem \"$HIP_CLANG_INCLUDE_PATH/..\"";
- $HIPCFLAGS .= " -isystem \"$HIP_CLANG_INCLUDE_PATH/..\"";
+ $HIPCXXFLAGS .= " -isystem \"$HIP_CLANG_INCLUDE_PATH\"";
+ $HIPCFLAGS .= " -isystem \"$HIP_CLANG_INCLUDE_PATH\"";
$HIPLDFLAGS .= " -L\"$HIP_LIB_PATH\"";
if ($isWindows) {
$HIPLDFLAGS .= " -lamdhip64";
@@ -625,7 +625,7 @@ if($HIP_PLATFORM eq "amd"){
$targetsStr = $ENV{HCC_AMDGPU_TARGET};
} elsif (not $isWindows) {
# Else try using rocm_agent_enumerator
- $ROCM_AGENT_ENUM = "${ROCM_PATH}/bin/rocm_agent_enumerator";
+ $ROCM_AGENT_ENUM = "@rocminfo@/bin/rocm_agent_enumerator";
$targetsStr = `${ROCM_AGENT_ENUM} -t GPU`;
$targetsStr =~ s/\n/,/g;
}
@@ -724,16 +724,16 @@ if ($HIP_PLATFORM eq "amd") {
if (not $isWindows and not $compileOnly) {
if ($linkType eq 0) {
- $toolArgs = " -L$HIP_LIB_PATH -lamdhip64 -L$ROCM_PATH/lib -lhsa-runtime64 -ldl -lnuma " . ${toolArgs};
+ $toolArgs = " -L$HIP_LIB_PATH -lamdhip64 -L@rocm_runtime@/lib -lhsa-runtime64 -ldl -lnuma " . ${toolArgs};
} else {
$toolArgs = ${toolArgs} . " -Wl,-rpath=$HIP_LIB_PATH:$ROCM_PATH/lib -lamdhip64 ";
}
# To support __fp16 and _Float16, explicitly link with compiler-rt
- $HIP_CLANG_BUILTIN_LIB="$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION/lib/$HIP_CLANG_TARGET/libclang_rt.builtins.a";
+ $HIP_CLANG_BUILTIN_LIB="@clang@/resource-root/lib/$HIP_CLANG_TARGET/libclang_rt.builtins.a";
if (-e $HIP_CLANG_BUILTIN_LIB) {
- $toolArgs .= " -L$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION/lib/$HIP_CLANG_TARGET -lclang_rt.builtins "
+ $toolArgs .= " -L@clang@/resource-root/lib/$HIP_CLANG_TARGET -lclang_rt.builtins "
} else {
- $toolArgs .= " -L$HIP_CLANG_PATH/../lib/clang/$HIP_CLANG_VERSION/lib/linux -lclang_rt.builtins-x86_64 "
+ $toolArgs .= " -L@clang@/resource-root/lib/linux -lclang_rt.builtins-x86_64 "
}
}
}
diff --git a/bin/hipconfig.pl b/bin/hipconfig.pl
index 5ddb8e9..6a76a2e 100755
--- a/bin/hipconfig.pl
+++ b/bin/hipconfig.pl
@@ -77,7 +77,7 @@ if ($HIP_COMPILER eq "clang") {
$CPP_CONFIG = " -D__HIP_PLATFORM_HCC__= -D__HIP_PLATFORM_AMD__=";
$HIP_PATH_INCLUDE = $HIP_PATH."/include";
- $HIP_CLANG_INCLUDE = $HIP_CLANG_PATH."/../lib/clang/".$HIP_CLANG_VERSION;
+ $HIP_CLANG_INCLUDE = "@clang@/resource-root/include";
if($isWindows) {
$CPP_CONFIG .= " -I\"$HIP_PATH_INCLUDE\" -I\"$HIP_CLANG_INCLUDE\"";
} else {
@@ -168,7 +168,7 @@ if (!$printed or $p_full) {
print ("HIP_CLANG_PATH : $HIP_CLANG_PATH\n");
if ($isWindows) {
system("\"$HIP_CLANG_PATH/clang++\" --version");
- system("\"$HIP_CLANG_PATH/llc\" --version");
+ system("\"@llvm@/bin/llc\" --version");
printf("hip-clang-cxxflags : ");
$win_output = `perl \"$HIP_PATH/bin/hipcc\" --cxxflags`;
printf("$win_output \n");
@@ -177,7 +177,7 @@ if (!$printed or $p_full) {
printf("$win_output \n");
} else {
system("$HIP_CLANG_PATH/clang++ --version");
- system("$HIP_CLANG_PATH/llc --version");
+ system("@llvm@/bin/llc --version");
print ("hip-clang-cxxflags : ");
system("$HIP_PATH/bin/hipcc --cxxflags");
printf("\n");
@@ -219,8 +219,8 @@ if (!$printed or $p_full) {
system ("uname -a");
}
- if (-e "/usr/bin/lsb_release") {
- system ("/usr/bin/lsb_release -a");
+ if (-e "@lsb_release@/bin/lsb_release") {
+ system ("@lsb_release@/bin/lsb_release -a");
}
print "\n" ;
diff --git a/hip-lang-config.cmake.in b/hip-lang-config.cmake.in
index 9250a68..f6e27b7 100644
--- a/hip-lang-config.cmake.in
+++ b/hip-lang-config.cmake.in
@@ -71,8 +71,8 @@ get_filename_component(_IMPORT_PREFIX "${_DIR}/../../../" REALPATH)
#need _IMPORT_PREFIX to be set #FILE_REORG_BACKWARD_COMPATIBILITY
-file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS "${_IMPORT_PREFIX}/../llvm/lib/clang/*/include")
-file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS_REORG "${_IMPORT_PREFIX}/llvm/lib/clang/*/include")
+file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS "@clang@/resource-root/include")
+file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS_REORG "@clang@/resource-root/include")
find_path(HIP_CLANG_INCLUDE_PATH __clang_cuda_math.h
HINTS ${HIP_CLANG_INCLUDE_SEARCH_PATHS}
${HIP_CLANG_INCLUDE_SEARCH_PATHS_REORG}
@@ -89,7 +89,7 @@ find_path(HSA_HEADER hsa/hsa.h
PATHS
"${_IMPORT_PREFIX}/../include" #FILE_REORG_BACKWARD_COMPATIBILITY
"${_IMPORT_PREFIX}/include"
- "${ROCM_PATH}/include"
+ "@rocm_runtime@/include"
)
if (NOT HSA_HEADER)
@@ -97,7 +97,7 @@ if (NOT HSA_HEADER)
endif()
get_filename_component(HIP_COMPILER_INSTALL_PATH ${CMAKE_HIP_COMPILER} DIRECTORY)
-file(GLOB HIP_CLANGRT_LIB_SEARCH_PATHS "${HIP_COMPILER_INSTALL_PATH}/../lib/clang/*/lib/*")
+file(GLOB HIP_CLANGRT_LIB_SEARCH_PATHS "@clang@/resource-root/lib/*")
find_library(CLANGRT_BUILTINS
NAMES
clang_rt.builtins

View file

@ -1,62 +0,0 @@
diff --git a/hip-config.cmake.in b/hip-config.cmake.in
index 89d1224..dc9ba05 100755
--- a/hip-config.cmake.in
+++ b/hip-config.cmake.in
@@ -142,7 +142,7 @@ if(HIP_COMPILER STREQUAL "clang")
file(TO_CMAKE_PATH "${HIP_PATH}/../lc" HIP_CLANG_ROOT)
endif()
else()
- set(HIP_CLANG_ROOT "${ROCM_PATH}/llvm")
+ set(HIP_CLANG_ROOT "@clang@")
endif()
if(NOT HIP_CXX_COMPILER)
set(HIP_CXX_COMPILER ${CMAKE_CXX_COMPILER})
@@ -171,7 +171,7 @@ if(HIP_COMPILER STREQUAL "clang")
get_filename_component(_HIP_CLANG_BIN_PATH "${_HIP_CLANG_REAL_PATH}" DIRECTORY)
get_filename_component(HIP_CLANG_ROOT "${_HIP_CLANG_BIN_PATH}" DIRECTORY)
endif()
- file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS ${HIP_CLANG_ROOT}/lib/clang/*/include)
+ file(GLOB HIP_CLANG_INCLUDE_SEARCH_PATHS "@clang@/resource-root/include")
find_path(HIP_CLANG_INCLUDE_PATH stddef.h
HINTS
${HIP_CLANG_INCLUDE_SEARCH_PATHS}
@@ -209,7 +209,7 @@ if(NOT WIN32)
"${_IMPORT_PREFIX}/include"
#FILE_REORG_BACKWARD_COMPATIBILITY ${_IMPORT_PREFIX}/../include is for Backward compatibility
"${_IMPORT_PREFIX}/../include"
- ${ROCM_PATH}/include
+ "@rocm_runtime@/include"
)
if (NOT HSA_HEADER)
@@ -291,7 +291,7 @@ if(HIP_COMPILER STREQUAL "clang")
endif()
endif()
- file(GLOB HIP_CLANGRT_LIB_SEARCH_PATHS "${HIP_CLANG_ROOT}/lib/clang/*/lib/*")
+ file(GLOB HIP_CLANGRT_LIB_SEARCH_PATHS "@clang@/resource-root/lib/*")
find_library(CLANGRT_BUILTINS
NAMES
clang_rt.builtins
diff --git a/src/hip_embed_pch.sh b/src/hip_embed_pch.sh
index 0a1572b..2feb19a 100755
--- a/src/hip_embed_pch.sh
+++ b/src/hip_embed_pch.sh
@@ -149,7 +149,7 @@ EOF
$LLVM_DIR/bin/clang -cc1 -O3 -emit-pch -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-linux-gnu -fcuda-is-device -std=c++17 -fgnuc-version=4.2.1 -o $tmp/hip_wave64.pch -x hip-cpp-output - <$tmp/pch_wave64.cui &&
- $LLVM_DIR/bin/llvm-mc -o hip_pch.o $tmp/hip_pch.mcin --filetype=obj &&
+ @llvm@/bin/llvm-mc -o hip_pch.o $tmp/hip_pch.mcin --filetype=obj &&
rm -rf $tmp
}
@@ -195,7 +195,7 @@ EOF
set -x
$LLVM_DIR/bin/clang -O3 --rocm-path=$HIP_INC_DIR/.. -std=c++14 -nogpulib --hip-version=4.4 -isystem $HIP_INC_DIR -isystem $HIP_BUILD_INC_DIR -isystem $HIP_AMD_INC_DIR --cuda-device-only -D__HIPCC_RTC__ -x hip $tmp/hipRTC_header.h -E -o $tmp/hiprtc &&
cat $macroFile >> $tmp/hiprtc &&
- $LLVM_DIR/bin/llvm-mc -o $tmp/hiprtc_header.o $tmp/hipRTC_header.mcin --filetype=obj &&
+ @llvm@/bin/llvm-mc -o $tmp/hiprtc_header.o $tmp/hipRTC_header.mcin --filetype=obj &&
$LLVM_DIR/bin/clang $tmp/hiprtc_header.o -o $rtc_shared_lib_out -shared &&
$LLVM_DIR/bin/clang -O3 --rocm-path=$HIP_INC_DIR/.. -std=c++14 -nogpulib -nogpuinc -emit-llvm -c -o $tmp/tmp.bc --cuda-device-only -D__HIPCC_RTC__ --offload-arch=gfx906 -x hip-cpp-output $tmp/hiprtc &&
rm -rf $tmp

View file

@ -1,197 +0,0 @@
{ lib
, stdenv
, fetchFromGitHub
, fetchpatch
, rocmUpdateScript
, substituteAll
, makeWrapper
, hip-common
, hipcc
, rocclr
, roctracer
, cmake
, perl
, llvm
, rocminfo
, rocm-thunk
, rocm-comgr
, rocm-device-libs
, rocm-runtime
, rocm-opencl-runtime
, cudatoolkit
, numactl
, libxml2
, libX11
, libglvnd
, doxygen
, graphviz
, fontconfig
, python3Packages
, buildDocs ? true
, buildTests ? false
, useNVIDIA ? false
}:
let
hipPlatform = if useNVIDIA then "nvidia" else "amd";
wrapperArgs = [
"--prefix PATH : $out/bin"
"--prefix LD_LIBRARY_PATH : ${rocm-runtime}"
"--set HIP_PLATFORM ${hipPlatform}"
"--set HIP_PATH $out"
"--set HIP_CLANG_PATH ${stdenv.cc}/bin"
"--set DEVICE_LIB_PATH ${rocm-device-libs}/amdgcn/bitcode"
"--set HSA_PATH ${rocm-runtime}"
"--set ROCM_PATH $out"
] ++ lib.optionals useNVIDIA [
"--set CUDA_PATH ${cudatoolkit}"
];
in stdenv.mkDerivation (finalAttrs: {
pname = "hip-${hipPlatform}";
version = "5.4.4";
outputs = [
"out"
] ++ lib.optionals buildDocs [
"doc"
];
src = fetchFromGitHub {
owner = "ROCm-Developer-Tools";
repo = "hipamd";
rev = "rocm-${finalAttrs.version}";
hash = "sha256-FcuylhkG7HqLYXH1J6ND6IVEIbDzHp7h7jg2ZZ4XoFM=";
};
patches = [
(substituteAll {
src = ./0000-fixup-paths.patch;
inherit llvm;
clang = stdenv.cc;
rocm_runtime = rocm-runtime;
})
# https://github.com/ROCm-Developer-Tools/hipamd/commit/be33ec55acc104a59d01df5912261d007c7f3ee9
(fetchpatch {
url = "https://github.com/ROCm-Developer-Tools/hipamd/commit/be33ec55acc104a59d01df5912261d007c7f3ee9.patch";
hash = "sha256-eTC4mUIN1FwRce1n38uDOlITFL/vpcOhvnaZTo5R7lo=";
})
];
nativeBuildInputs = [
makeWrapper
cmake
perl
python3Packages.python
python3Packages.cppheaderparser
] ++ lib.optionals buildDocs [
doxygen
graphviz
fontconfig
];
buildInputs = [
numactl
libxml2
libX11
libglvnd
];
propagatedBuildInputs = [
stdenv.cc
llvm
rocminfo
rocm-thunk
rocm-comgr
rocm-device-libs
rocm-runtime
rocm-opencl-runtime
] ++ lib.optionals useNVIDIA [
cudatoolkit
];
cmakeFlags = [
"-DROCM_PATH=${rocminfo}"
"-DHIP_PLATFORM=${hipPlatform}"
"-DHIP_COMMON_DIR=${hip-common}"
"-DHIPCC_BIN_DIR=${hipcc}/bin"
"-DHIP_LLVM_ROOT=${stdenv.cc}"
"-DROCCLR_PATH=${rocclr}"
"-DAMD_OPENCL_PATH=${rocm-opencl-runtime.src}"
"-DPROF_API_HEADER_PATH=${roctracer.src}/inc/ext"
# Temporarily set variables to work around upstream CMakeLists issue
# Can be removed once https://github.com/ROCm-Developer-Tools/hipamd/issues/55 is fixed
"-DCMAKE_INSTALL_BINDIR=bin"
"-DCMAKE_INSTALL_INCLUDEDIR=include"
"-DCMAKE_INSTALL_LIBDIR=lib"
] ++ lib.optionals buildTests [
"-DHIP_CATCH_TEST=1"
];
postPatch = ''
export HIP_CLANG_PATH=${stdenv.cc}/bin
patchShebangs src
'' + lib.optionalString buildDocs ''
export HOME=$(mktemp -d)
export FONTCONFIG_FILE=${fontconfig.out}/etc/fonts/fonts.conf
'';
doCheck = buildTests;
checkTarget = "build_tests";
preCheck = lib.optionalString buildTests ''
export ROCM_PATH=$PWD
export DEVICE_LIB_PATH=${rocm-device-libs}/amdgcn/bitcode
patchShebangs bin
'';
postInstall = ''
patchShebangs $out/bin
cp -a $out/bin/hipcc $out/bin/hipcc-pl
cp -a $out/bin/hipconfig $out/bin/hipconfig-pl
wrapProgram $out/bin/hipcc --set HIP_USE_PERL_SCRIPTS 0
wrapProgram $out/bin/hipconfig --set HIP_USE_PERL_SCRIPTS 0
wrapProgram $out/bin/hipcc.bin ${lib.concatStringsSep " " wrapperArgs}
wrapProgram $out/bin/hipconfig.bin ${lib.concatStringsSep " " wrapperArgs}
wrapProgram $out/bin/hipcc-pl --set HIP_USE_PERL_SCRIPTS 1
wrapProgram $out/bin/hipconfig-pl --set HIP_USE_PERL_SCRIPTS 1
wrapProgram $out/bin/hipcc.pl ${lib.concatStringsSep " " wrapperArgs}
wrapProgram $out/bin/hipconfig.pl ${lib.concatStringsSep " " wrapperArgs}
'';
passthru = {
# All known and valid general GPU targets
# We cannot use this for each ROCm library, as each defines their own supported targets
# See: https://github.com/RadeonOpenCompute/ROCm/blob/77cbac4abab13046ee93d8b5bf410684caf91145/README.md#library-target-matrix
gpuTargets = lib.forEach [
"803"
"900"
"906"
"908"
"90a"
"1010"
"1012"
"1030"
] (target: "gfx${target}");
updateScript = rocmUpdateScript {
name = finalAttrs.pname;
owner = finalAttrs.src.owner;
repo = finalAttrs.src.repo;
};
};
meta = with lib; {
description = "C++ Heterogeneous-Compute Interface for Portability specifically for AMD platform";
homepage = "https://github.com/ROCm-Developer-Tools/hipamd";
license = with licenses; [ mit ];
maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members;
platforms = platforms.linux;
# Tests require GPU, also include issues
broken =
versions.minor finalAttrs.version != versions.minor hip-common.version ||
versions.minor finalAttrs.version != versions.minor hipcc.version ||
buildTests;
};
})

View file

@ -1,130 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c21f247..5bd3e45 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -17,6 +17,6 @@ if (NOT WIN32) # C++17 does not require the std lib linking
target_link_libraries(hipconfig.bin ${LINK_LIBS} ) # for hipconfig.bin
endif()
-set(HIP_VERSION_MAJOR 4 PARENT_SCOPE)
-set(HIP_VERSION_MINOR 4 PARENT_SCOPE)
-set(HIP_VERSION_PATCH 4 PARENT_SCOPE)
+set(HIP_VERSION_MAJOR @version_major@)
+set(HIP_VERSION_MINOR @version_minor@)
+set(HIP_VERSION_PATCH @version_patch@)
diff --git a/src/hipBin_amd.h b/src/hipBin_amd.h
index f94e4a5..f0b1b83 100644
--- a/src/hipBin_amd.h
+++ b/src/hipBin_amd.h
@@ -207,7 +207,7 @@ void HipBinAmd::initializeHipCXXFlags() {
hipClangIncludePath = getCompilerIncludePath();
hipCXXFlags += " -isystem \"" + hipClangIncludePath;
fs::path hipCXXFlagsTempFs = hipCXXFlags;
- hipCXXFlagsTempFs /= "..\"";
+ hipCXXFlagsTempFs /= "\"";
hipCXXFlags = hipCXXFlagsTempFs.string();
const EnvVariables& var = getEnvVariables();
// Allow __fp16 as function parameter and return type.
@@ -266,7 +266,7 @@ void HipBinAmd::printCompilerInfo() const {
string cmd = hipClangPath + "/clang++ --version";
system(cmd.c_str()); // hipclang version
cout << "llc-version :" << endl;
- cmd = hipClangPath + "/llc --version";
+ cmd = "@llvm@/bin/llc --version";
system(cmd.c_str()); // llc version
cout << "hip-clang-cxxflags :" << endl;
cmd = hipPath + "/bin/hipcc --cxxflags";
@@ -278,7 +278,7 @@ void HipBinAmd::printCompilerInfo() const {
} else {
string cmd = hipClangPath + "/clang++ --version";
system(cmd.c_str()); // hipclang version
- cmd = hipClangPath + "/llc --version";
+ cmd = "@llvm@/bin/llc --version";
system(cmd.c_str()); // llc version
cout << "hip-clang-cxxflags :" << endl;
cmd = hipPath + "/bin/hipcc --cxxflags";
@@ -331,10 +331,7 @@ string HipBinAmd::getCppConfig() {
hipPathInclude /= "include";
const string& compilerPath = getCompilerPath();
- hipClangInclude = compilerPath;
- hipClangInclude = hipClangInclude.parent_path();
- hipClangInclude /= "lib/clang/";
- hipClangInclude /= compilerVersion;
+ hipClangInclude = "@clang@/resource-root/include";
string hipClangPath = hipClangInclude.string();
const OsType& osInfo = getOSInfo();
@@ -442,17 +439,7 @@ string HipBinAmd::getHipCC() const {
string HipBinAmd::getCompilerIncludePath() {
- string hipClangVersion, includePath, compilerIncludePath;
- const string& hipClangPath = getCompilerPath();
- hipClangVersion = getCompilerVersion();
- fs::path includePathfs = hipClangPath;
- includePathfs = includePathfs.parent_path();
- includePathfs /= "lib/clang/";
- includePathfs /= hipClangVersion;
- includePathfs /= "include";
- includePathfs = fs::absolute(includePathfs).string();
- compilerIncludePath = includePathfs.string();
- return compilerIncludePath;
+ return "@clang@/resource-root/include";
}
@@ -506,8 +493,8 @@ void HipBinAmd::printFull() {
cout << endl << "== Envirnoment Variables" << endl;
printEnvironmentVariables();
getSystemInfo();
- if (fs::exists("/usr/bin/lsb_release"))
- system("/usr/bin/lsb_release -a");
+ if (fs::exists("@lsb_release@/bin/lsb_release"))
+ system("@lsb_release@/bin/lsb_release -a");
cout << endl;
}
@@ -993,7 +980,7 @@ void HipBinAmd::executeHipCCCmd(vector<string> argv) {
} else if (os != windows) {
// Else try using rocm_agent_enumerator
string ROCM_AGENT_ENUM;
- ROCM_AGENT_ENUM = roccmPath + "/bin/rocm_agent_enumerator";
+ ROCM_AGENT_ENUM = "@rocminfo@/bin/rocm_agent_enumerator";
targetsStr = ROCM_AGENT_ENUM +" -t GPU";
SystemCmdOut sysOut = hipBinUtilPtr_->exec(targetsStr.c_str());
regex toReplace("\n+");
@@ -1097,7 +1084,7 @@ void HipBinAmd::executeHipCCCmd(vector<string> argv) {
string hipClangVersion, toolArgTemp;
if (linkType == 0) {
toolArgTemp = " -L"+ hipLibPath + "-lamdhip64 -L" +
- roccmPath+ "/lib -lhsa-runtime64 -ldl -lnuma " + toolArgs;
+ "@rocm_runtime@/lib -lhsa-runtime64 -ldl -lnuma " + toolArgs;
toolArgs = toolArgTemp;
} else {
toolArgTemp = toolArgs + " -Wl,--enable-new-dtags -Wl,-rpath=" + hipLibPath + ":"
@@ -1107,8 +1094,7 @@ void HipBinAmd::executeHipCCCmd(vector<string> argv) {
hipClangVersion = getCompilerVersion();
// To support __fp16 and _Float16, explicitly link with compiler-rt
- toolArgs += " -L" + hipClangPath + "/../lib/clang/" +
- hipClangVersion + "/lib/linux -lclang_rt.builtins-x86_64 ";
+ toolArgs += " -L@clang@/resource-root/lib/linux -lclang_rt.builtins-x86_64 ";
}
if (!var.hipccCompileFlagsAppendEnv_.empty()) {
HIPCXXFLAGS += " " + var.hipccCompileFlagsAppendEnv_ + " ";
diff --git a/src/hipBin_nvidia.h b/src/hipBin_nvidia.h
index 6feb315..b61739d 100644
--- a/src/hipBin_nvidia.h
+++ b/src/hipBin_nvidia.h
@@ -157,8 +157,8 @@ void HipBinNvidia::printFull() {
cout << endl << "== Envirnoment Variables" << endl;
printEnvironmentVariables();
getSystemInfo();
- if (fs::exists("/usr/bin/lsb_release"))
- system("/usr/bin/lsb_release -a");
+ if (fs::exists("@lsb_release@/bin/lsb_release"))
+ system("@lsb_release@/bin/lsb_release -a");
}
// returns hip include

View file

@ -1,64 +0,0 @@
{ lib
, stdenv
, fetchFromGitHub
, fetchpatch
, rocmUpdateScript
, rocm-comgr
}:
stdenv.mkDerivation (finalAttrs: {
pname = "rocclr";
version = "5.4.4";
src = fetchFromGitHub {
owner = "ROCm-Developer-Tools";
repo = "ROCclr";
rev = "rocm-${finalAttrs.version}";
hash = "sha256-DbN7kL8oyaPeYQB19Q96L3wX66v62TMSWl0Yor7Q4kE=";
};
patches = [
# Enable support for gfx8 again
# See the upstream issue: https://github.com/RadeonOpenCompute/ROCm/issues/1659
# And the arch patch: https://github.com/rocm-arch/rocm-arch/pull/742
(fetchpatch {
url = "https://raw.githubusercontent.com/John-Gee/rocm-arch/d6812d308fee3caf2b6bb01b4d19fe03a6a0e3bd/rocm-opencl-runtime/enable-gfx800.patch";
hash = "sha256-59jFDIIsTTZcNns9RyMVWPRUggn/bSlAGrky4quu8B4=";
})
];
postPatch = ''
substituteInPlace device/comgrctx.cpp \
--replace "libamd_comgr.so" "${rocm-comgr}/lib/libamd_comgr.so"
'';
dontConfigure = true;
dontBuild = true;
installPhase = ''
runHook preInstall
mkdir -p $out
cp -a * $out/
runHook postInstall
'';
passthru.updateScript = rocmUpdateScript {
name = finalAttrs.pname;
owner = finalAttrs.src.owner;
repo = finalAttrs.src.repo;
};
meta = with lib; {
description = "Source package of the Radeon Open Compute common language runtime";
homepage = "https://github.com/ROCm-Developer-Tools/ROCclr";
license = licenses.mit;
maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members;
# rocclr seems to have some AArch64 ifdefs, but does not seem
# to be supported yet by the build infrastructure. Recheck in
# the future.
platforms = [ "x86_64-linux" ];
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
};
})

View file

@ -1,365 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 62b857b..d21c7f4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -147,8 +147,8 @@ if (UNIX)
list(APPEND AMD_COMGR_PUBLIC_LINKER_OPTIONS -pthread)
if (NOT APPLE AND COMGR_BUILD_SHARED_LIBS)
configure_file(
- ${CMAKE_CURRENT_SOURCE_DIR}/src/exportmap.in
- ${CMAKE_CURRENT_BINARY_DIR}/src/exportmap @ONLY)
+ src/exportmap.in
+ src/exportmap @ONLY)
list(APPEND AMD_COMGR_PRIVATE_LINKER_OPTIONS
"-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/src/exportmap")
# When building a shared library with -fsanitize=address we can't be
@@ -175,10 +175,6 @@ endif()
# the shared header.
list(APPEND AMD_COMGR_PRIVATE_COMPILE_DEFINITIONS AMD_COMGR_EXPORT)
-configure_file(
- ${CMAKE_CURRENT_SOURCE_DIR}/include/amd_comgr.h.in
- ${CMAKE_CURRENT_BINARY_DIR}/include/amd_comgr.h @ONLY)
-
include(bc2h)
include(opencl_pch)
include(DeviceLibs)
@@ -212,10 +208,14 @@ target_include_directories(amd_comgr
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
$<INSTALL_INTERFACE:include>)
+configure_file(
+ include/amd_comgr.h.in
+ include/amd_comgr.h @ONLY)
+
set(AMD_COMGR_CONFIG_NAME amd_comgr-config.cmake)
set(AMD_COMGR_TARGETS_NAME amd_comgr-targets.cmake)
set(AMD_COMGR_VERSION_NAME amd_comgr-config-version.cmake)
-set(AMD_COMGR_PACKAGE_PREFIX ${CMAKE_INSTALL_LIBDIR}/cmake/amd_comgr)
+set(AMD_COMGR_PACKAGE_PREFIX cmake/amd_comgr)
# Generate the build-tree package.
set(AMD_COMGR_PREFIX_CODE)
@@ -226,13 +226,13 @@ if (NOT COMGR_BUILD_SHARED_LIBS)
endif()
set(AMD_COMGR_TARGETS_PATH
- "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
+ "${CMAKE_CURRENT_BINARY_DIR}/lib/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
set(AMD_COMGR_VERSION_PATH
- "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_VERSION_NAME}")
+ "${CMAKE_CURRENT_BINARY_DIR}/lib/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_VERSION_NAME}")
export(TARGETS amd_comgr
- FILE "${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
+ FILE "lib/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
configure_file("cmake/${AMD_COMGR_CONFIG_NAME}.in"
- "${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_CONFIG_NAME}"
+ "lib/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_CONFIG_NAME}"
@ONLY)
write_basic_package_version_file("${AMD_COMGR_VERSION_PATH}"
VERSION "${amd_comgr_VERSION}"
@@ -266,7 +266,7 @@ install(FILES
set(AMD_COMGR_PREFIX_CODE "
# Derive absolute install prefix from config file path.
get_filename_component(AMD_COMGR_PREFIX \"\${CMAKE_CURRENT_LIST_FILE}\" PATH)")
-string(REGEX REPLACE "/" ";" count "${AMD_COMGR_PACKAGE_PREFIX}")
+string(REGEX REPLACE "/" ";" count "${CMAKE_INSTALL_LIBDIR}/${AMD_COMGR_PACKAGE_PREFIX}")
foreach(p ${count})
set(AMD_COMGR_PREFIX_CODE "${AMD_COMGR_PREFIX_CODE}
get_filename_component(AMD_COMGR_PREFIX \"\${AMD_COMGR_PREFIX}\" PATH)")
@@ -278,20 +278,20 @@ if (NOT COMGR_BUILD_SHARED_LIBS)
string(APPEND AMD_COMGR_PREFIX_CODE "find_dependency(LLD REQUIRED)\n")
endif()
-set(AMD_COMGR_TARGETS_PATH "\${AMD_COMGR_PREFIX}/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
+set(AMD_COMGR_TARGETS_PATH "\${AMD_COMGR_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${AMD_COMGR_PACKAGE_PREFIX}/${AMD_COMGR_TARGETS_NAME}")
configure_file("cmake/${AMD_COMGR_CONFIG_NAME}.in"
- "${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_CONFIG_NAME}.install"
+ "${AMD_COMGR_CONFIG_NAME}.install"
@ONLY)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/${AMD_COMGR_CONFIG_NAME}.install"
- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}"
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/${AMD_COMGR_PACKAGE_PREFIX}"
RENAME "${AMD_COMGR_CONFIG_NAME}")
install(EXPORT amd_comgr_export
- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}"
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/${AMD_COMGR_PACKAGE_PREFIX}"
FILE "${AMD_COMGR_TARGETS_NAME}")
install(FILES
"${AMD_COMGR_VERSION_PATH}"
- DESTINATION "${AMD_COMGR_PACKAGE_PREFIX}")
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/${AMD_COMGR_PACKAGE_PREFIX}")
if(TARGET clangFrontendTool)
set(CLANG_LIBS
diff --git a/cmake/DeviceLibs.cmake b/cmake/DeviceLibs.cmake
index 27e9546..dfe1b57 100644
--- a/cmake/DeviceLibs.cmake
+++ b/cmake/DeviceLibs.cmake
@@ -1,8 +1,7 @@
set(INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
set(GEN_LIBRARY_INC_FILE ${INC_DIR}/libraries.inc)
-
-file(WRITE ${GEN_LIBRARY_INC_FILE} "// Automatically generated file; DO NOT EDIT.\n")
+set(GEN_LIBRARY_DEFS_INC_FILE ${INC_DIR}/libraries_defs.inc)
# cmake does not provide a way to query targets produced by a project,
# so we have to make one up. Ordinarily, individual library target
@@ -23,6 +22,7 @@ if(NOT AMD_DEVICE_LIBS_TARGETS)
message(FATAL_ERROR "Could not find list of device libraries")
endif()
+set(TARGETS_INCLUDES "")
foreach(AMDGCN_LIB_TARGET ${AMD_DEVICE_LIBS_TARGETS})
set(header ${AMDGCN_LIB_TARGET}.inc)
@@ -54,75 +54,52 @@ foreach(AMDGCN_LIB_TARGET ${AMD_DEVICE_LIBS_TARGETS})
add_custom_target(${AMDGCN_LIB_TARGET}_header DEPENDS ${INC_DIR}/${header})
add_dependencies(amd_comgr ${AMDGCN_LIB_TARGET}_header)
- file(APPEND ${GEN_LIBRARY_INC_FILE} "#include \"${header}\"\n")
+ list(APPEND TARGETS_INCLUDES "#include \"${header}\"")
+endforeach()
+
+list(JOIN TARGETS_INCLUDES "\n" TARGETS_INCLUDES)
+file(GENERATE OUTPUT ${GEN_LIBRARY_INC_FILE} CONTENT "${TARGETS_INCLUDES}")
+
+foreach(OPENCL_VERSION 1.2 2.0)
+ string(REPLACE . _ OPENCL_UNDERSCORE_VERSION ${OPENCL_VERSION})
+ add_custom_command(OUTPUT ${INC_DIR}/opencl${OPENCL_VERSION}-c.inc
+ COMMAND bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl${OPENCL_VERSION}-c.pch
+ ${INC_DIR}/opencl${OPENCL_VERSION}-c.inc
+ opencl${OPENCL_UNDERSCORE_VERSION}_c
+ DEPENDS bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl${OPENCL_VERSION}-c.pch
+ COMMENT "Generating opencl${OPENCL_VERSION}-c.inc"
+ )
+ set_property(DIRECTORY APPEND PROPERTY
+ ADDITIONAL_MAKE_CLEAN_FILES ${INC_DIR}/opencl${OPENCL_VERSION}-c.inc)
+ add_custom_target(opencl${OPENCL_VERSION}-c.inc_target DEPENDS ${INC_DIR}/opencl${OPENCL_VERSION}-c.inc)
+ add_dependencies(amd_comgr opencl${OPENCL_VERSION}-c.inc_target)
endforeach()
-add_custom_command(OUTPUT ${INC_DIR}/opencl1.2-c.inc
- COMMAND bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.pch
- ${INC_DIR}/opencl1.2-c.inc
- opencl1_2_c
- DEPENDS bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl1.2-c.pch
- COMMENT "Generating opencl1.2-c.inc"
-)
-set_property(DIRECTORY APPEND PROPERTY
- ADDITIONAL_MAKE_CLEAN_FILES ${INC_DIR}/opencl1.2-c.inc)
-add_custom_target(opencl1.2-c.inc_target DEPENDS ${INC_DIR}/opencl1.2-c.inc)
-add_dependencies(amd_comgr opencl1.2-c.inc_target)
-file(APPEND ${GEN_LIBRARY_INC_FILE} "#include \"opencl1.2-c.inc\"\n")
-
-add_custom_command(OUTPUT ${INC_DIR}/opencl2.0-c.inc
- COMMAND bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.pch
- ${INC_DIR}/opencl2.0-c.inc
- opencl2_0_c
- DEPENDS bc2h ${CMAKE_CURRENT_BINARY_DIR}/opencl2.0-c.pch
- COMMENT "Generating opencl2.0-c.inc"
-)
-set_property(DIRECTORY APPEND PROPERTY
- ADDITIONAL_MAKE_CLEAN_FILES ${INC_DIR}/opencl2.0-c.inc)
-add_custom_target(opencl2.0-c.inc_target DEPENDS ${INC_DIR}/opencl2.0-c.inc)
-add_dependencies(amd_comgr opencl2.0-c.inc_target)
-file(APPEND ${GEN_LIBRARY_INC_FILE} "#include \"opencl2.0-c.inc\"\n")
-
-# Generate function to select libraries for a given GFXIP number.
-file(APPEND ${GEN_LIBRARY_INC_FILE} "#include \"llvm/ADT/StringRef.h\"\n")
-file(APPEND ${GEN_LIBRARY_INC_FILE}
- "static std::tuple<const char*, const void*, size_t> get_oclc_isa_version(llvm::StringRef gfxip) {")
+set(TARGETS_DEFS "")
+list(APPEND TARGETS_DEFS "#ifndef AMD_DEVICE_LIBS_TARGET\n#define AMD_DEVICE_LIBS_TARGET(t)\n#endif")
+list(APPEND TARGETS_DEFS "#ifndef AMD_DEVICE_LIBS_GFXIP\n#define AMD_DEVICE_LIBS_GFXIP(t, g)\n#endif")
+list(APPEND TARGETS_DEFS "#ifndef AMD_DEVICE_LIBS_FUNCTION\n#define AMD_DEVICE_LIBS_FUNCTION(t, f)\n#endif")
+list(APPEND TARGETS_DEFS "")
foreach(AMDGCN_LIB_TARGET ${AMD_DEVICE_LIBS_TARGETS})
+ list(APPEND TARGETS_DEFS "AMD_DEVICE_LIBS_TARGET(${AMDGCN_LIB_TARGET})")
+ # Generate function to select libraries for a given GFXIP number.
if (${AMDGCN_LIB_TARGET} MATCHES "^oclc_isa_version_.+$")
string(REGEX REPLACE "^oclc_isa_version_(.+)$" "\\1" gfxip ${AMDGCN_LIB_TARGET})
- file(APPEND ${GEN_LIBRARY_INC_FILE}
- "if (gfxip == \"${gfxip}\") return std::make_tuple(\"${AMDGCN_LIB_TARGET}.bc\", ${AMDGCN_LIB_TARGET}_lib, ${AMDGCN_LIB_TARGET}_lib_size);")
+ list(APPEND TARGETS_DEFS "AMD_DEVICE_LIBS_GFXIP(${AMDGCN_LIB_TARGET}, \"${gfxip}\")")
endif()
-endforeach()
-file(APPEND ${GEN_LIBRARY_INC_FILE}
- "return std::make_tuple(nullptr, nullptr, 0); }")
-
-# Generate function to select libraries for given feature.
-foreach(AMDGCN_LIB_TARGET ${AMD_DEVICE_LIBS_TARGETS})
+ # Generate function to select libraries for given feature.
if (${AMDGCN_LIB_TARGET} MATCHES "^oclc_.*_on$")
string(REGEX REPLACE "^oclc_(.*)_on" "\\1" function ${AMDGCN_LIB_TARGET})
- file(APPEND ${GEN_LIBRARY_INC_FILE}
- "static std::tuple<const char*, const void*, size_t> get_oclc_${function}(bool on) { \
- return std::make_tuple( \
- on ? \"oclc_${function}_on_lib.bc\" : \"oclc_${function}_off_lib.bc\", \
- on ? oclc_${function}_on_lib : oclc_${function}_off_lib, \
- on ? oclc_${function}_on_lib_size : oclc_${function}_off_lib_size \
- ); }")
+ list(APPEND TARGETS_DEFS "AMD_DEVICE_LIBS_FUNCTION(${AMDGCN_LIB_TARGET}, ${function})")
endif()
endforeach()
-# Generate function yield all libraries.
-file(APPEND ${GEN_LIBRARY_INC_FILE} "\n#include \"llvm/ADT/ArrayRef.h\"\n")
-file(APPEND ${GEN_LIBRARY_INC_FILE}
- "llvm::ArrayRef<std::tuple<llvm::StringRef, llvm::StringRef>> COMGR::getDeviceLibraries() { \
- static std::tuple<llvm::StringRef, llvm::StringRef> DeviceLibs[] = {")
-foreach(AMDGCN_LIB_TARGET ${AMD_DEVICE_LIBS_TARGETS})
- file(APPEND ${GEN_LIBRARY_INC_FILE}
- "{\"${AMDGCN_LIB_TARGET}.bc\", llvm::StringRef(reinterpret_cast<const char *>(${AMDGCN_LIB_TARGET}_lib), ${AMDGCN_LIB_TARGET}_lib_size)},")
-endforeach()
-file(APPEND ${GEN_LIBRARY_INC_FILE}
- "}; \
- return DeviceLibs; \
- }")
+list(APPEND TARGETS_DEFS "")
+list(APPEND TARGETS_DEFS "#undef AMD_DEVICE_LIBS_TARGET")
+list(APPEND TARGETS_DEFS "#undef AMD_DEVICE_LIBS_GFXIP")
+list(APPEND TARGETS_DEFS "#undef AMD_DEVICE_LIBS_FUNCTION")
+
+list(JOIN TARGETS_DEFS "\n" TARGETS_DEFS)
+file(GENERATE OUTPUT ${GEN_LIBRARY_DEFS_INC_FILE} CONTENT "${TARGETS_DEFS}")
include_directories(${INC_DIR})
diff --git a/cmake/bc2h.cmake b/cmake/bc2h.cmake
index 146fe2b..9134985 100644
--- a/cmake/bc2h.cmake
+++ b/cmake/bc2h.cmake
@@ -1,40 +1,41 @@
-file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/bc2h.c
-"#include <stdio.h>\n"
-"int main(int argc, char **argv){\n"
-" FILE *ifp, *ofp;\n"
-" int c, i, l;\n"
-" if (argc != 4) return 1;\n"
-" ifp = fopen(argv[1], \"rb\");\n"
-" if (!ifp) return 1;\n"
-" i = fseek(ifp, 0, SEEK_END);\n"
-" if (i < 0) return 1;\n"
-" l = ftell(ifp);\n"
-" if (l < 0) return 1;\n"
-" i = fseek(ifp, 0, SEEK_SET);\n"
-" if (i < 0) return 1;\n"
-" ofp = fopen(argv[2], \"wb+\");\n"
-" if (!ofp) return 1;\n"
-" fprintf(ofp, \"#define %s_size %d\\n\\n\"\n"
-" \"#if defined __GNUC__\\n\"\n"
-" \"__attribute__((aligned (4096)))\\n\"\n"
-" \"#elif defined _MSC_VER\\n\"\n"
-" \"__declspec(align(4096))\\n\"\n"
-" \"#endif\\n\"\n"
-" \"static const unsigned char %s[%s_size+1] = {\",\n"
-" argv[3], l,\n"
-" argv[3], argv[3]);\n"
-" i = 0;\n"
-" while ((c = getc(ifp)) != EOF) {\n"
-" if (0 == (i&7)) fprintf(ofp, \"\\n \");\n"
-" fprintf(ofp, \" 0x%02x,\", c);\n"
-" ++i;\n"
-" }\n"
-" fprintf(ofp, \" 0x00\\n};\\n\\n\");\n"
-" fclose(ifp);\n"
-" fclose(ofp);\n"
-" return 0;\n"
-"}\n"
-)
+file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/bc2h.c
+ CONTENT
+"#include <stdio.h>
+int main(int argc, char **argv){
+ FILE *ifp, *ofp;
+ int c, i, l;
+ if (argc != 4) return 1;
+ ifp = fopen(argv[1], \"rb\");
+ if (!ifp) return 1;
+ i = fseek(ifp, 0, SEEK_END);
+ if (i < 0) return 1;
+ l = ftell(ifp);
+ if (l < 0) return 1;
+ i = fseek(ifp, 0, SEEK_SET);
+ if (i < 0) return 1;
+ ofp = fopen(argv[2], \"wb+\");
+ if (!ofp) return 1;
+ fprintf(ofp, \"#define %s_size %d\\n\\n\"
+ \"#if defined __GNUC__\\n\"
+ \"__attribute__((aligned (4096)))\\n\"
+ \"#elif defined _MSC_VER\\n\"
+ \"__declspec(align(4096))\\n\"
+ \"#endif\\n\"
+ \"static const unsigned char %s[%s_size+1] = {\",
+ argv[3], l,
+ argv[3], argv[3]);
+ i = 0;
+ while ((c = getc(ifp)) != EOF) {
+ if (0 == (i&7)) fprintf(ofp, \"\\n \");
+ fprintf(ofp, \" 0x%02x,\", c);
+ ++i;
+ }
+ fprintf(ofp, \" 0x00\\n};\\n\\n\");
+ fclose(ifp);
+ fclose(ofp);
+ return 0;
+}
+")
add_executable(bc2h ${CMAKE_CURRENT_BINARY_DIR}/bc2h.c)
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
diff --git a/src/comgr-device-libs.cpp b/src/comgr-device-libs.cpp
index 4d2b914..80786d1 100644
--- a/src/comgr-device-libs.cpp
+++ b/src/comgr-device-libs.cpp
@@ -35,7 +35,7 @@
#include "comgr-device-libs.h"
#include "comgr.h"
-#include "libraries.inc"
+#include "comgr-libraries.h"
#include "llvm/ADT/StringSwitch.h"
#include <cstdint>
diff --git a/src/comgr-libraries.h b/src/comgr-libraries.h
new file mode 100644
index 0000000..3caa0a0
--- /dev/null
+++ b/src/comgr-libraries.h
@@ -0,0 +1,34 @@
+#include "libraries.inc"
+#include "opencl1.2-c.inc"
+#include "opencl2.0-c.inc"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/ArrayRef.h"
+
+static std::tuple<const char*, const void*, size_t> get_oclc_isa_version(llvm::StringRef gfxip) {
+#define AMD_DEVICE_LIBS_GFXIP(target, target_gfxip) \
+ if (gfxip == target_gfxip) return std::make_tuple(#target ".bc", target##_lib, target##_lib_size);
+#include "libraries_defs.inc"
+
+ return std::make_tuple(nullptr, nullptr, 0);
+}
+
+#define AMD_DEVICE_LIBS_FUNCTION(target, function) \
+ static std::tuple<const char*, const void*, size_t> get_oclc_##function(bool on) { \
+ return std::make_tuple( \
+ on ? "oclc_" #function "_on_lib.bc" : "oclc_" #function "_off_lib.bc", \
+ on ? oclc_##function##_on_lib : oclc_##function##_off_lib, \
+ on ? oclc_##function##_on_lib_size : oclc_##function##_off_lib_size \
+ ); \
+ }
+#include "libraries_defs.inc"
+
+llvm::ArrayRef<std::tuple<llvm::StringRef, llvm::StringRef>> COMGR::getDeviceLibraries() {
+ static std::tuple<llvm::StringRef, llvm::StringRef> DeviceLibs[] = {
+#define AMD_DEVICE_LIBS_TARGET(target) \
+ {#target ".bc", llvm::StringRef(reinterpret_cast<const char *>(target##_lib), target##_lib_size)},
+#include "libraries_defs.inc"
+ };
+ return DeviceLibs;
+}
+
+

View file

@ -1,26 +0,0 @@
{ lib
, stdenv
, callPackage
, rocm-opencl-runtime
}:
stdenv.mkDerivation rec {
pname = "rocm-opencl-icd";
version = rocm-opencl-runtime.version;
dontUnpack = true;
installPhase = ''
mkdir -p $out/etc/OpenCL/vendors
echo "${rocm-opencl-runtime}/lib/libamdocl64.so" > $out/etc/OpenCL/vendors/amdocl64.icd
'';
passthru.impureTests = { rocm-opencl = callPackage ./test.nix { }; };
meta = with lib; {
description = "OpenCL ICD definition for AMD GPUs using the ROCm stack";
license = licenses.mit;
maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members;
platforms = platforms.linux;
};
}

View file

@ -1,19 +0,0 @@
{ lib, makeImpureTest, clinfo, rocm-opencl-icd, rocm-smi }:
makeImpureTest {
name = "rocm-opencl";
testedPackage = "rocm-opencl-icd";
nativeBuildInputs = [ clinfo rocm-smi ];
OCL_ICD_VENDORS = "${rocm-opencl-icd}/etc/OpenCL/vendors/";
testScript = ''
# Test fails if the number of platforms is 0
clinfo | grep -E 'Number of platforms * [1-9]'
rocm-smi | grep -A1 GPU
'';
meta = with lib; {
maintainers = teams.rocm.members;
};
}

View file

@ -1,69 +0,0 @@
{ lib
, stdenv
, fetchFromGitHub
, rocmUpdateScript
, addOpenGLRunpath
, cmake
, rocm-comgr
, rocm-runtime
, rocclr
, glew
, libX11
, numactl
}:
stdenv.mkDerivation (finalAttrs: {
pname = "rocm-opencl-runtime";
version = "5.4.4";
src = fetchFromGitHub {
owner = "RadeonOpenCompute";
repo = "ROCm-OpenCL-Runtime";
rev = "rocm-${finalAttrs.version}";
hash = "sha256-E1+Y/fgp5b+7H1LN+O1fwVi0/XRCgvsiSxTY3u/q+8I=";
};
nativeBuildInputs = [ cmake ];
buildInputs = [
rocm-comgr
rocm-runtime
glew
libX11
numactl
];
cmakeFlags = [
"-DAMD_OPENCL_PATH=${finalAttrs.src}"
"-DROCCLR_PATH=${rocclr}"
];
dontStrip = true;
# Remove clinfo, which is already provided through the
# `clinfo` package.
postInstall = ''
rm -rf $out/bin
'';
# Fix the ICD installation path for NixOS
postPatch = ''
substituteInPlace khronos/icd/loader/linux/icd_linux.c \
--replace 'ICD_VENDOR_PATH' '"${addOpenGLRunpath.driverLink}/etc/OpenCL/vendors/"'
'';
passthru.updateScript = rocmUpdateScript {
name = finalAttrs.pname;
owner = finalAttrs.src.owner;
repo = finalAttrs.src.repo;
};
meta = with lib; {
description = "OpenCL runtime for AMD GPUs, part of the ROCm stack";
homepage = "https://github.com/RadeonOpenCompute/ROCm-OpenCL-Runtime";
license = with licenses; [ asl20 mit ];
maintainers = with maintainers; [ acowley lovesegfault ] ++ teams.rocm.members;
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
};
})

View file

@ -1,20 +0,0 @@
diff --git a/src/util/hsa_rsrc_factory.cpp b/src/util/hsa_rsrc_factory.cpp
index 643ff16..c08d98f 100644
--- a/src/util/hsa_rsrc_factory.cpp
+++ b/src/util/hsa_rsrc_factory.cpp
@@ -127,15 +127,6 @@ HsaRsrcFactory::HsaRsrcFactory(bool initialize_hsa) : initialize_hsa_(initialize
if (cpu_pool_ == NULL) CHECK_STATUS("CPU memory pool is not found", HSA_STATUS_ERROR);
if (kern_arg_pool_ == NULL) CHECK_STATUS("Kern-arg memory pool is not found", HSA_STATUS_ERROR);
- // Get AqlProfile API table
- aqlprofile_api_ = {0};
-#ifdef ROCP_LD_AQLPROFILE
- status = LoadAqlProfileLib(&aqlprofile_api_);
-#else
- status = hsa_api_.hsa_system_get_major_extension_table(HSA_EXTENSION_AMD_AQLPROFILE, hsa_ven_amd_aqlprofile_VERSION_MAJOR, sizeof(aqlprofile_api_), &aqlprofile_api_);
-#endif
- CHECK_STATUS("aqlprofile API table load failed", status);
-
// Get Loader API table
loader_api_ = {0};
status = hsa_api_.hsa_system_get_major_extension_table(HSA_EXTENSION_AMD_LOADER, 1, sizeof(loader_api_), &loader_api_);

View file

@ -4,7 +4,7 @@
, enableCuda ? config.cudaSupport
, cudatoolkit
, enableRocm ? false
, rocm-core, rocm-runtime, rocm-device-libs, hip
, rocmPackages
}:
let
@ -13,9 +13,12 @@ let
inherit (cudatoolkit) name meta;
paths = [ cudatoolkit cudatoolkit.lib ];
};
rocmList = with rocmPackages; [ rocm-core rocm-runtime rocm-device-libs clr ];
rocm = symlinkJoin {
name = "rocm";
paths = [ rocm-core rocm-runtime rocm-device-libs hip ];
paths = rocmList;
};
in
@ -40,7 +43,7 @@ stdenv.mkDerivation rec {
rdma-core
zlib
] ++ lib.optional enableCuda cudatoolkit
++ lib.optionals enableRocm [ rocm-core rocm-runtime rocm-device-libs hip ];
++ lib.optionals enableRocm rocmList;
configureFlags = [
"--with-rdmacm=${lib.getDev rdma-core}"

View file

@ -0,0 +1,147 @@
{ lib
, stdenv
, fetchFromGitHub
, rocmUpdateScript
, makeWrapper
, cmake
, perl
, clang
, hip-common
, hipcc
, rocm-device-libs
, rocm-comgr
, rocm-runtime
, roctracer
, rocminfo
, numactl
, libGL
, libxml2
, libX11
, python3Packages
}:
let
wrapperArgs = [
"--prefix PATH : $out/bin"
"--prefix LD_LIBRARY_PATH : ${rocm-runtime}"
"--set HIP_PLATFORM amd"
"--set HIP_PATH $out"
"--set HIP_CLANG_PATH ${clang}/bin"
"--set DEVICE_LIB_PATH ${rocm-device-libs}/amdgcn/bitcode"
"--set HSA_PATH ${rocm-runtime}"
"--set ROCM_PATH $out"
];
in stdenv.mkDerivation (finalAttrs: {
pname = "clr";
version = "5.7.0";
src = fetchFromGitHub {
owner = "ROCm-Developer-Tools";
repo = "clr";
rev = "rocm-${finalAttrs.version}";
hash = "sha256-C+rFW/7kf35rz0sQTI2+iY5RhZZQY07fc5a+e6cB5OQ=";
};
nativeBuildInputs = [
makeWrapper
cmake
perl
python3Packages.python
python3Packages.cppheaderparser
];
buildInputs = [
numactl
libGL
libxml2
libX11
];
propagatedBuildInputs = [
rocm-device-libs
rocm-comgr
rocm-runtime
rocminfo
];
cmakeFlags = [
"-DCMAKE_POLICY_DEFAULT_CMP0072=NEW" # Prefer newer OpenGL libraries
"-DCLR_BUILD_HIP=ON"
"-DCLR_BUILD_OCL=ON"
"-DHIP_COMMON_DIR=${hip-common}"
"-DHIPCC_BIN_DIR=${hipcc}/bin"
"-DHIP_PLATFORM=amd"
"-DPROF_API_HEADER_PATH=${roctracer.src}/inc/ext"
"-DROCM_PATH=${rocminfo}"
# Temporarily set variables to work around upstream CMakeLists issue
# Can be removed once https://github.com/ROCm-Developer-Tools/hipamd/issues/55 is fixed
"-DCMAKE_INSTALL_BINDIR=bin"
"-DCMAKE_INSTALL_INCLUDEDIR=include"
"-DCMAKE_INSTALL_LIBDIR=lib"
];
postPatch = ''
patchShebangs hipamd/src
# We're not on Windows so these are never installed to hipcc...
substituteInPlace hipamd/CMakeLists.txt \
--replace "install(PROGRAMS \''${HIPCC_BIN_DIR}/hipcc.bat DESTINATION bin)" "" \
--replace "install(PROGRAMS \''${HIPCC_BIN_DIR}/hipconfig.bat DESTINATION bin)" ""
substituteInPlace hipamd/src/hip_embed_pch.sh \
--replace "\''$LLVM_DIR/bin/clang" "${clang}/bin/clang"
'';
postInstall = ''
patchShebangs $out/bin
# hipcc.bin and hipconfig.bin is mysteriously never installed
cp -a ${hipcc}/bin/{hipcc.bin,hipconfig.bin} $out/bin
wrapProgram $out/bin/hipcc.bin ${lib.concatStringsSep " " wrapperArgs}
wrapProgram $out/bin/hipconfig.bin ${lib.concatStringsSep " " wrapperArgs}
wrapProgram $out/bin/hipcc.pl ${lib.concatStringsSep " " wrapperArgs}
wrapProgram $out/bin/hipconfig.pl ${lib.concatStringsSep " " wrapperArgs}
# Just link rocminfo, it's easier
ln -s ${rocminfo}/bin/* $out/bin
'';
passthru = {
# All known and valid general GPU targets
# We cannot use this for each ROCm library, as each defines their own supported targets
# See: https://github.com/RadeonOpenCompute/ROCm/blob/77cbac4abab13046ee93d8b5bf410684caf91145/README.md#library-target-matrix
gpuTargets = lib.forEach [
"803"
"900"
"906"
"908"
"90a"
"940"
"941"
"942"
"1010"
"1012"
"1030"
"1100"
"1101"
"1102"
] (target: "gfx${target}");
updateScript = rocmUpdateScript {
name = finalAttrs.pname;
owner = finalAttrs.src.owner;
repo = finalAttrs.src.repo;
};
};
meta = with lib; {
description = "AMD Common Language Runtime for hipamd, opencl, and rocclr";
homepage = "https://github.com/ROCm-Developer-Tools/clr";
license = with licenses; [ mit ];
maintainers = with maintainers; [ lovesegfault ] ++ teams.rocm.members;
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
};
})

View file

@ -1,9 +1,244 @@
{ callPackage
, recurseIntoAttrs
, cudaPackages
, python3Packages
, elfutils
, boost179
}:
let
rocmUpdateScript = callPackage ./update.nix { };
in {
in rec {
## RadeonOpenCompute ##
llvm = recurseIntoAttrs (callPackage ./llvm/default.nix { inherit rocmUpdateScript; });
rocm-core = callPackage ./rocm-core {
inherit rocmUpdateScript;
stdenv = llvm.rocmClangStdenv;
};
rocm-cmake = callPackage ./rocm-cmake {
inherit rocmUpdateScript;
stdenv = llvm.rocmClangStdenv;
};
rocm-thunk = callPackage ./rocm-thunk {
inherit rocmUpdateScript;
stdenv = llvm.rocmClangStdenv;
};
rocm-smi = python3Packages.callPackage ./rocm-smi {
inherit rocmUpdateScript;
stdenv = llvm.rocmClangStdenv;
};
# Eventually will be in the LLVM repo
rocm-device-libs = callPackage ./rocm-device-libs {
inherit rocmUpdateScript rocm-cmake;
stdenv = llvm.rocmClangStdenv;
};
rocm-runtime = callPackage ./rocm-runtime {
inherit rocmUpdateScript rocm-device-libs rocm-thunk;
stdenv = llvm.rocmClangStdenv;
};
# Eventually will be in the LLVM repo
rocm-comgr = callPackage ./rocm-comgr {
inherit rocmUpdateScript rocm-cmake rocm-device-libs;
stdenv = llvm.rocmClangStdenv;
};
rocminfo = callPackage ./rocminfo {
inherit rocmUpdateScript rocm-cmake rocm-runtime;
stdenv = llvm.rocmClangStdenv;
};
clang-ocl = callPackage ./clang-ocl {
inherit rocmUpdateScript rocm-cmake rocm-device-libs;
stdenv = llvm.rocmClangStdenv;
};
# Broken, too many errors
rdc = callPackage ./rdc {
inherit rocmUpdateScript rocm-smi rocm-runtime;
# stdenv = llvm.rocmClangStdenv;
};
## ROCm-Developer-Tools ##
hip-common = callPackage ./hip-common {
inherit rocmUpdateScript;
stdenv = llvm.rocmClangStdenv;
};
# Eventually will be in the LLVM repo
hipcc = callPackage ./hipcc {
inherit rocmUpdateScript;
stdenv = llvm.rocmClangStdenv;
};
clr = callPackage ./clr {
inherit rocmUpdateScript hip-common hipcc rocm-device-libs rocm-comgr rocm-runtime roctracer rocminfo;
inherit (llvm) clang;
stdenv = llvm.rocmClangStdenv;
};
hipify = callPackage ./hipify {
inherit rocmUpdateScript;
inherit (llvm) clang;
stdenv = llvm.rocmClangStdenv;
};
# Needs GCC
rocprofiler = callPackage ./rocprofiler {
inherit (llvm) clang;
inherit rocmUpdateScript clr rocm-thunk roctracer rocm-smi hsa-amd-aqlprofile-bin;
};
# Needs GCC
roctracer = callPackage ./roctracer {
inherit rocmUpdateScript rocm-device-libs rocm-runtime rocprofiler clr;
inherit (llvm) clang;
};
# Needs GCC
rocgdb = callPackage ./rocgdb {
inherit rocmUpdateScript;
elfutils = elfutils.override { enableDebuginfod = true; };
};
rocdbgapi = callPackage ./rocdbgapi {
inherit rocmUpdateScript rocm-cmake rocm-comgr rocm-runtime;
stdenv = llvm.rocmClangStdenv;
};
rocr-debug-agent = callPackage ./rocr-debug-agent {
inherit rocmUpdateScript clr rocdbgapi;
stdenv = llvm.rocmClangStdenv;
};
composable_kernel = callPackage ./composable_kernel {
inherit (llvm) openmp clang-tools-extra;
stdenv = llvm.rocmClangStdenv;
};
hipcub = callPackage ./hipcub {
stdenv = llvm.rocmClangStdenv;
};
hipsparse = callPackage ./hipsparse {
inherit (llvm) openmp;
stdenv = llvm.rocmClangStdenv;
};
hipfort = callPackage ./hipfort {
stdenv = llvm.rocmClangStdenv;
};
hipfft = callPackage ./hipfft {
inherit (llvm) openmp;
stdenv = llvm.rocmClangStdenv;
};
hipsolver = callPackage ./hipsolver {
stdenv = llvm.rocmClangStdenv;
};
hipblas = callPackage ./hipblas {
stdenv = llvm.rocmClangStdenv;
};
migraphx = callPackage ./migraphx {
inherit (llvm) clang-tools-extra openmp;
stdenv = llvm.rocmClangStdenv;
rocmlir = rocmlir-rock;
};
rccl = callPackage ./rccl {
stdenv = llvm.rocmClangStdenv;
};
rocalution = callPackage ./rocalution {
inherit (llvm) openmp;
stdenv = llvm.rocmClangStdenv;
};
rocsolver = callPackage ./rocsolver {
stdenv = llvm.rocmClangStdenv;
};
rocmlir = callPackage ./rocmlir {
stdenv = llvm.rocmClangStdenv;
};
rocmlir-rock = rocmlir.override {
buildRockCompiler = true;
};
rocprim = callPackage ./rocprim {
stdenv = llvm.rocmClangStdenv;
};
rocsparse = callPackage ./rocsparse {
stdenv = llvm.rocmClangStdenv;
};
rocfft = callPackage ./rocfft {
inherit (llvm) openmp;
stdenv = llvm.rocmClangStdenv;
};
rocrand = callPackage ./rocrand {
stdenv = llvm.rocmClangStdenv;
};
tensile = python3Packages.callPackage ./tensile {
stdenv = llvm.rocmClangStdenv;
};
rocwmma = callPackage ./rocwmma {
inherit (llvm) openmp;
stdenv = llvm.rocmClangStdenv;
};
rocblas = callPackage ./rocblas {
inherit (llvm) openmp;
stdenv = llvm.rocmClangStdenv;
};
miopengemm = callPackage ./miopengemm {
stdenv = llvm.rocmClangStdenv;
};
rocthrust = callPackage ./rocthrust {
stdenv = llvm.rocmClangStdenv;
};
miopen = callPackage ./miopen {
inherit (llvm) llvm clang-tools-extra;
stdenv = llvm.rocmClangStdenv;
rocmlir = rocmlir-rock;
boost = boost179.override { enableStatic = true; };
};
miopen-hip = miopen.override {
useOpenCL = false;
};
miopen-opencl = miopen.override {
useOpenCL = true;
};
}

View file

@ -2,11 +2,6 @@
, stdenv
, fetchFromGitHub
, rocmUpdateScript
, substituteAll
, llvm
, rocm-runtime
, rocminfo
, lsb-release
}:
stdenv.mkDerivation (finalAttrs: {
@ -20,16 +15,6 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-1Abit9qZCwrCVcnaFT4uMygFB9G6ovRasLmTsOsJ/Fw=";
};
patches = [
(substituteAll {
src = ./0000-fixup-paths.patch;
inherit llvm rocminfo;
clang = stdenv.cc;
rocm_runtime = rocm-runtime;
lsb_release = lsb-release;
})
];
dontConfigure = true;
dontBuild = true;

View file

@ -95,6 +95,6 @@ stdenv.mkDerivation (finalAttrs: {
maintainers = teams.rocm.members;
platforms = platforms.linux;
# Fixed in develop branch by using C++17 and related refactor
broken = versions.minor finalAttrs.version != versions.minor hip.version || buildTests || buildBenchmarks || buildSamples;
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version || buildTests || buildBenchmarks || buildSamples;
};
})

View file

@ -2,11 +2,7 @@
, stdenv
, fetchFromGitHub
, rocmUpdateScript
, substituteAll
, cmake
, llvm
, rocm-runtime
, rocminfo
, lsb-release
}:
@ -21,28 +17,16 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-lJX6nF1V4YmK5ai7jivXlRnG3doIOf6X9CWLHVdRuVg=";
};
patches = [
(substituteAll {
src = ./0000-fixup-paths.patch;
inherit llvm rocminfo;
version_major = lib.versions.major finalAttrs.version;
version_minor = lib.versions.minor finalAttrs.version;
version_patch = lib.versions.patch finalAttrs.version;
clang = stdenv.cc;
rocm_runtime = rocm-runtime;
lsb_release = lsb-release;
})
];
nativeBuildInputs = [ cmake ];
installPhase = ''
runHook preInstall
postPatch = ''
substituteInPlace src/hipBin_amd.h \
--replace "/usr/bin/lsb_release" "${lsb-release}/bin/lsb_release"
'';
mkdir -p $out/bin
mv *.bin $out/bin
runHook postInstall
postInstall = ''
rm -r $out/hip/bin
ln -s $out/bin $out/hip/bin
'';
passthru.updateScript = rocmUpdateScript {

View file

@ -82,6 +82,6 @@ stdenv.mkDerivation (finalAttrs: {
license = with licenses; [ bsd3 ];
maintainers = teams.rocm.members;
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor hip.version;
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
};
})

View file

@ -102,6 +102,6 @@ stdenv.mkDerivation (finalAttrs: {
license = with licenses; [ mit ];
maintainers = teams.rocm.members;
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor hip.version;
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
};
})

View file

@ -3,6 +3,7 @@
, fetchFromGitHub
, rocmUpdateScript
, cmake
, clang
, libxml2
}:
@ -22,7 +23,7 @@ stdenv.mkDerivation (finalAttrs: {
postPatch = ''
substituteInPlace CMakeLists.txt \
--replace "\''${LLVM_TOOLS_BINARY_DIR}/clang" "${stdenv.cc}/bin/clang"
--replace "\''${LLVM_TOOLS_BINARY_DIR}/clang" "${clang}/bin/clang"
'';
passthru.updateScript = rocmUpdateScript {
@ -31,11 +32,11 @@ stdenv.mkDerivation (finalAttrs: {
repo = finalAttrs.src.repo;
};
# Fixup weird install paths
# Fixup bad symlinks
postInstall = ''
mkdir -p $out/bin
mv $out/{*.sh,hipify-*} $out/bin
cp -afs $out/bin $out/hip
rm -r $out/hip/bin
ln -s $out/bin $out/hip/bin
patchShebangs $out/bin
'';
meta = with lib; {

View file

@ -95,6 +95,6 @@ stdenv.mkDerivation (finalAttrs: {
license = with licenses; [ mit ];
maintainers = teams.rocm.members;
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor hip.version;
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
};
})

View file

@ -131,6 +131,6 @@ stdenv.mkDerivation (finalAttrs: {
license = with licenses; [ mit ];
maintainers = teams.rocm.members;
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor hip.version;
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
};
})

View file

@ -155,6 +155,6 @@ in stdenv.mkDerivation (finalAttrs: {
license = with licenses; [ mit ];
maintainers = teams.rocm.members;
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor hip.version;
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
};
})

View file

@ -185,6 +185,6 @@ in stdenv.mkDerivation (finalAttrs: {
license = with licenses; [ mit ];
maintainers = teams.rocm.members;
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor hip.version;
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
};
})

View file

@ -78,6 +78,6 @@ stdenv.mkDerivation (finalAttrs: {
license = with licenses; [ bsd2 bsd3 ];
maintainers = teams.rocm.members;
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor hip.version;
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
};
})

View file

@ -120,6 +120,7 @@ in stdenv.mkDerivation (finalAttrs: {
license = with licenses; [ mit ];
maintainers = teams.rocm.members;
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor rocm-smi.version;
# broken = versions.minor finalAttrs.version != versions.minor rocm-smi.version;
broken = true; # Too many errors, unsure how to fix
};
})

View file

@ -110,6 +110,6 @@ stdenv.mkDerivation (finalAttrs: {
license = with licenses; [ mit ];
maintainers = teams.rocm.members;
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor hip.version;
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
};
})

View file

@ -134,6 +134,6 @@ stdenv.mkDerivation (finalAttrs: {
license = with licenses; [ mit ];
maintainers = teams.rocm.members;
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor hip.version;
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
};
})

View file

@ -7,6 +7,7 @@
, git
, rocm-comgr
, rocm-runtime
, hwdata
, texlive
, doxygen
, graphviz
@ -65,6 +66,16 @@ in stdenv.mkDerivation (finalAttrs: {
buildInputs = [
rocm-comgr
rocm-runtime
hwdata
];
cmakeFlags = [
"-DPCI_IDS_PATH=${hwdata}/share/hwdata"
# Manually define CMAKE_INSTALL_<DIR>
# See: https://github.com/NixOS/nixpkgs/pull/197838
"-DCMAKE_INSTALL_BINDIR=bin"
"-DCMAKE_INSTALL_LIBDIR=lib"
"-DCMAKE_INSTALL_INCLUDEDIR=include"
];
# Unfortunately, it seems like we have to call make on this manually

View file

@ -238,6 +238,6 @@ stdenv.mkDerivation (finalAttrs: {
license = with licenses; [ mit ];
maintainers = with maintainers; [ kira-bruneau ] ++ teams.rocm.members;
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor hip.version;
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
};
})

View file

@ -22,6 +22,8 @@ stdenv.mkDerivation (finalAttrs: {
name = finalAttrs.pname;
owner = finalAttrs.src.owner;
repo = finalAttrs.src.repo;
page = "releases?per_page=2";
filter = ".[1].tag_name | split(\"-\") | .[1]";
};
meta = with lib; {

View file

@ -24,7 +24,6 @@ in stdenv.mkDerivation (finalAttrs: {
hash = "sha256-QB3G0V92UTW67hD6+zSuExN1+eMT820iYSlMyZeWSFw=";
};
patches = [ ./cmake.patch ];
sourceRoot = "${finalAttrs.src.name}/lib/comgr";
nativeBuildInputs = [

View file

@ -50,8 +50,10 @@ stdenv.mkDerivation (finalAttrs: {
--replace 'hsa/include/hsa' 'include/hsa'
# We compile clang before rocm-device-libs, so patch it in afterwards
# Replace object version: https://github.com/RadeonOpenCompute/ROCR-Runtime/issues/166 (TODO: Remove on LLVM update?)
substituteInPlace image/blit_src/CMakeLists.txt \
--replace '-cl-denorms-are-zero' '-cl-denorms-are-zero --rocm-device-lib-path=${rocm-device-libs}/amdgcn/bitcode'
--replace '-cl-denorms-are-zero' '-cl-denorms-are-zero --rocm-device-lib-path=${rocm-device-libs}/amdgcn/bitcode' \
--replace '-mcode-object-version=4' '-mcode-object-version=5'
'';
fixupPhase = ''

View file

@ -17,16 +17,24 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-swCRO4PBMBJ6fO2bLq/xxFZIYw2IgiFB490wsU8Wm2o=";
};
postPatch = ''
sed '1i#include <cstring>' -i src/rocm_smi{,_gpu_metrics}.cc # since gcc12 probably
'';
nativeBuildInputs = [ cmake wrapPython ];
patches = [ ./cmake.patch ];
nativeBuildInputs = [
cmake
wrapPython
];
cmakeFlags = [
# Manually define CMAKE_INSTALL_<DIR>
# See: https://github.com/NixOS/nixpkgs/pull/197838
"-DCMAKE_INSTALL_BINDIR=bin"
"-DCMAKE_INSTALL_LIBDIR=lib"
"-DCMAKE_INSTALL_INCLUDEDIR=include"
];
postInstall = ''
wrapPythonProgramsIn $out
mv $out/libexec/rocm_smi/.rsmiBindings.py-wrapped $out/libexec/rocm_smi/rsmiBindings.py
'';
passthru.updateScript = rocmUpdateScript {

View file

@ -4,11 +4,8 @@
, rocmUpdateScript
, pkg-config
, cmake
, rocm-cmake
, libdrm
, numactl
, valgrind
, gcc
}:
stdenv.mkDerivation (finalAttrs: {
@ -25,14 +22,11 @@ stdenv.mkDerivation (finalAttrs: {
nativeBuildInputs = [
pkg-config
cmake
rocm-cmake
];
buildInputs = [
libdrm
numactl
valgrind
gcc.cc.libgcc or null # TODO: unhack this?
];
cmakeFlags = [

View file

@ -77,6 +77,6 @@ stdenv.mkDerivation (finalAttrs: {
license = with licenses; [ mit ];
maintainers = teams.rocm.members;
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor hip.version;
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
};
})

View file

@ -3,10 +3,32 @@
, fetchFromGitHub
, rocmUpdateScript
, cmake
, rocm-runtime
, clang
, clr
, rocm-thunk
, roctracer
, rocm-smi
, hsa-amd-aqlprofile-bin
, numactl
, libpciaccess
, libxml2
, elfutils
, mpi
, gtest
, python3Packages
, gpuTargets ? [
"gfx900"
"gfx906"
"gfx908"
"gfx90a"
"gfx940"
"gfx941"
"gfx942"
"gfx1030"
"gfx1100"
"gfx1101"
"gfx1102"
]
}:
stdenv.mkDerivation (finalAttrs: {
@ -20,17 +42,33 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-ue/2uiLbhOv/5XY4cIJuZ8DUMRhniYgxolq9xMwO1FY=";
};
patches = [ ./0000-dont-require-hsa_amd_aqlprofile.patch ];
nativeBuildInputs = [ cmake ];
nativeBuildInputs = [
cmake
clang
clr
python3Packages.lxml
python3Packages.cppheaderparser
python3Packages.pyyaml
python3Packages.barectf
];
buildInputs = [
rocm-thunk
rocm-runtime
rocm-smi
hsa-amd-aqlprofile-bin
numactl
libpciaccess
libxml2
elfutils
mpi
gtest
];
cmakeFlags = [
"-DCMAKE_MODULE_PATH=${clr}/lib/cmake/hip"
"-DPROF_API_HEADER_PATH=${roctracer.src}/inc/ext"
"-DHIP_ROOT_DIR=${clr}"
"-DGPU_TARGETS=${lib.concatStringsSep ";" gpuTargets}"
# Manually define CMAKE_INSTALL_<DIR>
# See: https://github.com/NixOS/nixpkgs/pull/197838
"-DCMAKE_INSTALL_BINDIR=bin"
@ -39,14 +77,18 @@ stdenv.mkDerivation (finalAttrs: {
];
postPatch = ''
patchShebangs bin test
patchShebangs .
substituteInPlace cmake_modules/env.cmake \
--replace "FATAL_ERROR \"AQL_PROFILE" "WARNING \"AQL_PROFILE"
# Cannot find ROCm device library, pointless
substituteInPlace CMakeLists.txt \
--replace "add_subdirectory(tests-v2)" "" \
--replace "add_subdirectory(samples)" ""
'';
postInstall = ''
patchelf --set-rpath $out/lib:${lib.makeLibraryPath finalAttrs.buildInputs} $out/lib/rocprofiler/librocprof-tool.so
postBuild = ''
# HSACO aren't being built for some reason
substituteInPlace test/cmake_install.cmake \
--replace "file(INSTALL DESTINATION \"\''${CMAKE_INSTALL_PREFIX}/share/rocprofiler/tests-v1\" TYPE FILE FILES \"" "message(\""
'';
passthru.updateScript = rocmUpdateScript {
@ -61,6 +103,6 @@ stdenv.mkDerivation (finalAttrs: {
license = with licenses; [ mit ]; # mitx11
maintainers = teams.rocm.members;
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
broken = versions.minor finalAttrs.version != versions.minor clr.version;
};
})

View file

@ -3,10 +3,9 @@
, fetchFromGitHub
, rocmUpdateScript
, cmake
, hip
, clr
, git
, rocdbgapi
, rocm-runtime
, elfutils
}:
@ -23,20 +22,19 @@ stdenv.mkDerivation (finalAttrs: {
nativeBuildInputs = [
cmake
hip
clr
git
];
buildInputs = [
rocdbgapi
rocm-runtime
elfutils
];
cmakeFlags = [
"-DCMAKE_MODULE_PATH=${hip}/lib/cmake/hip"
"-DHIP_ROOT_DIR=${hip}"
"-DHIP_PATH=${hip}"
"-DCMAKE_MODULE_PATH=${clr}/lib/cmake/hip"
"-DHIP_ROOT_DIR=${clr}"
"-DHIP_PATH=${clr}"
];
# Weird install target
@ -56,6 +54,6 @@ stdenv.mkDerivation (finalAttrs: {
license = with licenses; [ ncsa ];
maintainers = teams.rocm.members;
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor hip.version;
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
};
})

View file

@ -80,6 +80,6 @@ stdenv.mkDerivation (finalAttrs: {
license = with licenses; [ mit ];
maintainers = teams.rocm.members;
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor hip.version;
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
};
})

View file

@ -90,6 +90,6 @@ stdenv.mkDerivation (finalAttrs: {
license = with licenses; [ bsd2 ];
maintainers = teams.rocm.members;
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor hip.version;
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
};
})

View file

@ -141,6 +141,6 @@ stdenv.mkDerivation (finalAttrs: {
license = with licenses; [ mit ];
maintainers = teams.rocm.members;
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor hip.version;
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
};
})

View file

@ -79,6 +79,6 @@ stdenv.mkDerivation (finalAttrs: {
license = with licenses; [ asl20 ];
maintainers = teams.rocm.members;
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor hip.version;
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
};
})

View file

@ -4,7 +4,7 @@
, rocmUpdateScript
, cmake
, clang
, hip
, clr
, rocm-device-libs
, rocprofiler
, libxml2
@ -39,14 +39,13 @@ stdenv.mkDerivation (finalAttrs: {
nativeBuildInputs = [
cmake
clang
hip
clr
] ++ lib.optionals buildDocs [
doxygen
graphviz
];
buildInputs = [
rocm-device-libs
rocprofiler
libxml2
python3Packages.python
@ -54,7 +53,7 @@ stdenv.mkDerivation (finalAttrs: {
];
cmakeFlags = [
"-DCMAKE_MODULE_PATH=${hip}/hip/cmake"
"-DCMAKE_MODULE_PATH=${clr}/hip/cmake"
# Manually define CMAKE_INSTALL_<DIR>
# See: https://github.com/NixOS/nixpkgs/pull/197838
"-DCMAKE_INSTALL_BINDIR=bin"
@ -85,7 +84,7 @@ stdenv.mkDerivation (finalAttrs: {
find $out/test -executable -type f -exec mv {} $test/bin \;
rm $test/bin/{*.sh,*.py}
patchelf --set-rpath $out/lib:${lib.makeLibraryPath (
finalAttrs.buildInputs ++ [ hip gcc-unwrapped.lib rocm-runtime ])} $test/bin/*
finalAttrs.buildInputs ++ [ clr gcc-unwrapped.lib rocm-runtime ])} $test/bin/*
rm -rf $out/test
'';
@ -101,6 +100,6 @@ stdenv.mkDerivation (finalAttrs: {
license = with licenses; [ mit ]; # mitx11
maintainers = teams.rocm.members;
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor hip.version;
broken = versions.minor finalAttrs.version != versions.minor clr.version;
};
})

View file

@ -141,6 +141,6 @@ in stdenv.mkDerivation (finalAttrs: {
license = with licenses; [ mit ];
maintainers = teams.rocm.members;
platforms = platforms.linux;
broken = versions.minor finalAttrs.version != versions.minor hip.version;
broken = versions.minor finalAttrs.version != versions.minor stdenv.cc.version;
};
})

View file

@ -12,7 +12,7 @@
let
pname =
if lib.hasPrefix "rocm-llvm-" name
then "rocmPackages_5.llvm.${lib.removePrefix "rocm-llvm-" name}"
then "llvm.${lib.removePrefix "rocm-llvm-" name}"
else name;
updateScript = writeScript "update.sh" ''
@ -27,6 +27,6 @@ let
version="''${version}.0"
fi
update-source-version ${pname} "$version" --ignore-same-hash
update-source-version rocmPackages_5.${pname} "$version" --ignore-same-hash
'';
in [ updateScript ]

View file

@ -16957,221 +16957,8 @@ with pkgs;
rml = callPackage ../development/compilers/rml { };
composable_kernel = callPackage ../development/libraries/composable_kernel {
inherit (rocmPackages.llvm) openmp clang-tools-extra;
stdenv = rocmClangStdenv;
};
rocprofiler = callPackage ../development/libraries/rocprofiler {
stdenv = rocmClangStdenv;
};
clang-ocl = callPackage ../development/libraries/clang-ocl {
stdenv = rocmClangStdenv;
};
rgxg = callPackage ../tools/text/rgxg { };
rocclr = callPackage ../development/libraries/rocclr {
stdenv = rocmClangStdenv;
};
hip-common = callPackage ../development/compilers/hip-common {
inherit (rocmPackages.llvm) llvm;
stdenv = rocmClangStdenv;
};
hipcc = callPackage ../development/compilers/hipcc {
inherit (rocmPackages.llvm) llvm;
stdenv = rocmClangStdenv;
};
hip = callPackage ../development/compilers/hip {
inherit (rocmPackages.llvm) llvm;
inherit (cudaPackages) cudatoolkit;
stdenv = rocmClangStdenv;
};
hip-amd = hip.override {
useNVIDIA = false;
};
hip-nvidia = hip.override {
useNVIDIA = true;
};
hipify = callPackage ../development/compilers/hipify {
stdenv = rocmClangStdenv;
};
hipcub = callPackage ../development/libraries/hipcub {
stdenv = rocmClangStdenv;
};
hipsparse = callPackage ../development/libraries/hipsparse {
inherit (rocmPackages.llvm) openmp;
stdenv = rocmClangStdenv;
};
hipfort = callPackage ../development/libraries/hipfort {
stdenv = rocmClangStdenv;
};
hipfft = callPackage ../development/libraries/hipfft {
inherit (rocmPackages.llvm) openmp;
stdenv = rocmClangStdenv;
};
hipsolver = callPackage ../development/libraries/hipsolver {
stdenv = rocmClangStdenv;
};
hipblas = callPackage ../development/libraries/hipblas {
stdenv = rocmClangStdenv;
};
migraphx = callPackage ../development/libraries/migraphx {
inherit (rocmPackages.llvm) clang-tools-extra openmp;
stdenv = rocmClangStdenv;
rocmlir = rocmlir-rock;
};
rccl = callPackage ../development/libraries/rccl {
stdenv = rocmClangStdenv;
};
rocm-cmake = callPackage ../development/tools/build-managers/rocm-cmake {
stdenv = rocmClangStdenv;
};
rocm-comgr = callPackage ../development/libraries/rocm-comgr {
stdenv = rocmClangStdenv;
};
rocalution = callPackage ../development/libraries/rocalution {
inherit (rocmPackages.llvm) openmp;
stdenv = rocmClangStdenv;
};
rocm-device-libs = callPackage ../development/libraries/rocm-device-libs {
stdenv = rocmClangStdenv;
};
rocm-opencl-icd = callPackage ../development/libraries/rocm-opencl-icd {
stdenv = rocmClangStdenv;
};
rocsolver = callPackage ../development/libraries/rocsolver {
stdenv = rocmClangStdenv;
};
rocm-opencl-runtime = callPackage ../development/libraries/rocm-opencl-runtime {
stdenv = rocmClangStdenv;
};
rocm-runtime = callPackage ../development/libraries/rocm-runtime {
stdenv = rocmClangStdenv;
};
rocm-smi = python3Packages.callPackage ../tools/system/rocm-smi {
stdenv = rocmClangStdenv;
};
rocm-thunk = callPackage ../development/libraries/rocm-thunk {
stdenv = rocmClangStdenv;
};
rocminfo = callPackage ../development/tools/rocminfo {
stdenv = rocmClangStdenv;
};
rocmlir = callPackage ../development/libraries/rocmlir {
stdenv = rocmClangStdenv;
};
# Best just use GCC here
rdc = callPackage ../development/tools/misc/rdc { };
# Best just use GCC here
rocgdb = callPackage ../development/tools/misc/rocgdb {
elfutils = elfutils.override { enableDebuginfod = true; };
};
rocdbgapi = callPackage ../development/libraries/rocdbgapi {
stdenv = rocmClangStdenv;
};
rocr-debug-agent = callPackage ../development/libraries/rocr-debug-agent {
stdenv = rocmClangStdenv;
};
rocmlir-rock = rocmlir.override {
buildRockCompiler = true;
};
rocm-core = callPackage ../development/libraries/rocm-core {
stdenv = rocmClangStdenv;
};
rocprim = callPackage ../development/libraries/rocprim {
stdenv = rocmClangStdenv;
};
rocsparse = callPackage ../development/libraries/rocsparse {
stdenv = rocmClangStdenv;
};
rocfft = callPackage ../development/libraries/rocfft {
inherit (rocmPackages.llvm) openmp;
stdenv = rocmClangStdenv;
};
rocrand = callPackage ../development/libraries/rocrand {
stdenv = rocmClangStdenv;
};
tensile = python3Packages.callPackage ../development/libraries/tensile {
stdenv = rocmClangStdenv;
};
rocwmma = callPackage ../development/libraries/rocwmma {
inherit (rocmPackages.llvm) openmp;
stdenv = rocmClangStdenv;
};
rocblas = callPackage ../development/libraries/rocblas {
inherit (rocmPackages.llvm) openmp;
stdenv = rocmClangStdenv;
};
miopengemm = callPackage ../development/libraries/miopengemm {
stdenv = rocmClangStdenv;
};
rocthrust = callPackage ../development/libraries/rocthrust {
stdenv = rocmClangStdenv;
};
miopen = callPackage ../development/libraries/miopen {
inherit (rocmPackages.llvm) llvm clang-tools-extra;
stdenv = rocmClangStdenv;
rocmlir = rocmlir-rock;
boost = boost179.override { enableStatic = true; };
};
miopen-hip = miopen.override {
useOpenCL = false;
};
miopen-opencl = miopen.override {
useOpenCL = true;
};
# Requires GCC
roctracer = callPackage ../development/libraries/roctracer {
inherit (rocmPackages.llvm) clang;
};
rtags = callPackage ../development/tools/rtags {
inherit (darwin) apple_sdk;
};
@ -30903,6 +30690,7 @@ with pkgs;
# LLVM 11 crashes when compiling GHOST_SystemCocoa.mm
stdenv = if stdenv.isDarwin then llvmPackages_10.stdenv else stdenv;
inherit (darwin.apple_sdk.frameworks) Cocoa CoreGraphics ForceFeedback OpenAL OpenGL;
inherit (rocmPackages) hip;
};
blender-with-packages = callPackage ../applications/misc/blender/wrapper.nix { };
@ -39476,6 +39264,7 @@ with pkgs;
inherit (callPackage ../development/libraries/science/math/magma {
inherit (rocmPackages.llvm) openmp;
inherit (rocmPackages) hip hipblas hipsparse;
}) magma magma_2_7_2 magma_2_6_2;
magma-cuda = magma.override {