Skip to content

Commit efd37c7

Browse files
committed
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.
1 parent 56c4bb9 commit efd37c7

5 files changed

Lines changed: 53 additions & 44 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77
## [dev] - XXX. XX, XXXX
88

99
### Added
10+
* 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)
1011

1112
### Changed
1213

‎dpctl/_sycl_platform.pyx‎

Lines changed: 44 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ cdef class SyclPlatform(_SyclPlatform):
317317

318318
@property
319319
def has_aspect_cpu(self):
320-
""" Returns ``True`` if all devices of this platform are CPU devices,
321-
``False`` otherwise.
320+
""" Returns ``True`` if all devices of this platform (if any) are CPU
321+
devices, ``False`` otherwise.
322322
323323
:Example:
324324
@@ -338,8 +338,8 @@ cdef class SyclPlatform(_SyclPlatform):
338338

339339
@property
340340
def has_aspect_gpu(self):
341-
""" Returns ``True`` if all devices of this platform are GPU devices,
342-
``False`` otherwise.
341+
""" Returns ``True`` if all devices of this platform (if any) are GPU
342+
devices, ``False`` otherwise.
343343
344344
Returns:
345345
bool:
@@ -350,8 +350,8 @@ cdef class SyclPlatform(_SyclPlatform):
350350

351351
@property
352352
def has_aspect_accelerator(self):
353-
""" Returns ``True`` if all devices of this platform are accelerator
354-
devices, ``False`` otherwise.
353+
""" Returns ``True`` if all devices of this platform (if any) are
354+
accelerator devices, ``False`` otherwise.
355355
356356
SYCL considers an accelerator to be a device that usually uses a
357357
peripheral interconnect for communication.
@@ -366,8 +366,8 @@ cdef class SyclPlatform(_SyclPlatform):
366366

367367
@property
368368
def has_aspect_custom(self):
369-
""" Returns ``True`` if all devices of this platform are custom
370-
devices, ``False`` otherwise.
369+
""" Returns ``True`` if all devices of this platform (if any) are
370+
custom devices, ``False`` otherwise.
371371
372372
A custom device can be a dedicated accelerator that can use the
373373
SYCL API, but programmable kernels cannot be dispatched to the device,
@@ -383,7 +383,7 @@ cdef class SyclPlatform(_SyclPlatform):
383383

384384
@property
385385
def has_aspect_fp16(self):
386-
""" Returns ``True`` if all devices of this platform support
386+
""" Returns ``True`` if all devices of this platform (if any) support
387387
half-precision floating point operations, ``False`` otherwise.
388388
389389
Returns:
@@ -396,8 +396,8 @@ cdef class SyclPlatform(_SyclPlatform):
396396

397397
@property
398398
def has_aspect_fp64(self):
399-
""" Returns ``True`` if all devices of this platform support 64-bit
400-
precision floating point operations, ``False`` otherwise.
399+
""" Returns ``True`` if all devices of this platform (if any) support
400+
64-bit precision floating point operations, ``False`` otherwise.
401401
402402
Returns:
403403
bool:
@@ -409,8 +409,8 @@ cdef class SyclPlatform(_SyclPlatform):
409409

410410
@property
411411
def has_aspect_atomic64(self):
412-
""" Returns ``True`` if all devices of this platform support a basic
413-
set of atomic operations, ``False`` otherwise.
412+
""" Returns ``True`` if all devices of this platform (if any) support a
413+
basic set of atomic operations, ``False`` otherwise.
414414
415415
Indicates that the devices support the following atomic operations on
416416
64-bit values:
@@ -433,8 +433,8 @@ cdef class SyclPlatform(_SyclPlatform):
433433

434434
@property
435435
def has_aspect_image(self):
436-
""" Returns ``True`` if all devices of this platform support images,
437-
``False`` otherwise (refer Sec 4.15.3 of SYCL 2020 spec).
436+
""" Returns ``True`` if all devices of this platform (if any) support
437+
images, ``False`` otherwise (refer Sec 4.15.3 of SYCL 2020 spec).
438438
439439
Returns:
440440
bool:
@@ -445,8 +445,8 @@ cdef class SyclPlatform(_SyclPlatform):
445445

