From 0a42617f580b629517c2419dfef79bad58af9fab Mon Sep 17 00:00:00 2001 From: Ioannis Assiouras Date: Mon, 10 Jun 2024 13:58:27 +0100 Subject: [PATCH] SWDEV-465236 - Changed RTCProgram::findIsa to not dlopen amdhip64 for static build Change-Id: I322ef4ca96ea426a0953f1234e60db6cebb09886 [ROCm/clr commit: 7b0259c4b76d878acd4596d1090f74cce40dd077] --- projects/clr/hipamd/src/hiprtc/CMakeLists.txt | 1 + .../clr/hipamd/src/hiprtc/hiprtcInternal.cpp | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/projects/clr/hipamd/src/hiprtc/CMakeLists.txt b/projects/clr/hipamd/src/hiprtc/CMakeLists.txt index 33f8334be5..60799f4aba 100644 --- a/projects/clr/hipamd/src/hiprtc/CMakeLists.txt +++ b/projects/clr/hipamd/src/hiprtc/CMakeLists.txt @@ -35,6 +35,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") if(BUILD_SHARED_LIBS) add_library(hiprtc SHARED) + target_compile_definitions(hiprtc PRIVATE BUILD_SHARED_LIBS) # Windows doesn't have a strip utility, so CMAKE_STRIP won't be set. if((CMAKE_BUILD_TYPE STREQUAL "Release") AND NOT ("${CMAKE_STRIP}" STREQUAL "")) add_custom_command(TARGET hiprtc POST_BUILD COMMAND ${CMAKE_STRIP} $) diff --git a/projects/clr/hipamd/src/hiprtc/hiprtcInternal.cpp b/projects/clr/hipamd/src/hiprtc/hiprtcInternal.cpp index de597272aa..d81d930bd6 100644 --- a/projects/clr/hipamd/src/hiprtc/hiprtcInternal.cpp +++ b/projects/clr/hipamd/src/hiprtc/hiprtcInternal.cpp @@ -65,6 +65,8 @@ RTCProgram::RTCProgram(std::string name) : name_(name) { } bool RTCProgram::findIsa() { + +#ifdef BUILD_SHARED_LIBS const char* libName; #ifdef _WIN32 std::string dll_name = std::string("amdhip64_" + std::to_string(HIP_VERSION_MAJOR) + ".dll"); @@ -121,6 +123,23 @@ bool RTCProgram::findIsa() { amd::Os::unloadLibrary(handle); return true; + +#else + int device; + hipError_t status = hipGetDevice(&device); + if (status != hipSuccess) { + return false; + } + hipDeviceProp_t props; + status = hipGetDeviceProperties(&props, device); + if (status != hipSuccess) { + return false; + } + isa_ = "amdgcn-amd-amdhsa--"; + isa_.append(props.gcnArchName); + + return true; +#endif } // RTC Compile Program Member Functions