Compare commits

...

2 Commits

Author SHA1 Message Date
Leonard
2b7c847c13
Merge 5cb6209de5 into 32d6ee6385 2024-12-23 14:50:29 -06:00
lhl
5cb6209de5 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
2024-12-16 16:44:57 +09:00
2 changed files with 8 additions and 6 deletions

View File

@ -237,7 +237,7 @@ cmake --build buildWithCublas --config Release
git clone https://github.com/oneapi-src/oneMKL git clone https://github.com/oneapi-src/oneMKL
cd oneMKL cd oneMKL
# Find your HIPTARGET with rocminfo, under the key 'Name:' # Find your HIPTARGET with rocminfo, under the key 'Name:'
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 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
cmake --build buildWithrocBLAS --config Release cmake --build buildWithrocBLAS --config Release
``` ```
@ -330,9 +330,10 @@ cmake --build build --config Release -j -v
```sh ```sh
# Export relevant ENV variables # Export relevant ENV variables
export LD_LIBRARY_PATH=/path/to/oneMKL/buildWithrocBLAS/lib:$LD_LIBRARY_PATH export MKL_ROCBLAS=/path/to/oneMKL/buildWithrocmBLAS/lib
export LIBRARY_PATH=/path/to/oneMKL/buildWithrocBLAS/lib:$LIBRARY_PATH export LD_LIBRARY_PATH=$MKL_ROCBLAS:$LD_LIBRARY_PATH
export CPLUS_INCLUDE_DIR=/path/to/oneMKL/buildWithrocBLAS/include:$CPLUS_INCLUDE_DIR export LIBRARY_PATH=$MKL_ROCBLAS:$LIBRARY_PATH
export CPLUS_INCLUDE_DIR=$MKL_ROCBLAS:$CPLUS_INCLUDE_DIR
# Build LLAMA with rocBLAS acceleration through SYCL # Build LLAMA with rocBLAS acceleration through SYCL
@ -340,7 +341,8 @@ export CPLUS_INCLUDE_DIR=/path/to/oneMKL/buildWithrocBLAS/include:$CPLUS_INCLUDE
# Use FP32, FP16 is not supported # Use FP32, FP16 is not supported
# Find your GGML_SYCL_DEVICE_ARCH with rocminfo, under the key 'Name:' # Find your GGML_SYCL_DEVICE_ARCH with rocminfo, under the key 'Name:'
GGML_SYCL_DEVICE_ARCH=gfx90a # Example architecture GGML_SYCL_DEVICE_ARCH=gfx90a # Example architecture
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 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"
# build all binary # build all binary
cmake --build build --config Release -j -v cmake --build build --config Release -j -v

View File

@ -75,7 +75,7 @@ else()
message(ERROR "Can't enable SYCL hip backend, GGML_SYCL_DEVICE_ARCH has not been set.") message(ERROR "Can't enable SYCL hip backend, GGML_SYCL_DEVICE_ARCH has not been set.")
endif() endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl-targets=amdgcn-amd-amdhsa") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl-targets=amdgcn-amd-amdhsa")
target_link_libraries(ggml-sycl PRIVATE sycl pthread m dl onemkl) target_link_libraries(ggml-sycl PRIVATE sycl pthread m dl onemath_blas_rocblas)
endif() endif()
if (GGML_SYCL_DEVICE_ARCH) if (GGML_SYCL_DEVICE_ARCH)