1 # As of rocm-3.7, hsa is installed with cmake packages and kmt is found via hsa
2 find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
4 # Create the library and add the default arguments.
5 add_target_library(omptarget.rtl.amdgpu AMDGPU)
7 target_sources(omptarget.rtl.amdgpu PRIVATE src/rtl.cpp)
8 target_include_directories(omptarget.rtl.amdgpu PRIVATE
9 ${CMAKE_CURRENT_SOURCE_DIR}/utils)
11 if(hsa-runtime64_FOUND AND NOT "amdgpu" IN_LIST LIBOMPTARGET_DLOPEN_PLUGINS)
12 message(STATUS "Building AMDGPU plugin linked against libhsa")
13 target_link_libraries(omptarget.rtl.amdgpu PRIVATE hsa-runtime64::hsa-runtime64 LLVMFrontendOffloading)
15 message(STATUS "Building AMDGPU plugin for dlopened libhsa")
16 target_include_directories(omptarget.rtl.amdgpu PRIVATE dynamic_hsa)
17 target_sources(omptarget.rtl.amdgpu PRIVATE dynamic_hsa/hsa.cpp)
18 target_link_libraries(omptarget.rtl.amdgpu PRIVATE LLVMFrontendOffloading)
21 # Configure testing for the AMDGPU plugin. We will build tests if we could a
22 # functional AMD GPU on the system, or if manually specifies by the user.
23 option(LIBOMPTARGET_FORCE_AMDGPU_TESTS "Build AMDGPU libomptarget tests" OFF)
24 if (LIBOMPTARGET_FOUND_AMDGPU_GPU OR LIBOMPTARGET_FORCE_AMDGPU_TESTS)
25 # Report to the parent scope that we are building a plugin for amdgpu
26 set(LIBOMPTARGET_SYSTEM_TARGETS
27 "${LIBOMPTARGET_SYSTEM_TARGETS} amdgcn-amd-amdhsa" PARENT_SCOPE)
28 list(APPEND LIBOMPTARGET_TESTED_PLUGINS "omptarget.rtl.amdgpu")
29 set(LIBOMPTARGET_TESTED_PLUGINS "${LIBOMPTARGET_TESTED_PLUGINS}" PARENT_SCOPE)
31 message(STATUS "Not generating AMDGPU tests, no supported devices detected."
32 " Use 'LIBOMPTARGET_FORCE_AMDGPU_TESTS' to override.")