@@ -98,7 +98,7 @@ static ggml_sycl_device_info ggml_sycl_init() {
9898 for (int i = 0 ; i < info.device_count ; ++i) {
9999 info.devices [i].vmm = 0 ;
100100 dpct::device_info prop;
101- sycl::device device = dpct::dev_mgr::instance ().get_device (i);
101+ auto & device = dpct::dev_mgr::instance ().get_device (i);
102102
103103 SYCL_CHECK (CHECK_TRY_ERROR (dpct::get_device_info (
104104 prop, device)));
@@ -117,6 +117,12 @@ static ggml_sycl_device_info ggml_sycl_init() {
117117 info.devices [i].max_wg_per_cu = info.max_work_group_sizes [i] / prop.get_max_compute_units ();
118118 info.devices [i].hw_info = get_device_hw_info (&device);
119119
120+ // Only check GPU devices; CPU devices use OpenCL and would otherwise
121+ // disable Level Zero for the GPUs on systems without ONEAPI_DEVICE_SELECTOR set.
122+ if (device.is_gpu () && device.default_queue ().get_backend () != sycl::backend::ext_oneapi_level_zero) {
123+ GGML_LOG_WARN (" SYCL GPU device %d does not use Level Zero backend, disabling Level Zero memory API\n " , i);
124+ info.ext_oneapi_level_zero = false ;
125+ }
120126 }
121127
122128 for (int id = 0 ; id < info.device_count ; ++id) {
@@ -230,26 +236,10 @@ static void ggml_check_sycl() try {
230236 g_ggml_sycl_disable_dnn = get_sycl_env (" GGML_SYCL_DISABLE_DNN" , 0 );
231237 g_ggml_sycl_prioritize_dmmv = get_sycl_env (" GGML_SYCL_PRIORITIZE_DMMV" , 0 );
232238#ifdef GGML_SYCL_SUPPORT_LEVEL_ZERO
233- g_ggml_sycl_enable_level_zero = get_sycl_env (" GGML_SYCL_ENABLE_LEVEL_ZERO" , 1 );
239+ g_ggml_sycl_enable_level_zero = get_sycl_env (" GGML_SYCL_ENABLE_LEVEL_ZERO" , ggml_sycl_info (). ext_oneapi_level_zero );
234240#else
235241 g_ggml_sycl_enable_level_zero = 0 ;
236242#endif
237- if (g_ggml_sycl_enable_level_zero) {
238- // Verify all GPU devices use the Level Zero backend before enabling L0 APIs.
239- // Only check GPU devices; CPU devices use OpenCL and would otherwise
240- // disable Level Zero for the GPUs on systems without ONEAPI_DEVICE_SELECTOR set.
241- for (unsigned int i = 0 ; i < dpct::dev_mgr::instance ().device_count (); i++) {
242- auto & q = dpct::dev_mgr::instance ().get_device (i).default_queue ();
243- if (!q.get_device ().is_gpu ()) {
244- continue ;
245- }
246- if (q.get_backend () != sycl::backend::ext_oneapi_level_zero) {
247- GGML_LOG_WARN (" SYCL GPU device %d does not use Level Zero backend, disabling Level Zero memory API\n " , i);
248- g_ggml_sycl_enable_level_zero = 0 ;
249- break ;
250- }
251- }
252- }
253243
254244#ifdef SYCL_FLASH_ATTN
255245 g_ggml_sycl_enable_flash_attention = get_sycl_env (" GGML_SYCL_ENABLE_FLASH_ATTN" , 1 );
0 commit comments