diff options
author | Brad King <brad.king@kitware.com> | 2021-09-16 17:36:40 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-09-16 18:45:07 (GMT) |
commit | b125e9809a1a3f3e28fc1682c8a33c3a928f79b5 (patch) | |
tree | 28ca771d0e701fbbd23991cfe03a97c1835686c0 /Modules | |
parent | 735f41fc2d91bac11506ebf355136b0dbd8ac8c7 (diff) | |
download | CMake-b125e9809a1a3f3e28fc1682c8a33c3a928f79b5.zip CMake-b125e9809a1a3f3e28fc1682c8a33c3a928f79b5.tar.gz CMake-b125e9809a1a3f3e28fc1682c8a33c3a928f79b5.tar.bz2 |
HIP: Detect ROCm path earlier
Fail early if it is not found.
Use the detected location as a hint to find `rocm_agent_enumerator`.
Also remove the leading `_` prefix in case we want to document this
publicly later.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CMakeDetermineCompilerId.cmake | 11 | ||||
-rw-r--r-- | Modules/CMakeDetermineHIPCompiler.cmake | 14 | ||||
-rw-r--r-- | Modules/CMakeHIPRuntime.cmake.in | 8 |
3 files changed, 18 insertions, 15 deletions
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index e933cf4..65e7236 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -172,17 +172,6 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) set(CMAKE_${lang}_COMPILER "${output}/clang++" PARENT_SCOPE) endif() endif() - if(lang STREQUAL "HIP") - execute_process( - COMMAND "${_hipcc_dir}/hipconfig" - --rocmpath - OUTPUT_VARIABLE output - RESULT_VARIABLE result - ) - if(result EQUAL 0) - set(_CMAKE_HIP_COMPILER_ROCM_ROOT "${output}" PARENT_SCOPE) - endif() - endif() endif() if (COMPILER_QNXNTO AND CMAKE_${lang}_COMPILER_ID STREQUAL "GNU") diff --git a/Modules/CMakeDetermineHIPCompiler.cmake b/Modules/CMakeDetermineHIPCompiler.cmake index 4f0b754..394f8e2 100644 --- a/Modules/CMakeDetermineHIPCompiler.cmake +++ b/Modules/CMakeDetermineHIPCompiler.cmake @@ -52,7 +52,20 @@ if(NOT CMAKE_HIP_COMPILER_ID_RUN) CMAKE_DETERMINE_COMPILER_ID(HIP HIPFLAGS CMakeHIPCompilerId.hip) _cmake_find_compiler_sysroot(HIP) +endif() +if(NOT CMAKE_HIP_COMPILER_ROCM_ROOT) + execute_process( + COMMAND hipconfig --rocmpath + OUTPUT_VARIABLE _CMAKE_HIPCONFIG_ROCMPATH + RESULT_VARIABLE _CMAKE_HIPCONFIG_RESULT + ) + if(_CMAKE_HIPCONFIG_RESULT EQUAL 0 AND EXISTS "${_CMAKE_HIPCONFIG_ROCMPATH}") + set(CMAKE_HIP_COMPILER_ROCM_ROOT "${_CMAKE_HIPCONFIG_ROCMPATH}") + endif() +endif() +if(NOT CMAKE_HIP_COMPILER_ROCM_ROOT) + message(FATAL_ERROR "Failed to find ROCm root directory.") endif() if (NOT _CMAKE_TOOLCHAIN_LOCATION) @@ -89,6 +102,7 @@ if(NOT DEFINED CMAKE_HIP_ARCHITECTURES) set(_CMAKE_HIP_ARCHITECTURES) find_program(_CMAKE_HIP_ROCM_AGENT_ENUMERATOR NAMES rocm_agent_enumerator + HINTS "${CMAKE_HIP_COMPILER_ROCM_ROOT}/bin" NO_CACHE) if(_CMAKE_HIP_ROCM_AGENT_ENUMERATOR) execute_process(COMMAND "${_CMAKE_HIP_ROCM_AGENT_ENUMERATOR}" -t GPU diff --git a/Modules/CMakeHIPRuntime.cmake.in b/Modules/CMakeHIPRuntime.cmake.in index ade26bb..3b345aa 100644 --- a/Modules/CMakeHIPRuntime.cmake.in +++ b/Modules/CMakeHIPRuntime.cmake.in @@ -4,7 +4,7 @@ function(_CMAKE_FIND_HIP_RUNTIME ) # Determined when hipcc is the HIP compiler - set(_CMAKE_HIP_COMPILER_ROCM_ROOT "@_CMAKE_HIP_COMPILER_ROCM_ROOT@") + set(CMAKE_HIP_COMPILER_ROCM_ROOT "@CMAKE_HIP_COMPILER_ROCM_ROOT@") # Forward facing value that can be provided by the user set(CMAKE_HIP_COMPILER_TOOLKIT_ROOT @CMAKE_HIP_COMPILER_TOOLKIT_ROOT@) @@ -24,10 +24,10 @@ function(_CMAKE_FIND_HIP_RUNTIME ) set(explicit_search_only TRUE) set(error_message_location "CMAKE_HIP_COMPILER_TOOLKIT_ROOT") set(error_message_location "the environment variable CMAKE_HIP_COMPILER_TOOLKIT_ROOT [\"$ENV{CMAKE_HIP_COMPILER_TOOLKIT_ROOT}\"]") - elseif(DEFINED _CMAKE_HIP_COMPILER_ROCM_ROOT) - set(rocm_root_dirs "${_CMAKE_HIP_COMPILER_ROCM_ROOT}") + elseif(DEFINED CMAKE_HIP_COMPILER_ROCM_ROOT) + set(rocm_root_dirs "${CMAKE_HIP_COMPILER_ROCM_ROOT}") set(explicit_search_only TRUE) - set(error_message_location "the associated hipconfig --rocmpath [\"${_CMAKE_HIP_COMPILER_ROCM_ROOT}\"]") + set(error_message_location "the associated hipconfig --rocmpath [\"${CMAKE_HIP_COMPILER_ROCM_ROOT}\"]") endif() # Guess on where rocm is installed |