Skip to content

Commit 87729b4

Browse files
Copilotvlkale
andcommitted
Fix clang-format issues and improve ROCm CMake path detection
- Apply clang-format to align assignments in vtune-connector - Enhance ROCm path detection with fallback to /opt/rocm - Try multiple potential hip CMake config locations - Add detailed diagnostic messages for ROCm configuration - Improves robustness for different ROCm versions and installations Co-authored-by: vlkale <11766050+vlkale@users.noreply.github.com>
1 parent 54f7483 commit 87729b4

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

CMakeLists.txt

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,39 @@ option(KokkosTools_ENABLE_TESTS "Build tests" OFF)
5252

5353
# Configure CMAKE_PREFIX_PATH for ROCm/HIP if ROCM_PATH is set
5454
# This is needed for find_package(Kokkos) when Kokkos was built with HIP support
55+
set(ROCM_PATH_TO_USE "")
5556
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}")
57+
set(ROCM_PATH_TO_USE "$ENV{ROCM_PATH}")
58+
elseif(EXISTS "/opt/rocm")
59+
# Fallback to default ROCm installation path
60+
set(ROCM_PATH_TO_USE "/opt/rocm")
61+
message(STATUS "ROCM_PATH not set, using default: /opt/rocm")
62+
endif()
63+
64+
if(NOT "${ROCM_PATH_TO_USE}" STREQUAL "")
65+
message(STATUS "Configuring ROCm paths from: ${ROCM_PATH_TO_USE}")
66+
67+
# Add multiple potential locations for ROCm CMake configs
68+
list(APPEND CMAKE_PREFIX_PATH "${ROCM_PATH_TO_USE}")
69+
list(APPEND CMAKE_PREFIX_PATH "${ROCM_PATH_TO_USE}/lib/cmake")
70+
list(APPEND CMAKE_PREFIX_PATH "${ROCM_PATH_TO_USE}/hip/lib/cmake")
71+
list(APPEND CMAKE_PREFIX_PATH "${ROCM_PATH_TO_USE}/lib/cmake/hip")
6072

6173
# 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}")
74+
# Try multiple potential locations
75+
if(NOT DEFINED hip_DIR)
76+
if(EXISTS "${ROCM_PATH_TO_USE}/lib/cmake/hip")
77+
set(hip_DIR "${ROCM_PATH_TO_USE}/lib/cmake/hip" CACHE PATH "Path to hip CMake config")
78+
message(STATUS "Setting hip_DIR hint: ${hip_DIR}")
79+
elseif(EXISTS "${ROCM_PATH_TO_USE}/hip/lib/cmake/hip")
80+
set(hip_DIR "${ROCM_PATH_TO_USE}/hip/lib/cmake/hip" CACHE PATH "Path to hip CMake config")
81+
message(STATUS "Setting hip_DIR hint: ${hip_DIR}")
82+
else()
83+
message(STATUS "hip CMake config not found in standard locations under ${ROCM_PATH_TO_USE}")
84+
endif()
6585
endif()
86+
87+
message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
6688
endif()
6789

6890
# Fetch Kokkos options:

profiling/vtune-connector/kp_vtune_connector.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ void kokkosp_pop_profile_region() {
167167
}
168168

169169
void kokkosp_create_profile_section(const char* name, uint32_t* sID) {
170-
*sID = kokkosp_sections.size();
170+
*sID = kokkosp_sections.size();
171171
__itt_domain* domain = __itt_domain_create(name);
172172
domain->flags = 1;
173173
kokkosp_sections.push_back({std::string(name), domain});

0 commit comments

Comments
 (0)