Skip to content

Commit

Permalink
Do not place in experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
sommerlukas committed Feb 12, 2025
1 parent 04efec6 commit 67c915e
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 160 deletions.
1 change: 0 additions & 1 deletion dpctl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -207,4 +207,3 @@ add_subdirectory(program)
add_subdirectory(memory)
add_subdirectory(tensor)
add_subdirectory(utils)
add_subdirectory(experimental)
2 changes: 2 additions & 0 deletions dpctl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
SyclKernelSubmitError,
SyclQueue,
SyclQueueCreationError,
WorkGroupMemory,
)
from ._sycl_queue_manager import get_device_cached_queue
from ._sycl_timer import SyclTimer
Expand Down Expand Up @@ -100,6 +101,7 @@
"SyclKernelInvalidRangeError",
"SyclKernelSubmitError",
"SyclQueueCreationError",
"WorkGroupMemory",
]
__all__ += [
"get_device_cached_queue",
Expand Down
1 change: 0 additions & 1 deletion dpctl/_backend.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,6 @@ cdef extern from "syclinterface/dpctl_sycl_extension_interface.h":
cdef struct RawWorkGroupMemoryTy
ctypedef RawWorkGroupMemoryTy RawWorkGroupMemory


cdef struct DPCTLOpaqueWorkGroupMemory
ctypedef DPCTLOpaqueWorkGroupMemory *DPCTLSyclWorkGroupMemoryRef;

Expand Down
17 changes: 16 additions & 1 deletion dpctl/_sycl_queue.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@

from libcpp cimport bool as cpp_bool

from ._backend cimport DPCTLSyclDeviceRef, DPCTLSyclQueueRef, _arg_data_type
from ._backend cimport (
DPCTLSyclDeviceRef,
DPCTLSyclQueueRef,
DPCTLSyclWorkGroupMemoryRef,
_arg_data_type,
)
from ._sycl_context cimport SyclContext
from ._sycl_device cimport SyclDevice
from ._sycl_event cimport SyclEvent
Expand Down Expand Up @@ -98,3 +103,13 @@ cdef public api class SyclQueue (_SyclQueue) [
cpdef prefetch(self, ptr, size_t count=*)
cpdef mem_advise(self, ptr, size_t count, int mem)
cpdef SyclEvent submit_barrier(self, dependent_events=*)

cdef public api class _WorkGroupMemory [
object Py_WorkGroupMemoryObject, type Py_WorkGroupMemoryType
]:
cdef DPCTLSyclWorkGroupMemoryRef _mem_ref

cdef public api class WorkGroupMemory(_WorkGroupMemory) [
object PyWorkGroupMemoryObject, type PyWorkGroupMemoryType
]:
pass
42 changes: 41 additions & 1 deletion dpctl/_sycl_queue.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,13 @@ from ._backend cimport ( # noqa: E211
DPCTLSyclContextRef,
DPCTLSyclDeviceSelectorRef,
DPCTLSyclEventRef,
DPCTLWorkGroupMemory_Available,
DPCTLWorkGroupMemory_Create,
DPCTLWorkGroupMemory_Delete,
_arg_data_type,
_backend_type,
_queue_property_type,
)
from .experimental._work_group_memory cimport WorkGroupMemory
from .memory._memory cimport _Memory

import ctypes
Expand Down Expand Up @@ -1537,3 +1539,41 @@ cdef api SyclQueue SyclQueue_Make(DPCTLSyclQueueRef QRef):
"""
cdef DPCTLSyclQueueRef copied_QRef = DPCTLQueue_Copy(QRef)
return SyclQueue._create(copied_QRef)

cdef class _WorkGroupMemory:
def __dealloc__(self):
if(self._mem_ref):
DPCTLWorkGroupMemory_Delete(self._mem_ref)

cdef class WorkGroupMemory:
"""
WorkGroupMemory(nbytes)
Python class representing the ``work_group_memory`` class from the
Workgroup Memory oneAPI SYCL extension for low-overhead allocation of local
memory shared by the workitems in a workgroup.
This is based on a DPC++ SYCL extension and only available in newer
versions. Use ``is_available()`` to check availability in your build.
Args:
nbytes (int)
number of bytes to allocate in local memory.
Expected to be positive.
"""
def __cinit__(self, Py_ssize_t nbytes):
if not DPCTLWorkGroupMemory_Available():
raise RuntimeError("Workgroup memory extension not available")

self._mem_ref = DPCTLWorkGroupMemory_Create(nbytes)

"""Check whether the work_group_memory extension is available"""
@staticmethod
def is_available():
return DPCTLWorkGroupMemory_Available()

property _ref:
"""Returns the address of the C API ``DPCTLWorkGroupMemoryRef``
pointer as a ``size_t``.
"""
def __get__(self):
return <size_t>self._mem_ref
6 changes: 4 additions & 2 deletions dpctl/apis/include/dpctl_capi.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@
#pragma once

// clang-format off
// Ordering of includes is important here. dpctl_sycl_types defines types
// used by dpctl's Python C-API headers.
// Ordering of includes is important here. dpctl_sycl_types and
// dpctl_sycl_extension_interface define types used by dpctl's Python
// C-API headers.
#include "syclinterface/dpctl_sycl_types.h"
#include "syclinterface/dpctl_sycl_extension_interface.h"
#ifdef __cplusplus
#define CYTHON_EXTERN_C extern "C"
#else
Expand Down
7 changes: 0 additions & 7 deletions dpctl/experimental/CMakeLists.txt

This file was deleted.

25 changes: 0 additions & 25 deletions dpctl/experimental/__init__.pxd

This file was deleted.

27 changes: 0 additions & 27 deletions dpctl/experimental/__init__.py

This file was deleted.

31 changes: 0 additions & 31 deletions dpctl/experimental/_work_group_memory.pxd

This file was deleted.

60 changes: 0 additions & 60 deletions dpctl/experimental/_work_group_memory.pyx

This file was deleted.

4 changes: 2 additions & 2 deletions dpctl/tests/test_work_group_memory.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def get_spirv_abspath(fn):


def test_submit_work_group_memory():
if not dpctl.experimental.WorkGroupMemory.is_available():
if not dpctl.WorkGroupMemory.is_available():
pytest.skip("Work group memory extension not supported")

try:
Expand All @@ -78,7 +78,7 @@ def test_submit_work_group_memory():
[
x.usm_data,
y.usm_data,
dpctl.experimental.WorkGroupMemory(local_size * x.itemsize),
dpctl.WorkGroupMemory(local_size * x.itemsize),
],
[global_size],
[local_size],
Expand Down
4 changes: 2 additions & 2 deletions dpctl/tests/test_work_group_memory_opencl.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@


def test_submit_work_group_memory_opencl():
if not dpctl.experimental.WorkGroupMemory.is_available():
if not dpctl.WorkGroupMemory.is_available():
pytest.skip("Work group memory extension not supported")

try:
Expand All @@ -65,7 +65,7 @@ def test_submit_work_group_memory_opencl():
[
x_dev,
y_dev,
dpctl.experimental.WorkGroupMemory(local_size * x.itemsize),
dpctl.WorkGroupMemory(local_size * x.itemsize),
],
[global_size],
[local_size],
Expand Down

0 comments on commit 67c915e

Please sign in to comment.