Skip to content
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

Handle possible NULL return from DPCTLDevice_GetMaxWorkGroupSize1d, 2d #1690

Merged
merged 1 commit into from
May 22, 2024
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
14 changes: 13 additions & 1 deletion dpctl/_sycl_device.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -193,13 +193,21 @@ cdef str _device_type_to_filter_string_part(_device_type DTy):
return "unknown"


cdef void _init_helper(_SyclDevice device, DPCTLSyclDeviceRef DRef):
cdef void _init_helper(_SyclDevice device, DPCTLSyclDeviceRef DRef) except *:
"Populate attributes of device from opaque device reference DRef"
device._device_ref = DRef
device._name = DPCTLDevice_GetName(DRef)
if device._name is NULL:
raise RuntimeError("Descriptor 'name' not available")
device._driver_version = DPCTLDevice_GetDriverVersion(DRef)
if device._driver_version is NULL:
raise RuntimeError("Descriptor 'driver_version' not available")
device._vendor = DPCTLDevice_GetVendor(DRef)
if device._vendor is NULL:
raise RuntimeError("Descriptor 'vendor' not available")
device._max_work_item_sizes = DPCTLDevice_GetMaxWorkItemSizes3d(DRef)
if device._max_work_item_sizes is NULL:
raise RuntimeError("Descriptor 'max_work_item_sizes3d' not available")


@functools.lru_cache(maxsize=None)
Expand Down Expand Up @@ -938,6 +946,8 @@ cdef class SyclDevice(_SyclDevice):
max_work_item_sizes1d = DPCTLDevice_GetMaxWorkItemSizes1d(
self._device_ref
)
if max_work_item_sizes1d is NULL:
raise RuntimeError("error obtaining 'max_work_item_sizes1d'")
s0 = max_work_item_sizes1d[0]
DPCTLSize_t_Array_Delete(max_work_item_sizes1d)
return (s0, )
Expand All @@ -960,6 +970,8 @@ cdef class SyclDevice(_SyclDevice):
max_work_item_sizes2d = DPCTLDevice_GetMaxWorkItemSizes2d(
self._device_ref
)
if max_work_item_sizes2d is NULL:
raise RuntimeError("error obtaining 'max_work_item_sizes2d'")
s0 = max_work_item_sizes2d[0]
s1 = max_work_item_sizes2d[1]
DPCTLSize_t_Array_Delete(max_work_item_sizes2d)
Expand Down