Spaces:
Sleeping
Sleeping
Alberto Cabrera Pérez
commited on
Commit
·
7d7ac98
1
Parent(s):
7d66a68
Initial cmake support of SYCL for AMD GPUs (llama/9658)
Browse files- ggml/src/CMakeLists.txt +17 -2
ggml/src/CMakeLists.txt
CHANGED
|
@@ -511,8 +511,8 @@ if (GGML_HIPBLAS)
|
|
| 511 |
endif()
|
| 512 |
|
| 513 |
if (GGML_SYCL)
|
| 514 |
-
if (NOT GGML_SYCL_TARGET MATCHES "^(INTEL|NVIDIA)$")
|
| 515 |
-
message(FATAL_ERROR "Invalid backend chosen, supported options are INTEL or
|
| 516 |
endif()
|
| 517 |
|
| 518 |
check_cxx_compiler_flag("-fsycl" SUPPORTS_SYCL)
|
|
@@ -532,6 +532,9 @@ if (GGML_SYCL)
|
|
| 532 |
list(APPEND GGML_CDEF_PUBLIC GGML_USE_SYCL)
|
| 533 |
|
| 534 |
if (GGML_SYCL_F16)
|
|
|
|
|
|
|
|
|
|
| 535 |
add_compile_definitions(GGML_SYCL_F16)
|
| 536 |
endif()
|
| 537 |
|
|
@@ -543,6 +546,12 @@ if (GGML_SYCL)
|
|
| 543 |
|
| 544 |
if (GGML_SYCL_TARGET STREQUAL "NVIDIA")
|
| 545 |
add_compile_definitions(GGML_SYCL_WARP_SIZE=32)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 546 |
else()
|
| 547 |
add_compile_definitions(GGML_SYCL_WARP_SIZE=16)
|
| 548 |
endif()
|
|
@@ -576,6 +585,12 @@ if (GGML_SYCL)
|
|
| 576 |
elseif (GGML_SYCL_TARGET STREQUAL "NVIDIA")
|
| 577 |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl-targets=nvptx64-nvidia-cuda")
|
| 578 |
list(APPEND GGML_EXTRA_LIBS_PRIVATE sycl pthread m dl onemkl)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 579 |
endif()
|
| 580 |
endif()
|
| 581 |
endif()
|
|
|
|
| 511 |
endif()
|
| 512 |
|
| 513 |
if (GGML_SYCL)
|
| 514 |
+
if (NOT GGML_SYCL_TARGET MATCHES "^(INTEL|NVIDIA|AMD)$")
|
| 515 |
+
message(FATAL_ERROR "Invalid backend chosen, supported options are INTEL, NVIDIA, or AMD")
|
| 516 |
endif()
|
| 517 |
|
| 518 |
check_cxx_compiler_flag("-fsycl" SUPPORTS_SYCL)
|
|
|
|
| 532 |
list(APPEND GGML_CDEF_PUBLIC GGML_USE_SYCL)
|
| 533 |
|
| 534 |
if (GGML_SYCL_F16)
|
| 535 |
+
if (GGML_SYCL_TARGET STREQUAL "AMD")
|
| 536 |
+
message(WARNING "AMD target does not entirely support FP16 in the SYCL backend.")
|
| 537 |
+
endif()
|
| 538 |
add_compile_definitions(GGML_SYCL_F16)
|
| 539 |
endif()
|
| 540 |
|
|
|
|
| 546 |
|
| 547 |
if (GGML_SYCL_TARGET STREQUAL "NVIDIA")
|
| 548 |
add_compile_definitions(GGML_SYCL_WARP_SIZE=32)
|
| 549 |
+
elseif (GGML_SYCL_TARGET STREQUAL "AMD")
|
| 550 |
+
# INFO: Allowed Sub_group_sizes are not consistent through all
|
| 551 |
+
# hip targets. For example, 64 is used for certain models, but the backend
|
| 552 |
+
# does not support it.
|
| 553 |
+
# Target archs tested working: gfx1030, gfx1031, (Only tested sub_group_size = 32)
|
| 554 |
+
add_compile_definitions(GGML_SYCL_WARP_SIZE=32)
|
| 555 |
else()
|
| 556 |
add_compile_definitions(GGML_SYCL_WARP_SIZE=16)
|
| 557 |
endif()
|
|
|
|
| 585 |
elseif (GGML_SYCL_TARGET STREQUAL "NVIDIA")
|
| 586 |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl-targets=nvptx64-nvidia-cuda")
|
| 587 |
list(APPEND GGML_EXTRA_LIBS_PRIVATE sycl pthread m dl onemkl)
|
| 588 |
+
elseif (GGML_SYCL_TARGET STREQUAL "AMD")
|
| 589 |
+
if (GGML_SYCL_HIP_TARGET STREQUAL "")
|
| 590 |
+
message(ERROR "Can't enable SYCL hip backend, GGML_SYCL_HIP_TARGET has not been set.")
|
| 591 |
+
endif()
|
| 592 |
+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsycl-targets=amdgcn-amd-amdhsa -Xsycl-target-backend --offload-arch=${GGML_SYCL_HIP_TARGET}")
|
| 593 |
+
list(APPEND GGML_EXTRA_LIBS_PRIVATE sycl pthread m dl onemkl)
|
| 594 |
endif()
|
| 595 |
endif()
|
| 596 |
endif()
|