Skip to content

Commit fd4b3a6

Browse files
sshi-amdclaude
andauthored
Unify ROCM_INSTALL_DIR and ROCM_ROOT to ROCM_PATH (#440)
* Unify ROCM_INSTALL_DIR and ROCM_ROOT to ROCM_PATH Standardize all ROCm installation path variables to use ROCM_PATH, aligning with TheRock infrastructure conventions. Changes: - Rename ROCM_ROOT to ROCM_PATH in all CMakeLists.txt files - Rename ROCM_INSTALL_DIR to ROCM_PATH in all Makefiles - Update build_packages.sh (variable, CLI flag --rocm-path) - Update CI workflow to pass -DROCM_PATH instead of -DROCM_ROOT - Update documentation references in README files - Rename ROCM_ROOT_PATH C++ macro to ROCM_DEFAULT_PATH in rocWMMA hiprtc_gemm example (both CMake definition and usage) Note: CMAKE_HIP_COMPILER_ROCM_ROOT in CMakePresets.json is a CMake built-in variable and is intentionally left unchanged. Addresses: #429 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Extract ROCM_PATH resolution into shared Common/ROCmPath.cmake Replace the duplicated ~12-line ROCM_PATH setting block in 427 CMakeLists.txt files with a single include of a new shared module. The new module resolves ROCM_PATH with proper priority: 1. Existing cache value (-DROCM_PATH=...) 2. $ENV{ROCM_PATH} (TheRock CI / standard ROCm) 3. $ENV{HIP_PATH} (Windows HIP SDK) 4. /opt/rocm (hardcoded fallback) This eliminates duplication and lets CI pick up ROCM_PATH from the environment automatically, removing the need for -DROCM_PATH on the cmake command line. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Fix ROCmPath.cmake scope issue breaking standalone subdirectory builds Change include_guard(GLOBAL) to include_guard(DIRECTORY) so that each directory scope gets its own CMAKE_PREFIX_PATH update. With GLOBAL guard, only the first add_subdirectory() child to include ROCmPath.cmake would get ROCM_PATH appended to CMAKE_PREFIX_PATH — siblings would silently skip the include and their find_package() calls would fail. Also add ROCmPath.cmake include to all parent-level CMakeLists.txt files used as CI entry points (HIP-Doc, Applications, Libraries, Programming-Guide, Tutorials) so they set ROCM_PATH in parent scope before processing children. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 543939b commit fd4b3a6

821 files changed

Lines changed: 2114 additions & 6733 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/build-rocm-examples-reusable.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ jobs:
107107
108108
- name: CMake configure
109109
run: |
110-
cmake -S . -B build -DCMAKE_HIP_ARCHITECTURES="${{ matrix.gpu_config.gpu_target }}" -DROCM_ROOT="${ROCM_PATH}" -DCMAKE_BUILD_RPATH="${ROCM_PATH}/lib" -DROCM_EXAMPLES_ENABLE_OPENMP="${ENABLE_OPENMP}" 2> >(tee cmake_error.log >&2)
110+
cmake -S . -B build -DCMAKE_HIP_ARCHITECTURES="${{ matrix.gpu_config.gpu_target }}" -DCMAKE_BUILD_RPATH="${ROCM_PATH}/lib" -DROCM_EXAMPLES_ENABLE_OPENMP="${ENABLE_OPENMP}" 2> >(tee cmake_error.log >&2)
111111
112112
- name: CMake configure error summary
113113
if: ${{ !cancelled() }}

Applications/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/${folder_bin})
2929

3030
include("${CMAKE_CURRENT_LIST_DIR}/../Common/FindFilesystem.cmake")
3131
include("${CMAKE_CURRENT_LIST_DIR}/../Common/HipPlatform.cmake")
32+
include("${CMAKE_CURRENT_LIST_DIR}/../Common/ROCmPath.cmake")
3233
select_gpu_language()
3334
# select_hip_platform requires the language to be enabled
3435
enable_language(${ROCM_EXAMPLES_GPU_LANGUAGE})

Applications/bitonic_sort/CMakeLists.txt

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,7 @@ set(CMAKE_${ROCM_EXAMPLES_GPU_LANGUAGE}_EXTENSIONS OFF)
3434
set(CMAKE_${ROCM_EXAMPLES_GPU_LANGUAGE}_STANDARD_REQUIRED ON)
3535
select_hip_platform()
3636

