mirror of
https://github.com/Kitware/CMake.git
synced 2025-12-31 19:00:54 -06:00
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.
This commit is contained in:
@@ -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")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user