[PR #2626] [CLOSED] HIP build: honor -DGPU_TARGETS / -DAMDGPU_TARGETS when CMAKE_HIP_ARCHITECTURES is not given #4174

Closed
opened 2026-11-07 15:33:47 +07:00 by bsakaguchi · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/Niko1221/Strata/pull/2626
Author: @justincinmd
Created: 10/15/2026
Status: ❌ Closed

Base: main ← Head: pr/hip-gpu-targets


📝 Commits (1)

  • 39be1ea HIP build: -DGPU_TARGETS / -DAMDGPU_TARGETS choose the architectures when CMAKE_HIP_ARCHITECTURES is not given

📊 Changes

6 files changed (+479 additions, -5 deletions)

View changed files

📝 CMakeLists.txt (+8 -0)
➕ cmake/hip_arch_select.cmake (+162 -0)
📝 cmake/hip_backend.cmake (+6 -4)
➕ cmake/tests/hip_arch_select/CMakeLists.txt (+70 -0)
➕ cmake/tests/hip_arch_select_test.cmake (+228 -0)
📝 docs/AMD_HIP.md (+5 -1)

📄 Description

Summary

A manual HIP build with -DGPU_TARGETS=gfx1201 builds a gfx1100 engine. Configure and link give no warning. At start-up the engine refuses the card. This PR makes -DGPU_TARGETS and -DAMDGPU_TARGETS choose the architecture when CMAKE_HIP_ARCHITECTURES is not given.

Cause: cmake/hip_backend.cmake defaults CMAKE_HIP_ARCHITECTURES to gfx1100 and reads nothing else. ROCm applies GPU_TARGETS only to hip::device, and Strata links hip::host.

# v0.1.43, ROCm 7.2.4
cmake -S . -B build-hip -G Ninja -DSTRATA_ENABLE_HIP=ON -DCMAKE_PREFIX_PATH=/opt/rocm -DGPU_TARGETS=gfx1201
# -- Strata: HIP enabled, arch gfx1100

What changed

  • cmake/hip_arch_select.cmake (new): the order is CMAKE_HIP_ARCHITECTURES, GPU_TARGETS, AMDGPU_TARGETS, then gfx1100. The default does not change. ggml-hip uses the same order.
  • The configure line names the source, e.g. arch gfx1201 (from GPU_TARGETS). If CMAKE_HIP_ARCHITECTURES and a target variable disagree, CMAKE_HIP_ARCHITECTURES wins and configure warns.
  • Only values the user gave count. find_package(hip) caches its own GPU_TARGETS (amdgpu-arch's list), and ROCm 5.7 / 6.2 retype the user's entry. The selector tells them apart by CMake's -D marks and a record of what find_package(hip) left. A toolchain or parent-project variable wins over the cache, as usual in CMake.
  • Strata no longer writes CMAKE_HIP_ARCHITECTURES to the cache. The same flags give the same result in a new or a used build folder. A 0.1.43 folder's cached default (gfx1100) is dropped; a value the user edited there is kept.
  • cmake/hip_backend.cmake calls the selector before and after find_package(hip).
  • docs/AMD_HIP.md: three sentences in the Build section.

Not changed: setup.py and tools/hip/build_windows.bat pass CMAKE_HIP_ARCHITECTURES, so they build as before. The gfx906 path does not use this file.

Testing

  • cmake/tests/hip_arch_select_test.cmake, in ctest as hip_arch_select_test under STRATA_BUILD_TESTS. It runs 234 configures of a small project that replays ROCm 5.7, 6.2 and 7.2's cache declarations. It needs no HIP toolchain. It covers new and used folders, -U, -C, toolchain values (also equal to the cache), 0.1.43 folders and the conflict warning. It passes on CMake 3.24, 3.28, 4.1 and 4.4.
  • ROCm 7.2.4: -DGPU_TARGETS=gfx1201 builds gfx1201 code only (57 code objects). v0.1.43 builds gfx1100.
  • CUDA 13.0.2 (sm_120) and oneAPI DPC++ 2026.1.1 (SYCL) build with no new diagnostics. Compile only.

Extra Notes

One case stays as in 0.1.43: in a 0.1.43 folder where ROCm 5.7 / 6.2 retyped the user's GPU_TARGETS, that value cannot be told from ROCm's own entry. Give -DGPU_TARGETS again to use it.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/Niko1221/Strata/pull/2626 **Author:** [@justincinmd](https://github.com/justincinmd) **Created:** 10/15/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `pr/hip-gpu-targets` --- ### 📝 Commits (1) - [`39be1ea`](https://github.com/Niko1221/Strata/commit/39be1ea8e794c770ff3f13df3ec13eefd9e17fa0) HIP build: -DGPU_TARGETS / -DAMDGPU_TARGETS choose the architectures when CMAKE_HIP_ARCHITECTURES is not given ### 📊 Changes **6 files changed** (+479 additions, -5 deletions) <details> <summary>View changed files</summary> 📝 `CMakeLists.txt` (+8 -0) ➕ `cmake/hip_arch_select.cmake` (+162 -0) 📝 `cmake/hip_backend.cmake` (+6 -4) ➕ `cmake/tests/hip_arch_select/CMakeLists.txt` (+70 -0) ➕ `cmake/tests/hip_arch_select_test.cmake` (+228 -0) 📝 `docs/AMD_HIP.md` (+5 -1) </details> ### 📄 Description ## Summary A manual HIP build with `-DGPU_TARGETS=gfx1201` builds a gfx1100 engine. Configure and link give no warning. At start-up the engine refuses the card. This PR makes `-DGPU_TARGETS` and `-DAMDGPU_TARGETS` choose the architecture when `CMAKE_HIP_ARCHITECTURES` is not given. Cause: `cmake/hip_backend.cmake` defaults `CMAKE_HIP_ARCHITECTURES` to gfx1100 and reads nothing else. ROCm applies `GPU_TARGETS` only to `hip::device`, and Strata links `hip::host`. ```sh # v0.1.43, ROCm 7.2.4 cmake -S . -B build-hip -G Ninja -DSTRATA_ENABLE_HIP=ON -DCMAKE_PREFIX_PATH=/opt/rocm -DGPU_TARGETS=gfx1201 # -- Strata: HIP enabled, arch gfx1100 ``` ## What changed - `cmake/hip_arch_select.cmake` (new): the order is `CMAKE_HIP_ARCHITECTURES`, `GPU_TARGETS`, `AMDGPU_TARGETS`, then gfx1100. The default does not change. ggml-hip uses the same order. - The configure line names the source, e.g. `arch gfx1201 (from GPU_TARGETS)`. If `CMAKE_HIP_ARCHITECTURES` and a target variable disagree, `CMAKE_HIP_ARCHITECTURES` wins and configure warns. - Only values the user gave count. `find_package(hip)` caches its own `GPU_TARGETS` (amdgpu-arch's list), and ROCm 5.7 / 6.2 retype the user's entry. The selector tells them apart by CMake's `-D` marks and a record of what `find_package(hip)` left. A toolchain or parent-project variable wins over the cache, as usual in CMake. - Strata no longer writes `CMAKE_HIP_ARCHITECTURES` to the cache. The same flags give the same result in a new or a used build folder. A 0.1.43 folder's cached default (gfx1100) is dropped; a value the user edited there is kept. - `cmake/hip_backend.cmake` calls the selector before and after `find_package(hip)`. - docs/AMD_HIP.md: three sentences in the Build section. Not changed: setup.py and `tools/hip/build_windows.bat` pass `CMAKE_HIP_ARCHITECTURES`, so they build as before. The gfx906 path does not use this file. ## Testing - `cmake/tests/hip_arch_select_test.cmake`, in ctest as `hip_arch_select_test` under `STRATA_BUILD_TESTS`. It runs 234 configures of a small project that replays ROCm 5.7, 6.2 and 7.2's cache declarations. It needs no HIP toolchain. It covers new and used folders, `-U`, `-C`, toolchain values (also equal to the cache), 0.1.43 folders and the conflict warning. It passes on CMake 3.24, 3.28, 4.1 and 4.4. - ROCm 7.2.4: `-DGPU_TARGETS=gfx1201` builds gfx1201 code only (57 code objects). v0.1.43 builds gfx1100. - CUDA 13.0.2 (sm_120) and oneAPI DPC++ 2026.1.1 (SYCL) build with no new diagnostics. Compile only. ## Extra Notes One case stays as in 0.1.43: in a 0.1.43 folder where ROCm 5.7 / 6.2 retyped the user's `GPU_TARGETS`, that value cannot be told from ROCm's own entry. Give `-DGPU_TARGETS` again to use it. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
bsakaguchi 2026-11-07 15:33:47 +07:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Niko1221/Strata#4174
No description provided.