Skip to content

Commit 1833975

Browse files
JohannesGaesslertheo77186
authored andcommitted
HIP: fix AMDGPU_TARGETS, update documentation (ggml-org#16803)
1 parent 1eb85ec commit 1833975

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

docs/build.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,12 @@ You can download it from your Linux distro's package manager or from here: [ROCm
261261
- Using `CMake` for Linux (assuming a gfx1030-compatible AMD GPU):
262262
```bash
263263
HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -R)" \
264-
cmake -S . -B build -DGGML_HIP=ON -DAMDGPU_TARGETS=gfx1030 -DCMAKE_BUILD_TYPE=Release \
264+
cmake -S . -B build -DGGML_HIP=ON -DGPU_TARGETS=gfx1030 -DCMAKE_BUILD_TYPE=Release \
265265
&& cmake --build build --config Release -- -j 16
266266
```
267267

268+
Note: `GPU_TARGETS` is optional, omitting it will build the code for all GPUs in the current system.
269+
268270
To enhance flash attention performance on RDNA3+ or CDNA architectures, you can utilize the rocWMMA library by enabling the `-DGGML_HIP_ROCWMMA_FATTN=ON` option. This requires rocWMMA headers to be installed on the build system.
269271

270272
The rocWMMA library is included by default when installing the ROCm SDK using the `rocm` meta package provided by AMD. Alternatively, if you are not using the meta package, you can install the library using the `rocwmma-dev` or `rocwmma-devel` package, depending on your system's package manager.
@@ -282,17 +284,17 @@ You can download it from your Linux distro's package manager or from here: [ROCm
282284
```bash
283285
HIPCXX="$(hipconfig -l)/clang" HIP_PATH="$(hipconfig -p)" \
284286
HIP_DEVICE_LIB_PATH=<directory-you-just-found> \
285-
cmake -S . -B build -DGGML_HIP=ON -DAMDGPU_TARGETS=gfx1030 -DCMAKE_BUILD_TYPE=Release \
287+
cmake -S . -B build -DGGML_HIP=ON -DGPU_TARGETS=gfx1030 -DCMAKE_BUILD_TYPE=Release \
286288
&& cmake --build build -- -j 16
287289
```
288290

289291
- Using `CMake` for Windows (using x64 Native Tools Command Prompt for VS, and assuming a gfx1100-compatible AMD GPU):
290292
```bash
291293
set PATH=%HIP_PATH%\bin;%PATH%
292-
cmake -S . -B build -G Ninja -DAMDGPU_TARGETS=gfx1100 -DGGML_HIP=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release
294+
cmake -S . -B build -G Ninja -DGPU_TARGETS=gfx1100 -DGGML_HIP=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_BUILD_TYPE=Release
293295
cmake --build build
294296
```
295-
Make sure that `AMDGPU_TARGETS` is set to the GPU arch you want to compile for. The above example uses `gfx1100` that corresponds to Radeon RX 7900XTX/XT/GRE. You can find a list of targets [here](https://llvm.org/docs/AMDGPUUsage.html#processors)
297+
If necessary, adapt `GPU_TARGETS` to the GPU arch you want to compile for. The above example uses `gfx1100` that corresponds to Radeon RX 7900XTX/XT/GRE. You can find a list of targets [here](https://llvm.org/docs/AMDGPUUsage.html#processors)
296298
Find your gpu version string by matching the most significant version information from `rocminfo | grep gfx | head -1 | awk '{print $2}'` with the list of processors, e.g. `gfx1035` maps to `gfx1030`.
297299

298300

ggml/src/ggml-hip/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,11 @@ if (CXX_IS_HIPCC)
2929
endif()
3030
else()
3131
# Forward (AMD)GPU_TARGETS to CMAKE_HIP_ARCHITECTURES.
32+
if(AMDGPU_TARGETS AND NOT GPU_TARGETS)
33+
set(GPU_TARGETS ${AMDGPU_TARGETS})
34+
endif()
3235
if(GPU_TARGETS AND NOT CMAKE_HIP_ARCHITECTURES)
3336
set(CMAKE_HIP_ARCHITECTURES ${GPU_TARGETS})
34-
elseif(AMDGPU_TARGETS AND NOT CMAKE_HIP_ARCHITECTURES)
35-
set(CMAKE_HIP_ARCHITECTURES ${AMDGPU_TARGETS})
3637
endif()
3738
cmake_minimum_required(VERSION 3.21)
3839
enable_language(HIP)

0 commit comments

Comments
 (0)