From aa265056d692ab1221a8be8f19fdbc266149821a Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Sun, 2 Aug 2020 10:02:14 -0700 Subject: [PATCH 1/4] [SYCL] Extend select_device to take parameters This PR allows users to request a specific device of their choice, in terms of device_type, backend, and device_num. select_device now can take 3 OPTIONAL parameters for this purpose. When these 3 parameters are specified, the user can pin down a specific device on which they want to run a kernel. SYCL_DEVICE_TRIPLE will also affect this api, and filters out unspecified devices. If any device that can satisfy the paraemters, it will fall back to the default heuristic approach. (current implemantion) Signed-off-by: Byoungro So --- sycl/CMakeLists.txt | 2 +- sycl/include/CL/sycl/device_selector.hpp | 10 ++- sycl/source/device_selector.cpp | 51 ++++++++++++++- sycl/test/abi/sycl_symbols_linux.dump | 2 +- sycl/test/basic_tests/select_device.cpp | 80 ++++++++++++++++++++++++ 5 files changed, 138 insertions(+), 7 deletions(-) create mode 100644 sycl/test/basic_tests/select_device.cpp diff --git a/sycl/CMakeLists.txt b/sycl/CMakeLists.txt index 1b7ae47f7b7fb..1242cc7dc50a0 100644 --- a/sycl/CMakeLists.txt +++ b/sycl/CMakeLists.txt @@ -14,7 +14,7 @@ include(AddSYCLExecutable) set(SYCL_MAJOR_VERSION 2) set(SYCL_MINOR_VERSION 1) set(SYCL_PATCH_VERSION 0) -set(SYCL_DEV_ABI_VERSION 4) +set(SYCL_DEV_ABI_VERSION 5) if (SYCL_ADD_DEV_VERSION_POSTFIX) set(SYCL_VERSION_POSTFIX "-${SYCL_DEV_ABI_VERSION}") endif() diff --git a/sycl/include/CL/sycl/device_selector.hpp b/sycl/include/CL/sycl/device_selector.hpp index 76d0e9489ce84..4fcd9fd540697 100644 --- a/sycl/include/CL/sycl/device_selector.hpp +++ b/sycl/include/CL/sycl/device_selector.hpp @@ -8,7 +8,9 @@ #pragma once +#include #include +#include // 4.6.1 Device selection class @@ -32,8 +34,12 @@ class __SYCL_EXPORT device_selector { public: virtual ~device_selector() = default; - device select_device() const; - + // deviceType is an optional parameter to set the desired device + // info::device_type::all means a heuristic is used to select a device with + // highest score + device select_device(info::device_type deviceType = info::device_type::all, + backend be = backend::opencl, unsigned deviceNum = 0) const; + virtual int operator()(const device &device) const = 0; }; diff --git a/sycl/source/device_selector.cpp b/sycl/source/device_selector.cpp index 831ae5f124bfa..5c60bbeea9393 100644 --- a/sycl/source/device_selector.cpp +++ b/sycl/source/device_selector.cpp @@ -28,7 +28,46 @@ static bool isDeviceOfPreferredSyclBe(const device &Device) { backend::level_zero; } -device device_selector::select_device() const { +// return a device with the requested deviceType, backend, deviceNum +// if no such device is found, heuristic is used to select a device. +// 'deviceType' is the desired device type +// info::device_type::all means it relies on the heuristic to select a device +// 'be' is a specific desired backend choice when multiple backends can support +// the device type. +// 'deviceNum' is the index in the vector of devices returned from +// sycl::platform::get_devices(). +device device_selector::select_device(info::device_type deviceType, + backend be, unsigned deviceNum) const { + // return if a requested deviceType is found + if (deviceType != info::device_type::all) { + if (deviceType == info::device_type::host) { + return device{}; + } + + const vector_class &plugins = RT::initialize(); + for (unsigned int i = 0; i < plugins.size(); i++) { + pi_uint32 numPlatforms = 0; + plugins[i].call(0, nullptr, + &numPlatforms); + if (numPlatforms) { + vector_class piPlatforms(numPlatforms); + plugins[i].call( + numPlatforms, piPlatforms.data(), nullptr); + for (const auto &piPlatform : piPlatforms) { + platform pltf = detail::createSyclObjFromImpl( + std::make_shared(piPlatform, plugins[i])); + if (!pltf.is_host() && be == pltf.get_backend()) { + vector_class devices = pltf.get_devices(deviceType); + if (devices.size()>0) { + assert(deviceNum < devices.size()); + return devices[deviceNum]; + } + } + } + } + } + } + vector_class devices = device::get_devices(); int score = REJECT_DEVICE_SCORE; const device *res = nullptr; @@ -66,9 +105,9 @@ device device_selector::select_device() const { } if (res != nullptr) { + string_class PlatformName = res->get_info() + .get_info(); if (detail::pi::trace(detail::pi::TraceLevel::PI_TRACE_BASIC)) { - string_class PlatformName = res->get_info() - .get_info(); string_class DeviceName = res->get_info(); std::cout << "SYCL_PI_TRACE[all]: " << "Selected device ->" << std::endl @@ -77,6 +116,12 @@ device device_selector::select_device() const { << "SYCL_PI_TRACE[all]: " << " device: " << DeviceName << std::endl; } + if (deviceType != info::device_type::all) { + std::cout + << "WARNING: Requested device with backend & deviceNum is not found"; + std::cout << std::endl + << PlatformName << " is chosen based on a heuristic.\n"; + } return *res; } diff --git a/sycl/test/abi/sycl_symbols_linux.dump b/sycl/test/abi/sycl_symbols_linux.dump index 0b336464462d3..c32b83e5a1f4f 100644 --- a/sycl/test/abi/sycl_symbols_linux.dump +++ b/sycl/test/abi/sycl_symbols_linux.dump @@ -3858,7 +3858,7 @@ _ZNK2cl4sycl14interop_handle12getNativeMemEPNS0_6detail16AccessorImplHostE _ZNK2cl4sycl14interop_handle14getNativeQueueEv _ZNK2cl4sycl14interop_handle15getNativeDeviceEv _ZNK2cl4sycl14interop_handle16getNativeContextEv -_ZNK2cl4sycl15device_selector13select_deviceEv +_ZNK2cl4sycl15device_selector13select_deviceENS0_4info11device_typeENS0_7backendEj _ZNK2cl4sycl15interop_handler12GetNativeMemEPNS0_6detail16AccessorImplHostE _ZNK2cl4sycl15interop_handler14GetNativeQueueEv _ZNK2cl4sycl16default_selectorclERKNS0_6deviceE diff --git a/sycl/test/basic_tests/select_device.cpp b/sycl/test/basic_tests/select_device.cpp new file mode 100644 index 0000000000000..97d7144485e94 --- /dev/null +++ b/sycl/test/basic_tests/select_device.cpp @@ -0,0 +1,80 @@ +// RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out +// RUN: %t.out +// UN: env SYCL_DEVICE_TRIPLE=gpu:level0 %t.out +// UN: env SYCL_DEVICE_TRIPLE=cpu,acc %t.out +// UN: env SYCL_DEVICE_TRIPLE=*:opencl %t.out +// UN: env SYCL_DEVICE_TRIPLE=*:opencl,gpu:level0 %t.out +// +// Checks that only designated plugins are loaded when SYCL_DEVICE_TRIPLE is set. +// Checks that all different device types can be acquired from select_device() +// UNSUPPORTED: windows + +#include +#include + +using namespace cl::sycl; + +int main() { + const char *pis = std::getenv("SYCL_DEVICE_TRIPLE"); + std::string forcedPIs; + if (pis) { + forcedPIs = pis; + } + + default_selector ds; + if (!pis || forcedPIs.find("gpu:level0") != std::string::npos) { + device d = ds.select_device(info::device_type::gpu, backend::level_zero); + std::cout << "Level-zero GPU Device is found: " << std::boolalpha + << d.is_gpu() << std::endl; + } + if (!pis || forcedPIs.find("opencl") != std::string::npos) { + device d = ds.select_device(info::device_type::gpu, backend::opencl); + std::cout << "OpenCL GPU Device is found: " << std::boolalpha << d.is_gpu() + << std::endl; + } + if (!pis || forcedPIs.find("opencl") != std::string::npos || + forcedPIs.find("cpu") != std::string::npos) { + device d = ds.select_device(info::device_type::cpu); + std::cout << "CPU device is found: " << d.is_cpu() << std::endl; + } + // HOST device is always available. + { + device d = ds.select_device(info::device_type::host); + std::cout << "HOST device is found: " << d.is_host() << std::endl; + } + if (!pis || forcedPIs.find("opencl") != std::string::npos || + forcedPIs.find("acc") != std::string::npos) { + device d = ds.select_device(info::device_type::accelerator); + std::cout << "ACC device is found: " << d.is_accelerator() << std::endl; + } + // If SYCL_DEVICE_TRIPLE is set with level0, + // GPU device should not be found by get_devices(info::device_type::gpu) + // but found by select_device(info::device_type::gpu). + if (pis && forcedPIs.find("level0") != std::string::npos && + forcedPIs.find("opencl") == std::string::npos && + forcedPIs.find("cpu") == std::string::npos && + forcedPIs.find("*") == std::string::npos) { + auto devices = device::get_devices(info::device_type::gpu); + assert(devices.size() == 0 && + "Error: CPU device is found when SYCL_DEVICE_TRIPLE contains level0"); + device d = ds.select_device(info::device_type::gpu, backend::level_zero); + assert(d.is_gpu() && "Error: GPU device is not found by select_device."); + } + // CPU device should not be loaded if SYCL_DEVICE_TRIPLE does not + // include 'opencl' string. + if (pis && forcedPIs.find("opencl") == std::string::npos && + forcedPIs.find("cpu") == std::string::npos && + forcedPIs.find("*") == std::string::npos) { + try { + device d = ds.select_device(info::device_type::cpu); + } catch (...) { + std::cout << "Expectedly, CPU device is not found." << std::endl; + return 0; + } + std::cout << "Error: CPU device is found" << std::endl; + return -1; + } + device d = ds.select_device(info::device_type::gpu, backend::opencl); + + return 0; +} From f5e0422ee6aaf12b08d3d969868db5bcf8154e7f Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Sun, 2 Aug 2020 10:10:39 -0700 Subject: [PATCH 2/4] fix clang-format Signed-off-by: Byoungro So --- sycl/include/CL/sycl/device_selector.hpp | 5 +++-- sycl/source/device_selector.cpp | 16 ++++++++-------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/sycl/include/CL/sycl/device_selector.hpp b/sycl/include/CL/sycl/device_selector.hpp index 4fcd9fd540697..8f6105bccd5db 100644 --- a/sycl/include/CL/sycl/device_selector.hpp +++ b/sycl/include/CL/sycl/device_selector.hpp @@ -38,8 +38,9 @@ class __SYCL_EXPORT device_selector { // info::device_type::all means a heuristic is used to select a device with // highest score device select_device(info::device_type deviceType = info::device_type::all, - backend be = backend::opencl, unsigned deviceNum = 0) const; - + backend be = backend::opencl, + unsigned deviceNum = 0) const; + virtual int operator()(const device &device) const = 0; }; diff --git a/sycl/source/device_selector.cpp b/sycl/source/device_selector.cpp index 5c60bbeea9393..bf940835e92d5 100644 --- a/sycl/source/device_selector.cpp +++ b/sycl/source/device_selector.cpp @@ -36,8 +36,8 @@ static bool isDeviceOfPreferredSyclBe(const device &Device) { // the device type. // 'deviceNum' is the index in the vector of devices returned from // sycl::platform::get_devices(). -device device_selector::select_device(info::device_type deviceType, - backend be, unsigned deviceNum) const { +device device_selector::select_device(info::device_type deviceType, backend be, + unsigned deviceNum) const { // return if a requested deviceType is found if (deviceType != info::device_type::all) { if (deviceType == info::device_type::host) { @@ -58,10 +58,10 @@ device device_selector::select_device(info::device_type deviceType, std::make_shared(piPlatform, plugins[i])); if (!pltf.is_host() && be == pltf.get_backend()) { vector_class devices = pltf.get_devices(deviceType); - if (devices.size()>0) { - assert(deviceNum < devices.size()); - return devices[deviceNum]; - } + if (devices.size() > 0) { + assert(deviceNum < devices.size()); + return devices[deviceNum]; + } } } } @@ -106,7 +106,7 @@ device device_selector::select_device(info::device_type deviceType, if (res != nullptr) { string_class PlatformName = res->get_info() - .get_info(); + .get_info(); if (detail::pi::trace(detail::pi::TraceLevel::PI_TRACE_BASIC)) { string_class DeviceName = res->get_info(); std::cout << "SYCL_PI_TRACE[all]: " @@ -120,7 +120,7 @@ device device_selector::select_device(info::device_type deviceType, std::cout << "WARNING: Requested device with backend & deviceNum is not found"; std::cout << std::endl - << PlatformName << " is chosen based on a heuristic.\n"; + << PlatformName << " is chosen based on a heuristic.\n"; } return *res; } From fd1556711cfb681ec182b662b6e65fbbd458fd70 Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Sun, 2 Aug 2020 12:01:38 -0700 Subject: [PATCH 3/4] more clang-format Signed-off-by: Byoungro So --- sycl/test/basic_tests/select_device.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/sycl/test/basic_tests/select_device.cpp b/sycl/test/basic_tests/select_device.cpp index 97d7144485e94..ca2b41eb2448d 100644 --- a/sycl/test/basic_tests/select_device.cpp +++ b/sycl/test/basic_tests/select_device.cpp @@ -5,8 +5,9 @@ // UN: env SYCL_DEVICE_TRIPLE=*:opencl %t.out // UN: env SYCL_DEVICE_TRIPLE=*:opencl,gpu:level0 %t.out // -// Checks that only designated plugins are loaded when SYCL_DEVICE_TRIPLE is set. -// Checks that all different device types can be acquired from select_device() +// Checks that only designated plugins are loaded when SYCL_DEVICE_TRIPLE is +// set. Checks that all different device types can be acquired from +// select_device() // UNSUPPORTED: windows #include @@ -55,8 +56,9 @@ int main() { forcedPIs.find("cpu") == std::string::npos && forcedPIs.find("*") == std::string::npos) { auto devices = device::get_devices(info::device_type::gpu); - assert(devices.size() == 0 && - "Error: CPU device is found when SYCL_DEVICE_TRIPLE contains level0"); + assert( + devices.size() == 0 && + "Error: CPU device is found when SYCL_DEVICE_TRIPLE contains level0"); device d = ds.select_device(info::device_type::gpu, backend::level_zero); assert(d.is_gpu() && "Error: GPU device is not found by select_device."); } From 7b9a83444c12c605729ef5ddb28c2fcda5a8ab8b Mon Sep 17 00:00:00 2001 From: Byoungro So Date: Sun, 16 Aug 2020 13:40:44 -0700 Subject: [PATCH 4/4] added all backend type Signed-off-by: Byoungro So --- sycl/include/CL/sycl/backend_types.hpp | 5 +- sycl/include/CL/sycl/device_selector.hpp | 3 +- sycl/source/device_selector.cpp | 46 +++++++++-------- sycl/test/basic_tests/select_device.cpp | 65 +++++++++++++----------- 4 files changed, 64 insertions(+), 55 deletions(-) diff --git a/sycl/include/CL/sycl/backend_types.hpp b/sycl/include/CL/sycl/backend_types.hpp index 655bbf89d8d39..272ef72406fbd 100644 --- a/sycl/include/CL/sycl/backend_types.hpp +++ b/sycl/include/CL/sycl/backend_types.hpp @@ -18,7 +18,7 @@ __SYCL_INLINE_NAMESPACE(cl) { namespace sycl { -enum class backend : char { host, opencl, level_zero, cuda }; +enum class backend : char { host, opencl, level_zero, cuda, all }; template struct interop; @@ -35,6 +35,9 @@ inline std::ostream &operator<<(std::ostream &Out, backend be) { break; case backend::cuda: Out << std::string("cuda"); + break; + case backend::all: + Out << std::string("all"); } return Out; } diff --git a/sycl/include/CL/sycl/device_selector.hpp b/sycl/include/CL/sycl/device_selector.hpp index 8f6105bccd5db..fcc23867d2276 100644 --- a/sycl/include/CL/sycl/device_selector.hpp +++ b/sycl/include/CL/sycl/device_selector.hpp @@ -38,8 +38,7 @@ class __SYCL_EXPORT device_selector { // info::device_type::all means a heuristic is used to select a device with // highest score device select_device(info::device_type deviceType = info::device_type::all, - backend be = backend::opencl, - unsigned deviceNum = 0) const; + backend be = backend::all, unsigned deviceNum = 0) const; virtual int operator()(const device &device) const = 0; }; diff --git a/sycl/source/device_selector.cpp b/sycl/source/device_selector.cpp index bf940835e92d5..5401e093b1286 100644 --- a/sycl/source/device_selector.cpp +++ b/sycl/source/device_selector.cpp @@ -36,31 +36,33 @@ static bool isDeviceOfPreferredSyclBe(const device &Device) { // the device type. // 'deviceNum' is the index in the vector of devices returned from // sycl::platform::get_devices(). -device device_selector::select_device(info::device_type deviceType, backend be, - unsigned deviceNum) const { +device device_selector::select_device(info::device_type DeviceType, backend BE, + unsigned DeviceNum) const { // return if a requested deviceType is found - if (deviceType != info::device_type::all) { - if (deviceType == info::device_type::host) { + if (DeviceType != info::device_type::all) { + if (DeviceType == info::device_type::host) { return device{}; } - const vector_class &plugins = RT::initialize(); - for (unsigned int i = 0; i < plugins.size(); i++) { - pi_uint32 numPlatforms = 0; - plugins[i].call(0, nullptr, - &numPlatforms); - if (numPlatforms) { - vector_class piPlatforms(numPlatforms); - plugins[i].call( - numPlatforms, piPlatforms.data(), nullptr); - for (const auto &piPlatform : piPlatforms) { - platform pltf = detail::createSyclObjFromImpl( - std::make_shared(piPlatform, plugins[i])); - if (!pltf.is_host() && be == pltf.get_backend()) { - vector_class devices = pltf.get_devices(deviceType); - if (devices.size() > 0) { - assert(deviceNum < devices.size()); - return devices[deviceNum]; + const vector_class &Plugins = RT::initialize(); + for (const detail::plugin &Plugin : Plugins) { + pi_uint32 NumPlatforms = 0; + Plugin.call(0, nullptr, &NumPlatforms); + if (NumPlatforms) { + vector_class PiPlatforms(NumPlatforms); + Plugin.call( + NumPlatforms, PiPlatforms.data(), nullptr); + for (const auto &PiPlatform : PiPlatforms) { + platform Pltf = detail::createSyclObjFromImpl( + std::make_shared(PiPlatform, Plugin)); + backend Backend = Pltf.get_backend(); + if (!Pltf.is_host() && (BE == backend::all || BE == Backend)) { + vector_class Devices = Pltf.get_devices(DeviceType); + if (Devices.size() > 0) { + if (DeviceNum >= Devices.size()) + throw cl::sycl::invalid_parameter_error("Invalid DeviceNum", + PI_INVALID_VALUE); + return Devices[DeviceNum]; } } } @@ -116,7 +118,7 @@ device device_selector::select_device(info::device_type deviceType, backend be, << "SYCL_PI_TRACE[all]: " << " device: " << DeviceName << std::endl; } - if (deviceType != info::device_type::all) { + if (DeviceType != info::device_type::all) { std::cout << "WARNING: Requested device with backend & deviceNum is not found"; std::cout << std::endl diff --git a/sycl/test/basic_tests/select_device.cpp b/sycl/test/basic_tests/select_device.cpp index ca2b41eb2448d..71faf22d59355 100644 --- a/sycl/test/basic_tests/select_device.cpp +++ b/sycl/test/basic_tests/select_device.cpp @@ -1,11 +1,13 @@ // RUN: %clangxx -fsycl -fsycl-targets=%sycl_triple %s -o %t.out // RUN: %t.out -// UN: env SYCL_DEVICE_TRIPLE=gpu:level0 %t.out -// UN: env SYCL_DEVICE_TRIPLE=cpu,acc %t.out -// UN: env SYCL_DEVICE_TRIPLE=*:opencl %t.out -// UN: env SYCL_DEVICE_TRIPLE=*:opencl,gpu:level0 %t.out +// RUN: env SYCL_DEVICE_TRIPLES="*" %t.out +// RUN: env SYCL_DEVICE_TRIPLES=gpu:level_zero %t.out +// RUN: env SYCL_DEVICE_TRIPLES=cpu,acc %t.out +// RUN: env SYCL_DEVICE_TRIPLES="*:opencl" %t.out +// RUN: env SYCL_DEVICE_TRIPLES="*:opencl,gpu:level_zero" %t.out +// RUN: env SYCL_DEVICE_TRIPLES=acc:opencl:0 %t.out // -// Checks that only designated plugins are loaded when SYCL_DEVICE_TRIPLE is +// Checks that only designated plugins are loaded when SYCL_DEVICE_TRIPLES is // set. Checks that all different device types can be acquired from // select_device() // UNSUPPORTED: windows @@ -16,24 +18,27 @@ using namespace cl::sycl; int main() { - const char *pis = std::getenv("SYCL_DEVICE_TRIPLE"); + const char *pis = std::getenv("SYCL_DEVICE_TRIPLES"); std::string forcedPIs; if (pis) { forcedPIs = pis; } default_selector ds; - if (!pis || forcedPIs.find("gpu:level0") != std::string::npos) { + if (!pis || forcedPIs == "*" || + forcedPIs.find("gpu:level_zero") != std::string::npos) { device d = ds.select_device(info::device_type::gpu, backend::level_zero); std::cout << "Level-zero GPU Device is found: " << std::boolalpha << d.is_gpu() << std::endl; } - if (!pis || forcedPIs.find("opencl") != std::string::npos) { + if (!pis || forcedPIs == "*" || + forcedPIs.find("opencl") != std::string::npos) { device d = ds.select_device(info::device_type::gpu, backend::opencl); std::cout << "OpenCL GPU Device is found: " << std::boolalpha << d.is_gpu() << std::endl; } - if (!pis || forcedPIs.find("opencl") != std::string::npos || + if (!pis || forcedPIs == "*" || + forcedPIs.find("opencl") != std::string::npos || forcedPIs.find("cpu") != std::string::npos) { device d = ds.select_device(info::device_type::cpu); std::cout << "CPU device is found: " << d.is_cpu() << std::endl; @@ -43,40 +48,40 @@ int main() { device d = ds.select_device(info::device_type::host); std::cout << "HOST device is found: " << d.is_host() << std::endl; } - if (!pis || forcedPIs.find("opencl") != std::string::npos || + if (!pis || forcedPIs == "*" || + forcedPIs.find("opencl") != std::string::npos || forcedPIs.find("acc") != std::string::npos) { device d = ds.select_device(info::device_type::accelerator); std::cout << "ACC device is found: " << d.is_accelerator() << std::endl; } - // If SYCL_DEVICE_TRIPLE is set with level0, - // GPU device should not be found by get_devices(info::device_type::gpu) - // but found by select_device(info::device_type::gpu). - if (pis && forcedPIs.find("level0") != std::string::npos && + /* + // Enable the following tests after https://github.com/intel/llvm/pull/2239 + // is merged. + // If SYCL_DEVICE_TRIPLES is set with level_zero, + // CPU device should not be found by get_devices(info::device_type::cpu) + // but GPU should be found by select_device(info::device_type::gpu). + if (pis && forcedPIs.find("level_zero") != std::string::npos && forcedPIs.find("opencl") == std::string::npos && forcedPIs.find("cpu") == std::string::npos && - forcedPIs.find("*") == std::string::npos) { - auto devices = device::get_devices(info::device_type::gpu); - assert( - devices.size() == 0 && - "Error: CPU device is found when SYCL_DEVICE_TRIPLE contains level0"); + forcedPIs != "*") { + auto devices = device::get_devices(info::device_type::cpu); + for (const device& d : devices) { + assert(!d.is_cpu() && + "Error: CPU device is found when SYCL_DEVICE_TRIPLES sets level_zero"); + } device d = ds.select_device(info::device_type::gpu, backend::level_zero); assert(d.is_gpu() && "Error: GPU device is not found by select_device."); } - // CPU device should not be loaded if SYCL_DEVICE_TRIPLE does not + + // CPU device should not be loaded if SYCL_DEVICE_TRIPLES does not // include 'opencl' string. if (pis && forcedPIs.find("opencl") == std::string::npos && forcedPIs.find("cpu") == std::string::npos && forcedPIs.find("*") == std::string::npos) { - try { - device d = ds.select_device(info::device_type::cpu); - } catch (...) { - std::cout << "Expectedly, CPU device is not found." << std::endl; - return 0; - } - std::cout << "Error: CPU device is found" << std::endl; - return -1; + device d = ds.select_device(info::device_type::cpu); + assert(!d.is_cpu() && "Error: CPU device is found when opencl is not + loaded"); } - device d = ds.select_device(info::device_type::gpu, backend::opencl); - + */ return 0; }