Skip to content

Commit 2bd1432

Browse files
author
Diptorup Deb
committed
Fix the docstrings for some of the SyclDevice aspect properties.
1 parent eb8ddb2 commit 2bd1432

File tree

1 file changed

+153
-35
lines changed

1 file changed

+153
-35
lines changed

dpctl/_sycl_device.pyx

Lines changed: 153 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ cdef class SyclDevice(_SyclDevice):
373373
Returns:
374374
device_type: The type of device encoded as a device_type enum.
375375
Raises:
376-
A ValueError is raised if the device type is not recognized.
376+
ValueError: If the device type is not recognized.
377377
"""
378378
cdef _device_type DTy = (
379379
DPCTLDevice_GetDeviceType(self._device_ref)
@@ -393,116 +393,199 @@ cdef class SyclDevice(_SyclDevice):
393393

394394
@property
395395
def has_aspect_host(self):
396-
"Returns True if this device is a host device, False otherwise"
396+
""" Returns True if this device is a host device, False otherwise.
397+
398+
Returns:
399+
bool: Indicates if the device is a host device.
400+
"""
397401
cdef _aspect_type AT = _aspect_type._host
398402
return DPCTLDevice_HasAspect(self._device_ref, AT)
399403

400404
@property
401405
def has_aspect_cpu(self):
402-
"Returns True if this device is a CPU device, False otherwise"
406+
""" Returns True if this device is a CPU device, False otherwise.
407+
408+
Returns:
409+
bool: Indicates if the device is a cpu.
410+
"""
403411
cdef _aspect_type AT = _aspect_type._cpu
404412
return DPCTLDevice_HasAspect(self._device_ref, AT)
405413

406414
@property
407415
def has_aspect_gpu(self):
408-
"Returns True if this device is a GPU device, False otherwise"
416+
""" Returns True if this device is a GPU device, False otherwise.
417+
418+
Returns:
419+
bool: Indicates if the device is a gpu.
420+
"""
409421
cdef _aspect_type AT = _aspect_type._gpu
410422
return DPCTLDevice_HasAspect(self._device_ref, AT)
411423

412424
@property
413425
def has_aspect_accelerator(self):
414-
"Returns True if this device is an accelerator device, False otherwise"
426+
""" Returns True if this device is an accelerator device, False
427+
otherwise.
428+
429+
SYCL considers an accelerator to be a device that usually uses a
430+
peripheral interconnect for communication.
431+
432+
Returns:
433+
bool: Indicates if the device is an accelerator.
434+
"""
415435
cdef _aspect_type AT = _aspect_type._accelerator
416436
return DPCTLDevice_HasAspect(self._device_ref, AT)
417437

418438
@property
419439
def has_aspect_custom(self):
420-
"Returns True if this device is a custom device, False otherwise"
440+
""" Returns True if this device is a custom device, False otherwise.
441+
442+
A custom device can be a dedicated accelerator that can use the
443+
SYCL API, but programmable kernels cannot be dispatched to the device,
444+
only fixed functionality is available. Refer SYCL spec for more details.
445+
446+
Returns:
447+
bool: Indicates if the device is a custom SYCL device.
448+
"""
421449
cdef _aspect_type AT = _aspect_type._custom
422450
return DPCTLDevice_HasAspect(self._device_ref, AT)
423451

424452
@property
425453
def has_aspect_fp16(self):
426-
""" Returns True if kernels submitted to this device
427-
may use 16-bit floating point types, False otherwise
454+
""" Returns True if the device supports half-precision floating point
455+
operations, False otherwise.
456+
457+
Returns:
458+
bool: Indicates that the device supports half precision floating
459+
point operations.
428460
"""
429461
cdef _aspect_type AT = _aspect_type._fp16
430462
return DPCTLDevice_HasAspect(self._device_ref, AT)
431463

