From 988bf4f93d0cfd7bc3472da737db2d7777cf0a66 Mon Sep 17 00:00:00 2001 From: Ammar ELWazir Date: Sun, 12 May 2024 16:43:26 +0000 Subject: [PATCH] SWDEV-415888: fixing issues with rocprof tool duplication for testing Change-Id: I9168029cfc9519879bd024286ca6e2d9842deb85 --- test/CMakeLists.txt | 8 -------- test/ctrl/test_hsa.cpp | 9 ++++++++- test/run.sh | 32 +++++++++++++++++++++----------- 3 files changed, 29 insertions(+), 20 deletions(-) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 46efbd5baf..5b1a659bc9 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -208,10 +208,6 @@ configure_file(${TEST_DIR}/run.sh ${PROJECT_BINARY_DIR}/run.sh COPYONLY) execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${XML_FILES} ${PROJECT_BINARY_DIR}/) # TODO(aelwazir): Should be replaced by the current location in the main CMakeLists.txt -install( - TARGETS ${EXE_NAME} - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/tests-v1/test - COMPONENT tests) install( TARGETS ${EXE_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}/${ROCPROFILER_NAME} @@ -227,10 +223,6 @@ target_include_directories(${TEST_LIB} PRIVATE ${TEST_DIR} ${ROOT_DIR} target_link_libraries(${TEST_LIB} ${ROCPROFILER_TARGET} hsa-runtime64::hsa-runtime64 Threads::Threads atomic dl) # TODO(aelwazir): Should be replaced by the current location in the main CMakeLists.txt -install( - TARGETS ${TEST_LIB} - DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/tests-v1/test - COMPONENT tests) install( TARGETS ${TEST_LIB} DESTINATION ${CMAKE_INSTALL_LIBDIR}/${ROCPROFILER_NAME} diff --git a/test/ctrl/test_hsa.cpp b/test/ctrl/test_hsa.cpp index 6383f20aef..bbc9c360e6 100644 --- a/test/ctrl/test_hsa.cpp +++ b/test/ctrl/test_hsa.cpp @@ -88,9 +88,16 @@ bool TestHsa::Initialize(int /*arg_cnt*/, char** /*arg_list*/) { // Obtain the code object file name std::string agentName(agent_info_->name); + const char* hsaco_obj_files_path_str = getenv("HSACO_OBJ_FILES_PATH"); + fs::path hsaco_obj_files_path; Dl_info dl_info; + if(hsaco_obj_files_path_str) { + hsaco_obj_files_path = fs::path(hsaco_obj_files_path_str); + } else { + hsaco_obj_files_path = fs::path(dl_info.dli_fname); + } if (dladdr(reinterpret_cast(TestHsa::HsaShutdown), &dl_info) != 0) - brig_path_obj_.append(fs::path(dl_info.dli_fname).remove_filename().remove_filename()); + brig_path_obj_.append(hsaco_obj_files_path.remove_filename().remove_filename()); brig_path_obj_.append(agentName); brig_path_obj_.append("_" + name_ + ".hsaco"); diff --git a/test/run.sh b/test/run.sh index 03f5c030ad..d6aa7dbf9e 100755 --- a/test/run.sh +++ b/test/run.sh @@ -84,6 +84,20 @@ export ROCP_METRICS=$BIN_DIR/metrics.xml ## C test eval_test "C test" $BIN_DIR/test/c_test +export HSACO_OBJ_FILES_PATH="$BIN_DIR/test/" + +if test -f "$BIN_DIR/test/librocprof-tool.so" ; then + export ROCPROF_TOOL_PATH="$BIN_DIR/test/" +else + export ROCPROF_TOOL_PATH="$BIN_DIR/../../../lib/rocprofiler/" +fi + +if test -f "$BIN_DIR/test/rocprof-ctrl" ; then + export ROCPROF_CTRL_PATH="$BIN_DIR/test/" +else + export ROCPROF_CTRL_PATH="$BIN_DIR/../../../lib/rocprofiler/" +fi + ## Standalone sampling usage model test unset HSA_TOOLS_LIB unset ROCP_TOOL_LIB @@ -111,48 +125,44 @@ export ROCP_KITER=20 export ROCP_DITER=20 export ROCP_AGENTS=1 export ROCP_THRS=3 -eval_test "Intercepting usage model test" $BIN_DIR/test/rocprof-ctrl +eval_test "Intercepting usage model test" ${ROCPROF_CTRL_PATH}rocprof-ctrl ## Libtool test # tool library loaded by ROC profiler -export ROCP_TOOL_LIB=librocprof-tool.so +export ROCP_TOOL_LIB="${ROCPROF_TOOL_PATH}librocprof-tool.so" # ROC profiler kernels timing export ROCP_TIMESTAMP_ON=1 # output directory for the tool library, for metrics results file 'results.txt' mkdir -p /tmp/rocprofiler/RESULTS export ROCP_OUTPUT_DIR=/tmp/rocprofiler/RESULTS -if [ ! -e $ROCP_TOOL_LIB ] ; then - export ROCP_TOOL_LIB=$BIN_DIR/test/librocprof-tool.so -fi - export ROCP_KITER=20 export ROCP_DITER=20 export ROCP_AGENTS=1 export ROCP_THRS=1 export ROCP_INPUT=$BIN_DIR/pmc_input.xml -eval_test "'rocprof' rocprof-tool PMC test" $BIN_DIR/test/rocprof-ctrl +eval_test "'rocprof' rocprof-tool PMC test" ${ROCPROF_CTRL_PATH}rocprof-ctrl export ROCP_KITER=20 export ROCP_DITER=20 export ROCP_AGENTS=1 export ROCP_THRS=10 export ROCP_INPUT=$BIN_DIR/pmc_input.xml -eval_test "'rocprof' rocprof-tool PMC n-thread test" $BIN_DIR/test/rocprof-ctrl +eval_test "'rocprof' rocprof-tool PMC n-thread test" ${ROCPROF_CTRL_PATH}rocprof-ctrl export ROCP_KITER=20 export ROCP_DITER=20 export ROCP_AGENTS=1 export ROCP_THRS=1 export ROCP_INPUT=$BIN_DIR/pmc_input1.xml -eval_test "'rocprof' rocprof-tool PMC test1" $BIN_DIR/test/rocprof-ctrl +eval_test "'rocprof' rocprof-tool PMC test1" ${ROCPROF_CTRL_PATH}rocprof-ctrl export ROCP_KITER=20 export ROCP_DITER=20 export ROCP_AGENTS=1 export ROCP_THRS=10 export ROCP_INPUT=$BIN_DIR/pmc_input1.xml -eval_test "'rocprof' rocprof-tool PMC n-thread test1" $BIN_DIR/test/rocprof-ctrl +eval_test "'rocprof' rocprof-tool PMC n-thread test1" ${ROCPROF_CTRL_PATH}rocprof-ctrl unset ROCP_MCOPY_TRACKING # enable HSA intercepting @@ -160,7 +170,7 @@ export ROCP_HSA_INTERC=1 export ROCP_KITER=10 export ROCP_DITER=10 -eval_test "rocprof-tool test, counter sets" $BIN_DIR/test/rocprof-ctrl +eval_test "rocprof-tool test, counter sets" ${ROCPROF_CTRL_PATH}rocprof-ctrl ## OpenCL test #eval_test "libtool test, OpenCL sample" ./test/ocl/SimpleConvolution