446446
@property
447447
def has_aspect_online_compiler(self):
448-
""" Returns ``True`` if all devices of this platform support online
449-
compilation of device code, ``False`` otherwise.
448+
""" Returns ``True`` if all devices of this platform (if any) support
449+
online compilation of device code, ``False`` otherwise.
450450
451451
Returns:
452452
bool:
@@ -458,8 +458,8 @@ cdef class SyclPlatform(_SyclPlatform):
458458

459459
@property
460460
def has_aspect_online_linker(self):
461-
""" Returns ``True`` if all devices of this platform support online
462-
linking of device code, ``False`` otherwise.
461+
""" Returns ``True`` if all devices of this platform (if any) support
462+
online linking of device code, ``False`` otherwise.
463463
464464
Returns:
465465
bool:
@@ -471,8 +471,8 @@ cdef class SyclPlatform(_SyclPlatform):
471471

472472
@property
473473
def has_aspect_queue_profiling(self):
474-
""" Returns ``True`` if all devices of this platform support queue
475-
profiling, ``False`` otherwise.
474+
""" Returns ``True`` if all devices of this platform (if any) support
475+
queue profiling, ``False`` otherwise.
476476
477477
Returns:
478478
bool:
@@ -484,8 +484,8 @@ cdef class SyclPlatform(_SyclPlatform):
484484

485485
@property
486486
def has_aspect_usm_device_allocations(self):
487-
""" Returns ``True`` if all devices of this platform support explicit
488-
USM allocations, ``False`` otherwise.
487+
""" Returns ``True`` if all devices of this platform (if any) support
488+
explicit USM allocations, ``False`` otherwise.
489489
490490
Returns:
491491
bool:
@@ -497,8 +497,9 @@ cdef class SyclPlatform(_SyclPlatform):
497497

498498
@property
499499
def has_aspect_usm_host_allocations(self):
500-
""" Returns ``True`` if all devices of this platform can access USM
501-
memory allocated via ``sycl::malloc_host``, ``False`` otherwise.
500+
""" Returns ``True`` if all devices of this platform (if any) can
501+
access USM memory allocated via ``sycl::malloc_host``, ``False``
502+
otherwise.
502503
503504
Returns:
504505
bool:
@@ -510,8 +511,8 @@ cdef class SyclPlatform(_SyclPlatform):
510511

