Get ROCr and ROCt dependencies using cmake targets
Instead of detecting files (header/library), use cmake's find_package to locate the required dependencies (hsa-runtime64 and hsakmt). Adding hsa-runtime64::hsa-runtime64 and hsakmt::hsakmt to the target_link_libraries also takes care of adding the interfaces include directories to the search path. Change-Id: I64eb77c97dac7982ac96d3158ad57df776cc0b53
This commit is contained in:
@@ -107,12 +107,13 @@ elseif ( ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86" )
|
||||
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32" )
|
||||
endif ()
|
||||
|
||||
## Find hsa-runtime headers/lib
|
||||
find_file ( HSA_RUNTIME_INC "hsa/hsa.h" )
|
||||
find_library ( HSA_RUNTIME_LIB "libhsa-runtime${NBIT}.so" )
|
||||
get_filename_component ( HSA_RUNTIME_INC_PATH "${HSA_RUNTIME_INC}" DIRECTORY )
|
||||
get_filename_component ( HSA_RUNTIME_LIB_PATH "${HSA_RUNTIME_LIB}" DIRECTORY )
|
||||
## Find hsa-runtime
|
||||
find_package(hsa-runtime64 1.0 REQUIRED HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
|
||||
|
||||
# find KFD thunk
|
||||
find_package(hsakmt 1.0 REQUIRED HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
|
||||
|
||||
## Find ROCm
|
||||
find_library ( HSA_KMT_LIB "libhsakmt.so" )
|
||||
if ( "${HSA_KMT_LIB_PATH}" STREQUAL "" )
|
||||
find_library ( HSA_KMT_LIB "libhsakmt.a" )
|
||||
@@ -125,24 +126,11 @@ message ( "----------------NBit: ${NBIT}" )
|
||||
message ( "----------Build-Type: ${CMAKE_BUILD_TYPE}" )
|
||||
message ( "------------Compiler: ${CMAKE_CXX_COMPILER}" )
|
||||
message ( "----Compiler-Version: ${CMAKE_CXX_COMPILER_VERSION}" )
|
||||
message ( "-----HSA-Runtime-Inc: ${HSA_RUNTIME_INC_PATH}" )
|
||||
message ( "-----HSA-Runtime-Lib: ${HSA_RUNTIME_LIB_PATH}" )
|
||||
message ( "----HSA_KMT_LIB_PATH: ${HSA_KMT_LIB_PATH}" )
|
||||
message ( "-------ROCM_ROOT_DIR: ${ROCM_ROOT_DIR}" )
|
||||
message ( "-----CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}" )
|
||||
message ( "---CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}" )
|
||||
message ( "---------GPU_TARGETS: ${GPU_TARGETS}" )
|
||||
|
||||
## Check the ROCm pathes
|
||||
if ( "${HSA_RUNTIME_INC_PATH}" STREQUAL "" )
|
||||
message ( FATAL_ERROR "HSA_RUNTIME_INC_PATH is not found." )
|
||||
endif ()
|
||||
if ( "${HSA_RUNTIME_LIB_PATH}" STREQUAL "" )
|
||||
message ( FATAL_ERROR "HSA_RUNTIME_LIB_PATH is not found." )
|
||||
endif ()
|
||||
if ( "${HSA_KMT_LIB_PATH}" STREQUAL "" )
|
||||
message ( FATAL_ERROR "HSA_KMT_LIB_PATH is not found." )
|
||||
endif ()
|
||||
if ( "${ROCM_ROOT_DIR}" STREQUAL "" )
|
||||
message ( FATAL_ERROR "ROCM_ROOT_DIR is not found." )
|
||||
endif ()
|
||||
|
||||
@@ -35,5 +35,5 @@ set ( LIB_SRC
|
||||
${LIB_DIR}/util/hsa_rsrc_factory.cpp
|
||||
)
|
||||
add_library ( ${TARGET_LIB} SHARED ${LIB_SRC} )
|
||||
target_include_directories ( ${TARGET_LIB} PRIVATE ${LIB_DIR} ${ROOT_DIR} ${HSA_RUNTIME_INC_PATH} ${HSA_KMT_LIB_PATH}/.. )
|
||||
target_link_libraries( ${TARGET_LIB} PRIVATE ${HSA_RUNTIME_LIB} c stdc++ )
|
||||
target_include_directories ( ${TARGET_LIB} PRIVATE ${LIB_DIR} ${ROOT_DIR} )
|
||||
target_link_libraries( ${TARGET_LIB} PRIVATE hsa-runtime64::hsa-runtime64 c stdc++ )
|
||||
|
||||
+15
-12
@@ -27,14 +27,17 @@ set ( EXE_NAME "ctrl" )
|
||||
|
||||
if ( NOT DEFINED TEST_DIR )
|
||||
set ( TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR} )
|
||||
project ( ${EXE_NAME} )
|
||||
project ( ${EXE_NAME} C CXX )
|
||||
## Set build environment
|
||||
include ( env )
|
||||
endif ()
|
||||
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
## C test
|
||||
add_executable ( "c_test" ${TEST_DIR}/app/c_test.c )
|
||||
target_include_directories ( "c_test" PRIVATE ${ROOT_DIR} ${HSA_RUNTIME_INC_PATH} )
|
||||
target_include_directories ( "c_test" PRIVATE ${ROOT_DIR} $<TARGET_PROPERTY:hsa-runtime64::hsa-runtime64,INTERFACE_INCLUDE_DIRECTORIES> )
|
||||
|
||||
## Util sources
|
||||
file( GLOB UTIL_SRC "${TEST_DIR}/util/*.cpp" )
|
||||
@@ -80,23 +83,23 @@ add_custom_target( mytest
|
||||
|
||||
## 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} ${HSA_RUNTIME_INC_PATH} )
|
||||
target_link_libraries ( ${ST_EXE_NAME} ${ROCPROFILER_TARGET} ${HSA_RUNTIME_LIB} ${HSA_KMT_LIB} c stdc++ dl pthread rt numa )
|
||||
target_include_directories ( ${ST_EXE_NAME} PRIVATE ${TEST_DIR} ${ROOT_DIR} )
|
||||
target_link_libraries ( ${ST_EXE_NAME} ${ROCPROFILER_TARGET} hsa-runtime64::hsa-runtime64 hsakmt::hsakmt Threads::Threads dl )
|
||||
|
||||
## 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} ${HSA_RUNTIME_INC_PATH} )
|
||||
target_link_libraries ( ${STIN_EXE_NAME} ${ROCPROFILER_TARGET} ${HSA_RUNTIME_LIB} ${HSA_KMT_LIB} c stdc++ dl pthread rt numa )
|
||||
target_include_directories ( ${STIN_EXE_NAME} PRIVATE ${TEST_DIR} ${ROOT_DIR} )
|
||||
target_link_libraries ( ${STIN_EXE_NAME} ${ROCPROFILER_TARGET} hsa-runtime64::hsa-runtime64 hsakmt::hsakmt Threads::Threads dl )
|
||||
|
||||
## 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} ${HSA_RUNTIME_INC_PATH} )
|
||||
target_link_libraries ( ${IN_EXE_NAME} ${ROCPROFILER_TARGET} ${HSA_RUNTIME_LIB} ${HSA_KMT_LIB} c stdc++ dl pthread rt numa )
|
||||
target_include_directories ( ${IN_EXE_NAME} PRIVATE ${TEST_DIR} ${ROOT_DIR} )
|
||||
target_link_libraries ( ${IN_EXE_NAME} ${ROCPROFILER_TARGET} hsa-runtime64::hsa-runtime64 hsakmt::hsakmt Threads::Threads dl )
|
||||
|
||||
## Building ctrl test executable
|
||||
add_executable ( ${EXE_NAME} ${CTRL_SRC} ${UTIL_SRC} ${KERN_SRC} )
|
||||
target_include_directories ( ${EXE_NAME} PRIVATE ${TEST_DIR} ${ROOT_DIR} ${HSA_RUNTIME_INC_PATH} ${HSA_RUNTIME_LIB_PATH}/../include )
|
||||
target_link_libraries ( ${EXE_NAME} ${HSA_RUNTIME_LIB} ${HSA_KMT_LIB} c stdc++ dl pthread rt numa )
|
||||
target_include_directories ( ${EXE_NAME} PRIVATE ${TEST_DIR} ${ROOT_DIR} )
|
||||
target_link_libraries ( ${EXE_NAME} hsa-runtime64::hsa-runtime64 hsakmt::hsakmt Threads::Threads 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" )
|
||||
@@ -105,8 +108,8 @@ execute_process ( COMMAND sh -xc "mkdir -p ${PROJECT_BINARY_DIR}/RESULTS" )
|
||||
set ( TEST_LIB "tool" )
|
||||
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} ${HSA_RUNTIME_INC_PATH} )
|
||||
target_link_libraries ( ${TEST_LIB} ${ROCPROFILER_TARGET} ${HSA_RUNTIME_LIB} c stdc++ dl pthread rt numa )
|
||||
target_include_directories ( ${TEST_LIB} PRIVATE ${TEST_DIR} ${ROOT_DIR} )
|
||||
target_link_libraries ( ${TEST_LIB} ${ROCPROFILER_TARGET} hsa-runtime64::hsa-runtime64 Threads::Threads dl )
|
||||
|
||||
## Build memory test bench
|
||||
add_custom_target( mbench
|
||||
|
||||
مرجع در شماره جدید
Block a user