Skip to content

Commit 5cb6209

Browse files
committed
Fixes for building SYCL backend for AMD GPUs
- cmake has a hardcoded `onemkl` that will cause linker failure for AMD path and needs to be changed - docfix: oneMKL compile needs `-DHIP_TARGETS` not `-DHIPTARGETS` - docfix: modified cmake build parameters to pass in more linker flags, otherwise linking will fail (might be slight overkill, but without adding `-DCMAKE_SHARED_LINKER_FLAGS` it fails
1 parent 4ddd199 commit 5cb6209

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

docs/backend/SYCL.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ cmake --build buildWithCublas --config Release
237237
git clone https://github.com/oneapi-src/oneMKL
238238
cd oneMKL
239239
# Find your HIPTARGET with rocminfo, under the key 'Name:'
240-
cmake -B buildWithrocBLAS -DCMAKE_CXX_COMPILER=icpx -DCMAKE_C_COMPILER=icx -DENABLE_MKLGPU_BACKEND=OFF -DENABLE_MKLCPU_BACKEND=OFF -DENABLE_ROCBLAS_BACKEND=ON -DHIPTARGETS=${HIPTARGET} -DTARGET_DOMAINS=blas
240+
cmake -B buildWithrocBLAS -DCMAKE_CXX_COMPILER=icpx -DCMAKE_C_COMPILER=icx -DENABLE_MKLGPU_BACKEND=OFF -DENABLE_MKLCPU_BACKEND=OFF -DENABLE_ROCBLAS_BACKEND=ON -DHIP_TARGETS=${HIPTARGET} -DTARGET_DOMAINS=blas
241241
cmake --build buildWithrocBLAS --config Release
242242
```
243243

@@ -330,17 +330,19 @@ cmake --build build --config Release -j -v
330330

331331
```sh
332332
# Export relevant ENV variables
333-
export LD_LIBRARY_PATH=/path/to/oneMKL/buildWithrocBLAS/lib:$LD_LIBRARY_PATH
334-
export LIBRARY_PATH=/path/to/oneMKL/buildWithrocBLAS/lib:$LIBRARY_PATH
335-
export CPLUS_INCLUDE_DIR=/path/to/oneMKL/buildWithrocBLAS/include:$CPLUS_INCLUDE_DIR
333+
export MKL_ROCBLAS=/path/to/oneMKL/buildWithrocmBLAS/lib
334+
export LD_LIBRARY_PATH=$MKL_ROCBLAS:$LD_LIBRARY_PATH
335+
export LIBRARY_PATH=$MKL_ROCBLAS:$LIBRARY_PATH
336+
export CPLUS_INCLUDE_DIR=$MKL_ROCBLAS:$CPLUS_INCLUDE_DIR
336337

337338
# Build LLAMA with rocBLAS acceleration through SYCL
338339

339340
## AMD
340341
# Use FP32, FP16 is not supported
341342
# Find your GGML_SYCL_DEVICE_ARCH with rocminfo, under the key 'Name:'
342343
GGML_SYCL_DEVICE_ARCH=gfx90a # Example architecture
343-
cmake -B build -DGGML_SYCL=ON -DGGML_SYCL_TARGET=AMD -DGGML_SYCL_DEVICE_ARCH=${GGML_SYCL_DEVICE_ARCH} -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx
344+
cmake -B build -DGGML_SYCL=ON -DGGML_SYCL_TARGET=AMD -DGGML_SYCL_DEVICE_ARCH=${GGML_SYCL_DEVICE_ARCH} -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DCMAKE_SHARED_LINKER_FLAGS="-L$MKL_ROCBLAS -L/opt/intel/oneapi/mkl/latest/lib/intel64 -lonemath_blas_rocblas -Wl,--no-as-needed -lmkl_sycl -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core"
345+
344346

345347
# build all binary
346348
cmake --build build --config Release -j -v

ggml/src/ggml-sycl/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ else()
7575
message(ERROR "Can't enable SYCL hip backend, GGML_SYCL_DEVICE_ARCH has not been set.")
7676
endif()
7777
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl-targets=amdgcn-amd-amdhsa")
78-
target_link_libraries(ggml-sycl PRIVATE sycl pthread m dl onemkl)
78+
target_link_libraries(ggml-sycl PRIVATE sycl pthread m dl onemath_blas_rocblas)
7979
endif()
8080

8181
if (GGML_SYCL_DEVICE_ARCH)

0 commit comments

Comments
 (0)