Skip to content

Commit fc24fe9

Browse files
Exposed dpctl.SyclDevice.partition_max_sub_devices property
This change closes #1004.
1 parent f1c3869 commit fc24fe9

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

dpctl/_backend.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ cdef extern from "syclinterface/dpctl_sycl_device_interface.h":
206206
const DPCTLSyclDeviceRef DRef)
207207
cdef size_t *DPCTLDevice_GetSubGroupSizes(const DPCTLSyclDeviceRef DRef,
208208
size_t *res_len)
209+
cdef uint32_t DPCTLDevice_GetPartitionMaxSubDevices(const DPCTLSyclDeviceRef DRef)
209210

210211

211212
cdef extern from "syclinterface/dpctl_sycl_device_manager.h":

dpctl/_sycl_device.pyx

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ from ._backend cimport ( # noqa: E211
5555
DPCTLDevice_GetMaxWriteImageArgs,
5656
DPCTLDevice_GetName,
5757
DPCTLDevice_GetParentDevice,
58+
DPCTLDevice_GetPartitionMaxSubDevices,
5859
DPCTLDevice_GetPlatform,
5960
DPCTLDevice_GetPreferredVectorWidthChar,
6061
DPCTLDevice_GetPreferredVectorWidthDouble,
@@ -1292,9 +1293,25 @@ cdef class SyclDevice(_SyclDevice):
12921293
"""
12931294
cdef uint64_t cache_line_sz = DPCTLDevice_GetGlobalMemCacheLineSize(
12941295
self._device_ref
1295-
)
1296+
)
12961297
return cache_line_sz
12971298

1299+
@property
1300+
def partition_max_sub_devices(self):
1301+
""" The maximum number of sub-devices this :class:`dpctl.SyclDevice`
1302+
instance can be partitioned into. The value returned cannot exceed the
1303+
value returned by :attr:`dpctl.SyclDevice.max_compute_units`.
1304+
1305+
Returns:
1306+
int: The maximum number of sub-devices that can be created when this
1307+
device is partitioned. Zero value indicates that device can not
1308+
be partitioned.
1309+
"""
1310+
cdef uint32_t max_part = DPCTLDevice_GetPartitionMaxSubDevices(
1311+
self._device_ref
1312+
)
1313+
return max_part
1314+
12981315
cdef cpp_bool equals(self, SyclDevice other):
12991316
""" Returns ``True`` if the :class:`dpctl.SyclDevice` argument has the
13001317
same _device_ref as this SyclDevice.

dpctl/tests/_device_attributes_checks.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,13 @@ def check_parent_device(device):
540540
assert pd is None or isinstance(pd, dpctl.SyclDevice)
541541

542542

543+
def check_partition_max_sub_devices(device):
544+
max_part = device.partition_max_sub_devices
545+
assert isinstance(max_part, int)
546+
assert max_part >= 0
547+
assert max_part <= device.max_compute_units
548+
549+
543550
def check_filter_string(device):
544551
try:
545552
fs = device.filter_string
@@ -670,6 +677,7 @@ def check_global_mem_cache_line_size(device):
670677
check_profiling_timer_resolution,
671678
check_platform,
672679
check_parent_device,
680+
check_partition_max_sub_devices,
673681
check_filter_string,
674682
check_vendor,
675683
check_driver_version,

0 commit comments

Comments
 (0)