Skip to content

Commit

Permalink
avoid g_sycl_gpu_mgr null
Browse files Browse the repository at this point in the history
  • Loading branch information
airMeng committed Apr 30, 2024
1 parent 68ba9a0 commit ee2f923
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
15 changes: 0 additions & 15 deletions ggml-sycl/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,21 +31,6 @@ void check_allow_gpu_index(const int device_index) {
}
}

void check_allow_gpu_id(const int device_id) {
if (!g_sycl_gpu_mgr->is_allowed_gpu(device_id)) {
char error_buf[256];
snprintf(
error_buf,
sizeof(error_buf),
"error: cannot set device=%d, which is not allowed. Please "
"set GPU ID in: [%s]",
device_id,
g_sycl_gpu_mgr->gpus_list.c_str());
fprintf(stderr, "%s\n", error_buf);
throw std::invalid_argument(error_buf);
}
}

int get_current_device_id() {
return dpct::dev_mgr::instance().current_device_id();
}
Expand Down
16 changes: 15 additions & 1 deletion ggml-sycl/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,21 @@ void check_allow_gpu_index(const int device_index);
device_id: device ID is shown by ggml_backend_sycl_print_sycl_devices().
It is only used to set current working device.
*/
void check_allow_gpu_id(const int device_id);
inline void check_allow_gpu_id(const int device_id) {
if (!g_sycl_gpu_mgr->is_allowed_gpu(device_id)) {
char error_buf[256];
snprintf(
error_buf,
sizeof(error_buf),
"error: cannot set device=%d, which is not allowed. Please "
"set GPU ID in: [%s]",
device_id,
g_sycl_gpu_mgr->gpus_list.c_str());
fprintf(stderr, "%s\n", error_buf);
throw std::invalid_argument(error_buf);
}
}


int get_current_device_id();

Expand Down

0 comments on commit ee2f923

Please sign in to comment.