Romain Biessy commited on
Commit
0d836df
·
1 Parent(s): 5cb851d

sycl : Add option to set the SYCL architecture for all targets (llama/10266)

Browse files

* Add option to set the SYCL architecture for all targets
* Convert GGML_SYCL_HIP_TARGET to the more generic GGML_SYCL_ARCH option
* Document that setting GGML_SYCL_ARCH can improve the performance

ggml/CMakeLists.txt CHANGED
@@ -164,6 +164,8 @@ option(GGML_SYCL "ggml: use SYCL"
164
  option(GGML_SYCL_F16 "ggml: use 16 bit floats for sycl calculations" OFF)
165
  set (GGML_SYCL_TARGET "INTEL" CACHE STRING
166
  "ggml: sycl target device")
 
 
167
 
168
  # extra artifacts
169
  option(GGML_BUILD_TESTS "ggml: build tests" ${GGML_STANDALONE})
 
164
  option(GGML_SYCL_F16 "ggml: use 16 bit floats for sycl calculations" OFF)
165
  set (GGML_SYCL_TARGET "INTEL" CACHE STRING
166
  "ggml: sycl target device")
167
+ set (GGML_SYCL_DEVICE_ARCH "" CACHE STRING
168
+ "ggml: sycl device architecture")
169
 
170
  # extra artifacts
171
  option(GGML_BUILD_TESTS "ggml: build tests" ${GGML_STANDALONE})
ggml/src/ggml-sycl/CMakeLists.txt CHANGED
@@ -72,10 +72,14 @@ else()
72
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl-targets=nvptx64-nvidia-cuda")
73
  target_link_libraries(ggml-sycl PRIVATE sycl pthread m dl onemkl)
74
  elseif (GGML_SYCL_TARGET STREQUAL "AMD")
75
- if (GGML_SYCL_HIP_TARGET STREQUAL "")
76
- message(ERROR "Can't enable SYCL hip backend, GGML_SYCL_HIP_TARGET has not been set.")
77
  endif()
78
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=${GGML_SYCL_HIP_TARGET}")
79
  target_link_libraries(ggml-sycl PRIVATE sycl pthread m dl onemkl)
80
  endif()
 
 
 
 
81
  endif()
 
72
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl-targets=nvptx64-nvidia-cuda")
73
  target_link_libraries(ggml-sycl PRIVATE sycl pthread m dl onemkl)
74
  elseif (GGML_SYCL_TARGET STREQUAL "AMD")
75
+ if (NOT GGML_SYCL_DEVICE_ARCH)
76
+ message(ERROR "Can't enable SYCL hip backend, GGML_SYCL_DEVICE_ARCH has not been set.")
77
  endif()
78
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl-targets=amdgcn-amd-amdhsa")
79
  target_link_libraries(ggml-sycl PRIVATE sycl pthread m dl onemkl)
80
  endif()
81
+
82
+ if (GGML_SYCL_DEVICE_ARCH)
83
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xsycl-target-backend --offload-arch=${GGML_SYCL_DEVICE_ARCH}")
84
+ endif()
85
  endif()