rocm-runtime-ext: init at 3.5.1
This package provides the closed-source extension for rocm-runtime that is necessary for OpenCL image processing.
This commit is contained in:
parent
d2754e07bb
commit
68fecda43a
42
pkgs/development/libraries/rocm-runtime-ext/default.nix
Normal file
42
pkgs/development/libraries/rocm-runtime-ext/default.nix
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
{ stdenv, fetchurl, autoPatchelfHook, rpmextract, rocm-runtime }:
|
||||||
|
|
||||||
|
stdenv.mkDerivation rec {
|
||||||
|
pname = "rocm-runtime-ext";
|
||||||
|
version = "3.5.1";
|
||||||
|
|
||||||
|
src = fetchurl {
|
||||||
|
url = "https://repo.radeon.com/rocm/yum/3.5.1/hsa-ext-rocr-dev-1.1.30501.0-rocm-rel-3.5-34-def83d8a-Linux.rpm";
|
||||||
|
sha256 = "0r7lrmnplr10hs6wrji55i3dnczfzlmp8jahm1g3mhq2x12zmly0";
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeBuildInputs = [ autoPatchelfHook rpmextract ];
|
||||||
|
|
||||||
|
buildInputs = [ rocm-runtime stdenv.cc.cc ];
|
||||||
|
|
||||||
|
unpackPhase = "rpmextract ${src}";
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out/lib
|
||||||
|
cp -R opt/rocm-${version}/hsa/lib $out/lib/rocm-runtime-ext
|
||||||
|
'';
|
||||||
|
|
||||||
|
setupHook = ./setup-hook.sh;
|
||||||
|
|
||||||
|
meta = with stdenv.lib; {
|
||||||
|
description = "Platform runtime for ROCm (closed-source extensions)";
|
||||||
|
longDescription = ''
|
||||||
|
This package provides closed-source extensions to the ROCm
|
||||||
|
runtime. Currently this adds support for OpenCL image
|
||||||
|
processing.
|
||||||
|
|
||||||
|
In order for the ROCm runtime to pick up the extension, you
|
||||||
|
should either set the ROCR_EXT_DIR environment variable should
|
||||||
|
be set to ''${rocm-runtime-ext}/lib/rocm-runtime-ext or this
|
||||||
|
package should be added to the hardware.opengl.extraPackages
|
||||||
|
NixOS configuration option.
|
||||||
|
'';
|
||||||
|
homepage = "https://github.com/RadeonOpenCompute/ROCR-Runtime";
|
||||||
|
license = with licenses; [ unfreeRedistributable ];
|
||||||
|
maintainers = with maintainers; [ danieldk ];
|
||||||
|
};
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
addRocmRuntimeExtDir () {
|
||||||
|
if [[ -z "${ROCR_EXT_DIR-}" ]]; then
|
||||||
|
export ROCR_EXT_DIR="@out@/lib/rocm-runtime-ext"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
addEnvHooks "$hostOffset" addRocmRuntimeExtDir
|
@ -1,4 +1,9 @@
|
|||||||
{ stdenv, fetchFromGitHub, cmake, elfutils, rocm-thunk }:
|
{ stdenv
|
||||||
|
, fetchFromGitHub
|
||||||
|
, addOpenGLRunpath
|
||||||
|
, cmake
|
||||||
|
, elfutils
|
||||||
|
, rocm-thunk }:
|
||||||
|
|
||||||
stdenv.mkDerivation rec {
|
stdenv.mkDerivation rec {
|
||||||
pname = "rocm-runtime";
|
pname = "rocm-runtime";
|
||||||
@ -17,14 +22,15 @@ stdenv.mkDerivation rec {
|
|||||||
|
|
||||||
cmakeFlags = [ "-DCMAKE_PREFIX_PATH=${rocm-thunk}" ];
|
cmakeFlags = [ "-DCMAKE_PREFIX_PATH=${rocm-thunk}" ];
|
||||||
|
|
||||||
# Use the ROCR_EXT_DIR environment variable to try to find
|
# Use the ROCR_EXT_DIR environment variable and/or OpenGL driver
|
||||||
# binary-only extension libraries. This environment variable is set
|
# link path to try to find binary-only ROCm runtime extension
|
||||||
# by the `rocr-ext` derivation. If that derivation is not in scope,
|
# libraries. Without this change, we would have to rely on
|
||||||
# then the extension libraries are not loaded. Without this edit, we
|
# LD_LIBRARY_PATH to let the HSA runtime discover the shared
|
||||||
# would have to rely on LD_LIBRARY_PATH to let the HSA runtime
|
# libraries.
|
||||||
# discover the shared libraries.
|
|
||||||
patchPhase = ''
|
patchPhase = ''
|
||||||
sed 's/\(k\(Image\|Finalizer\)Lib\[os_index(os::current_os)\]\)/os::GetEnvVar("ROCR_EXT_DIR") + "\/" + \1/g' -i core/runtime/runtime.cpp
|
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
|
||||||
'';
|
'';
|
||||||
|
|
||||||
fixupPhase = ''
|
fixupPhase = ''
|
||||||
|
24
pkgs/development/libraries/rocm-runtime/rocr-ext-dir.diff
Normal file
24
pkgs/development/libraries/rocm-runtime/rocr-ext-dir.diff
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
diff --git a/src/core/util/lnx/os_linux.cpp b/src/core/util/lnx/os_linux.cpp
|
||||||
|
index fdbe19a..42d4ef8 100644
|
||||||
|
--- a/src/core/util/lnx/os_linux.cpp
|
||||||
|
+++ b/src/core/util/lnx/os_linux.cpp
|
||||||
|
@@ -161,8 +161,17 @@ static_assert(sizeof(Mutex) == sizeof(pthread_mutex_t*), "OS abstraction size mi
|
||||||
|
static_assert(sizeof(Thread) == sizeof(os_thread*), "OS abstraction size mismatch");
|
||||||
|
|
||||||
|
LibHandle LoadLib(std::string filename) {
|
||||||
|
- void* ret = dlopen(filename.c_str(), RTLD_LAZY);
|
||||||
|
- if (ret == nullptr) debug_print("LoadLib(%s) failed: %s\n", filename.c_str(), dlerror());
|
||||||
|
+ std::string extDirFilename = GetEnvVar("ROCR_EXT_DIR") + "/" + filename;
|
||||||
|
+ void* ret = dlopen(extDirFilename.c_str(), RTLD_LAZY);
|
||||||
|
+
|
||||||
|
+ // Attempt to load from the directory hardcoded by rocrExtDir.
|
||||||
|
+ if (ret == nullptr) {
|
||||||
|
+ std::string runpathFilename = std::string("@rocrExtDir@") + "/" + filename;
|
||||||
|
+ ret = dlopen(runpathFilename.c_str(), RTLD_LAZY);
|
||||||
|
+
|
||||||
|
+ if (ret == nullptr) debug_print("LoadLib(%s) failed: %s\n", filename.c_str(), dlerror());
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
return *(LibHandle*)&ret;
|
||||||
|
}
|
||||||
|
|
@ -9282,6 +9282,8 @@ in
|
|||||||
|
|
||||||
rocm-runtime = callPackage ../development/libraries/rocm-runtime { };
|
rocm-runtime = callPackage ../development/libraries/rocm-runtime { };
|
||||||
|
|
||||||
|
rocm-runtime-ext = callPackage ../development/libraries/rocm-runtime-ext { };
|
||||||
|
|
||||||
rocm-thunk = callPackage ../development/libraries/rocm-thunk { };
|
rocm-thunk = callPackage ../development/libraries/rocm-thunk { };
|
||||||
|
|
||||||
rtags = callPackage ../development/tools/rtags {
|
rtags = callPackage ../development/tools/rtags {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user