432464
@property
433465
def has_aspect_fp64(self):
434-
""" Returns True if kernels submitted to this device
435-
may use 64-bit floating point types, False otherwise
466+
""" Returns True if the device supports 64-bit precision floating point
467+
operations, False otherwise.
468+
469+
Returns:
470+
bool: Indicates that the device supports 64-bit precision floating
471+
point operations.
436472
"""
437473
cdef _aspect_type AT = _aspect_type._fp64
438474
return DPCTLDevice_HasAspect(self._device_ref, AT)
439475

440476
@property
441477
def has_aspect_atomic64(self):
442-
""" Returns True if kernels submitted to this device
443-
may perform 64-bit atomic operations, False otherwise
478+
""" Returns true if the device supports a basic set of atomic
479+
operations, False otherwise.
480+
481+
Indicates that the device supports the following atomic operations on
482+
64-bit values:
483+
- atomic::load
484+
- atomic::store
485+
- atomic::fetch_add
486+
- atomic::fetch_sub
487+
- atomic::exchange
488+
- atomic::compare_exchange_strong
489+
- atomic::compare_exchange_weak
490+
491+
Returns:
492+
bool: Indicates that the device supports a basic set of atomic
493+
operations on 64-bit values.
444494
"""
445495
cdef _aspect_type AT = _aspect_type._atomic64
446496
return DPCTLDevice_HasAspect(self._device_ref, AT)
447497

