remove sycl part from common backend

This commit is contained in:
Meng, Hengyu 2024-03-24 02:43:01 +00:00
parent 0c2aa1a249
commit 5f8a87d752
3 changed files with 4 additions and 9 deletions

View file

@ -12921,7 +12921,7 @@ int get_work_group_size(int user_device_id) {
return prop.get_max_work_group_size(); return prop.get_max_work_group_size();
} }
void ggml_init_sycl() try { static void ggml_init_sycl() try {
static bool initialized = false; static bool initialized = false;
if (!initialized) { if (!initialized) {
@ -16417,6 +16417,7 @@ static ggml_backend_buffer_type_i ggml_backend_sycl_buffer_type_interface = {
}; };
ggml_backend_buffer_type_t ggml_backend_sycl_buffer_type(int device_index) { ggml_backend_buffer_type_t ggml_backend_sycl_buffer_type(int device_index) {
ggml_init_sycl();
if (device_index>=g_device_count or device_index<0) { if (device_index>=g_device_count or device_index<0) {
printf("ggml_backend_sycl_buffer_type error: device_index:%d is out of range [0, %d], miss to call ggml_backend_sycl_set_single_device()\n", printf("ggml_backend_sycl_buffer_type error: device_index:%d is out of range [0, %d], miss to call ggml_backend_sycl_set_single_device()\n",
device_index, g_device_count-1); device_index, g_device_count-1);
@ -16786,6 +16787,7 @@ static ggml_backend_buffer_type_i ggml_backend_sycl_split_buffer_type_interface
}; };
GGML_CALL ggml_backend_buffer_type_t ggml_backend_sycl_split_buffer_type(const float * tensor_split) { GGML_CALL ggml_backend_buffer_type_t ggml_backend_sycl_split_buffer_type(const float * tensor_split) {
ggml_init_sycl();
// FIXME: this is not thread safe // FIXME: this is not thread safe
static std::map<std::array<float, GGML_SYCL_MAX_DEVICES>, struct ggml_backend_buffer_type> buft_map; static std::map<std::array<float, GGML_SYCL_MAX_DEVICES>, struct ggml_backend_buffer_type> buft_map;
@ -17153,7 +17155,7 @@ static ggml_guid_t ggml_backend_sycl_guid() {
} }
GGML_CALL ggml_backend_t ggml_backend_sycl_init(int device) { GGML_CALL ggml_backend_t ggml_backend_sycl_init(int device) {
ggml_init_sycl(); // TODO: remove from ggml.c ggml_init_sycl();
check_allow_gpu_index(device); check_allow_gpu_index(device);

View file

@ -16,9 +16,6 @@ extern "C" {
#define GGML_SYCL_MAX_DEVICES 48 #define GGML_SYCL_MAX_DEVICES 48
#define GGML_SYCL_NAME "SYCL" #define GGML_SYCL_NAME "SYCL"
GGML_API void ggml_init_sycl(void);
GGML_API bool ggml_sycl_compute_forward(struct ggml_compute_params * params, struct ggml_tensor * tensor);
// backend API // backend API
GGML_API ggml_backend_t ggml_backend_sycl_init(int device); GGML_API ggml_backend_t ggml_backend_sycl_init(int device);

4
ggml.c
View file

@ -286,8 +286,6 @@ inline static void * ggml_calloc(size_t num, size_t size) {
#include "ggml-opencl.h" #include "ggml-opencl.h"
#elif defined(GGML_USE_VULKAN) #elif defined(GGML_USE_VULKAN)
#include "ggml-vulkan.h" #include "ggml-vulkan.h"
#elif defined(GGML_USE_SYCL)
#include "ggml-sycl.h"
#endif #endif
// floating point type used to accumulate sums // floating point type used to accumulate sums
@ -2642,8 +2640,6 @@ struct ggml_context * ggml_init(struct ggml_init_params params) {
ggml_cl_init(); ggml_cl_init();
#elif defined(GGML_USE_VULKAN) #elif defined(GGML_USE_VULKAN)
ggml_vk_init_cpu_assist(); ggml_vk_init_cpu_assist();
#elif defined(GGML_USE_SYCL)
ggml_init_sycl();
#endif #endif
ggml_setup_op_has_task_pass(); ggml_setup_op_has_task_pass();