From 4badab2b6cbc6691eae67317cd863b3413799f61 Mon Sep 17 00:00:00 2001 From: Salvatore Mesoraca Date: Sat, 31 Aug 2024 13:26:16 +0200 Subject: [PATCH] SYCL: do not skip CPU or FPGA if explicitly selected It can be useful to be able to use SYCL on CPU e.g. to run tests on a machine without a GPU. With this commit a user can enable the use of the CPU with the following env variable: export ONEAPI_DEVICE_SELECTOR="opencl:cpu" Signed-off-by: Salvatore Mesoraca --- ggml/src/ggml-sycl/dpct/helper.hpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/ggml/src/ggml-sycl/dpct/helper.hpp b/ggml/src/ggml-sycl/dpct/helper.hpp index fe4a8f744..e82d8ce6e 100644 --- a/ggml/src/ggml-sycl/dpct/helper.hpp +++ b/ggml/src/ggml-sycl/dpct/helper.hpp @@ -910,15 +910,17 @@ namespace dpct auto platform_list = sycl::platform::get_platforms(); for (const auto& platform : platform_list) { - auto devices = platform.get_devices(); - auto gpu_dev = std::find_if(devices.begin(), devices.end(), [](const sycl::device& d) { - return d.is_gpu(); - }); + if (!env || !std::strstr(env, "cpu")) { + auto devices = platform.get_devices(); + auto gpu_dev = std::find_if(devices.begin(), devices.end(), [](const sycl::device& d) { + return d.is_gpu(); + }); - if (gpu_dev == devices.end()) { - // cout << "platform [" << platform_name - // << "] does not contain GPU devices, skipping\n"; - continue; + if (gpu_dev == devices.end()) { + // cout << "platform [" << platform_name + // << "] does not contain GPU devices, skipping\n"; + continue; + } } auto platform_name = platform.get_info();