Skip to content

Commit f563d87

Browse files
SyclDevice.create_sub_devices checks partition argument better
Use of zero EU counts now raises and error.
1 parent 54c61a4 commit f563d87

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

dpctl/_sycl_device.pyx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,12 @@ cdef class SyclDevice(_SyclDevice):
706706
the sub-devices.
707707
"""
708708
cdef DPCTLDeviceVectorRef DVRef = NULL
709-
DVRef = DPCTLDevice_CreateSubDevicesEqually(self._device_ref, count)
709+
if count > 0:
710+
DVRef = DPCTLDevice_CreateSubDevicesEqually(self._device_ref, count)
711+
else:
712+
raise ValueError(
713+
"Creating sub-devices with zero compute units is requested"
714+
)
710715
if DVRef is NULL:
711716
raise SubDeviceCreationError("Sub-devices were not created.")
712717
return _get_devices(DVRef)
@@ -720,6 +725,7 @@ cdef class SyclDevice(_SyclDevice):
720725
"""
721726
cdef int ncounts = len(counts)
722727
cdef size_t *counts_buff = NULL
728+
cdef size_t min_count = 1
723729
cdef DPCTLDeviceVectorRef DVRef = NULL
724730
cdef int i
725731

@@ -734,10 +740,17 @@ cdef class SyclDevice(_SyclDevice):
734740
)
735741
for i in range(ncounts):
736742
counts_buff[i] = counts[i]
737-
DVRef = DPCTLDevice_CreateSubDevicesByCounts(
738-
self._device_ref, counts_buff, ncounts
739-
)
743+
if counts_buff[i] == 0:
744+
min_count = 0
745+
if min_count:
746+
DVRef = DPCTLDevice_CreateSubDevicesByCounts(
747+
self._device_ref, counts_buff, ncounts
748+
)
740749
free(counts_buff)
750+
if min_count == 0:
751+
raise ValueError(
752+
"Targeted sub-device execution units must positive"
753+
)
741754
if DVRef is NULL:
742755
raise SubDeviceCreationError("Sub-devices were not created.")
743756
return _get_devices(DVRef)

0 commit comments

Comments
 (0)