Skip to content

Commit

Permalink
Use partition_type_property descriptor in DPCTLDevice_GetParentDevice
Browse files Browse the repository at this point in the history
This allows to test that the device is an unpartition device without
raising and handling the C++ exception.

If info::device::partition_type_property is
info::partition_property::no_partition then retrieving the parent_device
descriptor will throw.
  • Loading branch information
oleksandr-pavlyk committed Oct 23, 2023
1 parent b437c47 commit 4ac53fd
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions libsyclinterface/source/dpctl_sycl_device_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,18 @@ DPCTLDevice_GetParentDevice(__dpctl_keep const DPCTLSyclDeviceRef DRef)
{
auto D = unwrap<device>(DRef);
if (D) {
bool is_unpartitioned = false;
try {
auto pp =
D->get_info<sycl::info::device::partition_type_property>();
is_unpartitioned =
(pp == sycl::info::partition_property::no_partition);
} catch (std::exception const &e) {
error_handler(e, __FILE__, __func__, __LINE__);
return nullptr;
}
if (is_unpartitioned)
return nullptr;
try {
const auto &parent_D = D->get_info<info::device::parent_device>();
return wrap<device>(new device(parent_D));
Expand Down

0 comments on commit 4ac53fd

Please sign in to comment.