Skip to content

Commit 451ca50

Browse files
Feature/get ref address (#105)
* Rename all functions to addressof_ref and add docstring. Co-authored-by: reazul.hoque <reazul.hoque@intel.com>
1 parent d10f0e3 commit 451ca50

File tree

1 file changed

+57
-0
lines changed

1 file changed

+57
-0
lines changed

dpctl/sycl_core.pyx

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,15 @@ cdef class SyclContext:
105105
cdef DPPLSyclContextRef get_context_ref (self):
106106
return self._ctxt_ref
107107

108+
def addressof_ref (self):
109+
"""Returns the address of the DPPLSyclContextRef pointer as a
110+
long.
111+
112+
Returns:
113+
The address of the DPPLSyclContextRef object used to create this
114+
SyclContext cast to a long.
115+
"""
116+
return int(<long>self._ctx_ref)
108117

109118
cdef class SyclDevice:
110119
''' Wrapper class for a Sycl Device
@@ -163,6 +172,15 @@ cdef class SyclDevice:
163172
'''
164173
return self._device_ref
165174

175+
def addressof_ref (self):
176+
"""Returns the address of the DPPLSyclDeviceRef pointer as a
177+
long.
178+
179+
Returns:
180+
The address of the DPPLSyclDeviceRef object used to create this
181+
SyclDevice cast to a long.
182+
"""
183+
return int(<long>self._device_ref)
166184

167185
cdef class SyclEvent:
168186
''' Wrapper class for a Sycl Event
@@ -187,6 +205,16 @@ cdef class SyclEvent:
187205
cpdef void wait (self):
188206
DPPLEvent_Wait(self._event_ref)
189207

208+
def addressof_ref (self):
209+
"""Returns the address of the C API DPPLSyclEventRef pointer as
210+
a long.
211+
212+
Returns:
213+
The address of the DPPLSyclEventRef object used to create this
214+
SyclEvent cast to a long.
215+
"""
216+
return int(<long>self._event_ref)
217+
190218

191219
cdef class SyclKernel:
192220
''' Wraps a sycl::kernel object created from an OpenCL interoperability
@@ -219,6 +247,15 @@ cdef class SyclKernel:
219247
'''
220248
return self._kernel_ref
221249

250+
def addressof_ref (self):
251+
"""Returns the address of the C API DPPLSyclKernelRef pointer
252+
as a long.
253+
254+
Returns:
255+
The address of the DPPLSyclKernelRef object used to create this
256+
SyclKernel cast to a long.
257+
"""
258+
return int(<long>self._kernel_ref)
222259

223260
cdef class SyclProgram:
224261
''' Wraps a sycl::program object created from an OpenCL interoperability
@@ -250,6 +287,16 @@ cdef class SyclProgram:
250287
name = kernel_name.encode('utf8')
251288
return DPPLProgram_HasKernel(self._program_ref, name)
252289

290+
def addressof_ref (self):
291+
"""Returns the address of the C API DPPLSyclProgramRef pointer
292+
as a long.
293+
294+
Returns:
295+
The address of the DPPLSyclProgramRef object used to create this
296+
SyclProgram cast to a long.
297+
"""
298+
return int(<long>self._program_ref)
299+
253300
import ctypes
254301

255302
cdef class SyclQueue:
@@ -380,6 +427,16 @@ cdef class SyclQueue:
380427
cdef DPPLSyclQueueRef get_queue_ref (self):
381428
return self._queue_ref
382429

430+
def addressof_ref (self):
431+
"""Returns the address of the C API DPPLSyclQueueRef pointer as
432+
a long.
433+
434+
Returns:
435+
The address of the DPPLSyclQueueRef object used to create this
436+
SyclQueue cast to a long.
437+
"""
438+
return int(<long>self._queue_ref)
439+
383440
cpdef SyclEvent submit (self, SyclKernel kernel, list args, list gS, \
384441
list lS = None, list dEvents = None):
385442

0 commit comments

Comments
 (0)