diff --git a/sycl/source/detail/device_info.hpp b/sycl/source/detail/device_info.hpp index 38e5988a37456..2862913194ae0 100644 --- a/sycl/source/detail/device_info.hpp +++ b/sycl/source/detail/device_info.hpp @@ -1411,6 +1411,32 @@ typename Param::return_type get_device_info(const DeviceImplPtr &Dev) { return get_device_info_impl::get(Dev); } +template <> +inline typename info::device::preferred_interop_user_sync::return_type +get_device_info( + const DeviceImplPtr &Dev) { + if (Dev->getBackend() != backend::opencl) { + throw sycl::exception( + errc::invalid, + "the info::device::preferred_interop_user_sync info descriptor can " + "only be queried with an OpenCL backend"); + } + using Param = info::device::preferred_interop_user_sync; + return get_device_info_impl::get(Dev); +} + +template <> +inline typename info::device::profile::return_type +get_device_info(const DeviceImplPtr &Dev) { + if (Dev->getBackend() != backend::opencl) { + throw sycl::exception(errc::invalid, + "the info::device::profile info descriptor can " + "only be queried with an OpenCL backend"); + } + using Param = info::device::profile; + return get_device_info_impl::get(Dev); +} + template <> inline ext::intel::info::device::device_id::return_type get_device_info(const DeviceImplPtr &Dev) { diff --git a/sycl/test-e2e/Basic/info.cpp b/sycl/test-e2e/Basic/info.cpp index 3fd83be26e994..4a43817646340 100644 --- a/sycl/test-e2e/Basic/info.cpp +++ b/sycl/test-e2e/Basic/info.cpp @@ -208,6 +208,7 @@ int main() { std::string separator(std::string(80, '-') + "\n"); std::cout << separator << "Device information\n" << separator; device dev(default_selector_v); + backend backend{dev.get_backend()}; print_info(dev, "Device type"); print_info(dev, "Vendor ID"); @@ -322,7 +323,14 @@ int main() { print_info(dev, "Name"); print_info(dev, "Vendor"); print_info(dev, "Driver version"); - print_info(dev, "Profile"); + try { + print_info(dev, "Profile"); + assert(backend == sycl::backend::opencl && + "An exception is expected for non OpenCL backend"); + } catch (const sycl::exception &e) { + assert(e.code() == sycl::errc::invalid && + backend != sycl::backend::opencl && "Unexpected exception"); + } print_info(dev, "Version"); print_info(dev, "Backend version"); @@ -332,11 +340,18 @@ int main() { "Extensions"); print_info(dev, "Printf buffer size"); - print_info( - dev, "Preferred interop user sync"); + try { + print_info( + dev, "Preferred interop user sync"); + assert(backend == sycl::backend::opencl && + "An exception is expected for non OpenCL backend"); + } catch (const sycl::exception &e) { + assert(e.code() == sycl::errc::invalid && + backend != sycl::backend::opencl && "Unexpected exception"); + } try { print_info(dev, "Parent device"); - } catch (sycl::exception e) { + } catch (const sycl::exception &e) { std::cout << "Expected exception has been caught: " << e.what() << std::endl; }