Skip to content

Commit 54f7483

Browse files
Copilotvlkale
andcommitted
Fix ROCm build failures by configuring CMAKE_PREFIX_PATH and hip_DIR
- Add CMAKE_PREFIX_PATH configuration for ROCM_PATH before finding Kokkos - Set hip_DIR hint when ROCM_PATH is defined to help find_package(hip) - Add ROCM_PATH environment variable to CI workflow for ROCm builds - Fixes hip_DIR not found errors when Kokkos is built with HIP support Co-authored-by: vlkale <11766050+vlkale@users.noreply.github.com>
1 parent 23c8538 commit 54f7483

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

.github/workflows/build-with-kokkos.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ jobs:
3030
env:
3131
Kokkos_ROOT: /opt/kokkos
3232
VARIORUM_ROOT: /opt/variorum
33+
ROCM_PATH: /opt/rocm
3334
steps:
3435
- name: Checkout Kokkos Tools
3536
uses: actions/checkout@v4

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,21 @@ option(KokkosTools_ENABLE_SYSTEMTAP "Enable SystemTap support" OFF)
5050
option(KokkosTools_ENABLE_EXAMPLES "Build examples" OFF)
5151
option(KokkosTools_ENABLE_TESTS "Build tests" OFF)
5252

53+
# Configure CMAKE_PREFIX_PATH for ROCm/HIP if ROCM_PATH is set
54+
# This is needed for find_package(Kokkos) when Kokkos was built with HIP support
55+
if(DEFINED ENV{ROCM_PATH} AND NOT "$ENV{ROCM_PATH}" STREQUAL "")
56+
list(APPEND CMAKE_PREFIX_PATH "$ENV{ROCM_PATH}")
57+
list(APPEND CMAKE_PREFIX_PATH "$ENV{ROCM_PATH}/lib/cmake")
58+
list(APPEND CMAKE_PREFIX_PATH "$ENV{ROCM_PATH}/hip")
59+
message(STATUS "Adding ROCM_PATH to CMAKE_PREFIX_PATH: $ENV{ROCM_PATH}")
60+
61+
# Also set hip_DIR as a hint for find_package(hip) if not already set
62+
if(NOT DEFINED hip_DIR AND EXISTS "$ENV{ROCM_PATH}/lib/cmake/hip")
63+
set(hip_DIR "$ENV{ROCM_PATH}/lib/cmake/hip" CACHE PATH "Path to hip CMake config")
64+
message(STATUS "Setting hip_DIR hint: ${hip_DIR}")
65+
endif()
66+
endif()
67+
5368
# Fetch Kokkos options:
5469
acquire_kokkos_config()
5570
if(DEFINED Kokkos_FOUND_MSG)

0 commit comments

Comments
 (0)