Skip to content

Commit 4ac53fd

Browse files
Use partition_type_property descriptor in DPCTLDevice_GetParentDevice
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.
1 parent b437c47 commit 4ac53fd

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

libsyclinterface/source/dpctl_sycl_device_interface.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -543,6 +543,18 @@ DPCTLDevice_GetParentDevice(__dpctl_keep const DPCTLSyclDeviceRef DRef)
543543
{
544544
auto D = unwrap<device>(DRef);
545545
if (D) {
546+
bool is_unpartitioned = false;
547+
try {
548+
auto pp =
549+
D->get_info<sycl::info::device::partition_type_property>();
550+
is_unpartitioned =
551+
(pp == sycl::info::partition_property::no_partition);
552+
} catch (std::exception const &e) {
553+
error_handler(e, __FILE__, __func__, __LINE__);
554+
return nullptr;
555+
}
556+
if (is_unpartitioned)
557+
return nullptr;
546558
try {
547559
const auto &parent_D = D->get_info<info::device::parent_device>();
548560
return wrap<device>(new device(parent_D));

0 commit comments

Comments
 (0)