rocm-runtime: 3.5.0 -> 3.7.0

This commit is contained in:
Daniël de Kok 2020-08-21 08:40:30 +02:00
parent acc68bba6a
commit d4e40af589
3 changed files with 19 additions and 39 deletions

View file

@ -1,41 +1,42 @@
{ stdenv
, fetchFromGitHub
, addOpenGLRunpath
, clang-unwrapped
, cmake
, xxd
, elfutils
, llvm
, rocm-device-libs
, rocm-thunk }:
stdenv.mkDerivation rec {
pname = "rocm-runtime";
version = "3.5.0";
version = "3.7.0";
src = fetchFromGitHub {
owner = "RadeonOpenCompute";
repo = "ROCR-Runtime";
rev = "rocm-${version}";
sha256 = "028x1f0if6lw41cpfpysp82ikp6c3fdxxd2a6ixs0vpm4424svb1";
sha256 = "1lm4cbx1d727zll85vjc1kykc72mk82nfhyyhjljv82gd4mnz00c";
};
sourceRoot = "source/src";
buildInputs = [ cmake elfutils ];
nativeBuildInputs = [ cmake xxd ];
cmakeFlags = [ "-DCMAKE_PREFIX_PATH=${rocm-thunk}" ];
buildInputs = [ clang-unwrapped elfutils llvm ];
# Use the ROCR_EXT_DIR environment variable and/or OpenGL driver
# link path to try to find binary-only ROCm runtime extension
# libraries. Without this change, we would have to rely on
# LD_LIBRARY_PATH to let the HSA runtime discover the shared
# libraries.
patchPhase = ''
substitute '${./rocr-ext-dir.diff}' ./rocr-ext-dir.diff \
--subst-var-by rocrExtDir "${addOpenGLRunpath.driverLink}/lib/rocm-runtime-ext"
patch -p2 < ./rocr-ext-dir.diff
cmakeFlags = [
"-DBITCODE_DIR=${rocm-device-libs}/lib"
"-DCMAKE_PREFIX_PATH=${rocm-thunk}"
];
postPatch = ''
patchShebangs image/blit_src/create_hsaco_ascii_file.sh
'';
fixupPhase = ''
rm -r $out/lib $out/include
mv $out/hsa/lib $out/hsa/include $out
rm -rf $out/hsa
'';
meta = with stdenv.lib; {

View file

@ -1,23 +0,0 @@
diff --git a/src/core/runtime/runtime.cpp b/src/core/runtime/runtime.cpp
index dd6a15c..fb6de49 100644
--- a/src/core/runtime/runtime.cpp
+++ b/src/core/runtime/runtime.cpp
@@ -1358,7 +1358,17 @@ void Runtime::LoadExtensions() {
core::HsaApiTable::HSA_EXT_FINALIZER_API_TABLE_ID);
// Update Hsa Api Table with handle of Image extension Apis
- extensions_.LoadImage(kImageLib[os_index(os::current_os)]);
+ //
+ // Use ROCR_EXT_DIR when it is non-empty. Otherwise, try to load the
+ // library from the OpenGL driver path.
+ std::string extDirVar = os::GetEnvVar("ROCR_EXT_DIR");
+ if (!extDirVar.empty()) {
+ extensions_.LoadImage(extDirVar + "/" + kImageLib[os_index(os::current_os)]);
+ } else {
+ std::string globalDriverDir("@rocrExtDir@");
+ extensions_.LoadImage(globalDriverDir + "/" + kImageLib[os_index(os::current_os)]);
+ }
+
hsa_api_table_.LinkExts(&extensions_.image_api,
core::HsaApiTable::HSA_EXT_IMAGE_API_TABLE_ID);
}

View file

@ -9354,7 +9354,9 @@ in
inherit (llvmPackages_rocm) clang clang-unwrapped lld llvm;
};
rocm-runtime = callPackage ../development/libraries/rocm-runtime { };
rocm-runtime = callPackage ../development/libraries/rocm-runtime {
inherit (llvmPackages_rocm) clang-unwrapped llvm;
};
rocm-runtime-ext = callPackage ../development/libraries/rocm-runtime-ext { };