改动 / #2626
#2626 HIP build: honor -DGPU_TARGETS / -DAMDGPU_TARGETS when CMAKE_HIP_ARCHITECTURES is not given
open · @justincinmd · 0 评论 · 去 GitHub 看
Setup & installAMD / HIPNVIDIA / CUDADocumentationWindows
说明
## 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.
本站相关内容
相关页面的快捷入口。