From 48eccefb639e8b87bb09f2bdaf8fb9c2242229df Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Wed, 29 Apr 2026 15:42:53 -0700 Subject: [PATCH 1/2] work around UR warnings from SyclPlatform.get_devices --- .../source/dpctl_sycl_platform_interface.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libsyclinterface/source/dpctl_sycl_platform_interface.cpp b/libsyclinterface/source/dpctl_sycl_platform_interface.cpp index d19d9844bb..e6c5bd56f4 100644 --- a/libsyclinterface/source/dpctl_sycl_platform_interface.cpp +++ b/libsyclinterface/source/dpctl_sycl_platform_interface.cpp @@ -304,6 +304,15 @@ DPCTLPlatform_GetDevices(__dpctl_keep const DPCTLSyclPlatformRef PRef, return wrap(DevicesVectorPtr); } + DPCTLSyclBackendType BTy = + DPCTL_SyclBackendToDPCTLBackendType(P->get_backend()); + if (DTy == DPCTLSyclDeviceType::DPCTL_CUSTOM && + BTy == DPCTLSyclBackendType::DPCTL_LEVEL_ZERO) + { + // avoid ugly warnings from unified runtime + return wrap(DevicesVectorPtr); + } + try { auto SyclDTy = DPCTL_DPCTLDeviceTypeToSyclDeviceType(DTy); auto Devices = P->get_devices(SyclDTy); From 91e597c56fd57e93afa2a9162e00f7a3f907c5b0 Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Tue, 3 Nov 2026 13:31:24 -0800 Subject: [PATCH 2/2] skip custom device lookup on all non-opencl platforms only opencl supports custom devices; other backends may warn when asked for them. add a test that no output is printed, and document the behavior --- CHANGELOG.md | 1 + dpctl/_sycl_platform.pyx | 6 ++++-- dpctl/tests/test_sycl_platform.py | 18 ++++++++++++++++++ .../dpctl_sycl_platform_interface.h | 3 +++ .../source/dpctl_sycl_platform_interface.cpp | 8 ++++---- 5 files changed, 30 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f660fa239b..6ecef415e2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed * Removed stale `select_host_device` and `has_host_device` names from `dpctl.__all__`, which made `from dpctl import *` fail with `AttributeError` [gh-2410](https://github.com/IntelPython/dpctl/pull/2410) * A USM allocation that fails now drops the references held for offloaded tasks that have completed, and is attempted once more if that released anything, so that memory only waiting to be given up is not reported as unavailable [gh-2359](https://github.com/IntelPython/dpctl/pull/2359) +* `dpctl.SyclPlatform.get_devices` no longer prints Unified Runtime warnings for `device_type="custom"` on non-OpenCL platforms, where custom devices are not supported [gh-2306](https://github.com/IntelPython/dpctl/pull/2306) ### Maintenance * Removed the `-fno-sycl-id-queries-fit-in-int` compile option, which none of the `dpctl` extensions need since `dpctl.tensor` moved to `dpnp` [gh-2413](https://github.com/IntelPython/dpctl/pull/2413) diff --git a/dpctl/_sycl_platform.pyx b/dpctl/_sycl_platform.pyx index d722e93b50..04af9bb86e 100644 --- a/dpctl/_sycl_platform.pyx +++ b/dpctl/_sycl_platform.pyx @@ -387,8 +387,10 @@ cdef class SyclPlatform(_SyclPlatform): device_type (str, :class:`dpctl.device_type`, optional): A :class:`dpctl.device_type` enum value or a string that specifies a SYCL device type. Currently, accepted values are: - "gpu", "cpu", "accelerator", or "all", and their equivalent - ``dpctl.device_type`` enumerators. + "gpu", "cpu", "accelerator", "automatic", "custom", or "all", + and their equivalent ``dpctl.device_type`` enumerators. + Only OpenCL platforms support custom devices; for other + platforms, "custom" returns an empty tuple. Default: ``dpctl.device_type.all``. Returns: diff --git a/dpctl/tests/test_sycl_platform.py b/dpctl/tests/test_sycl_platform.py index 0660617752..7364a5ea87 100644 --- a/dpctl/tests/test_sycl_platform.py +++ b/dpctl/tests/test_sycl_platform.py @@ -260,6 +260,24 @@ def test_platform_get_devices_enum_device_type(): assert (d.device_type == dty for d in devices) +@pytest.mark.parametrize("dty", ["custom", device_type.custom]) +def test_platform_get_devices_custom_non_opencl(dty, capfd): + platforms = [ + p + for p in dpctl.get_platforms() + if p.backend != dpctl.backend_type.opencl + ] + if not platforms: + pytest.skip("No non-OpenCL platforms available") + capfd.readouterr() + for p in platforms: + assert len(p.get_devices(device_type=dty)) == 0 + out, err = capfd.readouterr() + # e.g., the Level Zero adapter warns on device_type::custom + assert out == "" + assert err == "" + + def test_platform_get_composite_devices(): platforms = dpctl.get_platforms() if platforms: diff --git a/libsyclinterface/include/syclinterface/dpctl_sycl_platform_interface.h b/libsyclinterface/include/syclinterface/dpctl_sycl_platform_interface.h index 1cde75d710..affc16150e 100644 --- a/libsyclinterface/include/syclinterface/dpctl_sycl_platform_interface.h +++ b/libsyclinterface/include/syclinterface/dpctl_sycl_platform_interface.h @@ -183,6 +183,9 @@ size_t DPCTLPlatform_Hash(__dpctl_keep const DPCTLSyclPlatformRef PRef); * @brief Returns a vector of devices associated with sycl::platform referenced * by DPCTLSyclPlatformRef object. * + * Only OpenCL platforms support custom devices; for other platforms, + * DPCTL_CUSTOM returns an empty vector. + * * @param PRef The DPCTLSyclPlatformRef pointer. * @param DTy A DPCTLSyclDeviceType enum value. * @return A DPCTLDeviceVectorRef with devices associated with given PRef. diff --git a/libsyclinterface/source/dpctl_sycl_platform_interface.cpp b/libsyclinterface/source/dpctl_sycl_platform_interface.cpp index e6c5bd56f4..b76c703f42 100644 --- a/libsyclinterface/source/dpctl_sycl_platform_interface.cpp +++ b/libsyclinterface/source/dpctl_sycl_platform_interface.cpp @@ -304,12 +304,12 @@ DPCTLPlatform_GetDevices(__dpctl_keep const DPCTLSyclPlatformRef PRef, return wrap(DevicesVectorPtr); } - DPCTLSyclBackendType BTy = - DPCTL_SyclBackendToDPCTLBackendType(P->get_backend()); + // Only OpenCL supports custom devices; other backends may warn when asked + // for them (e.g., the Unified Runtime Level Zero adapter) if (DTy == DPCTLSyclDeviceType::DPCTL_CUSTOM && - BTy == DPCTLSyclBackendType::DPCTL_LEVEL_ZERO) + DPCTL_SyclBackendToDPCTLBackendType(P->get_backend()) != + DPCTLSyclBackendType::DPCTL_OPENCL) { - // avoid ugly warnings from unified runtime return wrap(DevicesVectorPtr); }