diff --git a/sycl/source/detail/device_info.hpp b/sycl/source/detail/device_info.hpp index 81ec78624477e..af2855f641c85 100644 --- a/sycl/source/detail/device_info.hpp +++ b/sycl/source/detail/device_info.hpp @@ -359,6 +359,11 @@ template <> struct get_device_info_impl, info::device::execution_capabilities> { static std::vector get(const DeviceImplPtr &Dev) { + if (Dev->getBackend() != backend::opencl) + throw exception(make_error_code(errc::invalid), + "info::device::execution_capabilities is available for " + "backend::opencl only"); + ur_device_exec_capability_flag_t result; Dev->getAdapter()->call( Dev->getHandleRef(), diff --git a/sycl/test-e2e/Basic/info.cpp b/sycl/test-e2e/Basic/info.cpp index 4a43817646340..1c74bbfddd20f 100644 --- a/sycl/test-e2e/Basic/info.cpp +++ b/sycl/test-e2e/Basic/info.cpp @@ -313,9 +313,17 @@ int main() { dev, "Is compiler available"); print_info(dev, "Is linker available"); - print_info>(dev, - "Execution capabilities"); + try { + print_info>( + dev, "Execution capabilities"); + 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, "Queue profiling"); print_info>( dev, "Built in kernels");