Skip to content

Unify ROCM_INSTALL_DIR and ROCM_ROOT to ROCM_PATH - #440

Merged
sshi-amd merged 3 commits into
ROCm:amd-stagingfrom
sshi-amd:unify-rocm-path
Mar 31, 2026
Merged

sshi-amd merged 3 commits into
ROCm:amd-stagingfrom
sshi-amd:unify-rocm-path

Conversation

@sshi-amd

@sshi-amd sshi-amd commented Mar 20, 2026 •

Copy link
Copy Markdown
Contributor

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

Test Plan

Tested through local CI

Test Result

Passed CI: https://github.com/sshi-amd/rocm-examples/actions/runs/23312401667

Added/Updated documentation?

  • Yes
  • No, does not apply to this PR.

Included Visual Studio files?

  • Yes
  • No, does not apply to this PR.

Submission Checklist

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: ROCm#429

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sshi-amd
sshi-amd requested review from a team as code owners March 20, 2026 16:12
@zichguan-amd

Copy link
Copy Markdown
Collaborator

For CMake I was hoping to not have to set -DROCM_PATH if we can get it from the environment (I believe the env var is required for most ROCm component with TheRock). The priority for ROCM_PATH should be something like

  1. Existing cache: ROCM_PATH already set (e.g. -DROCM_PATH or previous configure)
  2. Unix: non-empty $ENV{ROCM_PATH}
  3. Unix: non-empty $ENV{HIP_PATH}
  4. Hardcoded default /opt/rocm

Would it be better if we extract this part of the CMake files into a separate file that we include to all the projects?

if(CMAKE_SYSTEM_NAME MATCHES "Windows")
    set(ROCM_ROOT
        "$ENV{HIP_PATH}"
        CACHE PATH
        "Root directory of the ROCm installation"
    )
else()
    set(ROCM_ROOT
        "/opt/rocm"
        CACHE PATH
        "Root directory of the ROCm installation"
    )
endif()

list(APPEND CMAKE_PREFIX_PATH "${ROCM_ROOT}")

Correct me if I'm wrong but I think it block is in every example.

sshi-amd and others added 2 commits March 23, 2026 19:36
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>
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>

@zichguan-amd zichguan-amd left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks!

@sshi-amd
sshi-amd merged commit fd4b3a6 into ROCm:amd-staging Mar 31, 2026
41 of 49 checks passed
sshi-amd added a commit to sshi-amd/rocm-examples that referenced this pull request Apr 23, 2026
Resolves 378 leaf-Makefile conflicts produced by upstream PR ROCm#440 which
renamed ROCM_INSTALL_DIR -> ROCM_PATH and changed the assignment style
from `:=` with `$(or ...)` to `?=`. Every conflict block was identical
in shape, so the resolution is uniform: take upstream's ROCM_PATH form.

Additional follow-up renames not covered by upstream's PR:
- Common/require_deps.mk: rename internal ROCM_INSTALL_DIR -> ROCM_PATH
  in the amd_comgr fallback detection block.
- Libraries/Makefile: same rename in the parent dispatch Makefile.
- .github/workflows/build-rocm-examples-reusable.yml: drop redundant
  `ROCM_INSTALL_DIR=${ROCM_PATH}` env exports and the
  `make ROCM_INSTALL_DIR=...` argument; ROCM_PATH is already exported
  in the env and consumed directly by the leaf Makefiles.

REQUIRED_DEPS / SKIP_BUILD wrappers added by this branch are preserved
unchanged where they auto-merged cleanly.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
sshi-amd added a commit to sshi-amd/rocm-examples that referenced this pull request Apr 23, 2026
These leaf Makefiles were missed by upstream PR ROCm#440 (which renamed
ROCM_INSTALL_DIR -> ROCM_PATH and switched := to ?= for env override
support). They kept `ROCM_PATH := /opt/rocm` (hard assignment), so
the CI's exported ROCM_PATH=/therock-tarball/install was overridden
back to /opt/rocm and the build invoked /opt/rocm/bin/hipcc which
doesn't exist in the runner container, surfacing as:

  make[2]: /opt/rocm/bin/hipcc: Command not found
  make[1]: *** [Makefile:39: ROCgdb] Error 2

