From 34f2fc15ea2c3ef921780d6017318e26577ea4df Mon Sep 17 00:00:00 2001 From: Li He Date: Tue, 10 Dec 2024 22:17:24 -0800 Subject: [PATCH] opencl: rename backend `opencl2` -> `opencl` --- ggml/include/{ggml-opencl2.h => ggml-opencl.h} | 0 ggml/src/CMakeLists.txt | 9 +-------- ggml/src/ggml-backend-reg.cpp | 7 ++++--- .../{ggml-opencl2 => ggml-opencl}/CMakeLists.txt | 13 +++---------- .../ggml-opencl.cpp} | 2 +- .../kernels/embed_kernel.py | 0 .../kernels/ggml-opencl2.cl | 0 .../kernels/ggml-opencl2_cvt.cl | 0 .../kernels/ggml-opencl2_gemv_noshuffle.cl | 0 .../kernels/ggml-opencl2_gemv_noshuffle_general.cl | 0 .../kernels/ggml-opencl2_mm.cl | 0 .../kernels/ggml-opencl2_mul_mat_Ab_Bi_8x4.cl | 0 .../kernels/ggml-opencl2_transpose_16.cl | 0 .../kernels/ggml-opencl2_transpose_32.cl | 0 .../kernels/ggml-opencl2_transpose_32_16.cl | 0 15 files changed, 9 insertions(+), 22 deletions(-) rename ggml/include/{ggml-opencl2.h => ggml-opencl.h} (100%) rename ggml/src/{ggml-opencl2 => ggml-opencl}/CMakeLists.txt (92%) rename ggml/src/{ggml-opencl2/ggml-opencl2.cpp => ggml-opencl/ggml-opencl.cpp} (99%) rename ggml/src/{ggml-opencl2 => ggml-opencl}/kernels/embed_kernel.py (100%) rename ggml/src/{ggml-opencl2 => ggml-opencl}/kernels/ggml-opencl2.cl (100%) rename ggml/src/{ggml-opencl2 => ggml-opencl}/kernels/ggml-opencl2_cvt.cl (100%) rename ggml/src/{ggml-opencl2 => ggml-opencl}/kernels/ggml-opencl2_gemv_noshuffle.cl (100%) rename ggml/src/{ggml-opencl2 => ggml-opencl}/kernels/ggml-opencl2_gemv_noshuffle_general.cl (100%) rename ggml/src/{ggml-opencl2 => ggml-opencl}/kernels/ggml-opencl2_mm.cl (100%) rename ggml/src/{ggml-opencl2 => ggml-opencl}/kernels/ggml-opencl2_mul_mat_Ab_Bi_8x4.cl (100%) rename ggml/src/{ggml-opencl2 => ggml-opencl}/kernels/ggml-opencl2_transpose_16.cl (100%) rename ggml/src/{ggml-opencl2 => ggml-opencl}/kernels/ggml-opencl2_transpose_32.cl (100%) rename ggml/src/{ggml-opencl2 => ggml-opencl}/kernels/ggml-opencl2_transpose_32_16.cl (100%) diff --git a/ggml/include/ggml-opencl2.h b/ggml/include/ggml-opencl.h similarity index 100% rename from ggml/include/ggml-opencl2.h rename to ggml/include/ggml-opencl.h diff --git a/ggml/src/CMakeLists.txt b/ggml/src/CMakeLists.txt index c8744341b..bf5ee5fc2 100644 --- a/ggml/src/CMakeLists.txt +++ b/ggml/src/CMakeLists.txt @@ -298,13 +298,6 @@ else () ggml_add_cpu_backend_variant_impl("") endif() -if (GGML_OPENCL) - set(GGML_OPENCL2 ON) - add_compile_definitions(GGML_USE_OPENCL) -else () - set(GGML_OPENCL2 OFF) -endif () - ggml_add_backend(BLAS) ggml_add_backend(CANN) ggml_add_backend(CUDA) @@ -315,7 +308,7 @@ ggml_add_backend(MUSA) ggml_add_backend(RPC) ggml_add_backend(SYCL) ggml_add_backend(Vulkan) -ggml_add_backend(OpenCL2) +ggml_add_backend(OpenCL) foreach (target ggml-base ggml) target_include_directories(${target} PUBLIC $ $) diff --git a/ggml/src/ggml-backend-reg.cpp b/ggml/src/ggml-backend-reg.cpp index d4281b2d8..93fa07e61 100644 --- a/ggml/src/ggml-backend-reg.cpp +++ b/ggml/src/ggml-backend-reg.cpp @@ -46,8 +46,8 @@ #include "ggml-vulkan.h" #endif -#ifdef GGML_USE_OPENCL2 -#include "ggml-opencl2.h" +#ifdef GGML_USE_OPENCL +#include "ggml-opencl.h" #endif #ifdef GGML_USE_BLAS @@ -150,7 +150,7 @@ struct ggml_backend_registry { #ifdef GGML_USE_VULKAN register_backend(ggml_backend_vk_reg()); #endif -#ifdef GGML_USE_OPENCL2 +#ifdef GGML_USE_OPENCL register_backend(ggml_backend_opencl2_reg()); #endif #ifdef GGML_USE_CANN @@ -546,6 +546,7 @@ void ggml_backend_load_all_from_path(const char * dir_path) { ggml_backend_load_best("rpc", silent, dir_path); ggml_backend_load_best("sycl", silent, dir_path); ggml_backend_load_best("vulkan", silent, dir_path); + ggml_backend_load_best("opencl", silent, dir_path); ggml_backend_load_best("musa", silent, dir_path); ggml_backend_load_best("cpu", silent, dir_path); } diff --git a/ggml/src/ggml-opencl2/CMakeLists.txt b/ggml/src/ggml-opencl/CMakeLists.txt similarity index 92% rename from ggml/src/ggml-opencl2/CMakeLists.txt rename to ggml/src/ggml-opencl/CMakeLists.txt index 6965cf026..dd61b396a 100644 --- a/ggml/src/ggml-opencl2/CMakeLists.txt +++ b/ggml/src/ggml-opencl/CMakeLists.txt @@ -4,21 +4,14 @@ find_package(OpenCL) if (OpenCL_FOUND) find_package(Python3 REQUIRED) - set(TARGET_NAME ggml-opencl2) + set(TARGET_NAME ggml-opencl) ggml_add_backend_library(${TARGET_NAME} - ggml-opencl2.cpp - ../../include/ggml-opencl2.h) + ggml-opencl.cpp + ../../include/ggml-opencl.h) target_link_libraries(${TARGET_NAME} PRIVATE ggml-base ${OpenCL_LIBRARIES}) target_include_directories(${TARGET_NAME} PRIVATE . .. ${OpenCL_INCLUDE_DIRS}) - # TODO - this is kind of strange. We have been calling this backend OpenCL2, - # so everything (function names, folder name, etc) except macro switches - # has been OpenCL2. Now, the backend frameworke enforces the use of the folder - # name as the backend name and switch. So, GGML_USE_OPENCL2 is used in - # ggml-backend-reg.cpp, but the rest still uses GGML_USE_OPENCL. - add_compile_definitions(GGML_USE_OPENCL) - if (GGML_OPENCL_PROFILING) message(STATUS "OpenCL profiling enabled (increases CPU overhead)") add_compile_definitions(GGML_OPENCL_PROFILING) diff --git a/ggml/src/ggml-opencl2/ggml-opencl2.cpp b/ggml/src/ggml-opencl/ggml-opencl.cpp similarity index 99% rename from ggml/src/ggml-opencl2/ggml-opencl2.cpp rename to ggml/src/ggml-opencl/ggml-opencl.cpp index 519f4cce1..a671a18b8 100644 --- a/ggml/src/ggml-opencl2/ggml-opencl2.cpp +++ b/ggml/src/ggml-opencl/ggml-opencl.cpp @@ -7,7 +7,7 @@ #pragma GCC diagnostic ignored "-Wgnu-anonymous-struct" #pragma GCC diagnostic ignored "-Woverlength-strings" -#include "ggml-opencl2.h" +#include "ggml-opencl.h" #include "ggml-backend.h" #include "ggml-impl.h" #include "ggml-backend-impl.h" diff --git a/ggml/src/ggml-opencl2/kernels/embed_kernel.py b/ggml/src/ggml-opencl/kernels/embed_kernel.py similarity index 100% rename from ggml/src/ggml-opencl2/kernels/embed_kernel.py rename to ggml/src/ggml-opencl/kernels/embed_kernel.py diff --git a/ggml/src/ggml-opencl2/kernels/ggml-opencl2.cl b/ggml/src/ggml-opencl/kernels/ggml-opencl2.cl similarity index 100% rename from ggml/src/ggml-opencl2/kernels/ggml-opencl2.cl rename to ggml/src/ggml-opencl/kernels/ggml-opencl2.cl diff --git a/ggml/src/ggml-opencl2/kernels/ggml-opencl2_cvt.cl b/ggml/src/ggml-opencl/kernels/ggml-opencl2_cvt.cl similarity index 100% rename from ggml/src/ggml-opencl2/kernels/ggml-opencl2_cvt.cl rename to ggml/src/ggml-opencl/kernels/ggml-opencl2_cvt.cl diff --git a/ggml/src/ggml-opencl2/kernels/ggml-opencl2_gemv_noshuffle.cl b/ggml/src/ggml-opencl/kernels/ggml-opencl2_gemv_noshuffle.cl similarity index 100% rename from ggml/src/ggml-opencl2/kernels/ggml-opencl2_gemv_noshuffle.cl rename to ggml/src/ggml-opencl/kernels/ggml-opencl2_gemv_noshuffle.cl diff --git a/ggml/src/ggml-opencl2/kernels/ggml-opencl2_gemv_noshuffle_general.cl b/ggml/src/ggml-opencl/kernels/ggml-opencl2_gemv_noshuffle_general.cl similarity index 100% rename from ggml/src/ggml-opencl2/kernels/ggml-opencl2_gemv_noshuffle_general.cl rename to ggml/src/ggml-opencl/kernels/ggml-opencl2_gemv_noshuffle_general.cl diff --git a/ggml/src/ggml-opencl2/kernels/ggml-opencl2_mm.cl b/ggml/src/ggml-opencl/kernels/ggml-opencl2_mm.cl similarity index 100% rename from ggml/src/ggml-opencl2/kernels/ggml-opencl2_mm.cl rename to ggml/src/ggml-opencl/kernels/ggml-opencl2_mm.cl diff --git a/ggml/src/ggml-opencl2/kernels/ggml-opencl2_mul_mat_Ab_Bi_8x4.cl b/ggml/src/ggml-opencl/kernels/ggml-opencl2_mul_mat_Ab_Bi_8x4.cl similarity index 100% rename from ggml/src/ggml-opencl2/kernels/ggml-opencl2_mul_mat_Ab_Bi_8x4.cl rename to ggml/src/ggml-opencl/kernels/ggml-opencl2_mul_mat_Ab_Bi_8x4.cl diff --git a/ggml/src/ggml-opencl2/kernels/ggml-opencl2_transpose_16.cl b/ggml/src/ggml-opencl/kernels/ggml-opencl2_transpose_16.cl similarity index 100% rename from ggml/src/ggml-opencl2/kernels/ggml-opencl2_transpose_16.cl rename to ggml/src/ggml-opencl/kernels/ggml-opencl2_transpose_16.cl diff --git a/ggml/src/ggml-opencl2/kernels/ggml-opencl2_transpose_32.cl b/ggml/src/ggml-opencl/kernels/ggml-opencl2_transpose_32.cl similarity index 100% rename from ggml/src/ggml-opencl2/kernels/ggml-opencl2_transpose_32.cl rename to ggml/src/ggml-opencl/kernels/ggml-opencl2_transpose_32.cl diff --git a/ggml/src/ggml-opencl2/kernels/ggml-opencl2_transpose_32_16.cl b/ggml/src/ggml-opencl/kernels/ggml-opencl2_transpose_32_16.cl similarity index 100% rename from ggml/src/ggml-opencl2/kernels/ggml-opencl2_transpose_32_16.cl rename to ggml/src/ggml-opencl/kernels/ggml-opencl2_transpose_32_16.cl