Add DetectHIPInstallation.cmake

Extending CMAKE_PREFIX_PATH is needed in both GPU and KOKKOS package to
make HIP CMake available.
This commit is contained in:
Richard Berger
2023-04-06 23:17:20 -06:00
parent 3950765e8f
commit 4e8038a4f5
3 changed files with 18 additions and 16 deletions

View File

@ -256,22 +256,7 @@ elseif(GPU_API STREQUAL "OPENCL")
add_dependencies(ocl_get_devices OpenCL::OpenCL)
elseif(GPU_API STREQUAL "HIP")
if(NOT DEFINED HIP_PATH)
if(NOT DEFINED ENV{HIP_PATH})
message(FATAL_ERROR "GPU_API=HIP requires HIP_PATH to be defined.\n"
"Either pass the HIP_PATH as a CMake option via -DHIP_PATH=... or set the HIP_PATH environment variable.")
else()
set(HIP_PATH $ENV{HIP_PATH} CACHE PATH "Path to HIP installation")
endif()
endif()
if(NOT DEFINED ROCM_PATH)
if(NOT DEFINED ENV{ROCM_PATH})
set(ROCM_PATH "/opt/rocm" CACHE PATH "Path to ROCm installation")
else()
set(ROCM_PATH $ENV{ROCM_PATH} CACHE PATH "Path to ROCm installation")
endif()
endif()
list(APPEND CMAKE_PREFIX_PATH ${HIP_PATH} ${ROCM_PATH})
include(DetectHIPInstallation)
find_package(hip REQUIRED)
option(HIP_USE_DEVICE_SORT "Use GPU sorting" ON)