Skip to content
This repository has been archived by the owner on Jan 26, 2024. It is now read-only.

Fix AMD CoMGR loading #32

Open
wants to merge 1 commit into
base: rocm-5.0.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion device/comgrctx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ bool Comgr::LoadLib() {
static constexpr const char* ComgrLibName =
LP64_SWITCH(WINDOWS_SWITCH("amd_comgr32.dll", "libamd_comgr32.so.2"),
WINDOWS_SWITCH("amd_comgr.dll", "libamd_comgr.so.2"));
cep_.handle = Os::loadLibrary(ComgrLibName);
cep_.handle = Os::loadLibrary(ComgrLibName, /*global*/true);
if (nullptr == cep_.handle) {
ClPrint(amd::LOG_ERROR, amd::LOG_CODE, "Failed to load COMGR library.");
return false;
Expand Down
6 changes: 3 additions & 3 deletions os/os.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

namespace amd {

void* Os::loadLibrary(const char* libraryname) {
void* Os::loadLibrary(const char* libraryname, bool global) {
void* handle;

// Try with the system library prefix and extension instead.
Expand Down Expand Up @@ -73,7 +73,7 @@ void* Os::loadLibrary(const char* libraryname) {
#endif
}

handle = Os::loadLibrary_(libraryname);
handle = Os::loadLibrary_(libraryname, global);
if (handle != NULL) {
return handle;
}
Expand All @@ -96,7 +96,7 @@ void* Os::loadLibrary(const char* libraryname) {
}
str.append(Os::libraryExtension());

handle = Os::loadLibrary_(str.c_str());
handle = Os::loadLibrary_(str.c_str(), global);
if (handle != NULL || str.find(fileSeparator()) != std::string::npos) {
return handle;
}
Expand Down
5 changes: 3 additions & 2 deletions os/os.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ class Os : AllStatic {

private:
//! Load the shared library named by \a filename
static void* loadLibrary_(const char* filename);
static void* loadLibrary_(const char* filename, bool global);

public:
//! Initialize the Os package.
Expand Down Expand Up @@ -280,7 +280,8 @@ class Os : AllStatic {
typedef bool (*SymbolCallback)(std::string, const void*, void*);

//! Load the shared library named by \a filename
static void* loadLibrary(const char* filename);
static void* loadLibrary(const char* filename, bool global=false);

//! Unload the shared library.
static void unloadLibrary(void* handle);
//! Return the address of the function identified by \a name.
Expand Down
6 changes: 4 additions & 2 deletions os/os_posix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,10 @@ static void __exit() { Os::tearDown(); }

void Os::tearDown() { Thread::tearDown(); }

void* Os::loadLibrary_(const char* filename) {
return (*filename == '\0') ? NULL : ::dlopen(filename, RTLD_LAZY);
void* Os::loadLibrary_(const char* filename, bool global) {
int flags = RTLD_LAZY;
if (global) flags |= RTLD_GLOBAL;
return (*filename == '\0') ? NULL : ::dlopen(filename, flags);
}

void Os::unloadLibrary(void* handle) { ::dlclose(handle); }
Expand Down
2 changes: 1 addition & 1 deletion os/os_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ __declspec(allocate(".CRT$XTU")) void (*__exit)(void) = Os::tearDown;

void Os::tearDown() { Thread::tearDown(); }

void* Os::loadLibrary_(const char* filename) {
void* Os::loadLibrary_(const char* filename, bool global) {
if (filename != NULL) {
HMODULE hModule = ::LoadLibrary(filename);
return hModule;
Expand Down