@@ -116,6 +116,7 @@ option(LLAMA_MPI "llama: use MPI"
116
116
option (LLAMA_QKK_64 "llama: use super-block size of 64 for k-quants" OFF )
117
117
option (LLAMA_SYCL "llama: use SYCL" OFF )
118
118
option (LLAMA_SYCL_F16 "llama: use 16 bit floats for sycl calculations" OFF )
119
+ set (LLAMA_SYCL_TARGET "INTEL" CACHE STRING "llama: sycl target device" )
119
120
option (LLAMA_CPU_HBM "llama: use memkind for CPU HBM" OFF )
120
121
121
122
option (LLAMA_BUILD_TESTS "llama: build tests" ${LLAMA_STANDALONE} )
@@ -533,6 +534,10 @@ if (LLAMA_HIPBLAS)
533
534
endif ()
534
535
535
536
if (LLAMA_SYCL )
537
+ if (NOT LLAMA_SYCL_TARGET MATCHES "^(INTEL|NVIDIA)$" )
538
+ message (FATAL_ERROR "Invalid backend chosen, supported options are INTEL or NVIDIA" )
539
+ endif ()
540
+
536
541
if ( NOT DEFINED ENV{ONEAPI_ROOT} )
537
542
message (FATAL_ERROR "Not detect ENV {ONEAPI_ROOT}, please install oneAPI & source it, like: source /opt/intel/oneapi/setvars.sh" )
538
543
endif ()
@@ -554,14 +559,22 @@ if (LLAMA_SYCL)
554
559
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing" )
555
560
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3" )
556
561
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl -L${MKLROOT} /lib" )
562
+ if (LLAMA_SYCL_TARGET STREQUAL "NVIDIA" )
563
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl-targets=nvptx64-nvidia-cuda" )
564
+ endif ()
557
565
558
566
set (GGML_HEADERS_SYCL ggml-sycl.h )
559
567
set (GGML_SOURCES_SYCL ggml-sycl.cpp )
560
568
561
569
if (WIN32 )
562
570
set (LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} -fsycl sycl7 OpenCL mkl_sycl_blas_dll.lib mkl_intel_ilp64_dll.lib mkl_sequential_dll.lib mkl_core_dll.lib )
563
571
else ()
564
- set (LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} -fsycl OpenCL mkl_core pthread m dl mkl_sycl_blas mkl_intel_ilp64 mkl_tbb_thread )
572
+ if (LLAMA_SYCL_BACKEND STREQUAL "INTEL" )
573
+ set (LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} -fsycl OpenCL mkl_core pthread m dl mkl_sycl_blas mkl_intel_ilp64 mkl_tbb_thread )
574
+ elseif (LLAMA_SYCL_TARGET STREQUAL "NVIDIA" )
575
+ set (LLAMA_EXTRA_LIBS ${LLAMA_EXTRA_LIBS} -fsycl pthread m dl onemkl )
576
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl-targets=nvptx64-nvidia-cuda" )
577
+ endif ()
565
578
endif ()
566
579
endif ()
567
580
0 commit comments