Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions sycl/source/detail/device_info.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1411,6 +1411,32 @@ typename Param::return_type get_device_info(const DeviceImplPtr &Dev) {
return get_device_info_impl<typename Param::return_type, Param>::get(Dev);
}

template <>
inline typename info::device::preferred_interop_user_sync::return_type
get_device_info<info::device::preferred_interop_user_sync>(
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<Param::return_type, Param>::get(Dev);
}

template <>
inline typename info::device::profile::return_type
get_device_info<info::device::profile>(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<Param::return_type, Param>::get(Dev);
}

template <>
inline ext::intel::info::device::device_id::return_type
get_device_info<ext::intel::info::device::device_id>(const DeviceImplPtr &Dev) {
Expand Down
23 changes: 19 additions & 4 deletions sycl/test-e2e/Basic/info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<info::device::device_type, info::device_type>(dev, "Device type");
print_info<info::device::vendor_id, std::uint32_t>(dev, "Vendor ID");
Expand Down Expand Up @@ -322,7 +323,14 @@ int main() {
print_info<info::device::name, std::string>(dev, "Name");
print_info<info::device::vendor, std::string>(dev, "Vendor");
print_info<info::device::driver_version, std::string>(dev, "Driver version");
print_info<info::device::profile, std::string>(dev, "Profile");
try {
print_info<info::device::profile, std::string>(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<info::device::version, std::string>(dev, "Version");
print_info<info::device::backend_version, std::string>(dev,
"Backend version");
Expand All @@ -332,11 +340,18 @@ int main() {
"Extensions");
print_info<info::device::printf_buffer_size, size_t>(dev,
"Printf buffer size");
print_info<info::device::preferred_interop_user_sync, bool>(
dev, "Preferred interop user sync");
try {
print_info<info::device::preferred_interop_user_sync, bool>(
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<info::device::parent_device, device>(dev, "Parent device");
} catch (sycl::exception e) {
} catch (const sycl::exception &e) {
std::cout << "Expected exception has been caught: " << e.what()
<< std::endl;
}
Expand Down