Skip to content

Commit 3666293

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

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

dpctl/_sycl_device.pyx

Lines changed: 10 additions & 10 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(

0 commit comments

Comments
 (0)