Fixing ROCProfiler V1 Tests & V1 Tests Packaging
Change-Id: I741e29b8fbce9d4643c4f13afafd7d4fd648094b
[ROCm/rocprofiler commit: 19e3253049]
This commit is contained in:
@@ -48,6 +48,7 @@ include_directories(${HSA_RUNTIME_INC_PATH})
|
||||
## C test
|
||||
add_executable ( "c_test" ${TEST_DIR}/app/c_test.c )
|
||||
target_include_directories ( "c_test" PRIVATE ${ROOT_DIR} ${PROJECT_SOURCE_DIR}/include $<TARGET_PROPERTY:hsa-runtime64::hsa-runtime64,INTERFACE_INCLUDE_DIRECTORIES> )
|
||||
install(TARGETS "c_test" DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/tests-v1/test COMPONENT tests)
|
||||
|
||||
## Util sources
|
||||
file( GLOB UTIL_SRC "${TEST_DIR}/util/*.cpp" )
|
||||
@@ -86,33 +87,73 @@ set ( TEST_NAME simple_convolution )
|
||||
set ( KERN_SRC ${TEST_DIR}/${TEST_NAME}/${TEST_NAME}.cpp )
|
||||
|
||||
## Building test kernels
|
||||
add_custom_target( mytest
|
||||
COMMAND sh -xc "${TEST_DIR}/../bin/build_kernel.sh ${TEST_DIR}/${DUMMY_NAME}/${DUMMY_NAME} ${PROJECT_BINARY_DIR} '${ROCM_ROOT_DIR}' '${GPU_TARGETS}'"
|
||||
COMMAND sh -xc "${TEST_DIR}/../bin/build_kernel.sh ${TEST_DIR}/${TEST_NAME}/${TEST_NAME} ${PROJECT_BINARY_DIR} '${ROCM_ROOT_DIR}' '${GPU_TARGETS}'"
|
||||
)
|
||||
# add_custom_target( mytest
|
||||
# COMMAND sh -xc "${TEST_DIR}/../bin/build_kernel.sh ${TEST_DIR}/${DUMMY_NAME}/${DUMMY_NAME} ${PROJECT_BINARY_DIR} '${ROCM_ROOT_DIR}' '${GPU_TARGETS}'"
|
||||
# COMMAND sh -xc "${TEST_DIR}/../bin/build_kernel.sh ${TEST_DIR}/${TEST_NAME}/${TEST_NAME} ${PROJECT_BINARY_DIR} '${ROCM_ROOT_DIR}' '${GPU_TARGETS}'"
|
||||
# )
|
||||
|
||||
find_package(Clang REQUIRED CONFIG
|
||||
PATHS ${ROCM_ROOT_DIR}
|
||||
PATH_SUFFIXES "llvm/lib/cmake/clang")
|
||||
|
||||
## Build the hsa (standalone) simple_convolution test
|
||||
function(generate_hsaco TARGET_ID INPUT_FILE OUTPUT_FILE)
|
||||
separate_arguments(CLANG_ARG_LIST UNIX_COMMAND
|
||||
"-O2 -x cl -Xclang -finclude-default-header -cl-denorms-are-zero -cl-std=CL2.0 --hip-device-lib-path=${ROCM_ROOT_DIR}/amdgcn/bitcode
|
||||
-Wl,--build-id=sha1 -target amdgcn-amd-amdhsa -mcpu=${TARGET_ID} -mcode-object-version=4 -o ${OUTPUT_FILE} ${INPUT_FILE}")
|
||||
add_custom_command(OUTPUT ${PROJECT_BINARY_DIR}/${OUTPUT_FILE}
|
||||
COMMAND clang ${CLANG_ARG_LIST}
|
||||
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||
DEPENDS ${INPUT_FILE} clang
|
||||
COMMENT "Building ${OUTPUT_FILE}..."
|
||||
VERBATIM)
|
||||
install(FILES ${PROJECT_BINARY_DIR}/${OUTPUT_FILE} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/tests-v1 COMPONENT tests)
|
||||
set(HSACO_TARGET_LIST ${HSACO_TARGET_LIST} ${PROJECT_BINARY_DIR}/${OUTPUT_FILE} PARENT_SCOPE)
|
||||
endfunction(generate_hsaco)
|
||||
|
||||
separate_arguments(GPU_TARGETS)
|
||||
list(LENGTH GPU_TARGETS list_count)
|
||||
if (${list_count} LESS_EQUAL 1)
|
||||
string(REPLACE " " ";" GPU_LIST ${GPU_TARGETS})
|
||||
string(REPLACE "," ";" GPU_LIST ${GPU_TARGETS})
|
||||
else()
|
||||
set(GPU_LIST ${GPU_TARGETS})
|
||||
endif()
|
||||
foreach(target_id ${GPU_LIST})
|
||||
## generate kernel bitcodes
|
||||
generate_hsaco(${target_id} ${TEST_DIR}/${TEST_NAME}/${TEST_NAME}.cl ${target_id}_SimpleConvolution.hsaco)
|
||||
generate_hsaco(${target_id} ${TEST_DIR}/${DUMMY_NAME}/${DUMMY_NAME}.cl ${target_id}_DummyKernel.hsaco)
|
||||
endforeach(target_id)
|
||||
add_custom_target(test DEPENDS ${HSACO_TARGET_LIST})
|
||||
add_custom_target(mytest DEPENDS ${HSACO_TARGET_LIST})
|
||||
|
||||
## Building standalone test executable
|
||||
add_executable ( ${ST_EXE_NAME} ${ST_TST_SRC} ${UTIL_SRC} ${KERN_SRC} )
|
||||
target_include_directories ( ${ST_EXE_NAME} PRIVATE ${TEST_DIR} ${ROOT_DIR} ${PROJECT_SOURCE_DIR}/include )
|
||||
target_link_libraries ( ${ST_EXE_NAME} ${ROCPROFILER_TARGET} hsa-runtime64::hsa-runtime64 hsakmt::hsakmt Threads::Threads dl )
|
||||
target_link_libraries ( ${ST_EXE_NAME} ${ROCPROFILER_TARGET} hsa-runtime64::hsa-runtime64 hsakmt::hsakmt Threads::Threads stdc++fs dl )
|
||||
install(TARGETS ${ST_EXE_NAME} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/tests-v1/test COMPONENT tests)
|
||||
|
||||
## Building standalone intercept test executable
|
||||
add_executable ( ${STIN_EXE_NAME} ${STIN_TST_SRC} ${UTIL_SRC} ${KERN_SRC} )
|
||||
target_include_directories ( ${STIN_EXE_NAME} PRIVATE ${TEST_DIR} ${ROOT_DIR} ${PROJECT_SOURCE_DIR}/include )
|
||||
target_link_libraries ( ${STIN_EXE_NAME} ${ROCPROFILER_TARGET} hsa-runtime64::hsa-runtime64 hsakmt::hsakmt Threads::Threads dl )
|
||||
target_link_libraries ( ${STIN_EXE_NAME} ${ROCPROFILER_TARGET} hsa-runtime64::hsa-runtime64 hsakmt::hsakmt Threads::Threads stdc++fs dl )
|
||||
install(TARGETS ${STIN_EXE_NAME} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/tests-v1/test COMPONENT tests)
|
||||
|
||||
## Building intercept test executable
|
||||
add_library ( ${IN_EXE_NAME} SHARED ${IN_TST_SRC} ${UTIL_SRC} ${KERN_SRC} )
|
||||
target_include_directories ( ${IN_EXE_NAME} PRIVATE ${TEST_DIR} ${ROOT_DIR} ${PROJECT_SOURCE_DIR}/include )
|
||||
target_link_libraries ( ${IN_EXE_NAME} ${ROCPROFILER_TARGET} hsa-runtime64::hsa-runtime64 hsakmt::hsakmt Threads::Threads dl )
|
||||
target_link_libraries ( ${IN_EXE_NAME} ${ROCPROFILER_TARGET} hsa-runtime64::hsa-runtime64 hsakmt::hsakmt Threads::Threads stdc++fs dl )
|
||||
install(TARGETS ${IN_EXE_NAME} DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/tests-v1/test COMPONENT tests)
|
||||
|
||||
## Building ctrl test executable
|
||||
add_executable ( ${EXE_NAME} ${CTRL_SRC} ${UTIL_SRC} ${KERN_SRC} )
|
||||
target_include_directories ( ${EXE_NAME} PRIVATE ${TEST_DIR} ${ROOT_DIR} ${PROJECT_SOURCE_DIR}/include )
|
||||
target_link_libraries ( ${EXE_NAME} hsa-runtime64::hsa-runtime64 hsakmt::hsakmt Threads::Threads dl )
|
||||
target_link_libraries ( ${EXE_NAME} hsa-runtime64::hsa-runtime64 hsakmt::hsakmt Threads::Threads stdc++fs dl )
|
||||
execute_process ( COMMAND sh -xc "cp ${TEST_DIR}/run.sh ${PROJECT_BINARY_DIR}" )
|
||||
execute_process ( COMMAND sh -xc "cp ${TEST_DIR}/tool/*.xml ${PROJECT_BINARY_DIR}" )
|
||||
execute_process ( COMMAND sh -xc "mkdir -p ${PROJECT_BINARY_DIR}/RESULTS" )
|
||||
## 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)
|
||||
|
||||
## Build test library
|
||||
set ( TEST_LIB "rocprof-tool" )
|
||||
@@ -120,6 +161,8 @@ set ( TEST_LIB_SRC ${TEST_DIR}/tool/tool.cpp ${UTIL_SRC} )
|
||||
add_library ( ${TEST_LIB} SHARED ${TEST_LIB_SRC} )
|
||||
target_include_directories ( ${TEST_LIB} PRIVATE ${TEST_DIR} ${ROOT_DIR} ${PROJECT_SOURCE_DIR}/include )
|
||||
target_link_libraries ( ${TEST_LIB} ${ROCPROFILER_TARGET} hsa-runtime64::hsa-runtime64 Threads::Threads 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)
|
||||
|
||||
## Build memory test bench
|
||||
add_custom_target( mbench
|
||||
@@ -129,3 +172,23 @@ add_custom_target( mbench
|
||||
|
||||
## Copy OCL test
|
||||
execute_process ( COMMAND sh -xc "cp -r ${TEST_DIR}/ocl ${PROJECT_BINARY_DIR}/test/." )
|
||||
install(DIRECTORY ${TEST_DIR}/ocl DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/tests-v1/test COMPONENT tests)
|
||||
|
||||
file(GLOB TEST_XML_FILES ${CMAKE_CURRENT_SOURCE_DIR}/tool/*.xml)
|
||||
install(
|
||||
FILES ${TEST_XML_FILES}
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/tests-v1
|
||||
COMPONENT tests)
|
||||
|
||||
install(
|
||||
FILES ${PROJECT_BINARY_DIR}/run.sh
|
||||
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/tests-v1
|
||||
PERMISSIONS
|
||||
OWNER_READ
|
||||
OWNER_WRITE
|
||||
OWNER_EXECUTE
|
||||
GROUP_READ
|
||||
GROUP_EXECUTE
|
||||
WORLD_READ
|
||||
WORLD_EXECUTE
|
||||
COMPONENT tests)
|
||||
@@ -23,11 +23,16 @@ THE SOFTWARE.
|
||||
#include "ctrl/test_hsa.h"
|
||||
|
||||
#include <atomic>
|
||||
#include <experimental/filesystem>
|
||||
|
||||
#include <dlfcn.h> // for dladdr
|
||||
|
||||
#include "util/test_assert.h"
|
||||
#include "util/helper_funcs.h"
|
||||
#include "util/hsa_rsrc_factory.h"
|
||||
|
||||
namespace fs = std::experimental::filesystem;
|
||||
|
||||
HsaRsrcFactory* TestHsa::hsa_rsrc_ = NULL;
|
||||
|
||||
HsaRsrcFactory* TestHsa::HsaInstantiate() {
|
||||
@@ -82,6 +87,9 @@ bool TestHsa::Initialize(int /*arg_cnt*/, char** /*arg_list*/) {
|
||||
|
||||
// Obtain the code object file name
|
||||
std::string agentName(agent_info_->name);
|
||||
Dl_info dl_info;
|
||||
if (dladdr(reinterpret_cast<const void*>(TestHsa::HsaShutdown), &dl_info) != 0)
|
||||
brig_path_obj_.append(fs::path(dl_info.dli_fname).remove_filename().remove_filename());
|
||||
brig_path_obj_.append(agentName);
|
||||
brig_path_obj_.append("_" + name_ + ".hsaco");
|
||||
|
||||
|
||||
@@ -22,6 +22,9 @@
|
||||
# THE SOFTWARE.
|
||||
################################################################################
|
||||
|
||||
BIN_NAME=`basename $0`
|
||||
BIN_DIR=`dirname $0`
|
||||
|
||||
# test filter input
|
||||
test_filter=-1
|
||||
if [ -n "$1" ] ; then
|
||||
@@ -57,7 +60,7 @@ eval_test() {
|
||||
}
|
||||
|
||||
# paths to ROC profiler and oher libraries
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD:$PWD/../../lib:/opt/rocm/lib:/opt/rocm/lib/rocprofiler
|
||||
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$PWD:$PWD/../../lib:$BIN_DIR/../../../lib:$BIN_DIR/../../../lib/rocprofiler:/opt/rocm/lib:/opt/rocm/lib/rocprofiler
|
||||
|
||||
# enable tools load failure reporting
|
||||
export HSA_TOOLS_REPORT_LOAD_FAILURE=1
|
||||
@@ -73,35 +76,39 @@ export ROCP_OBJ_TRACKING=1
|
||||
# Disabple profiler own proxy queue
|
||||
unset ROCP_PROXY_QUEUE
|
||||
# ROC profiler metrics config file
|
||||
export ROCP_METRICS=metrics.xml
|
||||
export ROCP_METRICS=$BIN_DIR/metrics.xml
|
||||
|
||||
## C test
|
||||
eval_test "C test" ./test/c_test
|
||||
eval_test "C test" $BIN_DIR/test/c_test
|
||||
|
||||
## Standalone sampling usage model test
|
||||
unset HSA_TOOLS_LIB
|
||||
unset ROCP_TOOL_LIB
|
||||
eval_test "Standalone sampling usage model test" ./test/standalone_test
|
||||
eval_test "Standalone sampling usage model test" $BIN_DIR/test/standalone_test
|
||||
# Standalone intercepting test
|
||||
# ROC profiler library loaded by HSA runtime
|
||||
export HSA_TOOLS_LIB=librocprofiler64.so.1
|
||||
if test -f "$BIN_DIR/../../../lib/librocprofiler64.so.1" ; then
|
||||
export HSA_TOOLS_LIB="$BIN_DIR/../../../lib/librocprofiler64.so.1"
|
||||
else
|
||||
export HSA_TOOLS_LIB=librocprofiler64.so.1
|
||||
fi
|
||||
# enable intercepting mode in rocprofiler
|
||||
export ROCP_HSA_INTERCEPT=2
|
||||
# test macro for kernel iterations number
|
||||
export ROCP_KITER=20
|
||||
# test macro for per-kernel dispatching number
|
||||
export ROCP_DITER=10
|
||||
eval_test "Standalone intercepting test" ./test/stand_intercept_test
|
||||
eval_test "Standalone intercepting test" $BIN_DIR/test/stand_intercept_test
|
||||
unset ROCP_HSA_INTERCEPT
|
||||
|
||||
## Intercepting usage model test
|
||||
# tool library loaded by ROC profiler
|
||||
export ROCP_TOOL_LIB=./test/libintercept_test.so
|
||||
export ROCP_TOOL_LIB=$BIN_DIR/test/libintercept_test.so
|
||||
export ROCP_KITER=20
|
||||
export ROCP_DITER=20
|
||||
export ROCP_AGENTS=1
|
||||
export ROCP_THRS=3
|
||||
eval_test "Intercepting usage model test" ./test/rocprof-ctrl
|
||||
eval_test "Intercepting usage model test" $BIN_DIR/test/rocprof-ctrl
|
||||
|
||||
## Libtool test
|
||||
# tool library loaded by ROC profiler
|
||||
@@ -109,48 +116,49 @@ export ROCP_TOOL_LIB=librocprof-tool.so
|
||||
# ROC profiler kernels timing
|
||||
export ROCP_TIMESTAMP_ON=1
|
||||
# output directory for the tool library, for metrics results file 'results.txt'
|
||||
export ROCP_OUTPUT_DIR=./RESULTS
|
||||
mkdir -p /tmp/rocprofiler/RESULTS
|
||||
export ROCP_OUTPUT_DIR=/tmp/rocprofiler/RESULTS
|
||||
|
||||
if [ ! -e $ROCP_TOOL_LIB ] ; then
|
||||
export ROCP_TOOL_LIB=test/librocprof-tool.so
|
||||
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=pmc_input.xml
|
||||
eval_test "'rocprof' rocprof-tool PMC test" ./test/rocprof-ctrl
|
||||
export ROCP_INPUT=$BIN_DIR/pmc_input.xml
|
||||
eval_test "'rocprof' rocprof-tool PMC test" $BIN_DIR/test/rocprof-ctrl
|
||||
|
||||
export ROCP_KITER=20
|
||||
export ROCP_DITER=20
|
||||
export ROCP_AGENTS=1
|
||||
export ROCP_THRS=10
|
||||
export ROCP_INPUT=pmc_input.xml
|
||||
eval_test "'rocprof' rocprof-tool PMC n-thread test" ./test/rocprof-ctrl
|
||||
export ROCP_INPUT=$BIN_DIR/pmc_input.xml
|
||||
eval_test "'rocprof' rocprof-tool PMC n-thread test" $BIN_DIR/test/rocprof-ctrl
|
||||
|
||||
export ROCP_OPT_MODE=1
|
||||
export ROCP_KITER=20
|
||||
export ROCP_DITER=20
|
||||
export ROCP_AGENTS=1
|
||||
export ROCP_THRS=10
|
||||
export ROCP_INPUT=pmc_input.xml
|
||||
eval_test "'rocprof' rocprof-tool PMC n-thread opt test" ./test/rocprof-ctrl
|
||||
export ROCP_INPUT=$BIN_DIR/pmc_input.xml
|
||||
eval_test "'rocprof' rocprof-tool PMC n-thread opt test" $BIN_DIR/test/rocprof-ctrl
|
||||
unset ROCP_OPT_MODE
|
||||
|
||||
export ROCP_KITER=20
|
||||
export ROCP_DITER=20
|
||||
export ROCP_AGENTS=1
|
||||
export ROCP_THRS=1
|
||||
export ROCP_INPUT=pmc_input1.xml
|
||||
eval_test "'rocprof' rocprof-tool PMC test1" ./test/rocprof-ctrl
|
||||
export ROCP_INPUT=$BIN_DIR/pmc_input1.xml
|
||||
eval_test "'rocprof' rocprof-tool PMC test1" $BIN_DIR/test/rocprof-ctrl
|
||||
|
||||
export ROCP_KITER=20
|
||||
export ROCP_DITER=20
|
||||
export ROCP_AGENTS=1
|
||||
export ROCP_THRS=10
|
||||
export ROCP_INPUT=pmc_input1.xml
|
||||
eval_test "'rocprof' rocprof-tool PMC n-thread test1" ./test/rocprof-ctrl
|
||||
export ROCP_INPUT=$BIN_DIR/pmc_input1.xml
|
||||
eval_test "'rocprof' rocprof-tool PMC n-thread test1" $BIN_DIR/test/rocprof-ctrl
|
||||
|
||||
unset ROCP_MCOPY_TRACKING
|
||||
# enable HSA intercepting
|
||||
@@ -158,7 +166,7 @@ export ROCP_HSA_INTERC=1
|
||||
|
||||
export ROCP_KITER=10
|
||||
export ROCP_DITER=10
|
||||
eval_test "rocprof-tool test, counter sets" ./test/rocprof-ctrl
|
||||
eval_test "rocprof-tool test, counter sets" $BIN_DIR/test/rocprof-ctrl
|
||||
|
||||
## OpenCL test
|
||||
#eval_test "libtool test, OpenCL sample" ./test/ocl/SimpleConvolution
|
||||
|
||||
Reference in New Issue
Block a user