Skip to content

Commit ee2f923

Browse files
committed
avoid g_sycl_gpu_mgr null
1 parent 68ba9a0 commit ee2f923

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

ggml-sycl/common.cpp

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,6 @@ void check_allow_gpu_index(const int device_index) {
3131
}
3232
}
3333

34-
void check_allow_gpu_id(const int device_id) {
35-
if (!g_sycl_gpu_mgr->is_allowed_gpu(device_id)) {
36-
char error_buf[256];
37-
snprintf(
38-
error_buf,
39-
sizeof(error_buf),
40-
"error: cannot set device=%d, which is not allowed. Please "
41-
"set GPU ID in: [%s]",
42-
device_id,
43-
g_sycl_gpu_mgr->gpus_list.c_str());
44-
fprintf(stderr, "%s\n", error_buf);
45-
throw std::invalid_argument(error_buf);
46-
}
47-
}
48-
4934
int get_current_device_id() {
5035
return dpct::dev_mgr::instance().current_device_id();
5136
}

ggml-sycl/common.hpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,21 @@ void check_allow_gpu_index(const int device_index);
374374
device_id: device ID is shown by ggml_backend_sycl_print_sycl_devices().
375375
It is only used to set current working device.
376376
*/
377-
void check_allow_gpu_id(const int device_id);
377+
inline void check_allow_gpu_id(const int device_id) {
378+
if (!g_sycl_gpu_mgr->is_allowed_gpu(device_id)) {
379+
char error_buf[256];
380+
snprintf(
381+
error_buf,
382+
sizeof(error_buf),
383+
"error: cannot set device=%d, which is not allowed. Please "
384+
"set GPU ID in: [%s]",
385+
device_id,
386+
g_sycl_gpu_mgr->gpus_list.c_str());
387+
fprintf(stderr, "%s\n", error_buf);
388+
throw std::invalid_argument(error_buf);
389+
}
390+
}
391+
378392

379393
int get_current_device_id();
380394

0 commit comments

Comments
 (0)