Skip to content
Merged
57 changes: 57 additions & 0 deletions dpctl/sycl_core.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@ cdef class SyclContext:
cdef DPPLSyclContextRef get_context_ref (self):
return self._ctxt_ref

def addressof_ref (self):
"""Returns the address of the DPPLSyclContextRef pointer as a
long.

Returns:
The address of the DPPLSyclContextRef object used to create this
SyclContext cast to a long.
"""
return int(<long>self._ctx_ref)

cdef class SyclDevice:
''' Wrapper class for a Sycl Device
Expand Down Expand Up @@ -163,6 +172,15 @@ cdef class SyclDevice:
'''
return self._device_ref

def addressof_ref (self):
"""Returns the address of the DPPLSyclDeviceRef pointer as a
long.

Returns:
The address of the DPPLSyclDeviceRef object used to create this
SyclDevice cast to a long.
"""
return int(<long>self._device_ref)

cdef class SyclEvent:
''' Wrapper class for a Sycl Event
Expand All @@ -187,6 +205,16 @@ cdef class SyclEvent:
cpdef void wait (self):
DPPLEvent_Wait(self._event_ref)

def addressof_ref (self):
"""Returns the address of the C API DPPLSyclEventRef pointer as
a long.

Returns:
The address of the DPPLSyclEventRef object used to create this
SyclEvent cast to a long.
"""
return int(<long>self._event_ref)


cdef class SyclKernel:
''' Wraps a sycl::kernel object created from an OpenCL interoperability
Expand Down Expand Up @@ -219,6 +247,15 @@ cdef class SyclKernel:
'''
return self._kernel_ref

def addressof_ref (self):
"""Returns the address of the C API DPPLSyclKernelRef pointer
as a long.

Returns:
The address of the DPPLSyclKernelRef object used to create this
SyclKernel cast to a long.
"""
return int(<long>self._kernel_ref)

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

def addressof_ref (self):
"""Returns the address of the C API DPPLSyclProgramRef pointer
as a long.

Returns:
The address of the DPPLSyclProgramRef object used to create this
SyclProgram cast to a long.
"""
return int(<long>self._program_ref)
Copy link
Contributor

Choose a reason for hiding this comment

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

@PokhodenkoSA @diptorupd

Long is not good here. It is a 32-bit integer on Windows. We should be using <size_t> instead.


import ctypes

cdef class SyclQueue:
Expand Down Expand Up @@ -380,6 +427,16 @@ cdef class SyclQueue:
cdef DPPLSyclQueueRef get_queue_ref (self):
return self._queue_ref

def addressof_ref (self):
"""Returns the address of the C API DPPLSyclQueueRef pointer as
a long.

Returns:
The address of the DPPLSyclQueueRef object used to create this
SyclQueue cast to a long.
"""
return int(<long>self._queue_ref)

cpdef SyclEvent submit (self, SyclKernel kernel, list args, list gS, \
list lS = None, list dEvents = None):

Expand Down