Skip to content

Commit cf618ec

Browse files
Always raise SubDeviceCreationError even when counts are zero
1 parent d469c84 commit cf618ec

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

dpctl/_sycl_device.pyx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -739,12 +739,12 @@ cdef class SyclDevice(_SyclDevice):
739739
cdef DPCTLDeviceVectorRef DVRef = NULL
740740
if count > 0:
741741
DVRef = DPCTLDevice_CreateSubDevicesEqually(self._device_ref, count)
742-
else:
743-
raise ValueError(
744-
"Creating sub-devices with zero compute units is requested"
745-
)
746742
if DVRef is NULL:
747-
raise SubDeviceCreationError("Sub-devices were not created.")
743+
raise SubDeviceCreationError(
744+
"Sub-devices were not created." if (count > 0) else
745+
"Sub-devices were not created, "
746+
"requested compute units count was zero."
747+
)
748748
return _get_devices(DVRef)
749749

750750
cdef list create_sub_devices_by_counts(self, object counts):
@@ -778,12 +778,12 @@ cdef class SyclDevice(_SyclDevice):
778778
self._device_ref, counts_buff, ncounts
779779
)
780780
free(counts_buff)
781-
if min_count == 0:
782-
raise ValueError(
783-
"Targeted sub-device execution units must positive"
784-
)
785781
if DVRef is NULL:
786-
raise SubDeviceCreationError("Sub-devices were not created.")
782+
raise SubDeviceCreationError(
783+
"Sub-devices were not created." if (min_count > 0) else
784+
"Sub-devices were not created, "
785+
"sub-device execution units counts must be positive."
786+
)
787787
return _get_devices(DVRef)
788788

789789
cdef list create_sub_devices_by_affinity(
@@ -866,7 +866,7 @@ cdef class SyclDevice(_SyclDevice):
866866
raise TypeError(
867867
"create_sub_devices(partition=parition_spec) is expected."
868868
)
869-
if isinstance(partition, int) and partition > 0:
869+
if isinstance(partition, int) and partition >= 0:
870870
return self.create_sub_devices_equally(partition)
871871
elif isinstance(partition, str):
872872
if partition == "not_applicable":

0 commit comments

Comments
 (0)