Skip to content

Commit

Permalink
cmake : try to fix sycl 2
Browse files Browse the repository at this point in the history
  • Loading branch information
ggerganov committed Sep 13, 2024
1 parent ae9475d commit b653b1e
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions ggml/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,8 @@ if (GGML_SYCL)
endif()

check_cxx_compiler_flag("-fsycl" SUPPORTS_SYCL)
if ( DEFINED ENV{ONEAPI_ROOT})

if (DEFINED ENV{ONEAPI_ROOT})
message(STATUS "Using oneAPI Release SYCL compiler (icpx).")
elseif(SUPPORTS_SYCL)
message(WARNING "Using open-source SYCL compiler (clang++). Didn't detect ENV {ONEAPI_ROOT}.
Expand All @@ -538,7 +539,8 @@ if (GGML_SYCL)
add_compile_definitions(GGML_SYCL_FORCE_MMQ)
endif()

list(APPEND CMAKE_CXX_FLAGS -Wno-narrowing)
add_link_options (-fsycl)
add_compile_options(-fsycl -Wno-narrowing)

if (GGML_SYCL_TARGET STREQUAL "NVIDIA")
add_compile_definitions(GGML_SYCL_WARP_SIZE=32)
Expand All @@ -554,26 +556,29 @@ if (GGML_SYCL)

find_package(DNNL)
message("-- DNNL found:" ${DNNL_FOUND})

if (GGML_SYCL_TARGET STREQUAL "INTEL")
add_compile_definitions(GGML_SYCL_DNNL=${DNNL_FOUND})
else()
add_compile_definitions(GGML_SYCL_DNNL=0)
endif()

if (${DNNL_FOUND} AND GGML_SYCL_TARGET STREQUAL "INTEL")
list(APPEND GGML_EXTRA_LIBS DNNL::dnnl)
endif()

if (WIN32)
find_package(IntelSYCL REQUIRED)
find_package(MKL REQUIRED)
list(APPEND GGML_EXTRA_LIBS IntelSYCL::SYCL_CXX MKL::MKL MKL::MKL_SYCL)
else()
if (GGML_SYCL_TARGET STREQUAL "INTEL")
list(APPEND GGML_EXTRA_LIBS -fsycl OpenCL mkl_core pthread m dl mkl_sycl_blas mkl_intel_ilp64 mkl_tbb_thread)
list(APPEND GGML_EXTRA_LIBS OpenCL mkl_core pthread m dl mkl_sycl_blas mkl_intel_ilp64 mkl_tbb_thread)
elseif (GGML_SYCL_TARGET STREQUAL "NVIDIA")
list(APPEND CMAKE_CXX_FLAGS -fsycl-targets=nvptx64-nvidia-cuda)
list(APPEND GGML_EXTRA_LIBS -fsycl pthread m dl onemkl)
add_compile_options(-fsycl-targets=nvptx64-nvidia-cuda)
list(APPEND GGML_EXTRA_LIBS pthread m dl onemkl)
endif()
endif()
if (${DNNL_FOUND} AND GGML_SYCL_TARGET STREQUAL "INTEL")
list(APPEND GGML_EXTRA_LIBS -fsycl DNNL::dnnl)
endif()
endif()

if (GGML_RPC)
Expand Down

0 comments on commit b653b1e

Please sign in to comment.