From 8608504a5e6c85d1d3c17f01d3b2bae4ed42f3d7 Mon Sep 17 00:00:00 2001 From: smashingtags Date: Tue, 19 May 2026 16:15:49 -0400 Subject: [PATCH] cmake: add Intel Arc GPU support via SYCL backend - Add sycl to the backend link loop so ggml-sycl links when built statically - Add -fsycl link option for consumer executables (ggml-sycl links the SYCL runtime PRIVATE, so consumers need it on their own link line) - Gate _FORTIFY_SOURCE=2 with NOT GGML_SYCL: the fortified __memcpy_chk symbol is unresolvable in SPIR-V device code and aborts kernel compilation - Add buildsycl.sh convenience script (icx/icpx compilers) Tested on Intel Arc A310 (DG2) with oneAPI 2026.0 + Level Zero: full TTS generation produces correct audio output on the GPU. --- CMakeLists.txt | 13 ++++++++++--- buildsycl.sh | 8 ++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100755 buildsycl.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 8206fd2..47aa05f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,8 +40,10 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) # Audio tokenizer tensor names can exceed default GGML_MAX_NAME of 64 add_compile_definitions(GGML_MAX_NAME=128) -# Harden: mark fread/fwrite/etc with warn_unused_result on all platforms -if(NOT MSVC) +# Harden: mark fread/fwrite/etc with warn_unused_result on all platforms. +# Disabled for SYCL: _FORTIFY_SOURCE replaces memcpy with __memcpy_chk +# which is unresolvable in GPU device code and aborts kernel compilation. +if(NOT MSVC AND NOT GGML_SYCL) add_compile_definitions(_FORTIFY_SOURCE=2) endif() @@ -79,7 +81,7 @@ macro(link_ggml_backends target) if(TARGET ggml-base) target_link_libraries(${target} PRIVATE ggml-base) endif() - foreach(backend cpu blas cuda metal vulkan) + foreach(backend cpu blas cuda metal vulkan sycl) if(TARGET ggml-${backend}) get_target_property(CURRENT_BACKEND_TYPE ggml-${backend} TYPE) if (CURRENT_BACKEND_TYPE STREQUAL "MODULE_LIBRARY") @@ -90,6 +92,11 @@ macro(link_ggml_backends target) target_link_libraries(${target} PRIVATE ggml-${backend}) endif() endforeach() + # SYCL backend links the runtime PRIVATE, so consumers need -fsycl + # on their own link line to resolve libsycl.so symbols. + if(TARGET ggml-sycl AND GGML_SYCL) + target_link_options(${target} PRIVATE -fsycl) + endif() add_dependencies(${target} version) endmacro() diff --git a/buildsycl.sh b/buildsycl.sh new file mode 100755 index 0000000..0fe3818 --- /dev/null +++ b/buildsycl.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +rm -rf build +mkdir build +cd build + +cmake .. -DGGML_SYCL=ON -DCMAKE_C_COMPILER=icx -DCMAKE_CXX_COMPILER=icpx +cmake --build . --config Release -j "$(nproc)"