Merge pull request #93388 from danieldk/more-local-rocr-ext-dir
rocm-runtime: make ROCR_EXT_DIR handling more local
This commit is contained in:
commit
ae33b7daec
1 changed files with 19 additions and 20 deletions
|
@ -1,24 +1,23 @@
|
|||
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");
|
||||
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);
|
||||
|
||||
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());
|
||||
// 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)]);
|
||||
+ }
|
||||
+
|
||||
return *(LibHandle*)&ret;
|
||||
hsa_api_table_.LinkExts(&extensions_.image_api,
|
||||
core::HsaApiTable::HSA_EXT_IMAGE_API_TABLE_ID);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue