From 6b8ae3dd771d08f1aa9435b5440fb741e281267b Mon Sep 17 00:00:00 2001 From: Freddy Paul Date: Thu, 16 Jul 2020 22:26:16 -0700 Subject: [PATCH] Align to new hsa cmake target usage. HIP or any ROCm component above HIP may not be calling hsa-runtime directly. OpenCl and HIP are the two components calling ROCclr and to bring in the transitive dependency of thunk,ROCR,amd_comgr it is better to have the dependency chain set correctly in the ROCclr cmake target. With this change OpenCl or HIP should not be setting ROCR dependency directly. This helps to link OpenCl(libamdocl.so) link statically with comgr,hsa,thunk. Change-Id: I0d538b7abc6a0ce700ec3332b97fc144db5fc5ff --- rocclr/CMakeLists.txt | 24 ++++++++++++++++++------ rocclr/cmake/ROCclrConfig.cmake.in | 3 +++ rocclr/device/rocm/CMakeLists.txt | 2 +- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/rocclr/CMakeLists.txt b/rocclr/CMakeLists.txt index 5bd27a3d17..02bd9eab7b 100644 --- a/rocclr/CMakeLists.txt +++ b/rocclr/CMakeLists.txt @@ -52,6 +52,16 @@ find_package(amd_comgr REQUIRED CONFIG ) message(STATUS "Code Object Manager found at ${amd_comgr_DIR}.") +find_package(hsa-runtime64 REQUIRED CONFIG + PATHS + /opt/rocm/ + PATH_SUFFIXES + cmake/hsa-runtime64 + lib/cmake/hsa-runtime64 + lib64/cmake/hsa-runtime64 +) +message(STATUS "HSA Runtime found at ${hsa-runtime64_DIR}.") + if( NOT OPENCL_DIR ) find_path(OPENCL_INCLUDE_DIR NAMES OpenCL/cl.h CL/cl.h @@ -69,8 +79,6 @@ endif() -find_package(ROCT REQUIRED) -find_package(ROCR REQUIRED) set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) @@ -180,9 +188,7 @@ target_include_directories(amdrocclr_static $ $ PRIVATE - $ - ${ROCR_INCLUDES} - ${ROCT_INCLUDES}) + $) target_compile_definitions(amdrocclr_static PRIVATE BSD_LIBELF) @@ -195,10 +201,13 @@ if(USE_COMGR_LIBRARY) else() target_compile_definitions(amdrocclr_static PUBLIC USE_COMGR_LIBRARY) endif() + #Needed here to export as transitive dependency in rocclr-targets.cmake + target_link_libraries(amdrocclr_static PRIVATE amd_comgr) endif() target_link_libraries(amdrocclr_static PUBLIC Threads::Threads) -target_link_libraries(amdrocclr_static PUBLIC dl ${ROCT_LIBRARIES} ${ROCR_LIBRARIES} ) +target_link_libraries(amdrocclr_static PUBLIC dl) + if (BUILD_PAL) target_sources(amdrocclr_static PRIVATE $) @@ -212,6 +221,9 @@ if (BUILD_PAL) else() target_compile_definitions(amdrocclr_static PRIVATE WITH_HSA_DEVICE) + #ROCclr being static lib shall not link hsa-runtime64. + #Needed here to export as transitive dependency in rocclr-targets.cmake + target_link_libraries(amdrocclr_static PRIVATE hsa-runtime64::hsa-runtime64) target_sources(amdrocclr_static PRIVATE $) export(TARGETS amdrocclr_static FILE ${ROCCLR_TARGETS_PATH}) diff --git a/rocclr/cmake/ROCclrConfig.cmake.in b/rocclr/cmake/ROCclrConfig.cmake.in index ea5e7db9c6..cb9657d64b 100644 --- a/rocclr/cmake/ROCclrConfig.cmake.in +++ b/rocclr/cmake/ROCclrConfig.cmake.in @@ -1,3 +1,6 @@ @ROCCLR_PREFIX_CODE@ +include( CMakeFindDependencyMacro ) +find_dependency(hsa-runtime64) +find_dependency(amd_comgr) include("@ROCCLR_TARGETS_PATH@") diff --git a/rocclr/device/rocm/CMakeLists.txt b/rocclr/device/rocm/CMakeLists.txt index 35683571e5..3d6ec96aea 100644 --- a/rocclr/device/rocm/CMakeLists.txt +++ b/rocclr/device/rocm/CMakeLists.txt @@ -32,7 +32,7 @@ target_include_directories(oclrocm ${PROJECT_SOURCE_DIR}/compiler/lib/loaders/elf/utils/libelf ${CMAKE_CURRENT_BINARY_DIR} ${ROCM_OCL_INCLUDES} - ${ROCR_INCLUDES}) + $) option(BUILD_HMM "Build HMM support" OFF) if (BUILD_HMM)