Skip to content

Commit 9197366

Browse files
Merge pull request #533 from IntelPython/feature/public-defs
Use public for data owning class definitions
2 parents 8cd2c51 + 7e14c55 commit 9197366

File tree

6 files changed

+44
-7
lines changed

6 files changed

+44
-7
lines changed

dpctl/_sycl_context.pxd

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,19 @@ from ._backend cimport DPCTLSyclContextRef
2626
from ._sycl_device cimport SyclDevice
2727

2828

29-
cdef class _SyclContext:
29+
cdef public class _SyclContext [
30+
object Py_SyclContextObject,
31+
type Py_SyclContextType
32+
]:
3033
""" Data owner for SyclContext
3134
"""
3235
cdef DPCTLSyclContextRef _ctxt_ref
3336

3437

35-
cdef public class SyclContext(_SyclContext) [object PySyclContextObject, type PySyclContextType]:
38+
cdef public class SyclContext(_SyclContext) [
39+
object PySyclContextObject,
40+
type PySyclContextType
41+
]:
3642
''' Wrapper class for a Sycl Context
3743
'''
3844

dpctl/_sycl_context.pyx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -473,3 +473,10 @@ cdef class SyclContext(_SyclContext):
473473
"SyclContextRef",
474474
&_context_capsule_deleter
475475
)
476+
477+
cdef public DPCTLSyclContextRef get_context_ref(SyclContext ctx):
478+
"""
479+
C-API function to get opaque context reference from
480+
:class:`dpctl.SyclContext` instance.
481+
"""
482+
return ctx.get_context_ref()

dpctl/_sycl_device.pxd

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ from ._backend cimport (
2929
)
3030

3131

32-
cdef class _SyclDevice:
32+
cdef public class _SyclDevice [
33+
object Py_SyclDeviceObject,
34+
type Py_SyclDeviceType
35+
]:
3336
""" A helper data-owner class to abstract a `cl::sycl::device` instance.
3437
"""
3538
cdef DPCTLSyclDeviceRef _device_ref
@@ -39,7 +42,10 @@ cdef class _SyclDevice:
3942
cdef size_t *_max_work_item_sizes
4043

4144

42-
cdef public class SyclDevice(_SyclDevice) [object PySyclDeviceObject, type PySyclDeviceType]:
45+
cdef public class SyclDevice(_SyclDevice) [
46+
object PySyclDeviceObject,
47+
type PySyclDeviceType
48+
]:
4349
@staticmethod
4450
cdef SyclDevice _create(DPCTLSyclDeviceRef dref)
4551
cdef int _init_from__SyclDevice(self, _SyclDevice other)

dpctl/_sycl_device.pyx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,3 +1117,10 @@ cdef class SyclDevice(_SyclDevice):
11171117
return ":".join((dt_str, str(relId)))
11181118
else:
11191119
return str(relId)
1120+
1121+
cdef public DPCTLSyclDeviceRef get_device_ref(SyclDevice dev):
1122+
"""
1123+
C-API function to get opaque device reference from
1124+
:class:`dpctl.SyclDevice` instance.
1125+
"""
1126+
return dev.get_device_ref()

dpctl/_sycl_queue.pxd

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,15 +31,19 @@ from .program._program cimport SyclKernel
3131

3232
cdef void default_async_error_handler(int) nogil except *
3333

34-
cdef class _SyclQueue:
35-
""" Python wrapper class for a sycl::queue.
34+
cdef public class _SyclQueue [
35+
object Py_SyclQueueObject, type Py_SyclQueueType
36+
]:
37+
""" Python data owner class for a sycl::queue.
3638
"""
3739
cdef DPCTLSyclQueueRef _queue_ref
3840
cdef SyclContext _context
3941
cdef SyclDevice _device
4042

4143

42-
cdef public class SyclQueue (_SyclQueue) [object PySyclQueueObject, type PySyclQueueType]:
44+
cdef public class SyclQueue (_SyclQueue) [
45+
object PySyclQueueObject, type PySyclQueueType
46+
]:
4347
""" Python wrapper class for a sycl::queue.
4448
"""
4549
cdef int _init_queue_default(self, int)

dpctl/_sycl_queue.pyx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -931,3 +931,10 @@ cdef class SyclQueue(_SyclQueue):
931931
)
932932

933933
return SyclEvent._create(ERef, [])
934+
935+
cdef public DPCTLSyclQueueRef get_queue_ref(SyclQueue q):
936+
"""
937+
C-API function to get opaque queue reference from
938+
:class:`dpctl.SyclQueue` instance.
939+
"""
940+
return q.get_queue_ref()

0 commit comments

Comments
 (0)