From 3a2a1c03c17edf68499d7da9723dd2d9a27ccf5b Mon Sep 17 00:00:00 2001 From: Andrei Elovikov Date: Fri, 28 Jun 2024 10:17:10 -0700 Subject: [PATCH] [SYCL] Don't throw in `device_impl::has` 1) It isn't right 2) We need this change to get rid of deprecated `sycl::exception::get_cl_code` --- sycl/source/detail/device_impl.cpp | 4 ++-- sycl/source/device.cpp | 13 +++---------- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/sycl/source/detail/device_impl.cpp b/sycl/source/detail/device_impl.cpp index ef02558bba55a..cd29ad1eec64d 100644 --- a/sycl/source/detail/device_impl.cpp +++ b/sycl/source/detail/device_impl.cpp @@ -747,8 +747,8 @@ bool device_impl::has(aspect Aspect) const { return call_successful && support; } } - throw runtime_error("This device aspect has not been implemented yet.", - PI_ERROR_INVALID_DEVICE); + + return false; // This device aspect has not been implemented yet. } std::shared_ptr device_impl::getHostDeviceImpl() { diff --git a/sycl/source/device.cpp b/sycl/source/device.cpp index 70aa37aad26a2..20df5cf47256a 100644 --- a/sycl/source/device.cpp +++ b/sycl/source/device.cpp @@ -156,16 +156,9 @@ device::get_info_impl() const { #undef __SYCL_ASPECT }; - auto UnsupportedAspects = std::remove_if( - DeviceAspects.begin(), DeviceAspects.end(), [&](aspect Aspect) { - try { - return !impl->has(Aspect); - } catch (const runtime_error &ex) { - if (ex.get_cl_code() == PI_ERROR_INVALID_DEVICE) - return true; - throw; - } - }); + auto UnsupportedAspects = + std::remove_if(DeviceAspects.begin(), DeviceAspects.end(), + [&](aspect Aspect) { return !impl->has(Aspect); }); DeviceAspects.erase(UnsupportedAspects, DeviceAspects.end());