511512
@property
512513
def has_aspect_usm_shared_allocations(self):
513-
""" Returns ``True`` if all devices of this platform support USM
514-
memory allocated via ``sycl::malloc_shared``, ``False`` otherwise.
514+
""" Returns ``True`` if all devices of this platform (if any) support
515+
USM memory allocated via ``sycl::malloc_shared``, ``False`` otherwise.
515516
516517
Returns:
517518
bool:
@@ -525,7 +526,7 @@ cdef class SyclPlatform(_SyclPlatform):
525526
def has_aspect_usm_system_allocations(self):
526527
""" Returns ``True`` if the system allocator may be used instead of
527528
SYCL USM allocation mechanisms for ``shared`` allocations on all
528-
devices of this platform, ``False`` otherwise.
529+
devices of this platform (if any), ``False`` otherwise.
529530
530531
Returns:
531532
bool:
@@ -537,8 +538,8 @@ cdef class SyclPlatform(_SyclPlatform):
537538

538539
@property
539540
def has_aspect_usm_atomic_host_allocations(self):
540-
""" Returns ``True`` if all devices of this platform support USM
541-
memory allocated via ``sycl::malloc_host`` and can be accessed
541+
""" Returns ``True`` if all devices of this platform (if any) support
542+
USM memory allocated via ``sycl::malloc_host`` and can be accessed
542543
atomically, ``False`` otherwise.
543544
544545
Returns:
@@ -552,8 +553,8 @@ cdef class SyclPlatform(_SyclPlatform):
552553

553554
@property
554555
def has_aspect_usm_atomic_shared_allocations(self):
555-
""" Returns ``True`` if all devices of this platform support USM
556-
memory allocated via ``sycl::malloc_shared`` and can be accessed
556+
""" Returns ``True`` if all devices of this platform (if any) support
557+
USM memory allocated via ``sycl::malloc_shared`` and can be accessed
557558
atomically, ``False`` otherwise.
558559
559560
Returns:
@@ -567,8 +568,8 @@ cdef class SyclPlatform(_SyclPlatform):
567568

568569
@property
569570
def has_aspect_host_debuggable(self):
570-
""" Returns ``True`` if kernels running on all devices of this
571-
platform can be debugged using standard debuggers that are normally
571+
""" Returns ``True`` if kernels running on all devices of this platform
572+
(if any) can be debugged using standard debuggers that are normally
572573
available on the host system, ``False`` otherwise.
573574
574575
Returns:
@@ -582,8 +583,8 @@ cdef class SyclPlatform(_SyclPlatform):
582583

583584
@property
584585
def has_aspect_emulated(self):
585-
""" Returns ``True`` if all devices of this platform are somehow
586-
emulated, ``False`` otherwise. A device with this aspect is not
586+
""" Returns ``True`` if all devices of this platform (if any) are
587+
somehow emulated, ``False`` otherwise. A device with this aspect is not
587588
intended for performance, and instead will generally have another
588589
non-emulated platform as a better representation for performance.
589590
@@ -596,9 +597,9 @@ cdef class SyclPlatform(_SyclPlatform):
596597

597598
@property
598599
def has_aspect_is_component(self):
599-
""" Returns ``True`` if all devices of this platform are component
600-
devices, ``False`` otherwise. A device with this aspect will have a
601-
composite device from which it is descended.
600+
""" Returns ``True`` if all devices of this platform (if any) are
601+
component devices, ``False`` otherwise. A device with this aspect will
602+
have a composite device from which it is descended.
602603
603604
Returns:
604605
bool:
@@ -609,9 +610,9 @@ cdef class SyclPlatform(_SyclPlatform):
609610

610611
@property
611612
def has_aspect_is_composite(self):
612-
""" Returns ``True`` if all devices of this platform are composite
613-
devices, ``False`` otherwise. A device with this aspect contains
614-
component devices.
613+
""" Returns ``True`` if all devices of this platform (if any) are
614+
composite devices, ``False`` otherwise. A device with this aspect
615+
contains component devices.
615616
616617
Returns:
617618
bool:
@@ -622,7 +623,7 @@ cdef class SyclPlatform(_SyclPlatform):
622623

623624
@property
624625
def has_aspect_ext_oneapi_ipc_memory(self):
625-
""" Returns ``True`` if all devices of this platform support
626+
""" Returns ``True`` if all devices of this platform (if any) support
626627
inter-process communication (IPC) memory handles, ``False`` otherwise.
627628
628629
Returns:

‎dpctl/tests/test_sycl_platform.py‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,9 @@ def check_hash_in_dict(platform):
132132
"usm_atomic_shared_allocations",
133133
"host_debuggable",
134134
"emulated",
135+
"is_component",
136+
"is_composite",
137+
"ext_oneapi_ipc_memory",
135138
]
136139

137140

‎libsyclinterface/include/syclinterface/dpctl_sycl_platform_interface.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ DPCTLPlatform_GetCompositeDevices(__dpctl_keep const DPCTLSyclPlatformRef PRef);
213213
* @param PRef Opaque pointer to a ``sycl::platform``
214214
* @param AT DPCTLSyclAspectType of ``device::aspect``.
215215
* @return True if all ``sycl::device`` objects associated with the
216-
* ``sycl::platform`` have the given ``device::aspect``, else false.
216+
* ``sycl::platform`` have the given ``device::aspect``, else false. Also
217+
* returns false if ``PRef`` is NULL or the aspect query throws.
217218
* @ingroup PlatformInterface
218219
*/
219220
DPCTL_API

‎libsyclinterface/tests/test_sycl_platform_interface.cpp‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ const std::vector<DPCTLSyclAspectType> aspect_types = {
155155
DPCTLSyclAspectType::usm_atomic_shared_allocations,
156156
DPCTLSyclAspectType::host_debuggable,
157157
DPCTLSyclAspectType::emulated,
158+
DPCTLSyclAspectType::is_component,
159+
DPCTLSyclAspectType::is_composite,
160+
DPCTLSyclAspectType::ext_oneapi_ipc_memory,
158161
};
159162

160163
void check_platform_has_aspect(__dpctl_keep const DPCTLSyclPlatformRef PRef,

0 commit comments

Comments
 (0)