37-
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
38-
set(ROCM_ROOT
39-
"$ENV{HIP_PATH}"
40-
CACHE PATH
41-
"Root directory of the ROCm installation"
42-
)
43-
else()
44-
set(ROCM_ROOT
45-
"/opt/rocm"
46-
CACHE PATH
47-
"Root directory of the ROCm installation"
48-
)
49-
endif()
50-
51-
list(APPEND CMAKE_PREFIX_PATH "${ROCM_ROOT}")
37+
include("${CMAKE_CURRENT_LIST_DIR}/../../Common/ROCmPath.cmake")
5238

5339
add_executable(${example_name} main.hip)
5440
# Make example runnable using ctest
@@ -57,7 +43,7 @@ add_test(NAME ${example_name} COMMAND ${example_name})
5743
set(include_dirs "../../Common" "../../External")
5844
# For examples targeting NVIDIA, include the HIP header directory.
5945
if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia")
60-
list(APPEND include_dirs "${ROCM_ROOT}/include")
46+
list(APPEND include_dirs "${ROCM_PATH}/include")
6147
endif()
6248

6349
target_include_directories(${example_name} PRIVATE ${include_dirs})

Applications/bitonic_sort/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ EXTERNAL_DIR := ../../External
2626
GPU_RUNTIME ?= HIP
2727

2828
# HIP variables
29-
ROCM_INSTALL_DIR ?= /opt/rocm
30-
HIP_INCLUDE_DIR := $(ROCM_INSTALL_DIR)/include
29+
ROCM_PATH ?= /opt/rocm
30+
HIP_INCLUDE_DIR := $(ROCM_PATH)/include
3131

32-
HIPCXX ?= $(ROCM_INSTALL_DIR)/bin/hipcc
32+
HIPCXX ?= $(ROCM_PATH)/bin/hipcc
3333

3434
# Common variables and flags
3535
CXX_STD := c++17

Applications/convolution/CMakeLists.txt

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,7 @@ set(CMAKE_${ROCM_EXAMPLES_GPU_LANGUAGE}_EXTENSIONS OFF)
3434
set(CMAKE_${ROCM_EXAMPLES_GPU_LANGUAGE}_STANDARD_REQUIRED ON)
3535
select_hip_platform()
3636

37-
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
38-
set(ROCM_ROOT
39-
"$ENV{HIP_PATH}"
40-
CACHE PATH
41-
"Root directory of the ROCm installation"
42-
)
43-
else()
44-
set(ROCM_ROOT
45-
"/opt/rocm"
46-
CACHE PATH
47-
"Root directory of the ROCm installation"
48-
)
49-
endif()
50-
51-
list(APPEND CMAKE_PREFIX_PATH "${ROCM_ROOT}")
37+
include("${CMAKE_CURRENT_LIST_DIR}/../../Common/ROCmPath.cmake")
5238

5339
add_executable(${example_name} main.hip)
5440
# Make example runnable using ctest
@@ -57,7 +43,7 @@ add_test(NAME ${example_name} COMMAND ${example_name})
5743
set(include_dirs "../../Common" "../../External")
5844
# For examples targeting NVIDIA, include the HIP header directory.
5945
if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia")
60-
list(APPEND include_dirs "${ROCM_ROOT}/include")
46+
list(APPEND include_dirs "${ROCM_PATH}/include")
6147
endif()
6248

6349
target_include_directories(${example_name} PRIVATE ${include_dirs})

Applications/convolution/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ EXTERNAL_DIR := ../../External
2626
GPU_RUNTIME ?= HIP
2727

2828
# HIP variables
29-
ROCM_INSTALL_DIR ?= /opt/rocm
30-
HIP_INCLUDE_DIR := $(ROCM_INSTALL_DIR)/include
29+
ROCM_PATH ?= /opt/rocm
30+
HIP_INCLUDE_DIR := $(ROCM_PATH)/include
3131

32-
HIPCXX ?= $(ROCM_INSTALL_DIR)/bin/hipcc
32+
HIPCXX ?= $(ROCM_PATH)/bin/hipcc
3333

3434
# Common variables and flags
3535
CXX_STD := c++17

Applications/fdtd/CMakeLists.txt

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,7 @@ set(CMAKE_${ROCM_EXAMPLES_GPU_LANGUAGE}_EXTENSIONS OFF)
3535
set(CMAKE_${ROCM_EXAMPLES_GPU_LANGUAGE}_STANDARD_REQUIRED ON)
3636
select_hip_platform()
3737

