SWDEV-336448 - Support loading comgr versioned dll
Change-Id: I03283fc2a200d778c5efa43e509624bba9ce0541
This commit is contained in:
committato da
Maneesh Gupta
parent
50e0ddb055
commit
64c1c4757f
@@ -30,3 +30,8 @@ if(BUILD_SHARED_LIBS)
|
||||
target_compile_definitions(rocclr PUBLIC COMGR_DYN_DLL)
|
||||
endif()
|
||||
target_link_libraries(rocclr PUBLIC amd_comgr)
|
||||
|
||||
if(${CMAKE_PROJECT_NAME} STREQUAL "hip")
|
||||
add_definitions(-DHIP_MAJOR_VERSION=${HIP_VERSION_MAJOR})
|
||||
add_definitions(-DHIP_MINOR_VERSION=${HIP_VERSION_MINOR})
|
||||
endif()
|
||||
|
||||
@@ -28,13 +28,40 @@ std::once_flag Comgr::initialized;
|
||||
ComgrEntryPoints Comgr::cep_;
|
||||
bool Comgr::is_ready_ = false;
|
||||
|
||||
bool Comgr::LoadLib() {
|
||||
bool Comgr::LoadLib(bool is_versioned) {
|
||||
#if defined(COMGR_DYN_DLL)
|
||||
ClPrint(amd::LOG_INFO, amd::LOG_CODE, "Loading COMGR library.");
|
||||
static constexpr const char* ComgrLibName =
|
||||
|
||||
if (is_versioned) {
|
||||
#if defined(HIP_MAJOR_VERSION) && defined(HIP_MAJOR_VERSION)
|
||||
std::string comgr_versioned_name, major_version, minor_version;
|
||||
const std::string kComgrPrefix = "amd_comgr";
|
||||
|
||||
if (HIP_MAJOR_VERSION > 9) {
|
||||
major_version = std::to_string(HIP_MAJOR_VERSION);
|
||||
} else {
|
||||
major_version = "0" + std::to_string(HIP_MAJOR_VERSION);
|
||||
}
|
||||
|
||||
if (HIP_MINOR_VERSION > 9) {
|
||||
minor_version = std::to_string(HIP_MINOR_VERSION);
|
||||
} else {
|
||||
minor_version = "0" + std::to_string(HIP_MINOR_VERSION);
|
||||
}
|
||||
|
||||
comgr_versioned_name = kComgrPrefix + major_version + minor_version + std::string(".dll");
|
||||
|
||||
static const char* comgr_lib_name =
|
||||
LP64_SWITCH(WINDOWS_SWITCH("amd_comgr32.dll", "libamd_comgr32.so.2"),
|
||||
WINDOWS_SWITCH(comgr_versioned_name.c_str(), "libamd_comgr.so.2"));
|
||||
cep_.handle = Os::loadLibrary(comgr_lib_name);
|
||||
#endif
|
||||
} else {
|
||||
static constexpr const char* comgr_lib_name =
|
||||
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(comgr_lib_name);
|
||||
}
|
||||
if (nullptr == cep_.handle) {
|
||||
ClPrint(amd::LOG_ERROR, amd::LOG_CODE, "Failed to load COMGR library.");
|
||||
return false;
|
||||
|
||||
@@ -140,7 +140,7 @@ class Comgr : public amd::AllStatic {
|
||||
public:
|
||||
static std::once_flag initialized;
|
||||
|
||||
static bool LoadLib();
|
||||
static bool LoadLib(bool is_versioned = false);
|
||||
|
||||
static bool IsReady() { return is_ready_; }
|
||||
|
||||
|
||||
@@ -531,7 +531,8 @@ bool Device::ValidateComgr() {
|
||||
#if defined(USE_COMGR_LIBRARY)
|
||||
// Check if Lightning compiler was requested
|
||||
if (settings_->useLightning_) {
|
||||
std::call_once(amd::Comgr::initialized, amd::Comgr::LoadLib);
|
||||
constexpr bool kComgrVersioned = false;
|
||||
std::call_once(amd::Comgr::initialized, amd::Comgr::LoadLib, kComgrVersioned);
|
||||
// Use Lightning only if it's available
|
||||
settings_->useLightning_ = amd::Comgr::IsReady();
|
||||
return settings_->useLightning_;
|
||||
|
||||
Fai riferimento in un nuovo problema
Block a user