From ae1f707366f74e5271afb01b502ae690656fa9f9 Mon Sep 17 00:00:00 2001 From: Krzysztof Drewniak Date: Tue, 27 Sep 2022 15:41:09 +0000 Subject: [PATCH] [mlir] Use hip's config mode to find libraries Instead of using find_package(HIP) to find FindHIP.cmake, which doesn't seem to be the preferred way to find HIP anymore, use find_package(hip CONFIG) to find the HIP configuration. Give preference to ${ROCM_PATH} over ${ROCM_PATH}/hip in order to handle the fact that newer ROCm versions prefer the include path to use ${ROCM_PATH}/include/hip over ${ROCM_PATH}/hip/innclude/hip (the latter throws up a bunch of deprecation warnings) Then, instead of trying to manually find the host-side headers and runtime library by hand, use the hip::host and hip::amdhip64 libraries that the config module defines. This makes the CMake config much less error-prone and brings it in line with the recommended approach to finding HIP. Reviewed By: mehdi_amini Differential Revision: https://reviews.llvm.org/D134753 --- mlir/lib/ExecutionEngine/CMakeLists.txt | 30 +++--------------------------- 1 file changed, 3 insertions(+), 27 deletions(-) diff --git a/mlir/lib/ExecutionEngine/CMakeLists.txt b/mlir/lib/ExecutionEngine/CMakeLists.txt index 85fc811..5991ca4 100644 --- a/mlir/lib/ExecutionEngine/CMakeLists.txt +++ b/mlir/lib/ExecutionEngine/CMakeLists.txt @@ -190,23 +190,8 @@ if(MLIR_ENABLE_ROCM_RUNNER) set(ROCM_PATH $ENV{ROCM_PATH} CACHE PATH "Path to which ROCm has been installed") endif() endif() - set(HIP_PATH "${ROCM_PATH}/hip" CACHE PATH "Path to which HIP has been installed") - set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH}) - find_package(HIP) - if (NOT HIP_FOUND) - message(SEND_ERROR "Building mlir with ROCm support requires a working ROCm and HIP install") - else() - message(STATUS "ROCm HIP version: ${HIP_VERSION}") - endif() - - # Locate HIP runtime library. - find_library(ROCM_RUNTIME_LIBRARY amdhip64 - PATHS "${HIP_PATH}/lib") - if (NOT ROCM_RUNTIME_LIBRARY) - message(SEND_ERROR "Could not locate ROCm HIP runtime library") - else() - message(STATUS "ROCm HIP runtime lib: ${ROCM_RUNTIME_LIBRARY}") - endif() + list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH} "${ROCM_PATH}/hip") + find_package(hip REQUIRED) if (NOT DEFINED ROCM_TEST_CHIPSET) execute_process(COMMAND "${ROCM_PATH}/bin/rocm_agent_enumerator" @@ -263,20 +248,11 @@ if(MLIR_ENABLE_ROCM_RUNNER) "-Wno-gnu-anonymous-struct") endif() - target_compile_definitions(mlir_rocm_runtime - PRIVATE - __HIP_PLATFORM_HCC__ - ) - target_include_directories(mlir_rocm_runtime - PRIVATE - ${HIP_PATH}/include - ${ROCM_PATH}/include - ) set_property(TARGET mlir_rocm_runtime PROPERTY INSTALL_RPATH_USE_LINK_PATH ON) target_link_libraries(mlir_rocm_runtime PUBLIC - ${ROCM_RUNTIME_LIBRARY} + hip::host hip::amdhip64 ) endif() -- 2.7.4