From 4ac53fd0725d683e8b4935e2609ed20c0b5b55a1 Mon Sep 17 00:00:00 2001 From: Oleksandr Pavlyk Date: Sun, 22 Oct 2023 20:24:41 -0500 Subject: [PATCH] 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. --- .../source/dpctl_sycl_device_interface.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/libsyclinterface/source/dpctl_sycl_device_interface.cpp b/libsyclinterface/source/dpctl_sycl_device_interface.cpp index b5a97013c2..7a159a331c 100644 --- a/libsyclinterface/source/dpctl_sycl_device_interface.cpp +++ b/libsyclinterface/source/dpctl_sycl_device_interface.cpp @@ -543,6 +543,18 @@ DPCTLDevice_GetParentDevice(__dpctl_keep const DPCTLSyclDeviceRef DRef) { auto D = unwrap(DRef); if (D) { + bool is_unpartitioned = false; + try { + auto pp = + D->get_info(); + 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(); return wrap(new device(parent_D));