Skip to content

Commit 2c31e1d

Browse files
committed
Do not place in experimental
1 parent 10bafd9 commit 2c31e1d

13 files changed

+67
-160
lines changed

dpctl/CMakeLists.txt

-1
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,3 @@ add_subdirectory(program)
207207
add_subdirectory(memory)
208208
add_subdirectory(tensor)
209209
add_subdirectory(utils)
210-
add_subdirectory(experimental)

dpctl/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
SyclKernelSubmitError,
5353
SyclQueue,
5454
SyclQueueCreationError,
55+
WorkGroupMemory,
5556
)
5657
from ._sycl_queue_manager import get_device_cached_queue
5758
from ._sycl_timer import SyclTimer
@@ -100,6 +101,7 @@
100101
"SyclKernelInvalidRangeError",
101102
"SyclKernelSubmitError",
102103
"SyclQueueCreationError",
104+
"WorkGroupMemory",
103105
]
104106
__all__ += [
105107
"get_device_cached_queue",

dpctl/_backend.pxd

-1
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,6 @@ cdef extern from "syclinterface/dpctl_sycl_extension_interface.h":
474474
cdef struct RawWorkGroupMemoryTy
475475
ctypedef RawWorkGroupMemoryTy RawWorkGroupMemory
476476

477-
478477
cdef struct DPCTLOpaqueWorkGroupMemory
479478
ctypedef DPCTLOpaqueWorkGroupMemory *DPCTLSyclWorkGroupMemoryRef;
480479

dpctl/_sycl_queue.pxd

+16-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,12 @@
2222

2323
from libcpp cimport bool as cpp_bool
2424

25-
from ._backend cimport DPCTLSyclDeviceRef, DPCTLSyclQueueRef, _arg_data_type
25+
from ._backend cimport (
26+
DPCTLSyclDeviceRef,
27+
DPCTLSyclQueueRef,
28+
DPCTLSyclWorkGroupMemoryRef,
29+
_arg_data_type,
30+
)
2631
from ._sycl_context cimport SyclContext
2732
from ._sycl_device cimport SyclDevice
2833
from ._sycl_event cimport SyclEvent
@@ -98,3 +103,13 @@ cdef public api class SyclQueue (_SyclQueue) [
98103
cpdef prefetch(self, ptr, size_t count=*)
99104
cpdef mem_advise(self, ptr, size_t count, int mem)
100105
cpdef SyclEvent submit_barrier(self, dependent_events=*)
106+
107+
cdef public api class _WorkGroupMemory [
108+
object Py_WorkGroupMemoryObject, type Py_WorkGroupMemoryType
109+
]:
110+
cdef DPCTLSyclWorkGroupMemoryRef _mem_ref
111+
112+
cdef public api class WorkGroupMemory(_WorkGroupMemory) [
113+
object PyWorkGroupMemoryObject, type PyWorkGroupMemoryType
114+
]:
115+
pass

dpctl/_sycl_queue.pyx

+41-1
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ from ._backend cimport ( # noqa: E211
5454
DPCTLSyclContextRef,
5555
DPCTLSyclDeviceSelectorRef,
5656
DPCTLSyclEventRef,
57+
DPCTLWorkGroupMemory_Available,
58+
DPCTLWorkGroupMemory_Create,
59+
DPCTLWorkGroupMemory_Delete,
5760
_arg_data_type,
5861
_backend_type,
5962
_queue_property_type,
6063
)
61-
from .experimental._work_group_memory cimport WorkGroupMemory
6264
from .memory._memory cimport _Memory
6365

6466
import ctypes
@@ -1537,3 +1539,41 @@ cdef api SyclQueue SyclQueue_Make(DPCTLSyclQueueRef QRef):
15371539
"""
15381540
cdef DPCTLSyclQueueRef copied_QRef = DPCTLQueue_Copy(QRef)
15391541
return SyclQueue._create(copied_QRef)
1542+
1543+
cdef class _WorkGroupMemory:
1544+
def __dealloc__(self):
1545+
if(self._mem_ref):
1546+
DPCTLWorkGroupMemory_Delete(self._mem_ref)
1547+
1548+
cdef class WorkGroupMemory:
1549+
"""
1550+
WorkGroupMemory(nbytes)
1551+
Python class representing the ``work_group_memory`` class from the
1552+
Workgroup Memory oneAPI SYCL extension for low-overhead allocation of local
1553+
memory shared by the workitems in a workgroup.
1554+
1555+
This is based on a DPC++ SYCL extension and only available in newer
1556+
versions. Use ``is_available()`` to check availability in your build.
1557+
1558+
Args:
1559+
nbytes (int)
1560+
number of bytes to allocate in local memory.
1561+
Expected to be positive.
1562+
"""
1563+
def __cinit__(self, Py_ssize_t nbytes):
1564+
if not DPCTLWorkGroupMemory_Available():
1565+
raise RuntimeError("Workgroup memory extension not available")
1566+
1567+
self._mem_ref = DPCTLWorkGroupMemory_Create(nbytes)
1568+
1569+
"""Check whether the work_group_memory extension is available"""
1570+
@staticmethod
1571+
def is_available():
1572+
return DPCTLWorkGroupMemory_Available()
1573+
1574+
property _ref:
1575+
"""Returns the address of the C API ``DPCTLWorkGroupMemoryRef``
1576+
pointer as a ``size_t``.
1577+
"""
1578+
def __get__(self):
1579+
return <size_t>self._mem_ref

dpctl/apis/include/dpctl_capi.h

+4-2
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,11 @@
2525
#pragma once
2626

2727
// clang-format off
28-
// Ordering of includes is important here. dpctl_sycl_types defines types
29-
// used by dpctl's Python C-API headers.
28+
// Ordering of includes is important here. dpctl_sycl_types and
29+
// dpctl_sycl_extension_interface define types used by dpctl's Python
30+
// C-API headers.
3031
#include "syclinterface/dpctl_sycl_types.h"
32+
#include "syclinterface/dpctl_sycl_extension_interface.h"
3133
#ifdef __cplusplus
3234
#define CYTHON_EXTERN_C extern "C"
3335
#else

dpctl/experimental/CMakeLists.txt

-7
This file was deleted.

dpctl/experimental/__init__.pxd

-25
This file was deleted.

dpctl/experimental/__init__.py

-27
This file was deleted.

dpctl/experimental/_work_group_memory.pxd

-31
This file was deleted.

dpctl/experimental/_work_group_memory.pyx

-60
This file was deleted.

dpctl/tests/test_work_group_memory.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def get_spirv_abspath(fn):
5252

5353

5454
def test_submit_work_group_memory():
55-
if not dpctl.experimental.WorkGroupMemory.is_available():
55+
if not dpctl.WorkGroupMemory.is_available():
5656
pytest.skip("Work group memory extension not supported")
5757

5858
try:
@@ -78,7 +78,7 @@ def test_submit_work_group_memory():
7878
[
7979
x.usm_data,
8080
y.usm_data,
81-
dpctl.experimental.WorkGroupMemory(local_size * x.itemsize),
81+
dpctl.WorkGroupMemory(local_size * x.itemsize),
8282
],
8383
[global_size],
8484
[local_size],

dpctl/tests/test_work_group_memory_opencl.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939

4040
def test_submit_work_group_memory_opencl():
41-
if not dpctl.experimental.WorkGroupMemory.is_available():
41+
if not dpctl.WorkGroupMemory.is_available():
4242
pytest.skip("Work group memory extension not supported")
4343

4444
try:
@@ -65,7 +65,7 @@ def test_submit_work_group_memory_opencl():
6565
[
6666
x_dev,
6767
y_dev,
68-
dpctl.experimental.WorkGroupMemory(local_size * x.itemsize),
68+
dpctl.WorkGroupMemory(local_size * x.itemsize),
6969
],
7070
[global_size],
7171
[local_size],

0 commit comments

Comments
 (0)