448498
@property
449499
def has_aspect_image(self):
450-
""" Returns True if this device supports images, False otherwise
500+
""" Returns True if the device supports images, False otherwise (refer
501+
Sec 4.7.3 of SYCL 2020 spec).
502+
503+
Returns:
504+
bool: Indicates that the device supports images
451505
"""
452506
cdef _aspect_type AT = _aspect_type._image
453507
return DPCTLDevice_HasAspect(self._device_ref, AT)
454508

455509
@property
456510
def has_aspect_online_compiler(self):
457511
""" Returns True if this device supports online compilation of
458-
device code, False otherwise
512+
device code, False otherwise.
513+
514+
Returns:
515+
bool: Indicates that the device supports online compilation of
516+
device code.
459517
"""
460518
cdef _aspect_type AT = _aspect_type._online_compiler
461519
return DPCTLDevice_HasAspect(self._device_ref, AT)
462520

463521
@property
464522
def has_aspect_online_linker(self):
465523
""" Returns True if this device supports online linking of
466-
device code, False otherwise
524+
device code, False otherwise.
525+
526+
Returns:
527+
bool: Indicates that the device supports online linking of device
528+
code.
467529
"""
468530
cdef _aspect_type AT = _aspect_type._online_linker
469531
return DPCTLDevice_HasAspect(self._device_ref, AT)
470532

471533
@property
472534
def has_aspect_queue_profiling(self):
473535
""" Returns True if this device supports queue profiling,
474-
False otherwise
536+
False otherwise.
537+
538+
Returns:
539+
bool: Indicates that the device supports queue profiling.
475540
"""
476541
cdef _aspect_type AT = _aspect_type._queue_profiling
477542
return DPCTLDevice_HasAspect(self._device_ref, AT)
478543

479544
@property
480545
def has_aspect_usm_device_allocations(self):
481546
""" Returns True if this device supports explicit USM allocations,
482-
False otherwise
547+
False otherwise (refer Siction 4.8 of SYCL 2020 specs).
548+
549+
Returns:
550+
bool: Indicates that the device supports explicit USM allocations.
483551
"""
484552
cdef _aspect_type AT = _aspect_type._usm_device_allocations
485553
return DPCTLDevice_HasAspect(self._device_ref, AT)
486554

487555
@property
488556
def has_aspect_usm_host_allocations(self):
489557
""" Returns True if this device can access USM-host memory,
490-
False otherwise
558+
False otherwise (refer Siction 4.8 of SYCL 2020 specs).
559+
560+
Returns:
561+
bool: Indicates that the device can access USM memory
562+
allocated via ``usm::alloc::host``.
491563
"""
492564
cdef _aspect_type AT = _aspect_type._usm_host_allocations
493565
return DPCTLDevice_HasAspect(self._device_ref, AT)
494566

495567
@property
496568
def has_aspect_usm_shared_allocations(self):
497569
""" Returns True if this device supports USM-shared memory
498-
allocated on the same device, False otherwise
570+
allocated on the same device, False otherwise.
571+
572+
Returns:
573+
bool: Indicates that the device supports USM memory
574+
allocated via ``usm::alloc::shared``.
499575
"""
500576
cdef _aspect_type AT = _aspect_type._usm_shared_allocations
501577
return DPCTLDevice_HasAspect(self._device_ref, AT)
502578

503579
@property
504580
def has_aspect_usm_restricted_shared_allocations(self):
505-
""" Deprecated property, do not use.
581+
""" Returns True if this device supports USM memory
582+
allocated as restricted USM, False otherwise.
583+
584+
Returns:
585+
bool: Indicates that the device supports USM memory allocated via
586+
``usm::alloc::shared`` as restricted USM.
587+
588+
.. deprecated:: 0.14
506589
"""
507590
cdef _aspect_type AT = _aspect_type._usm_restricted_shared_allocations
508591
return DPCTLDevice_HasAspect(self._device_ref, AT)
@@ -511,7 +594,11 @@ cdef class SyclDevice(_SyclDevice):
511594
def has_aspect_usm_system_allocations(self):
512595
""" Returns True if system allocator may be used instead of SYCL USM
513596
allocation mechanism for USM-shared allocations on this device,
514-
False otherwise
597+
False otherwise.
598+
599+
Returns:
600+
bool: Indicates that system allocator may be used instead of SYCL
601+
``usm::alloc::shared``.
515602
"""
516603
cdef _aspect_type AT = _aspect_type._usm_system_allocations
517604
return DPCTLDevice_HasAspect(self._device_ref, AT)
@@ -650,6 +737,9 @@ cdef class SyclDevice(_SyclDevice):
650737
def max_work_item_dims(self):
651738
""" Returns the maximum dimensions that specify the global and local
652739
work-item IDs used by the data parallel execution model.
740+
741+
Returns:
742+
int: The maximum number of work items supported by the device.
653743
"""
654744
cdef uint32_t max_work_item_dims = 0
655745
max_work_item_dims = DPCTLDevice_GetMaxWorkItemDims(self._device_ref)
@@ -659,8 +749,12 @@ cdef class SyclDevice(_SyclDevice):
659749
def max_work_item_sizes1d(self):
660750
""" Returns the maximum number of work-items that are permitted in each
661751
dimension of the work-group of the nd_range<1>. The minimum value is
662-
`(1 )` for devices that are not of device type
663-
``info::device_type::custom``.
752+
`(1 )` for devices that evaluate to False for
753+
:py:attr:`~has_aspect_custom`.
754+
755+
Returns:
756+
tuple[int,]: A tuple with the maximum allowed value for a 1D range
757+
used to enqueue a kernel on the device.
664758
"""
665759
cdef size_t *max_work_item_sizes1d = NULL
666760
max_work_item_sizes1d = DPCTLDevice_GetMaxWorkItemSizes1d(
@@ -674,8 +768,12 @@ cdef class SyclDevice(_SyclDevice):
674768
def max_work_item_sizes2d(self):
675769
""" Returns the maximum number of work-items that are permitted in each
676770
dimension of the work-group of the nd_range<2>. The minimum value is
677-
`(1; 1)` for devices that are not of device type
678-
``info::device_type::custom``.
771+
`(1; 1)` for devices that evaluate to False for
772+
:py:attr:`~has_aspect_custom`.
773+
774+
Returns:
775+
tuple[int, int]: A tuple with the maximum allowed value for each
776+
dimension of a 2D range used to enqueue a kernel on the device.
679777
"""
680778
cdef size_t *max_work_item_sizes2d = NULL
681779
max_work_item_sizes2d = DPCTLDevice_GetMaxWorkItemSizes2d(
@@ -689,8 +787,12 @@ cdef class SyclDevice(_SyclDevice):
689787
def max_work_item_sizes3d(self):
690788
""" Returns the maximum number of work-items that are permitted in each
691789
dimension of the work-group of the nd_range<3>. The minimum value is
692-
`(1; 1; 1)` for devices that are not of device type
693-
``info::device_type::custom``.
790+
`(1; 1; 1)` for devices that evaluate to False for
791+
:py:attr:`~has_aspect_custom`.
792+
793+
Returns:
794+
tuple[int, int, int]: A tuple with the maximum allowed value for
795+
each dimension of a 3D range used to enqueue a kernel on the device.
694796
"""
695797
return (
696798
self._max_work_item_sizes[0],
@@ -702,8 +804,16 @@ cdef class SyclDevice(_SyclDevice):
702804
def max_work_item_sizes(self):
703805
""" Returns the maximum number of work-items that are permitted in each
704806
dimension of the work-group of the nd_range. The minimum value is
705-
`(1; 1; 1)` for devices that are not of device type
706-
``info::device_type::custom``.
807+
`(1; 1; 1)` for devices that evaluate to False for
808+
:py:attr:`~has_aspect_custom`.
809+
810+
Returns:
811+
tuple[int, int, int]: A tuple whose length depends on the number of
812+
workgrpup dimensions supported by the device.
813+
814+
.. deprecated:: 0.14
815+
The property is deprecated use :py:attr:`~max_work_item_sizes3d`
816+
instead.
707817
"""
708818
warnings.warn(
709819
"dpctl.SyclDevice.max_work_item_sizes is deprecated, "
@@ -720,17 +830,22 @@ cdef class SyclDevice(_SyclDevice):
720830
def max_compute_units(self):
721831
""" Returns the number of parallel compute units available to the
722832
device. The minimum value is 1.
833+
834+
Returns:
835+
int: The number of compute units in the device.
723836
"""
724837
cdef uint32_t max_compute_units = 0
725838
max_compute_units = DPCTLDevice_GetMaxComputeUnits(self._device_ref)
726839
return max_compute_units
727840

728841
@property
729842
def max_work_group_size(self):
730-
""" Returns the maximum number of work-items
731-
that are permitted in a work-group executing a
732-
kernel on a single compute unit. The minimum
843+
""" Returns the maximum number of work-items that are permitted in a
844+
work-group executing a kernel on a single compute unit. The minimum
733845
value is 1.
846+
847+
Returns:
848+
int: The maximum supported work group size.
734849
"""
735850
cdef uint32_t max_work_group_size = 0
736851
max_work_group_size = DPCTLDevice_GetMaxWorkGroupSize(self._device_ref)
@@ -755,8 +870,12 @@ cdef class SyclDevice(_SyclDevice):
755870

756871
@property
757872
def sub_group_independent_forward_progress(self):
758-
""" Returns true if the device supports independent forward progress of
873+
""" Returns True if the device supports independent forward progress of
759874
sub-groups with respect to other sub-groups in the same work-group.
875+
876+
Returns:
877+
bool: Indicates if the device supports independent forward progress
878+
of sub-groups.
760879
"""
761880
return DPCTLDevice_GetSubGroupIndependentForwardProgress(
762881
self._device_ref
@@ -1109,8 +1228,7 @@ cdef class SyclDevice(_SyclDevice):
11091228
Returns:
11101229
global_mem_cache_type: type of cache memory
11111230
Raises:
1112-
A RuntimeError is raised if an unrecognized memory type
1113-
is reported by runtime.
1231+
RuntimeError: If an unrecognized memory type is reported by runtime.
11141232
"""
11151233
cdef _global_mem_cache_type gmcTy = (
11161234
DPCTLDevice_GetGlobalMemCacheType(self._device_ref)

0 commit comments

Comments
 (0)