@@ -79,7 +79,6 @@ static int g_work_group_size = 0;
7979#endif
8080
8181typedef sycl::queue *queue_ptr;
82- typedef sycl::handler *handle_ptr;
8382
8483enum ggml_sycl_backend_gpu_mode {
8584 SYCL_UNSET_GPU_MODE = -1 ,
@@ -313,13 +312,12 @@ class sycl_gpu_mgr {
313312};
314313
315314static sycl_gpu_mgr* g_sycl_gpu_mgr = new sycl_gpu_mgr(0 );
316- static int g_device_count = -1 ;
317315static int g_all_sycl_device_count = -1 ;
318316static int g_main_device = -1 ;
319317static int g_main_device_id = -1 ;
320318static bool g_ggml_backend_sycl_buffer_type_initialized = false ;
321319
322- static std::array<float , SYCL_MAX_DEVICES > g_default_tensor_split = {};
320+ static std::array<float , GGML_SYCL_MAX_DEVICES > g_default_tensor_split = {};
323321
324322static float g_tensor_split[GGML_SYCL_MAX_DEVICES] = {0 };
325323
@@ -341,25 +339,6 @@ int get_main_device();
341339 (void )bad_arch; // suppress unused function warning
342340}
343341
344- /*
345- device_index: device index from 0 to n (continue numbers).
346- It is used for device select/set in SYCL backend internal data structure.
347- */
348- inline void check_allow_gpu_index (const int device_index) {
349- if (device_index >= g_device_count) {
350- char error_buf[256 ];
351- snprintf (
352- error_buf,
353- sizeof (error_buf),
354- " %s error: device_index:%d is out of range: [0-%d]" ,
355- __func__,
356- device_index,
357- g_device_count - 1 );
358- fprintf (stderr, " %s\n " , error_buf);
359- assert (false );
360- }
361- }
362-
363342/*
364343device_id: device ID is shown by ggml_backend_sycl_print_sycl_devices().
365344 It is only used to set current working device.
@@ -487,30 +466,16 @@ struct ggml_backend_sycl_context {
487466 std::string name;
488467
489468 queue_ptr qptrs[GGML_SYCL_MAX_DEVICES][GGML_SYCL_MAX_STREAMS] = { { nullptr } };
490- static sycl::handler * sycl_handles[GGML_SYCL_MAX_DEVICES] = {nullptr };
491469
492470 explicit ggml_backend_sycl_context (int device) :
493471 device(device),
494472 name(GGML_SYCL_NAME + std::to_string(device)) {
495473 }
496474
497- ~ggml_backend_sycl_context () {
498- for (int i = 0 ; i < GGML_SYCL_MAX_DEVICES; ++i) {
499- for (int j = 0 ; j < GGML_SYCL_MAX_STREAMS; ++j) {
500- if (qptrs[i][j] != nullptr ) {
501- SYCL_CHECK (free (qptrs[i][j]));
502- }
503- }
504- if (cublas_handles[i] != nullptr ) {
505- SYCL_CHECK (free (sycl_handles[i]));
506- }
507- }
508- }
509-
510475 queue_ptr stream (int device, int stream) {
511476 if (qptrs[device][stream] == nullptr ) {
512- SYCL_CHECK (dpct::get_current_device ().create_queue (
513- g_sycl_gpu_mgr->get_co_ctx (), dpct::get_current_device ()))) ;
477+ qptrs[device][stream] = (dpct::get_current_device ().create_queue (
478+ g_sycl_gpu_mgr->get_co_ctx (), dpct::get_current_device ()));
514479 }
515480 return qptrs[device][stream];
516481 }
@@ -519,27 +484,14 @@ struct ggml_backend_sycl_context {
519484 return stream (device, 0 );
520485 }
521486
522- handle_ptr sycl_handle (int device) {
523- if (sycl_handles[device] == nullptr ) {
524- const dpct::queue_ptr stream = qptrs[device][0 ];
525- // create sycl handle
526- SYCL_CHECK (CHECK_TRY_ERROR (sycl_handles[device] = stream));
527- }
528- return sycl_handles[device];
529- }
530-
531- handle_ptr sycl_handle () {
532- return sycl_handle (device);
533- }
534-
535487 // pool
536488 std::unique_ptr<ggml_sycl_pool> pools[GGML_SYCL_MAX_DEVICES];
537489
538490 static std::unique_ptr<ggml_sycl_pool> new_pool_for_device (queue_ptr qptr, int device);
539491
540492 ggml_sycl_pool & pool (int device) {
541493 if (pools[device] == nullptr ) {
542- pools[device] = new_pool_for_device (qptrs[ device][ 0 ] , device);
494+ pools[device] = new_pool_for_device (stream ( device, 0 ) , device);
543495 }
544496 return *pools[device];
545497 }
0 commit comments