[Mlir-commits] [mlir] d6fb08a - [mlri][ExecutionEngine] Don't globaly set CMake prefixes to find HIP

Krzysztof Drewniak llvmlistbot at llvm.org
Fri Jan 27 13:06:14 PST 2023


Author: Krzysztof Drewniak
Date: 2023-01-27T21:06:07Z
New Revision: d6fb08abf654b3ef9fdf990b3c11b7dde3fbbacd

URL: https://github.com/llvm/llvm-project/commit/d6fb08abf654b3ef9fdf990b3c11b7dde3fbbacd
DIFF: https://github.com/llvm/llvm-project/commit/d6fb08abf654b3ef9fdf990b3c11b7dde3fbbacd.diff

LOG: [mlri][ExecutionEngine] Don't globaly set CMake prefixes to find HIP

The HIP CMake files expect to find their own dependencies and don't
use or respect PATHS or HINTS, relying on CMAKE_PREFIX_PATH to contain
/opt/rocm and /opt/rocm/hip . This is not great for the rest of the
build. Therefore, copy the CMake prefix path, add the ROCm
directories, find HIP, and reset the path to its old value.

Reviewed By: arsenm

Differential Revision: https://reviews.llvm.org/D142391

Added: 
    

Modified: 
    mlir/lib/ExecutionEngine/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/mlir/lib/ExecutionEngine/CMakeLists.txt b/mlir/lib/ExecutionEngine/CMakeLists.txt
index ad752cfdcf8e2..bedc86fe185b1 100644
--- a/mlir/lib/ExecutionEngine/CMakeLists.txt
+++ b/mlir/lib/ExecutionEngine/CMakeLists.txt
@@ -206,8 +206,14 @@ if(MLIR_ENABLE_ROCM_RUNNER)
       set(ROCM_PATH $ENV{ROCM_PATH} CACHE PATH "Path to which ROCm has been installed")
     endif()
   endif()
+  # A lot of the ROCm CMake files expect to find their own dependencies in
+  # CMAKE_PREFIX_PATH and don't respect PATHS or HINTS :( .
+  # Therefore, temporarily add the ROCm path to CMAKE_PREFIX_PATH so we can
+  # load HIP, then remove it
+  set(REAL_CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH}")
   list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH} "${ROCM_PATH}/hip")
   find_package(hip REQUIRED)
+  set(CMAKE_PREFIX_PATH "${REAL_CMAKE_PREFIX_PATH}")
 
   if (NOT DEFINED ROCM_TEST_CHIPSET)
     execute_process(COMMAND "${ROCM_PATH}/bin/rocm_agent_enumerator"


        


More information about the Mlir-commits mailing list