Affected categories: HIP-Doc/Tutorials/Programming-Patterns (bfs,
histogram_atomics, image_convolution, kmeans, matrix_multiplication),
Libraries/{MIGraphX, MIVisionX, RCCL, RPP, rocAL, rocCV, rocJPEG,
hipBLASLt/gemm_clamp_bias}, Tools/ROCgdb.

Bulk-replaced with `?= /opt/rocm` so ROCM_PATH from env wins. Same
fix that upstream PR ROCm#440 applied to the rest of the tree.

Co-Authored-By: Claude Opus 4 (1M context) <noreply@anthropic.com>
sshi-amd added a commit that referenced this pull request Apr 24, 2026
…n, build, and test (#442)

Add Makefile build path to CI with configure-based dependency detection

Adds a parallel Makefile build to CI alongside the existing CMake/CTest flow,
so the standalone `make` workflow stays exercised on every commit.

## What's added

- **`Scripts/configure.sh`** — autoconf-style probe for external dependencies
  (FFmpeg, OpenCV, GLFW3, Vulkan, libdw, amd_comgr, glslangValidator) via
  `pkg-config` + link tests. Writes `config.mk` at the repo root.
- **`Common/require_deps.mk`** — leaf Makefiles declare `REQUIRED_DEPS :=
  GLFW3` (etc.) and include this. If a dependency is missing, `SKIP_BUILD`
  is set and the leaf's main rules collapse to no-ops, so parent cascades
  don't error.
- **`Common/find_filesystem.mk`** — probes whether `-lstdc++fs` is needed
  (older GCC like SLES 15.7's default) or whether `std::experimental::filesystem`
  is in libstdc++ proper (Ubuntu 22 / AlmaLinux 8 + gcc-toolset-13). Mirrors
  the existing `Common/FindFilesystem.cmake` for the Make path.

## Leaf Makefiles

- ~390 leaf Makefiles updated. 28 examples with external deps gain
  `REQUIRED_DEPS := …` + the `ifneq ($(SKIP_BUILD),1) … else … endif`
  wrapper. Examples without external deps are unchanged in behavior.
- All hard-coded `-lstdc++fs` (29 leaves total: 10 rocDecode + 19 others
  in Applications, HIP-Basic, HIP-Doc, rocJPEG, rocProfiler-SDK) converted
  to `$(CXX_FS_LIB)` from the new probe.
- 48 leaves still using `ROCM_PATH := /opt/rocm` (hard `:=`) flipped to
  `?= /opt/rocm` so the env-provided path wins. Same fix that upstream
  PR #440 applied to the rest of the tree.
- `Tools/ROCgdb/.gitignore` added; mismatched per-directory `.gitignore`
  entries fixed in two `warp_size_reduction` dirs.
- Five previously committed binary artifacts removed.
- One `EXAMPLE := <wrong>` typo fixed in
  `identifying_host_device_compilation_pass/Makefile`.

## CI workflow

- Adds **Makefile build**, **Collect Makefile build artifacts**, and
  **Upload Makefile build artifacts** steps to the reusable workflow.
- CMake configure / build are gated with `if: !cancelled()` so the CMake
  side still runs to completion when the Makefile build fails (for
  visibility).
- AlmaLinux 8 Dockerfile picks up `pkgconf-pkg-config` (it was missing,
  which broke every `pkg-config` probe on AlmaLinux) and extends
  `PKG_CONFIG_PATH` to discover source-built FFmpeg / GLFW.

## Out of scope (deferred to follow-up PR)

- Make-native `test` target (per-leaf `test:` depending on the build target,
  cascading from root via `make test`, with per-parent `SKIP_FROM_TEST`
  filter) — opened separately as a stacked PR.
- Per-GPU-arch test skipping for the Make path.
- Wiring up rocDecode's conditional test-data probing.

Signed-off-by: zichguan-amd <zichuan.guan@amd.com>
Co-authored-by: Claude (Anthropic) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants