@@ -70,12 +70,14 @@ if (APPLE)
70
70
option (WHISPER_COREML_ALLOW_FALLBACK "whisper: allow non-CoreML fallback" OFF )
71
71
option (WHISPER_METAL_EMBED_LIBRARY "whisper: embed Metal library" OFF )
72
72
else ()
73
- option (WHISPER_BLAS "whisper: use BLAS libraries" OFF )
74
- option (WHISPER_BLAS_VENDOR "whisper: BLAS library vendor" Generic)
75
- option (WHISPER_OPENBLAS "whisper: prefer OpenBLAS" OFF )
76
- option (WHISPER_CUBLAS "whisper: support for cuBLAS" OFF )
77
- option (WHISPER_HIPBLAS "whisper: support for hipBLAS" OFF )
78
- option (WHISPER_CLBLAST "whisper: use CLBlast" OFF )
73
+ option (WHISPER_BLAS "whisper: use BLAS libraries" OFF )
74
+ option (WHISPER_BLAS_VENDOR "whisper: BLAS library vendor" Generic)
75
+ option (WHISPER_OPENBLAS "whisper: prefer OpenBLAS" OFF )
76
+ option (WHISPER_CUBLAS "whisper: support for cuBLAS" OFF )
77
+ option (WHISPER_HIPBLAS "whisper: support for hipBLAS" OFF )
78
+ option (WHISPER_CLBLAST "whisper: use CLBlast" OFF )
79
+ option (WHISPER_SYCL "whisper: use SYCL" OFF )
80
+ option (WHISPER_SYCL_F16 "whisper: use 16 bit floats for sycl calculations" OFF )
79
81
endif ()
80
82
81
83
option (WHISPER_PERF "whisper: enable perf timings" OFF )
@@ -106,6 +108,13 @@ endif()
106
108
107
109
find_package (Threads REQUIRED)
108
110
111
+ #compile flag sycl
112
+ if (WHISPER_SYCL)
113
+ set (CMAKE_CXX_STANDARD 17)
114
+ else ()
115
+ set (CMAKE_CXX_STANDARD 11)
116
+ endif ()
117
+
109
118
# on APPLE
110
119
if (APPLE )
111
120
# include Accelerate framework
@@ -309,6 +318,30 @@ if( WHISPER_OPENVINO )
309
318
find_package (OpenVINO REQUIRED COMPONENTS Runtime)
310
319
endif ()
311
320
321
+ if (WHISPER_SYCL)
322
+ if ( NOT DEFINED ENV{ONEAPI_ROOT})
323
+ message (FATAL_ERROR "Not detect ENV {ONEAPI_ROOT}, please install oneAPI & source it, like: source /opt/intel/oneapi/setvars.sh" )
324
+ endif ()
325
+ #todo: AOT
326
+
327
+ find_package (IntelSYCL REQUIRED)
328
+ if (WHISPER_SYCL_F16)
329
+ add_compile_definitions (GGML_SYCL_F16)
330
+ endif ()
331
+ add_compile_definitions (GGML_USE_SYCL)
332
+
333
+ add_compile_options (-I./) #include DPCT
334
+ add_compile_options (-I/${SYCL_INCLUDE_DIR} )
335
+
336
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing" )
337
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3" )
338
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl -L${MKLROOT} /lib" )
339
+
340
+ set (GGML_HEADERS_SYCL ggml-sycl.h)
341
+ set (GGML_SOURCES_SYCL ggml-sycl.cpp)
342
+
343
+ set (WHISPER_EXTRA_LIBS ${WHISPER_EXTRA_LIBS} sycl OpenCL mkl_core pthread m dl mkl_sycl_blas mkl_intel_ilp64 mkl_tbb_thread)
344
+ endif ()
312
345
# compiler flags
313
346
314
347
if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES )
@@ -503,6 +536,8 @@ add_library(${TARGET}
503
536
${GGML_SOURCES_METAL}
504
537
${GGML_SOURCES_CUDA}
505
538
${GGML_SOURCES_OPENCL}
539
+ ${GGML_SOURCES_SYCL}
540
+ ${GGML_HEADERS_SYCL}
506
541
whisper.h
507
542
whisper.cpp
508
543
)
0 commit comments