endif()
if (GGML_SYCL)
- if (NOT GGML_SYCL_TARGET MATCHES "^(INTEL|NVIDIA)$")
- message(FATAL_ERROR "Invalid backend chosen, supported options are INTEL or NVIDIA")
+ if (NOT GGML_SYCL_TARGET MATCHES "^(INTEL|NVIDIA|AMD)$")
+ message(FATAL_ERROR "Invalid backend chosen, supported options are INTEL, NVIDIA, or AMD")
endif()
check_cxx_compiler_flag("-fsycl" SUPPORTS_SYCL)
list(APPEND GGML_CDEF_PUBLIC GGML_USE_SYCL)
if (GGML_SYCL_F16)
+ if (GGML_SYCL_TARGET STREQUAL "AMD")
+ message(WARNING "AMD target does not entirely support FP16 in the SYCL backend.")
+ endif()
add_compile_definitions(GGML_SYCL_F16)
endif()
if (GGML_SYCL_TARGET STREQUAL "NVIDIA")
add_compile_definitions(GGML_SYCL_WARP_SIZE=32)
+ elseif (GGML_SYCL_TARGET STREQUAL "AMD")
+ # INFO: Allowed Sub_group_sizes are not consistent through all
+ # hip targets. For example, 64 is used for certain models, but the backend
+ # does not support it.
+ # Target archs tested working: gfx1030, gfx1031, (Only tested sub_group_size = 32)
+ add_compile_definitions(GGML_SYCL_WARP_SIZE=32)
else()
add_compile_definitions(GGML_SYCL_WARP_SIZE=16)
endif()
elseif (GGML_SYCL_TARGET STREQUAL "NVIDIA")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl-targets=nvptx64-nvidia-cuda")
list(APPEND GGML_EXTRA_LIBS_PRIVATE sycl pthread m dl onemkl)
+ elseif (GGML_SYCL_TARGET STREQUAL "AMD")
+ if (GGML_SYCL_HIP_TARGET STREQUAL "")
+ message(ERROR "Can't enable SYCL hip backend, GGML_SYCL_HIP_TARGET has not been set.")
+ endif()
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=${GGML_SYCL_HIP_TARGET}")
+ list(APPEND GGML_EXTRA_LIBS_PRIVATE sycl pthread m dl onemkl)
endif()
endif()
endif()