Joe Todd commited on
Commit
2a5814c
·
1 Parent(s): 899145d

sycl : Add support for non-release DPC++ & oneMKL (llama/8644)

Browse files

* Update cmake to support nvidia hardware & open-source compiler
---------
Signed-off-by: Joe Todd <joe.todd@codeplay.com>

Files changed (1) hide show
  1. ggml/src/CMakeLists.txt +16 -15
ggml/src/CMakeLists.txt CHANGED
@@ -467,15 +467,18 @@ if (GGML_SYCL)
467
  message(FATAL_ERROR "Invalid backend chosen, supported options are INTEL or NVIDIA")
468
  endif()
469
 
470
- if ( NOT DEFINED ENV{ONEAPI_ROOT})
471
- message(FATAL_ERROR "Not detect ENV {ONEAPI_ROOT}, please install oneAPI & source it, like: source /opt/intel/oneapi/setvars.sh")
 
 
 
 
 
 
 
472
  endif()
473
- #todo: AOT
474
-
475
- find_package(IntelSYCL REQUIRED)
476
- find_package(MKL REQUIRED)
477
-
478
  message(STATUS "SYCL found")
 
479
 
480
  list(APPEND GGML_CDEF_PUBLIC GGML_USE_SYCL)
481
 
@@ -487,11 +490,9 @@ if (GGML_SYCL)
487
  add_compile_definitions(GGML_SYCL_FORCE_MMQ)
488
  endif()
489
 
490
- add_compile_options(-I./) #include DPCT
491
 
492
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing")
493
  if (GGML_SYCL_TARGET STREQUAL "NVIDIA")
494
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl-targets=nvptx64-nvidia-cuda")
495
  add_compile_definitions(GGML_SYCL_WARP_SIZE=32)
496
  else()
497
  add_compile_definitions(GGML_SYCL_WARP_SIZE=16)
@@ -504,15 +505,15 @@ if (GGML_SYCL)
504
  list(APPEND GGML_SOURCES_SYCL "ggml-sycl.cpp")
505
 
506
  if (WIN32)
 
 
507
  set(GGML_EXTRA_LIBS ${GGML_EXTRA_LIBS} IntelSYCL::SYCL_CXX MKL::MKL MKL::MKL_SYCL)
508
  else()
509
- add_compile_options(-I/${SYCL_INCLUDE_DIR})
510
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl -L${MKLROOT}/lib")
511
-
512
  if (GGML_SYCL_TARGET STREQUAL "INTEL")
513
- set(GGML_EXTRA_LIBS ${GGML_EXTRA_LIBS} -fsycl OpenCL mkl_core pthread m dl mkl_sycl_blas mkl_intel_ilp64 mkl_tbb_thread)
514
  elseif (GGML_SYCL_TARGET STREQUAL "NVIDIA")
515
- set(GGML_EXTRA_LIBS ${GGML_EXTRA_LIBS} -fsycl pthread m dl onemkl)
 
516
  endif()
517
  endif()
518
  endif()
 
467
  message(FATAL_ERROR "Invalid backend chosen, supported options are INTEL or NVIDIA")
468
  endif()
469
 
470
+ check_cxx_compiler_flag("-fsycl" SUPPORTS_SYCL)
471
+ if ( DEFINED ENV{ONEAPI_ROOT})
472
+ message(STATUS "Using oneAPI Release SYCL compiler (icpx).")
473
+ elseif(SUPPORTS_SYCL)
474
+ message(WARNING "Using open-source SYCL compiler (clang++). Didn't detect ENV {ONEAPI_ROOT}.
475
+ If you expected the oneAPI Release compiler, please install oneAPI & source it, like:
476
+ source /opt/intel/oneapi/setvars.sh")
477
+ else()
478
+ message(FATAL_ERROR, "C++ compiler lacks SYCL support.")
479
  endif()
 
 
 
 
 
480
  message(STATUS "SYCL found")
481
+ #todo: AOT
482
 
483
  list(APPEND GGML_CDEF_PUBLIC GGML_USE_SYCL)
484
 
 
490
  add_compile_definitions(GGML_SYCL_FORCE_MMQ)
491
  endif()
492
 
493
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing -fsycl")
494
 
 
495
  if (GGML_SYCL_TARGET STREQUAL "NVIDIA")
 
496
  add_compile_definitions(GGML_SYCL_WARP_SIZE=32)
497
  else()
498
  add_compile_definitions(GGML_SYCL_WARP_SIZE=16)
 
505
  list(APPEND GGML_SOURCES_SYCL "ggml-sycl.cpp")
506
 
507
  if (WIN32)
508
+ find_package(IntelSYCL REQUIRED)
509
+ find_package(MKL REQUIRED)
510
  set(GGML_EXTRA_LIBS ${GGML_EXTRA_LIBS} IntelSYCL::SYCL_CXX MKL::MKL MKL::MKL_SYCL)
511
  else()
 
 
 
512
  if (GGML_SYCL_TARGET STREQUAL "INTEL")
513
+ set(GGML_EXTRA_LIBS ${GGML_EXTRA_LIBS} OpenCL mkl_core pthread m dl mkl_sycl_blas mkl_intel_ilp64 mkl_tbb_thread)
514
  elseif (GGML_SYCL_TARGET STREQUAL "NVIDIA")
515
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl-targets=nvptx64-nvidia-cuda")
516
+ set(GGML_EXTRA_LIBS ${GGML_EXTRA_LIBS} pthread m dl onemkl)
517
  endif()
518
  endif()
519
  endif()