[Openmp-commits] [PATCH] D109885: [MLIR][[amdgpu-arch]][OpenMP] Remove direct dependency on /opt/rocm

Ye Luo via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Thu Sep 16 11:04:21 PDT 2021


ye-luo requested changes to this revision.
ye-luo added a comment.
This revision now requires changes to proceed.

The fallback opt/rocm is desired. If a module system needs to point to the specific rocm installation. Set CMAKE_PREFIX_PATH=<unconventional rocm> in the module file.
If you would like to honor ROCM_PATH, then do one find_library with explicit ROCM_PATH and another with all the defaults.



================
Comment at: mlir/lib/Dialect/GPU/CMakeLists.txt:137
   set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH})
   find_package(HIP)
   if (NOT HIP_FOUND)
----------------
Both ROCM_PATH HIP_PATH are used as hints without verification.
But they are used later for generating include paths. Overall logic is broken.

if ROCM_PATH takes the precedence over everything else
You can do this
if ROCM_PATH defined
    find_path(
      HIP_MODULE_FILE_DIR FindHIP.cmake
      HINTS ${ROCM_PATH}
      PATH_SUFFIXES hip/cmake REQUIRED
      NO_DEFAULT_PATH)
else
    find_path(
      HIP_MODULE_FILE_DIR FindHIP.cmake
      HINTS $ENV{ROCM_PATH} /opt/rocm
      PATH_SUFFIXES hip/cmake REQUIRED)
endif

by doing this, you can verify that ROCM_PATH is correct if provided and the path the hip module file has been verified. then it is safe to do
set(CMAKE_MODULE_PATH "${HIP_MODULE_FILE_DIR}" ${CMAKE_MODULE_PATH})
find_package(HIP)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109885/new/

https://reviews.llvm.org/D109885



More information about the Openmp-commits mailing list