Skip to content

Always raise SubDeviceCreationError even when counts are zero #622

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions dpctl/_sycl_device.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -739,12 +739,12 @@ cdef class SyclDevice(_SyclDevice):
cdef DPCTLDeviceVectorRef DVRef = NULL
if count > 0:
DVRef = DPCTLDevice_CreateSubDevicesEqually(self._device_ref, count)
else:
raise ValueError(
"Creating sub-devices with zero compute units is requested"
)
if DVRef is NULL:
raise SubDeviceCreationError("Sub-devices were not created.")
raise SubDeviceCreationError(
"Sub-devices were not created." if (count > 0) else
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The line is magic! :) Python 🥇

"Sub-devices were not created, "
"requested compute units count was zero."
)
return _get_devices(DVRef)

cdef list create_sub_devices_by_counts(self, object counts):
Expand Down Expand Up @@ -778,12 +778,12 @@ cdef class SyclDevice(_SyclDevice):
self._device_ref, counts_buff, ncounts
)
free(counts_buff)
if min_count == 0:
raise ValueError(
"Targeted sub-device execution units must positive"
)
if DVRef is NULL:
raise SubDeviceCreationError("Sub-devices were not created.")
raise SubDeviceCreationError(
"Sub-devices were not created." if (min_count > 0) else
"Sub-devices were not created, "
"sub-device execution units counts must be positive."
)
return _get_devices(DVRef)

cdef list create_sub_devices_by_affinity(
Expand Down Expand Up @@ -866,7 +866,7 @@ cdef class SyclDevice(_SyclDevice):
raise TypeError(
"create_sub_devices(partition=parition_spec) is expected."
)
if isinstance(partition, int) and partition > 0:
if isinstance(partition, int) and partition >= 0:
return self.create_sub_devices_equally(partition)
elif isinstance(partition, str):
if partition == "not_applicable":
Expand Down