SWDEV-428381 Remove Hardcoded rocm path

Change-Id: I39cfbc9add62813076db1992faea4426638859af
이 커밋은 다음에 포함됨:
AravindanC
2024-02-16 21:25:05 -08:00
커밋한 사람 Aravindan Cheruvally
부모 fe00badc6e
커밋 2d7167d068
3개의 변경된 파일42개의 추가작업 그리고 0개의 파일을 삭제
+6
파일 보기
@@ -168,6 +168,12 @@ if(NOT USE_PROF_API)
set(USE_PROF_API 1)
endif()
# Enable use of getROCmInstallPath() API
if(USE_GET_ROCM_PATH_API)
set(USE_GET_ROCM_PATH_API 1)
message(STATUS "Enabled Use of getROCmInstallPath() API" )
endif()
# Protocol header lookup
set(PROF_API_HEADER_NAME prof_protocol.h)
if(USE_PROF_API EQUAL 1)
+15
파일 보기
@@ -45,6 +45,14 @@ target_compile_definitions(
PRIVATE HIP_PROF_HIP_API_STRING=1 __HIP_PLATFORM_AMD__=1
CTF_PLUGIN_METADATA_FILE_PATH="${METADATA_STREAM_FILE_DIR}/metadata"
CTF_PLUGIN_INSTALL_PREFIX="${CMAKE_INSTALL_PREFIX}")
# Add definitions for getROCmInstallPath() API
if(USE_GET_ROCM_PATH_API)
target_compile_definitions(
ctf_plugin
PRIVATE USE_GET_ROCM_PATH_API=1)
endif()
target_include_directories(
ctf_plugin PRIVATE "${PROJECT_SOURCE_DIR}" "${CMAKE_BINARY_DIR}/src/api"
"${CMAKE_CURRENT_BINARY_DIR}")
@@ -53,6 +61,13 @@ target_link_options(
-Wl,--no-undefined)
target_link_libraries(ctf_plugin PRIVATE rocprofiler-v2 hsa-runtime64::hsa-runtime64
stdc++fs dl)
# Add link dependencies for getROCmInstallPath() API
if(USE_GET_ROCM_PATH_API)
find_library(ROCM_CORE_LIB rocm-core HINTS ${ROCM_PATH}/lib)
target_link_libraries(ctf_plugin PRIVATE ${ROCM_CORE_LIB})
endif()
install(TARGETS ctf_plugin LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}/${PROJECT_NAME}"
COMPONENT plugins)
+21
파일 보기
@@ -35,6 +35,9 @@
#include "rocprofiler_plugin.h"
#include "plugin.h"
#ifdef USE_GET_ROCM_PATH_API
#include <rocm-core/rocm_getpath.h>
#endif
namespace fs = std::experimental::filesystem;
@@ -84,6 +87,23 @@ ROCPROFILER_EXPORT int rocprofiler_plugin_initialize(const uint32_t rocprofiler_
_replace("\\$ENV\\{PPID\\}", getppid());
// Create the plugin instance.
#ifdef USE_GET_ROCM_PATH_API
char *installPath = nullptr;
unsigned int installPathLen = 0;
PathErrors_t retVal = PathSuccess;
auto metadata_path = std::string{CTF_PLUGIN_METADATA_FILE_PATH};
// Get ROCM install path
retVal = getROCmInstallPath( &installPath, &installPathLen );
if(PathSuccess == retVal){
metadata_path = fs::path(installPath);
}else {
std::cout << "Failed to get ROCm Install Path: " << retVal << std::endl;
}
// free allocated memory
if(nullptr != installPath) {
free(installPath);
}
#else
auto* this_plugin_handle = dlopen("libctf_plugin.so", RTLD_LAZY | RTLD_NOLOAD);
auto* librocprofiler_handle = dlopen("librocprofiler64.so", RTLD_LAZY | RTLD_NOLOAD);
auto metadata_path = std::string{CTF_PLUGIN_METADATA_FILE_PATH};
@@ -100,6 +120,7 @@ ROCPROFILER_EXPORT int rocprofiler_plugin_initialize(const uint32_t rocprofiler_
if (!fs::exists(metadata_path)) {
metadata_path = fs::path{CTF_PLUGIN_INSTALL_PREFIX} / CTF_PLUGIN_METADATA_FILE_PATH;
}
#endif // USE_GET_ROCM_PATH_API
try {
the_plugin = new rocm_ctf::Plugin{256 * 1024, fs::path{output_dir} / output_file,