Skip to content

Commit 49eaea9

Browse files
Static methods _init_helper made into functions
and removed from PXD files
1 parent 8a55469 commit 49eaea9

File tree

6 files changed

+29
-34
lines changed

6 files changed

+29
-34
lines changed

dpctl/_sycl_context.pxd

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ cdef public class SyclContext(_SyclContext) [object PySyclContextObject, type Py
3838

3939
@staticmethod
4040
cdef SyclContext _create (DPCTLSyclContextRef CRef)
41-
@staticmethod
42-
cdef void _init_helper(_SyclContext self, DPCTLSyclContextRef CRef)
4341
cdef int _init_context_from__SyclContext(self, _SyclContext other)
4442
cdef int _init_context_from_one_device(self, SyclDevice device, int props)
4543
cdef int _init_context_from_devices(self, object devices, int props)

dpctl/_sycl_context.pyx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ cdef void _context_capsule_deleter(object o):
6565
DPCTLContext_Delete(CRef)
6666

6767

68+
cdef void _init_helper(_SyclContext context, DPCTLSyclContextRef CRef):
69+
"Populate context attributes from opaque reference CRef"
70+
context._ctxt_ref = CRef
71+
72+
6873
cdef class _SyclContext:
6974
""" Data owner for SyclContext
7075
"""
@@ -157,11 +162,6 @@ cdef class SyclContext(_SyclContext):
157162
be renamed.
158163
159164
"""
160-
161-
@staticmethod
162-
cdef void _init_helper(_SyclContext context, DPCTLSyclContextRef CRef):
163-
context._ctxt_ref = CRef
164-
165165
@staticmethod
166166
cdef SyclContext _create(DPCTLSyclContextRef ctxt):
167167
"""
@@ -170,7 +170,7 @@ cdef class SyclContext(_SyclContext):
170170
Users should pass a copy if they intend to keep the argument ctxt alive.
171171
"""
172172
cdef _SyclContext ret = <_SyclContext>_SyclContext.__new__(_SyclContext)
173-
SyclContext._init_helper(ret, ctxt)
173+
_init_helper(ret, ctxt)
174174
return SyclContext(ret)
175175

176176
cdef int _init_context_from__SyclContext(self, _SyclContext other):
@@ -191,7 +191,7 @@ cdef class SyclContext(_SyclContext):
191191
CRef = DPCTLContext_Create(DRef, eh_callback, props)
192192
if (CRef is NULL):
193193
return -1
194-
SyclContext._init_helper(<_SyclContext> self, CRef)
194+
_init_helper(<_SyclContext> self, CRef)
195195
return 0
196196

197197
cdef int _init_context_from_devices(self, object devices, int props):
@@ -231,7 +231,7 @@ cdef class SyclContext(_SyclContext):
231231
DPCTLDeviceVector_Delete(DVRef)
232232
if (CRef is NULL):
233233
return -1
234-
SyclContext._init_helper(<_SyclContext> self, CRef)
234+
_init_helper(<_SyclContext> self, CRef)
235235
return 0
236236

237237
cdef int _init_context_from_capsule(self, object cap):

dpctl/_sycl_device.pxd

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ cdef class _SyclDevice:
4242
cdef public class SyclDevice(_SyclDevice) [object PySyclDeviceObject, type PySyclDeviceType]:
4343
@staticmethod
4444
cdef SyclDevice _create(DPCTLSyclDeviceRef dref)
45-
@staticmethod
46-
cdef void _init_helper(_SyclDevice device, DPCTLSyclDeviceRef DRef)
4745
cdef int _init_from__SyclDevice(self, _SyclDevice other)
4846
cdef int _init_from_selector(self, DPCTLSyclDeviceSelectorRef DSRef)
4947
cdef DPCTLSyclDeviceRef get_device_ref(self)

dpctl/_sycl_device.pyx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,14 @@ cdef str _device_type_to_filter_string_part(_device_type DTy):
162162
else:
163163
return "unknown"
164164

165+
cdef void _init_helper(_SyclDevice device, DPCTLSyclDeviceRef DRef):
166+
"Populate attributes of device from opaque device reference DRef"
167+
device._device_ref = DRef
168+
device._name = DPCTLDevice_GetName(DRef)
169+
device._driver_version = DPCTLDevice_GetDriverVersion(DRef)
170+
device._vendor = DPCTLDevice_GetVendor(DRef)
171+
device._max_work_item_sizes = DPCTLDevice_GetMaxWorkItemSizes(DRef)
172+
165173

166174
cdef class SyclDevice(_SyclDevice):
167175
""" SyclDevice(arg=None)
@@ -203,14 +211,6 @@ cdef class SyclDevice(_SyclDevice):
203211
gpu.print_device_info()
204212
205213
"""
206-
@staticmethod
207-
cdef void _init_helper(_SyclDevice device, DPCTLSyclDeviceRef DRef):
208-
device._device_ref = DRef
209-
device._name = DPCTLDevice_GetName(DRef)
210-
device._driver_version = DPCTLDevice_GetDriverVersion(DRef)
211-
device._vendor = DPCTLDevice_GetVendor(DRef)
212-
device._max_work_item_sizes = DPCTLDevice_GetMaxWorkItemSizes(DRef)
213-
214214
@staticmethod
215215
cdef SyclDevice _create(DPCTLSyclDeviceRef dref):
216216
"""
@@ -221,7 +221,7 @@ cdef class SyclDevice(_SyclDevice):
221221
"""
222222
cdef _SyclDevice ret = _SyclDevice.__new__(_SyclDevice)
223223
# Initialize the attributes of the SyclDevice object
224-
SyclDevice._init_helper(<_SyclDevice> ret, dref)
224+
_init_helper(<_SyclDevice> ret, dref)
225225
# ret is a temporary, and _SyclDevice.__dealloc__ will delete dref
226226
return SyclDevice(ret)
227227

@@ -245,7 +245,7 @@ cdef class SyclDevice(_SyclDevice):
245245
if DRef is NULL:
246246
return -1
247247
else:
248-
SyclDevice._init_helper(self, DRef)
248+
_init_helper(self, DRef)
249249
return 0
250250

251251
def __cinit__(self, arg=None):

dpctl/_sycl_platform.pxd

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ cdef class _SyclPlatform:
3636
cdef class SyclPlatform(_SyclPlatform):
3737
@staticmethod
3838
cdef SyclPlatform _create(DPCTLSyclPlatformRef dref)
39-
@staticmethod
40-
cdef void _init_helper(_SyclPlatform platform, DPCTLSyclPlatformRef DRef)
4139
cdef int _init_from_cstring(self, const char *string)
4240
cdef int _init_from_selector(self, DPCTLSyclDeviceSelectorRef DSRef)
4341
cdef int _init_from__SyclPlatform(self, _SyclPlatform other)

dpctl/_sycl_platform.pyx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,14 @@ cdef class _SyclPlatform:
6565
DPCTLCString_Delete(self._version)
6666

6767

68+
cdef void _init_helper(_SyclPlatform platform, DPCTLSyclPlatformRef PRef):
69+
"Populate attributes of class from opaque reference PRef"
70+
platform._platform_ref = PRef
71+
platform._name = DPCTLPlatform_GetName(PRef)
72+
platform._version = DPCTLPlatform_GetVersion(PRef)
73+
platform._vendor = DPCTLPlatform_GetVendor(PRef)
74+
75+
6876
cdef class SyclPlatform(_SyclPlatform):
6977
""" SyclPlatform(self, arg=None)
7078
Python class representing ``cl::sycl::platform`` class.
@@ -73,13 +81,6 @@ cdef class SyclPlatform(_SyclPlatform):
7381
SyclPlatform(filter_selector) - create platform selected by filter
7482
selector
7583
"""
76-
@staticmethod
77-
cdef void _init_helper(_SyclPlatform platform, DPCTLSyclPlatformRef PRef):
78-
platform._platform_ref = PRef
79-
platform._name = DPCTLPlatform_GetName(PRef)
80-
platform._version = DPCTLPlatform_GetVersion(PRef)
81-
platform._vendor = DPCTLPlatform_GetVendor(PRef)
82-
8384
@staticmethod
8485
cdef SyclPlatform _create(DPCTLSyclPlatformRef pref):
8586
"""
@@ -90,7 +91,7 @@ cdef class SyclPlatform(_SyclPlatform):
9091
"""
9192
cdef _SyclPlatform p = _SyclPlatform.__new__(_SyclPlatform)
9293
# Initialize the attributes of the SyclPlatform object
93-
SyclPlatform._init_helper(<_SyclPlatform>p, pref)
94+
_init_helper(<_SyclPlatform>p, pref)
9495
return SyclPlatform(p)
9596

9697
cdef int _init_from__SyclPlatform(self, _SyclPlatform other):
@@ -114,7 +115,7 @@ cdef class SyclPlatform(_SyclPlatform):
114115
if PRef is NULL:
115116
return -1
116117
else:
117-
SyclPlatform._init_helper(self, PRef)
118+
_init_helper(self, PRef)
118119
return 0
119120

120121
cdef DPCTLSyclPlatformRef get_platform_ref(self):
@@ -169,7 +170,7 @@ cdef class SyclPlatform(_SyclPlatform):
169170
"Could not create a SyclPlatform from default selector"
170171
)
171172
else:
172-
SyclPlatform._init_helper(self, PRef)
173+
_init_helper(self, PRef)
173174
else:
174175
raise ValueError(
175176
"Invalid argument. Argument should be a str object specifying "

0 commit comments

Comments
 (0)