From ee2f9231560db106d8ed28f363da13dc10da86ba Mon Sep 17 00:00:00 2001 From: "Meng, Hengyu" Date: Tue, 30 Apr 2024 09:22:46 +0000 Subject: [PATCH] avoid g_sycl_gpu_mgr null --- ggml-sycl/common.cpp | 15 --------------- ggml-sycl/common.hpp | 16 +++++++++++++++- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/ggml-sycl/common.cpp b/ggml-sycl/common.cpp index c16c63a07ea49..e5a8117f3d061 100644 --- a/ggml-sycl/common.cpp +++ b/ggml-sycl/common.cpp @@ -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(); } diff --git a/ggml-sycl/common.hpp b/ggml-sycl/common.hpp index 1259581a26cc9..e16e89b29fd9a 100644 --- a/ggml-sycl/common.hpp +++ b/ggml-sycl/common.hpp @@ -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();