Skip to content

Commit 9168265

Browse files
author
Aidan
committed
Add support for nvidia target in CMake
1 parent 67fd331 commit 9168265

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

CMakeLists.txt

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ option(LLAMA_MPI "llama: use MPI"
116116
option(LLAMA_QKK_64 "llama: use super-block size of 64 for k-quants" OFF)
117117
option(LLAMA_SYCL "llama: use SYCL" OFF)
118118
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")
119120
option(LLAMA_CPU_HBM "llama: use memkind for CPU HBM" OFF)
120121

121122
option(LLAMA_BUILD_TESTS "llama: build tests" ${LLAMA_STANDALONE})
@@ -533,6 +534,10 @@ if (LLAMA_HIPBLAS)
533534
endif()
534535

535536
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+
536541
if ( NOT DEFINED ENV{ONEAPI_ROOT})
537542
message(FATAL_ERROR "Not detect ENV {ONEAPI_ROOT}, please install oneAPI & source it, like: source /opt/intel/oneapi/setvars.sh")
538543
endif()
@@ -554,14 +559,22 @@ if (LLAMA_SYCL)
554559
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing")
555560
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
556561
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()
557565

558566
set(GGML_HEADERS_SYCL ggml-sycl.h)
559567
set(GGML_SOURCES_SYCL ggml-sycl.cpp)
560568

561569
if (WIN32)
562570
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)
563571
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()
565578
endif()
566579
endif()
567580

0 commit comments

Comments
 (0)