Skip to content

Commit a856351

Browse files
committed
Rename oneMKL Interface to oneMath
1 parent 70680c4 commit a856351

File tree

2 files changed

+29
-32
lines changed

2 files changed

+29
-32
lines changed

docs/backend/SYCL.md

Lines changed: 15 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
**oneAPI** is an open ecosystem and a standard-based specification, supporting multiple architectures including but not limited to intel CPUs, GPUs and FPGAs. The key components of the oneAPI ecosystem include:
2121

2222
- **DPCPP** *(Data Parallel C++)*: The primary oneAPI SYCL implementation, which includes the icpx/icx Compilers.
23-
- **oneAPI Libraries**: A set of highly optimized libraries targeting multiple domains *(e.g. oneMKL and oneDNN)*.
23+
- **oneAPI Libraries**: A set of highly optimized libraries targeting multiple domains *(e.g. Intel oneMKL, oneMath and oneDNN)*.
2424
- **oneAPI LevelZero**: A high performance low level interface for fine-grained control over intel iGPUs and dGPUs.
2525
- **Nvidia & AMD Plugins**: These are plugins extending oneAPI's DPCPP support to SYCL on Nvidia and AMD GPU targets.
2626

@@ -228,27 +228,27 @@ Upon a successful installation, SYCL is enabled for the available intel devices,
228228
**oneAPI Plugin**: In order to enable SYCL support on Nvidia GPUs, please install the [Codeplay oneAPI Plugin for Nvidia GPUs](https://developer.codeplay.com/products/oneapi/nvidia/download). User should also make sure the plugin version matches the installed base toolkit one *(previous step)* for a seamless "oneAPI on Nvidia GPU" setup.
229229

230230

231-
**oneMKL for cuBlas**: The current oneMKL releases *(shipped with the oneAPI base-toolkit)* do not contain the cuBLAS backend. A build from source of the upstream [oneMKL](https://github.com/oneapi-src/oneMKL) with the *cuBLAS* backend enabled is thus required to run it on Nvidia GPUs.
231+
**oneMath for cuBlas**: The current Intel oneMKL releases *(shipped with the oneAPI base-toolkit)* do not contain the cuBLAS backend. [oneMath](https://github.com/uxlfoundation/oneMath) is used instead to dispatch to *cuBLAS* on Nvidia GPUs.
232232

233233
```sh
234-
git clone https://github.com/oneapi-src/oneMKL
235-
cd oneMKL
236-
cmake -B buildWithCublas -DCMAKE_CXX_COMPILER=icpx -DCMAKE_C_COMPILER=icx -DENABLE_MKLGPU_BACKEND=OFF -DENABLE_MKLCPU_BACKEND=OFF -DENABLE_CUBLAS_BACKEND=ON -DTARGET_DOMAINS=blas
237-
cmake --build buildWithCublas --config Release
234+
git clone https://github.com/uxlfoundation/oneMath
235+
cd oneMath
236+
cmake -B buildWithCublas -DCMAKE_CXX_COMPILER=icpx -DCMAKE_C_COMPILER=icx -DENABLE_MKLGPU_BACKEND=OFF -DENABLE_MKLCPU_BACKEND=OFF -DENABLE_CUBLAS_BACKEND=ON -DTARGET_DOMAINS=blas -DCMAKE_INSTALL_PREFIX:PATH=install
237+
cmake --build buildWithCublas --target install --config Release
238238
```
239239

240240
- **Adding support to AMD GPUs**
241241

242242
**oneAPI Plugin**: In order to enable SYCL support on AMD GPUs, please install the [Codeplay oneAPI Plugin for AMD GPUs](https://developer.codeplay.com/products/oneapi/amd/download). As with Nvidia GPUs, the user should also make sure the plugin version matches the installed base toolkit.
243243

244-
**oneMKL for rocBlas**: The current oneMKL releases *(shipped with the oneAPI base-toolkit)* doesn't contain the rocBLAS backend. A build from source of the upstream [oneMKL](https://github.com/oneapi-src/oneMKL) with the *rocBLAS* backend enabled is thus required to run it on AMD GPUs.
244+
**oneMath for rocBlas**: The current Intel oneMKL releases *(shipped with the oneAPI base-toolkit)* do not contain the rocBLAS backend. [oneMath](https://github.com/uxlfoundation/oneMath) is used instead to dispatch to *rocBLAS* on AMD GPUs.
245245

246246
```sh
247-
git clone https://github.com/oneapi-src/oneMKL
248-
cd oneMKL
249-
# Find your HIPTARGET with rocminfo, under the key 'Name:'
250-
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
251-
cmake --build buildWithrocBLAS --config Release
247+
git clone https://github.com/uxlfoundation/oneMath
248+
cd oneMath
249+
# Find your HIP_TARGETS with rocminfo, under the key 'Name:'
250+
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=${HIP_TARGETS} -DTARGET_DOMAINS=blas -DCMAKE_INSTALL_PREFIX:PATH=install
251+
cmake --build buildWithrocBLAS --target install --config Release
252252
```
253253

254254
3. **Verify installation and environment**
@@ -316,21 +316,15 @@ cmake --build build --config Release -j -v
316316
#### Nvidia GPU
317317

318318
```sh
319-
# Export relevant ENV variables
320-
export LD_LIBRARY_PATH=/path/to/oneMKL/buildWithCublas/lib:$LD_LIBRARY_PATH
321-
export LIBRARY_PATH=/path/to/oneMKL/buildWithCublas/lib:$LIBRARY_PATH
322-
export CPLUS_INCLUDE_DIR=/path/to/oneMKL/buildWithCublas/include:$CPLUS_INCLUDE_DIR
323-
export CPLUS_INCLUDE_DIR=/path/to/oneMKL/include:$CPLUS_INCLUDE_DIR
324-
325319
# Build LLAMA with Nvidia BLAS acceleration through SYCL
326320
# Setting GGML_SYCL_DEVICE_ARCH is optional but can improve performance
327321
GGML_SYCL_DEVICE_ARCH=sm_80 # Example architecture
328322

329323
# Option 1: Use FP32 (recommended for better performance in most cases)
330-
cmake -B build -DGGML_SYCL=ON -DGGML_SYCL_TARGET=NVIDIA -DGGML_SYCL_DEVICE_ARCH=${GGML_SYCL_DEVICE_ARCH} -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx
324+
cmake -B build -DGGML_SYCL=ON -DGGML_SYCL_TARGET=NVIDIA -DGGML_SYCL_DEVICE_ARCH=${GGML_SYCL_DEVICE_ARCH} -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DoneMath_DIR=/path/to/oneMath/buildWithCublas/install/lib/cmake/oneMath
331325

332326
# Option 2: Use FP16
333-
cmake -B build -DGGML_SYCL=ON -DGGML_SYCL_TARGET=NVIDIA -DGGML_SYCL_DEVICE_ARCH=${GGML_SYCL_DEVICE_ARCH} -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DGGML_SYCL_F16=ON
327+
cmake -B build -DGGML_SYCL=ON -DGGML_SYCL_TARGET=NVIDIA -DGGML_SYCL_DEVICE_ARCH=${GGML_SYCL_DEVICE_ARCH} -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx -DoneMath_DIR=/path/to/oneMath/buildWithCublas/install/lib/cmake/oneMath -DGGML_SYCL_F16=ON
334328

335329
# build all binary
336330
cmake --build build --config Release -j -v
@@ -339,18 +333,13 @@ cmake --build build --config Release -j -v
339333
#### AMD GPU
340334

341335
```sh
342-
# Export relevant ENV variables
343-
export LD_LIBRARY_PATH=/path/to/oneMKL/buildWithrocBLAS/lib:$LD_LIBRARY_PATH
344-
export LIBRARY_PATH=/path/to/oneMKL/buildWithrocBLAS/lib:$LIBRARY_PATH
345-
export CPLUS_INCLUDE_DIR=/path/to/oneMKL/buildWithrocBLAS/include:$CPLUS_INCLUDE_DIR
346-
347336
# Build LLAMA with rocBLAS acceleration through SYCL
348337

349338
## AMD
350339
# Use FP32, FP16 is not supported
351340
# Find your GGML_SYCL_DEVICE_ARCH with rocminfo, under the key 'Name:'
352341
GGML_SYCL_DEVICE_ARCH=gfx90a # Example architecture
353-
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
342+
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 -DoneMath_DIR=/path/to/oneMath/buildWithrocBLAS/install/lib/cmake/oneMath
354343

355344
# build all binary
356345
cmake --build build --config Release -j -v

ggml/src/ggml-sycl/CMakeLists.txt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,18 +69,26 @@ else()
6969
if (GGML_SYCL_TARGET STREQUAL "INTEL")
7070
target_link_libraries(ggml-sycl PRIVATE sycl OpenCL mkl_core pthread m dl mkl_sycl_blas mkl_intel_ilp64 mkl_tbb_thread)
7171
elseif (GGML_SYCL_TARGET STREQUAL "NVIDIA")
72-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl-targets=nvptx64-nvidia-cuda")
7372
add_compile_definitions(GGML_SYCL_NVIDIA)
74-
target_link_libraries(ggml-sycl PRIVATE sycl pthread m dl onemkl_blas_cublas)
73+
find_package(oneMath REQUIRED)
74+
target_link_libraries(ggml-sycl PRIVATE sycl pthread m dl ONEMATH::onemath_blas_cublas)
75+
target_compile_options(ggml-sycl PRIVATE "-fsycl-targets=nvptx64-nvidia-cuda")
76+
# Disable warnings for using deprecated oneapi::mkl namespace in oneMath
77+
# Using the deprecated API in oneMath is useful to have a similar API than Intel oneMKL
78+
target_compile_options(ggml-sycl PRIVATE "-Wno-deprecated-declarations")
7579
elseif (GGML_SYCL_TARGET STREQUAL "AMD")
7680
if (NOT GGML_SYCL_DEVICE_ARCH)
7781
message(ERROR "Can't enable SYCL hip backend, GGML_SYCL_DEVICE_ARCH has not been set.")
7882
endif()
79-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl-targets=amdgcn-amd-amdhsa")
80-
target_link_libraries(ggml-sycl PRIVATE sycl pthread m dl onemkl)
83+
find_package(oneMath REQUIRED)
84+
target_link_libraries(ggml-sycl PRIVATE sycl pthread m dl onemath)
85+
target_compile_options(ggml-sycl PRIVATE "-fsycl-targets=amdgcn-amd-amdhsa")
86+
# Disable warnings for using deprecated oneapi::mkl namespace in oneMath
87+
# Using the deprecated API in oneMath is useful to have a similar API than Intel oneMKL
88+
target_compile_options(ggml-sycl PRIVATE "-Wno-deprecated-declarations")
8189
endif()
8290

8391
if (GGML_SYCL_DEVICE_ARCH)
84-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xsycl-target-backend --offload-arch=${GGML_SYCL_DEVICE_ARCH}")
85-
endif()
92+
target_compile_options(ggml-sycl PRIVATE "-Xsycl-target-backend --offload-arch=${GGML_SYCL_DEVICE_ARCH}")
93+
endif()
8694
endif()

0 commit comments

Comments
 (0)