From 56c4bb9734dc2f21214042aed80077da92fb1d3a Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Thu, 6 Aug 2026 08:15:09 -0700 Subject: [PATCH 1/2] add platform::has_aspect --- dpctl/_backend.pxd | 2 + dpctl/_sycl_platform.pyx | 358 +++++++++++++++++- dpctl/tests/test_sycl_platform.py | 48 +++ .../dpctl_sycl_platform_interface.h | 14 + .../source/dpctl_sycl_platform_interface.cpp | 19 + .../tests/test_sycl_platform_interface.cpp | 75 ++++ 6 files changed, 495 insertions(+), 21 deletions(-) diff --git a/dpctl/_backend.pxd b/dpctl/_backend.pxd index 3708ea9130..ebfecca05f 100644 --- a/dpctl/_backend.pxd +++ b/dpctl/_backend.pxd @@ -491,6 +491,8 @@ cdef extern from "syclinterface/dpctl_sycl_platform_interface.h": const DPCTLSyclPlatformRef PRef, _device_type DTy) cdef DPCTLDeviceVectorRef DPCTLPlatform_GetCompositeDevices( const DPCTLSyclPlatformRef PRef) + cdef bool DPCTLPlatform_HasAspect( + const DPCTLSyclPlatformRef, _aspect_type) cdef extern from "syclinterface/dpctl_sycl_context_interface.h": diff --git a/dpctl/_sycl_platform.pyx b/dpctl/_sycl_platform.pyx index d722e93b50..6f8c8833e0 100644 --- a/dpctl/_sycl_platform.pyx +++ b/dpctl/_sycl_platform.pyx @@ -45,6 +45,7 @@ from ._backend cimport ( # noqa: E211 DPCTLPlatform_GetPlatforms, DPCTLPlatform_GetVendor, DPCTLPlatform_GetVersion, + DPCTLPlatform_HasAspect, DPCTLPlatform_Hash, DPCTLPlatformMgr_GetInfo, DPCTLPlatformMgr_PrintInfo, @@ -56,6 +57,7 @@ from ._backend cimport ( # noqa: E211 DPCTLSyclDeviceRef, DPCTLSyclDeviceSelectorRef, DPCTLSyclPlatformRef, + _aspect_type, _backend_type, _device_type, ) @@ -313,6 +315,323 @@ cdef class SyclPlatform(_SyclPlatform): else: raise ValueError("Unknown backend type.") + @property + def has_aspect_cpu(self): + """ Returns ``True`` if all devices of this platform are CPU devices, + ``False`` otherwise. + + :Example: + + .. code-block:: python + + >>> import dpctl + >>> pl = dpctl.SyclPlatform("opencl:cpu") + >>> pl.has_aspect_cpu + True + + Returns: + bool: + Indicates whether all devices of the platform are cpus. + """ + cdef _aspect_type AT = _aspect_type._cpu + return DPCTLPlatform_HasAspect(self._platform_ref, AT) + + @property + def has_aspect_gpu(self): + """ Returns ``True`` if all devices of this platform are GPU devices, + ``False`` otherwise. + + Returns: + bool: + Indicates whether all devices of the platform are gpus. + """ + cdef _aspect_type AT = _aspect_type._gpu + return DPCTLPlatform_HasAspect(self._platform_ref, AT) + + @property + def has_aspect_accelerator(self): + """ Returns ``True`` if all devices of this platform are accelerator + devices, ``False`` otherwise. + + SYCL considers an accelerator to be a device that usually uses a + peripheral interconnect for communication. + + Returns: + bool: + Indicates whether all devices of the platform are + accelerators. + """ + cdef _aspect_type AT = _aspect_type._accelerator + return DPCTLPlatform_HasAspect(self._platform_ref, AT) + + @property + def has_aspect_custom(self): + """ Returns ``True`` if all devices of this platform are custom + devices, ``False`` otherwise. + + A custom device can be a dedicated accelerator that can use the + SYCL API, but programmable kernels cannot be dispatched to the device, + only fixed functionality is available. Refer SYCL spec for more details. + + Returns: + bool: + Indicates whether all devices of the platform are custom SYCL + devices. + """ + cdef _aspect_type AT = _aspect_type._custom + return DPCTLPlatform_HasAspect(self._platform_ref, AT) + + @property + def has_aspect_fp16(self): + """ Returns ``True`` if all devices of this platform support + half-precision floating point operations, ``False`` otherwise. + + Returns: + bool: + Indicates that all devices of the platform support half + precision floating point operations. + """ + cdef _aspect_type AT = _aspect_type._fp16 + return DPCTLPlatform_HasAspect(self._platform_ref, AT) + + @property + def has_aspect_fp64(self): + """ Returns ``True`` if all devices of this platform support 64-bit + precision floating point operations, ``False`` otherwise. + + Returns: + bool: + Indicates that all devices of the platform support 64-bit + precision floating point operations. + """ + cdef _aspect_type AT = _aspect_type._fp64 + return DPCTLPlatform_HasAspect(self._platform_ref, AT) + + @property + def has_aspect_atomic64(self): + """ Returns ``True`` if all devices of this platform support a basic + set of atomic operations, ``False`` otherwise. + + Indicates that the devices support the following atomic operations on + 64-bit values: + + - ``sycl::atomic_ref::load`` + - ``sycl::atomic_ref::store`` + - ``sycl::atomic_ref::fetch_add`` + - ``sycl::atomic_ref::fetch_sub`` + - ``sycl::atomic_ref::exchange`` + - ``sycl::atomic_ref::compare_exchange_strong`` + - ``sycl::atomic_ref::compare_exchange_weak`` + + Returns: + bool: + Indicates that all devices of the platform support a basic set + of atomic operations on 64-bit values. + """ + cdef _aspect_type AT = _aspect_type._atomic64 + return DPCTLPlatform_HasAspect(self._platform_ref, AT) + + @property + def has_aspect_image(self): + """ Returns ``True`` if all devices of this platform support images, + ``False`` otherwise (refer Sec 4.15.3 of SYCL 2020 spec). + + Returns: + bool: + Indicates that all devices of the platform support images. + """ + cdef _aspect_type AT = _aspect_type._image + return DPCTLPlatform_HasAspect(self._platform_ref, AT) + + @property + def has_aspect_online_compiler(self): + """ Returns ``True`` if all devices of this platform support online + compilation of device code, ``False`` otherwise. + + Returns: + bool: + Indicates that all devices of the platform support online + compilation of device code. + """ + cdef _aspect_type AT = _aspect_type._online_compiler + return DPCTLPlatform_HasAspect(self._platform_ref, AT) + + @property + def has_aspect_online_linker(self): + """ Returns ``True`` if all devices of this platform support online + linking of device code, ``False`` otherwise. + + Returns: + bool: + Indicates that all devices of the platform support online + linking of device code. + """ + cdef _aspect_type AT = _aspect_type._online_linker + return DPCTLPlatform_HasAspect(self._platform_ref, AT) + + @property + def has_aspect_queue_profiling(self): + """ Returns ``True`` if all devices of this platform support queue + profiling, ``False`` otherwise. + + Returns: + bool: + Indicates that all devices of the platform support queue + profiling. + """ + cdef _aspect_type AT = _aspect_type._queue_profiling + return DPCTLPlatform_HasAspect(self._platform_ref, AT) + + @property + def has_aspect_usm_device_allocations(self): + """ Returns ``True`` if all devices of this platform support explicit + USM allocations, ``False`` otherwise. + + Returns: + bool: + Indicates that all devices of the platform support explicit USM + allocations. + """ + cdef _aspect_type AT = _aspect_type._usm_device_allocations + return DPCTLPlatform_HasAspect(self._platform_ref, AT) + + @property + def has_aspect_usm_host_allocations(self): + """ Returns ``True`` if all devices of this platform can access USM + memory allocated via ``sycl::malloc_host``, ``False`` otherwise. + + Returns: + bool: + Indicates that all devices of the platform can access USM + memory allocated via ``sycl::malloc_host``. + """ + cdef _aspect_type AT = _aspect_type._usm_host_allocations + return DPCTLPlatform_HasAspect(self._platform_ref, AT) + + @property + def has_aspect_usm_shared_allocations(self): + """ Returns ``True`` if all devices of this platform support USM + memory allocated via ``sycl::malloc_shared``, ``False`` otherwise. + + Returns: + bool: + Indicates that all devices of the platform support USM memory + allocated via ``sycl::malloc_shared``. + """ + cdef _aspect_type AT = _aspect_type._usm_shared_allocations + return DPCTLPlatform_HasAspect(self._platform_ref, AT) + + @property + def has_aspect_usm_system_allocations(self): + """ Returns ``True`` if the system allocator may be used instead of + SYCL USM allocation mechanisms for ``shared`` allocations on all + devices of this platform, ``False`` otherwise. + + Returns: + bool: + Indicates that the system allocator may be used instead of + SYCL USM allocation mechanisms for ``shared`` allocations. + """ + cdef _aspect_type AT = _aspect_type._usm_system_allocations + return DPCTLPlatform_HasAspect(self._platform_ref, AT) + + @property + def has_aspect_usm_atomic_host_allocations(self): + """ Returns ``True`` if all devices of this platform support USM + memory allocated via ``sycl::malloc_host`` and can be accessed + atomically, ``False`` otherwise. + + Returns: + bool: + Indicates that all devices of the platform support USM memory + allocated via ``sycl::malloc_host`` and can be accessed + atomically. + """ + cdef _aspect_type AT = _aspect_type._usm_atomic_host_allocations + return DPCTLPlatform_HasAspect(self._platform_ref, AT) + + @property + def has_aspect_usm_atomic_shared_allocations(self): + """ Returns ``True`` if all devices of this platform support USM + memory allocated via ``sycl::malloc_shared`` and can be accessed + atomically, ``False`` otherwise. + + Returns: + bool: + Indicates that all devices of the platform support USM memory + allocated via ``sycl::malloc_shared`` and can be accessed + atomically. + """ + cdef _aspect_type AT = _aspect_type._usm_atomic_shared_allocations + return DPCTLPlatform_HasAspect(self._platform_ref, AT) + + @property + def has_aspect_host_debuggable(self): + """ Returns ``True`` if kernels running on all devices of this + platform can be debugged using standard debuggers that are normally + available on the host system, ``False`` otherwise. + + Returns: + bool: + Indicates that kernels running on all devices of the platform + can be debugged using standard debuggers that are normally + available on the host system. + """ + cdef _aspect_type AT = _aspect_type._host_debuggable + return DPCTLPlatform_HasAspect(self._platform_ref, AT) + + @property + def has_aspect_emulated(self): + """ Returns ``True`` if all devices of this platform are somehow + emulated, ``False`` otherwise. A device with this aspect is not + intended for performance, and instead will generally have another + non-emulated platform as a better representation for performance. + + Returns: + bool: + Indicates that all devices of the platform are emulated. + """ + cdef _aspect_type AT = _aspect_type._emulated + return DPCTLPlatform_HasAspect(self._platform_ref, AT) + + @property + def has_aspect_is_component(self): + """ Returns ``True`` if all devices of this platform are component + devices, ``False`` otherwise. A device with this aspect will have a + composite device from which it is descended. + + Returns: + bool: + Indicates if all devices of the platform are component devices. + """ + cdef _aspect_type AT = _aspect_type._is_component + return DPCTLPlatform_HasAspect(self._platform_ref, AT) + + @property + def has_aspect_is_composite(self): + """ Returns ``True`` if all devices of this platform are composite + devices, ``False`` otherwise. A device with this aspect contains + component devices. + + Returns: + bool: + Indicates if all devices of the platform are composite devices. + """ + cdef _aspect_type AT = _aspect_type._is_composite + return DPCTLPlatform_HasAspect(self._platform_ref, AT) + + @property + def has_aspect_ext_oneapi_ipc_memory(self): + """ Returns ``True`` if all devices of this platform support + inter-process communication (IPC) memory handles, ``False`` otherwise. + + Returns: + bool: + Indicates if all devices of the platform support IPC memory. + """ + cdef _aspect_type AT = _aspect_type._ext_oneapi_ipc_memory + return DPCTLPlatform_HasAspect(self._platform_ref, AT) + @property def default_context(self): """Returns the default platform context for this platform @@ -521,39 +840,36 @@ def lsplatform(verbosity=0): .. code-block:: text :caption: Sample output of lsplatform(verbosity=2) - Platform 0:: + Platform 0 :: Name Intel(R) OpenCL Version OpenCL 2.1 LINUX Vendor Intel(R) Corporation - Profile FULL_PROFILE Backend opencl - Devices 1 - Device 0:: - Name Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz - Driver version 2020.11.11.0.13_160000 - Device type cpu - Platform 1:: + Num Devices 1 + # 0 + Name Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz + Version 2020.11.11.0.13_160000 + Filter string opencl:cpu:0 + Platform 1 :: Name Intel(R) OpenCL HD Graphics Version OpenCL 3.0 Vendor Intel(R) Corporation - Profile FULL_PROFILE Backend opencl - Devices 1 - Device 0:: - Name Intel(R) Graphics Gen9 [0x3e98] - Driver version 20.47.18513 - Device type gpu - Platform 2:: + Num Devices 1 + # 0 + Name Intel(R) Graphics Gen9 [0x3e98] + Version 20.47.18513 + Filter string opencl:gpu:0 + Platform 2 :: Name Intel(R) Level-Zero Version 1.0 Vendor Intel(R) Corporation - Profile FULL_PROFILE Backend level_zero - Devices 1 - Device 0:: - Name Intel(R) Graphics Gen9 [0x3e98] - Driver version 1.0.18513 - Device type gpu + Num Devices 1 + # 0 + Name Intel(R) Graphics Gen9 [0x3e98] + Version 1.0.18513 + Filter string level_zero:gpu:0 Args: verbosity (Literal[0,1,2], optional): diff --git a/dpctl/tests/test_sycl_platform.py b/dpctl/tests/test_sycl_platform.py index 0660617752..94098b5c94 100644 --- a/dpctl/tests/test_sycl_platform.py +++ b/dpctl/tests/test_sycl_platform.py @@ -112,6 +112,39 @@ def check_hash_in_dict(platform): assert map[platform] == 0 +list_of_platform_aspects = [ + "cpu", + "gpu", + "accelerator", + "custom", + "fp16", + "fp64", + "atomic64", + "image", + "online_compiler", + "online_linker", + "queue_profiling", + "usm_device_allocations", + "usm_host_allocations", + "usm_shared_allocations", + "usm_system_allocations", + "usm_atomic_host_allocations", + "usm_atomic_shared_allocations", + "host_debuggable", + "emulated", +] + + +def check_has_aspect(platform): + for asp in list_of_platform_aspects: + attr = "has_aspect_" + asp + try: + res = getattr(platform, attr) + except Exception: + pytest.fail(f"Encountered an exception inside platform.{attr}.") + assert isinstance(res, bool) + + list_of_checks = [ check_name, check_vendor, @@ -122,6 +155,7 @@ def check_hash_in_dict(platform): check_default_context, check_equal_and_hash, check_hash_in_dict, + check_has_aspect, ] @@ -260,6 +294,20 @@ def test_platform_get_devices_enum_device_type(): assert (d.device_type == dty for d in devices) +def test_platform_has_aspect_agrees_with_devices(): + """A platform has an aspect only if all of its devices have it.""" + platforms = dpctl.get_platforms() + if not platforms: + pytest.skip("No platforms available") + for p in platforms: + devices = p.get_devices() + for asp in list_of_platform_aspects: + attr = "has_aspect_" + asp + assert getattr(p, attr) == all( + getattr(d, attr) for d in devices + ), f"platform.{attr} disagrees with its devices" + + 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..10531bc55b 100644 --- a/libsyclinterface/include/syclinterface/dpctl_sycl_platform_interface.h +++ b/libsyclinterface/include/syclinterface/dpctl_sycl_platform_interface.h @@ -206,4 +206,18 @@ DPCTL_API __dpctl_give DPCTLDeviceVectorRef DPCTLPlatform_GetCompositeDevices(__dpctl_keep const DPCTLSyclPlatformRef PRef); +/*! + * @brief Checks if all devices associated with the platform have the given + * aspect. + * + * @param PRef Opaque pointer to a ``sycl::platform`` + * @param AT DPCTLSyclAspectType of ``device::aspect``. + * @return True if all ``sycl::device`` objects associated with the + * ``sycl::platform`` have the given ``device::aspect``, else false. + * @ingroup PlatformInterface + */ +DPCTL_API +bool DPCTLPlatform_HasAspect(__dpctl_keep const DPCTLSyclPlatformRef PRef, + DPCTLSyclAspectType AT); + DPCTL_C_EXTERN_C_END diff --git a/libsyclinterface/source/dpctl_sycl_platform_interface.cpp b/libsyclinterface/source/dpctl_sycl_platform_interface.cpp index d19d9844bb..b72adb3833 100644 --- a/libsyclinterface/source/dpctl_sycl_platform_interface.cpp +++ b/libsyclinterface/source/dpctl_sycl_platform_interface.cpp @@ -355,3 +355,22 @@ DPCTLPlatform_GetCompositeDevices(__dpctl_keep const DPCTLSyclPlatformRef PRef) return nullptr; } } + +bool DPCTLPlatform_HasAspect(__dpctl_keep const DPCTLSyclPlatformRef PRef, + DPCTLSyclAspectType AT) +{ + bool hasAspect = false; + auto P = unwrap(PRef); + if (P) { + try { + hasAspect = P->has(DPCTL_DPCTLAspectTypeToSyclAspect(AT)); + } catch (std::exception const &e) { + error_handler(e, __FILE__, __func__, __LINE__); + } + } + else { + error_handler("Aspect cannot be looked up for a NULL platform.", + __FILE__, __func__, __LINE__); + } + return hasAspect; +} diff --git a/libsyclinterface/tests/test_sycl_platform_interface.cpp b/libsyclinterface/tests/test_sycl_platform_interface.cpp index 67de6b9158..d0bdfa5c37 100644 --- a/libsyclinterface/tests/test_sycl_platform_interface.cpp +++ b/libsyclinterface/tests/test_sycl_platform_interface.cpp @@ -135,6 +135,59 @@ void check_platform_get_composite_devices( EXPECT_NO_FATAL_FAILURE(DPCTLDeviceVector_Delete(CDVRef)); } +const std::vector aspect_types = { + DPCTLSyclAspectType::cpu, + DPCTLSyclAspectType::gpu, + DPCTLSyclAspectType::accelerator, + DPCTLSyclAspectType::custom, + DPCTLSyclAspectType::fp16, + DPCTLSyclAspectType::fp64, + DPCTLSyclAspectType::atomic64, + DPCTLSyclAspectType::image, + DPCTLSyclAspectType::online_compiler, + DPCTLSyclAspectType::online_linker, + DPCTLSyclAspectType::queue_profiling, + DPCTLSyclAspectType::usm_device_allocations, + DPCTLSyclAspectType::usm_host_allocations, + DPCTLSyclAspectType::usm_shared_allocations, + DPCTLSyclAspectType::usm_system_allocations, + DPCTLSyclAspectType::usm_atomic_host_allocations, + DPCTLSyclAspectType::usm_atomic_shared_allocations, + DPCTLSyclAspectType::host_debuggable, + DPCTLSyclAspectType::emulated, +}; + +void check_platform_has_aspect(__dpctl_keep const DPCTLSyclPlatformRef PRef, + DPCTLSyclAspectType AT) +{ + // A platform reports an aspect only if every one of its devices does, + // so cross-check the C API result against the devices themselves. + DPCTLDeviceVectorRef DVRef = nullptr; + size_t nDevices = 0; + bool hasAspect = false; + + EXPECT_NO_FATAL_FAILURE(hasAspect = DPCTLPlatform_HasAspect(PRef, AT)); + + EXPECT_NO_FATAL_FAILURE( + DVRef = DPCTLPlatform_GetDevices(PRef, DPCTLSyclDeviceType::DPCTL_ALL)); + ASSERT_TRUE(DVRef != nullptr); + EXPECT_NO_FATAL_FAILURE(nDevices = DPCTLDeviceVector_Size(DVRef)); + + bool allDevicesHaveAspect = true; + for (auto i = 0ul; i < nDevices; ++i) { + DPCTLSyclDeviceRef DRef = nullptr; + EXPECT_NO_FATAL_FAILURE(DRef = DPCTLDeviceVector_GetAt(DVRef, i)); + ASSERT_TRUE(DRef != nullptr); + allDevicesHaveAspect = + allDevicesHaveAspect && DPCTLDevice_HasAspect(DRef, AT); + EXPECT_NO_FATAL_FAILURE(DPCTLDevice_Delete(DRef)); + } + EXPECT_EQ(hasAspect, allDevicesHaveAspect); + + EXPECT_NO_FATAL_FAILURE(DPCTLDeviceVector_Clear(DVRef)); + EXPECT_NO_FATAL_FAILURE(DPCTLDeviceVector_Delete(DVRef)); +} + } // namespace struct TestDPCTLSyclPlatformInterface @@ -220,6 +273,14 @@ TEST_F(TestDPCTLSyclPlatformNull, ChkGetVersion) ASSERT_TRUE(version == nullptr); } +TEST_F(TestDPCTLSyclPlatformNull, ChkHasAspect) +{ + bool hasAspect = true; + EXPECT_NO_FATAL_FAILURE(hasAspect = DPCTLPlatform_HasAspect( + NullPRef, DPCTLSyclAspectType::cpu)); + ASSERT_FALSE(hasAspect); +} + TEST_F(TestDPCTLSyclPlatformNull, ChkGetDefaultConext) { DPCTLSyclContextRef CRef = nullptr; @@ -335,6 +396,13 @@ TEST_P(TestDPCTLSyclPlatformInterface, ChkGetCompositeDevices) check_platform_get_composite_devices(PRef); } +TEST_P(TestDPCTLSyclPlatformInterface, ChkHasAspect) +{ + for (auto AT : aspect_types) { + check_platform_has_aspect(PRef, AT); + } +} + TEST_F(TestDPCTLSyclDefaultPlatform, ChkGetName) { check_platform_name(PRef); } TEST_F(TestDPCTLSyclDefaultPlatform, ChkGetVendor) @@ -352,6 +420,13 @@ TEST_F(TestDPCTLSyclDefaultPlatform, ChkGetBackend) check_platform_backend(PRef); } +TEST_F(TestDPCTLSyclDefaultPlatform, ChkHasAspect) +{ + for (auto AT : aspect_types) { + check_platform_has_aspect(PRef, AT); + } +} + TEST_F(TestDPCTLSyclDefaultPlatform, ChkGetInfo0) { const char *info_str = nullptr; From efd37c7334fc4b5ee5ce2070f97140108b5a48e9 Mon Sep 17 00:00:00 2001 From: Nikita Grigorian Date: Wed, 4 Nov 2026 11:21:46 -0800 Subject: [PATCH 2/2] address review of platform::has_aspect Cover is_component, is_composite and ext_oneapi_ipc_memory in the Python and C-API platform aspect tests, note empty platforms in the docstrings, document the false-on-error return, and add a changelog entry. --- CHANGELOG.md | 1 + dpctl/_sycl_platform.pyx | 87 ++++++++++--------- dpctl/tests/test_sycl_platform.py | 3 + .../dpctl_sycl_platform_interface.h | 3 +- .../tests/test_sycl_platform_interface.cpp | 3 + 5 files changed, 53 insertions(+), 44 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0aa6be7eab..81b2430f55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [dev] - XXX. XX, XXXX ### Added +* Added `dpctl.SyclPlatform.has_aspect_*` properties and the `DPCTLPlatform_HasAspect` C-API function for querying aspects supported by all devices of a platform [gh-2412](https://github.com/IntelPython/dpctl/pull/2412) ### Changed diff --git a/dpctl/_sycl_platform.pyx b/dpctl/_sycl_platform.pyx index 6f8c8833e0..fbf0ec57bb 100644 --- a/dpctl/_sycl_platform.pyx +++ b/dpctl/_sycl_platform.pyx @@ -317,8 +317,8 @@ cdef class SyclPlatform(_SyclPlatform): @property def has_aspect_cpu(self): - """ Returns ``True`` if all devices of this platform are CPU devices, - ``False`` otherwise. + """ Returns ``True`` if all devices of this platform (if any) are CPU + devices, ``False`` otherwise. :Example: @@ -338,8 +338,8 @@ cdef class SyclPlatform(_SyclPlatform): @property def has_aspect_gpu(self): - """ Returns ``True`` if all devices of this platform are GPU devices, - ``False`` otherwise. + """ Returns ``True`` if all devices of this platform (if any) are GPU + devices, ``False`` otherwise. Returns: bool: @@ -350,8 +350,8 @@ cdef class SyclPlatform(_SyclPlatform): @property def has_aspect_accelerator(self): - """ Returns ``True`` if all devices of this platform are accelerator - devices, ``False`` otherwise. + """ Returns ``True`` if all devices of this platform (if any) are + accelerator devices, ``False`` otherwise. SYCL considers an accelerator to be a device that usually uses a peripheral interconnect for communication. @@ -366,8 +366,8 @@ cdef class SyclPlatform(_SyclPlatform): @property def has_aspect_custom(self): - """ Returns ``True`` if all devices of this platform are custom - devices, ``False`` otherwise. + """ Returns ``True`` if all devices of this platform (if any) are + custom devices, ``False`` otherwise. A custom device can be a dedicated accelerator that can use the SYCL API, but programmable kernels cannot be dispatched to the device, @@ -383,7 +383,7 @@ cdef class SyclPlatform(_SyclPlatform): @property def has_aspect_fp16(self): - """ Returns ``True`` if all devices of this platform support + """ Returns ``True`` if all devices of this platform (if any) support half-precision floating point operations, ``False`` otherwise. Returns: @@ -396,8 +396,8 @@ cdef class SyclPlatform(_SyclPlatform): @property def has_aspect_fp64(self): - """ Returns ``True`` if all devices of this platform support 64-bit - precision floating point operations, ``False`` otherwise. + """ Returns ``True`` if all devices of this platform (if any) support + 64-bit precision floating point operations, ``False`` otherwise. Returns: bool: @@ -409,8 +409,8 @@ cdef class SyclPlatform(_SyclPlatform): @property def has_aspect_atomic64(self): - """ Returns ``True`` if all devices of this platform support a basic - set of atomic operations, ``False`` otherwise. + """ Returns ``True`` if all devices of this platform (if any) support a + basic set of atomic operations, ``False`` otherwise. Indicates that the devices support the following atomic operations on 64-bit values: @@ -433,8 +433,8 @@ cdef class SyclPlatform(_SyclPlatform): @property def has_aspect_image(self): - """ Returns ``True`` if all devices of this platform support images, - ``False`` otherwise (refer Sec 4.15.3 of SYCL 2020 spec). + """ Returns ``True`` if all devices of this platform (if any) support + images, ``False`` otherwise (refer Sec 4.15.3 of SYCL 2020 spec). Returns: bool: @@ -445,8 +445,8 @@ cdef class SyclPlatform(_SyclPlatform): @property def has_aspect_online_compiler(self): - """ Returns ``True`` if all devices of this platform support online - compilation of device code, ``False`` otherwise. + """ Returns ``True`` if all devices of this platform (if any) support + online compilation of device code, ``False`` otherwise. Returns: bool: @@ -458,8 +458,8 @@ cdef class SyclPlatform(_SyclPlatform): @property def has_aspect_online_linker(self): - """ Returns ``True`` if all devices of this platform support online - linking of device code, ``False`` otherwise. + """ Returns ``True`` if all devices of this platform (if any) support + online linking of device code, ``False`` otherwise. Returns: bool: @@ -471,8 +471,8 @@ cdef class SyclPlatform(_SyclPlatform): @property def has_aspect_queue_profiling(self): - """ Returns ``True`` if all devices of this platform support queue - profiling, ``False`` otherwise. + """ Returns ``True`` if all devices of this platform (if any) support + queue profiling, ``False`` otherwise. Returns: bool: @@ -484,8 +484,8 @@ cdef class SyclPlatform(_SyclPlatform): @property def has_aspect_usm_device_allocations(self): - """ Returns ``True`` if all devices of this platform support explicit - USM allocations, ``False`` otherwise. + """ Returns ``True`` if all devices of this platform (if any) support + explicit USM allocations, ``False`` otherwise. Returns: bool: @@ -497,8 +497,9 @@ cdef class SyclPlatform(_SyclPlatform): @property def has_aspect_usm_host_allocations(self): - """ Returns ``True`` if all devices of this platform can access USM - memory allocated via ``sycl::malloc_host``, ``False`` otherwise. + """ Returns ``True`` if all devices of this platform (if any) can + access USM memory allocated via ``sycl::malloc_host``, ``False`` + otherwise. Returns: bool: @@ -510,8 +511,8 @@ cdef class SyclPlatform(_SyclPlatform): @property def has_aspect_usm_shared_allocations(self): - """ Returns ``True`` if all devices of this platform support USM - memory allocated via ``sycl::malloc_shared``, ``False`` otherwise. + """ Returns ``True`` if all devices of this platform (if any) support + USM memory allocated via ``sycl::malloc_shared``, ``False`` otherwise. Returns: bool: @@ -525,7 +526,7 @@ cdef class SyclPlatform(_SyclPlatform): def has_aspect_usm_system_allocations(self): """ Returns ``True`` if the system allocator may be used instead of SYCL USM allocation mechanisms for ``shared`` allocations on all - devices of this platform, ``False`` otherwise. + devices of this platform (if any), ``False`` otherwise. Returns: bool: @@ -537,8 +538,8 @@ cdef class SyclPlatform(_SyclPlatform): @property def has_aspect_usm_atomic_host_allocations(self): - """ Returns ``True`` if all devices of this platform support USM - memory allocated via ``sycl::malloc_host`` and can be accessed + """ Returns ``True`` if all devices of this platform (if any) support + USM memory allocated via ``sycl::malloc_host`` and can be accessed atomically, ``False`` otherwise. Returns: @@ -552,8 +553,8 @@ cdef class SyclPlatform(_SyclPlatform): @property def has_aspect_usm_atomic_shared_allocations(self): - """ Returns ``True`` if all devices of this platform support USM - memory allocated via ``sycl::malloc_shared`` and can be accessed + """ Returns ``True`` if all devices of this platform (if any) support + USM memory allocated via ``sycl::malloc_shared`` and can be accessed atomically, ``False`` otherwise. Returns: @@ -567,8 +568,8 @@ cdef class SyclPlatform(_SyclPlatform): @property def has_aspect_host_debuggable(self): - """ Returns ``True`` if kernels running on all devices of this - platform can be debugged using standard debuggers that are normally + """ Returns ``True`` if kernels running on all devices of this platform + (if any) can be debugged using standard debuggers that are normally available on the host system, ``False`` otherwise. Returns: @@ -582,8 +583,8 @@ cdef class SyclPlatform(_SyclPlatform): @property def has_aspect_emulated(self): - """ Returns ``True`` if all devices of this platform are somehow - emulated, ``False`` otherwise. A device with this aspect is not + """ Returns ``True`` if all devices of this platform (if any) are + somehow emulated, ``False`` otherwise. A device with this aspect is not intended for performance, and instead will generally have another non-emulated platform as a better representation for performance. @@ -596,9 +597,9 @@ cdef class SyclPlatform(_SyclPlatform): @property def has_aspect_is_component(self): - """ Returns ``True`` if all devices of this platform are component - devices, ``False`` otherwise. A device with this aspect will have a - composite device from which it is descended. + """ Returns ``True`` if all devices of this platform (if any) are + component devices, ``False`` otherwise. A device with this aspect will + have a composite device from which it is descended. Returns: bool: @@ -609,9 +610,9 @@ cdef class SyclPlatform(_SyclPlatform): @property def has_aspect_is_composite(self): - """ Returns ``True`` if all devices of this platform are composite - devices, ``False`` otherwise. A device with this aspect contains - component devices. + """ Returns ``True`` if all devices of this platform (if any) are + composite devices, ``False`` otherwise. A device with this aspect + contains component devices. Returns: bool: @@ -622,7 +623,7 @@ cdef class SyclPlatform(_SyclPlatform): @property def has_aspect_ext_oneapi_ipc_memory(self): - """ Returns ``True`` if all devices of this platform support + """ Returns ``True`` if all devices of this platform (if any) support inter-process communication (IPC) memory handles, ``False`` otherwise. Returns: diff --git a/dpctl/tests/test_sycl_platform.py b/dpctl/tests/test_sycl_platform.py index 94098b5c94..82dd43f405 100644 --- a/dpctl/tests/test_sycl_platform.py +++ b/dpctl/tests/test_sycl_platform.py @@ -132,6 +132,9 @@ def check_hash_in_dict(platform): "usm_atomic_shared_allocations", "host_debuggable", "emulated", + "is_component", + "is_composite", + "ext_oneapi_ipc_memory", ] diff --git a/libsyclinterface/include/syclinterface/dpctl_sycl_platform_interface.h b/libsyclinterface/include/syclinterface/dpctl_sycl_platform_interface.h index 10531bc55b..bab306db5d 100644 --- a/libsyclinterface/include/syclinterface/dpctl_sycl_platform_interface.h +++ b/libsyclinterface/include/syclinterface/dpctl_sycl_platform_interface.h @@ -213,7 +213,8 @@ DPCTLPlatform_GetCompositeDevices(__dpctl_keep const DPCTLSyclPlatformRef PRef); * @param PRef Opaque pointer to a ``sycl::platform`` * @param AT DPCTLSyclAspectType of ``device::aspect``. * @return True if all ``sycl::device`` objects associated with the - * ``sycl::platform`` have the given ``device::aspect``, else false. + * ``sycl::platform`` have the given ``device::aspect``, else false. Also + * returns false if ``PRef`` is NULL or the aspect query throws. * @ingroup PlatformInterface */ DPCTL_API diff --git a/libsyclinterface/tests/test_sycl_platform_interface.cpp b/libsyclinterface/tests/test_sycl_platform_interface.cpp index d0bdfa5c37..75fca9628d 100644 --- a/libsyclinterface/tests/test_sycl_platform_interface.cpp +++ b/libsyclinterface/tests/test_sycl_platform_interface.cpp @@ -155,6 +155,9 @@ const std::vector aspect_types = { DPCTLSyclAspectType::usm_atomic_shared_allocations, DPCTLSyclAspectType::host_debuggable, DPCTLSyclAspectType::emulated, + DPCTLSyclAspectType::is_component, + DPCTLSyclAspectType::is_composite, + DPCTLSyclAspectType::ext_oneapi_ipc_memory, }; void check_platform_has_aspect(__dpctl_keep const DPCTLSyclPlatformRef PRef,