Skip to content

Commit 837109e

Browse files
author
Diptorup Deb
committed
Adds a kernel_iface module in experimental.
- A new experimental module kernel_iface was added to store Python implementation of the kernel API. The initial module has the memory enum classes that can be used as flags in a numba_dpex.experimental.kernel
1 parent f562bd6 commit 837109e

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SPDX-FileCopyrightText: 2023 Intel Corporation
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
"""The kernel_iface provides a set of Python classes and functions that are
6+
analogous to the C++ SYCL API. The kernel_iface API is meant to allow
7+
prototyping SYCL-like kernels in pure Python before compiling them using
8+
numba_dpex.kernel.
9+
"""
10+
11+
from .memory_enums import AddressSpace, MemoryOrder, MemoryScope
12+
13+
__all__ = ["AddressSpace", "MemoryOrder", "MemoryScope"]
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# SPDX-FileCopyrightText: 2023 Intel Corporation
2+
#
3+
# SPDX-License-Identifier: Apache-2.0
4+
5+
"""A collection of FlagEnum classes that syntactically represents the SYCL
6+
memory enum classes.
7+
"""
8+
9+
from numba_dpex.experimental.flag_enum import FlagEnum
10+
11+
12+
class MemoryOrder(FlagEnum):
13+
"""
14+
An enumeration of the supported ``sycl::memory_order`` values in dpcpp. The
15+
integer values of the enums is kept consistent with the corresponding
16+
implementation in dpcpp.
17+
18+
===================== ============
19+
Order Enum value
20+
===================== ============
21+
RELAXED 0
22+
ACQUIRE 1
23+
CONSUME_UNSUPPORTED 2
24+
RELEASE 3
25+
ACQ_REL 4
26+
SEQ_CST 5
27+
===================== ============
28+
"""
29+
30+
RELAXED = 0
31+
ACQUIRE = 1
32+
CONSUME_UNSUPPORTED = 2
33+
RELEASE = 3
34+
ACQ_REL = 4
35+
SEQ_CST = 5
36+
37+
38+
class MemoryScope(FlagEnum):
39+
"""
40+
An enumeration of SYCL memory scope. For more details please refer to
41+
SYCL 2020 specification, section 3.8.3.2
42+
43+
=============== ============
44+
Memory Scope Enum value
45+
=============== ============
46+
WORK_ITEM 0
47+
SUB_GROUP 1
48+
WORK_GROUP 2
49+
DEVICE 3
50+
SYSTEM 4
51+
=============== ============
52+
"""
53+
54+
WORK_ITEM = 0
55+
SUB_GROUP = 1
56+
WORK_GROUP = 2
57+
DEVICE = 3
58+
SYSTEM = 4
59+
60+
61+
class AddressSpace(FlagEnum):
62+
"""The address space values supported by numba_dpex.
63+
64+
================== ============
65+
Address space Value
66+
================== ============
67+
PRIVATE 0
68+
GLOBAL 1
69+
CONSTANT 2
70+
LOCAL 3
71+
GENERIC 4
72+
================== ============
73+
"""
74+
75+
PRIVATE = 0
76+
GLOBAL = 1
77+
CONSTANT = 2
78+
LOCAL = 3
79+
GENERIC = 4

0 commit comments

Comments
 (0)