38-
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
39-
set(ROCM_ROOT
40-
"$ENV{HIP_PATH}"
41-
CACHE PATH
42-
"Root directory of the ROCm installation"
43-
)
44-
else()
45-
set(ROCM_ROOT
46-
"/opt/rocm"
47-
CACHE PATH
48-
"Root directory of the ROCm installation"
49-
)
50-
endif()
51-
52-
list(APPEND CMAKE_PREFIX_PATH "${ROCM_ROOT}")
38+
include("${CMAKE_CURRENT_LIST_DIR}/../../Common/ROCmPath.cmake")
5339

5440
add_executable(${example_name} main.hip)
5541

@@ -58,7 +44,7 @@ add_test(NAME ${example_name} COMMAND ${example_name})
5844
set(include_dirs "../../Common" "../../External")
5945

6046
if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia")
61-
list(APPEND include_dirs "${ROCM_ROOT}/include")
47+
list(APPEND include_dirs "${ROCM_PATH}/include")
6248
endif()
6349

6450
target_include_directories(${example_name} PRIVATE ${include_dirs})

Applications/fdtd/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ EXTERNAL_DIR := ../../External
2626
GPU_RUNTIME ?= HIP
2727

2828
# HIP variables
29-
ROCM_INSTALL_DIR ?= /opt/rocm
30-
HIP_INCLUDE_DIR := $(ROCM_INSTALL_DIR)/include
29+
ROCM_PATH ?= /opt/rocm
30+
HIP_INCLUDE_DIR := $(ROCM_PATH)/include
3131

32-
HIPCXX ?= $(ROCM_INSTALL_DIR)/bin/hipcc
32+
HIPCXX ?= $(ROCM_PATH)/bin/hipcc
3333

3434
# Common variables and flags
3535
CXX_STD := c++17

Applications/floyd_warshall/CMakeLists.txt

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -34,21 +34,7 @@ set(CMAKE_${ROCM_EXAMPLES_GPU_LANGUAGE}_EXTENSIONS OFF)
3434
set(CMAKE_${ROCM_EXAMPLES_GPU_LANGUAGE}_STANDARD_REQUIRED ON)
3535
select_hip_platform()
3636

37-
if(CMAKE_SYSTEM_NAME MATCHES "Windows")
38-
set(ROCM_ROOT
39-
"$ENV{HIP_PATH}"
40-
CACHE PATH
41-
"Root directory of the ROCm installation"
42-
)
43-
else()
44-
set(ROCM_ROOT
45-
"/opt/rocm"
46-
CACHE PATH
47-
"Root directory of the ROCm installation"
48-
)
49-
endif()
50-
51-
list(APPEND CMAKE_PREFIX_PATH "${ROCM_ROOT}")
37+
include("${CMAKE_CURRENT_LIST_DIR}/../../Common/ROCmPath.cmake")
5238

5339
add_executable(${example_name} main.hip)
5440
# Make example runnable using ctest
@@ -57,7 +43,7 @@ add_test(NAME ${example_name} COMMAND ${example_name})
5743
set(include_dirs "../../Common" "../../External")
5844
# For examples targeting NVIDIA, include the HIP header directory.
5945
if(ROCM_EXAMPLES_HIP_PLATFORM STREQUAL "nvidia")
60-
list(APPEND include_dirs "${ROCM_ROOT}/include")
46+
list(APPEND include_dirs "${ROCM_PATH}/include")
6147
endif()
6248

6349
target_include_directories(${example_name} PRIVATE ${include_dirs})

Applications/floyd_warshall/Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ EXTERNAL_DIR := ../../External
2626
GPU_RUNTIME ?= HIP
2727

2828
# HIP variables
29-
ROCM_INSTALL_DIR ?= /opt/rocm
30-
HIP_INCLUDE_DIR := $(ROCM_INSTALL_DIR)/include
29+
ROCM_PATH ?= /opt/rocm
30+
HIP_INCLUDE_DIR := $(ROCM_PATH)/include
3131

32-
HIPCXX ?= $(ROCM_INSTALL_DIR)/bin/hipcc
32+
HIPCXX ?= $(ROCM_PATH)/bin/hipcc
3333

3434
# Common variables and flags
3535
CXX_STD := c++17

0 commit comments

Comments
 (0)