Skip to content

Commit c8d6799

Browse files
author
Diptorup Deb
authored
Merge pull request #1304 from IntelPython/refactor/kernel_api
Move the kernel_iface module from experimental into a top-level module
2 parents f59d9e8 + 59bb09b commit c8d6799

File tree

13 files changed

+34
-41
lines changed

13 files changed

+34
-41
lines changed

numba_dpex/experimental/_kernel_dpcpp_spirv_overloads/_atomic_ref_overloads.py

Lines changed: 18 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# SPDX-License-Identifier: Apache-2.0
44

55
"""
6-
Implements the SPIR-V overloads for the kernel_api.atomic_ref class methods.
6+
Implements the SPIR-V overloads for the kernel_api.AtomicRef class methods.
77
"""
88

99
from llvmlite import ir as llvmir
@@ -15,9 +15,14 @@
1515
from numba_dpex.core.targets.kernel_target import CC_SPIR_FUNC, LLVM_SPIRV_ARGS
1616
from numba_dpex.core.types import USMNdArray
1717
from numba_dpex.experimental.flag_enum import FlagEnum
18+
from numba_dpex.kernel_api import (
19+
AddressSpace,
20+
AtomicRef,
21+
MemoryOrder,
22+
MemoryScope,
23+
)
1824

1925
from ..dpcpp_types import AtomicRefType
20-
from ..kernel_iface import AddressSpace, AtomicRef, MemoryOrder, MemoryScope
2126
from ..target import DPEX_KERNEL_EXP_TARGET_NAME
2227
from ._spv_atomic_inst_helper import (
2328
get_atomic_inst_name,
@@ -358,7 +363,7 @@ def ol_atomic_ref(
358363
address_space=AddressSpace.GLOBAL,
359364
):
360365
"""Overload of the constructor for the class
361-
class:`numba_dpex.experimental.kernel_iface.AtomicRef`.
366+
class:`numba_dpex.kernel_api.AtomicRef`.
362367
363368
Raises:
364369
errors.TypingError: If the `ref` argument is not a UsmNdArray type.
@@ -436,8 +441,7 @@ def ol_atomic_ref_ctor_impl(
436441

437442
@overload_method(AtomicRefType, "fetch_add", target=DPEX_KERNEL_EXP_TARGET_NAME)
438443
def ol_fetch_add(atomic_ref, val):
439-
"""SPIR-V overload for
440-
:meth:`numba_dpex.experimental.kernel_iface.AtomicRef.fetch_add`.
444+
"""SPIR-V overload for :meth:`numba_dpex.kernel_api.AtomicRef.fetch_add`.
441445
442446
Generates the same LLVM IR instruction as dpcpp for the
443447
`atomic_ref::fetch_add` function.
@@ -461,8 +465,7 @@ def ol_fetch_add_impl(atomic_ref, val):
461465

462466
@overload_method(AtomicRefType, "fetch_sub", target=DPEX_KERNEL_EXP_TARGET_NAME)
463467
def ol_fetch_sub(atomic_ref, val):
464-
"""SPIR-V overload for
465-
:meth:`numba_dpex.experimental.kernel_iface.AtomicRef.fetch_sub`.
468+
"""SPIR-V overload for :meth:`numba_dpex.kernel_api.AtomicRef.fetch_sub`.
466469
467470
Generates the same LLVM IR instruction as dpcpp for the
468471
`atomic_ref::fetch_sub` function.
@@ -486,8 +489,7 @@ def ol_fetch_sub_impl(atomic_ref, val):
486489

487490
@overload_method(AtomicRefType, "fetch_min", target=DPEX_KERNEL_EXP_TARGET_NAME)
488491
def ol_fetch_min(atomic_ref, val):
489-
"""SPIR-V overload for
490-
:meth:`numba_dpex.experimental.kernel_iface.AtomicRef.fetch_min`.
492+
"""SPIR-V overload for :meth:`numba_dpex.kernel_api.AtomicRef.fetch_min`.
491493
492494
Generates the same LLVM IR instruction as dpcpp for the
493495
`atomic_ref::fetch_min` function.
@@ -511,8 +513,7 @@ def ol_fetch_min_impl(atomic_ref, val):
511513

512514
@overload_method(AtomicRefType, "fetch_max", target=DPEX_KERNEL_EXP_TARGET_NAME)
513515
def ol_fetch_max(atomic_ref, val):
514-
"""SPIR-V overload for
515-
:meth:`numba_dpex.experimental.kernel_iface.AtomicRef.fetch_max`.
516+
"""SPIR-V overload for :meth:`numba_dpex.kernel_api.AtomicRef.fetch_max`.
516517
517518
Generates the same LLVM IR instruction as dpcpp for the
518519
`atomic_ref::fetch_max` function.
@@ -536,8 +537,7 @@ def ol_fetch_max_impl(atomic_ref, val):
536537

537538
@overload_method(AtomicRefType, "fetch_and", target=DPEX_KERNEL_EXP_TARGET_NAME)
538539
def ol_fetch_and(atomic_ref, val):
539-
"""SPIR-V overload for
540-
:meth:`numba_dpex.experimental.kernel_iface.AtomicRef.fetch_and`.
540+
"""SPIR-V overload for :meth:`numba_dpex.kernel_api.AtomicRef.fetch_and`.
541541
542542
Generates the same LLVM IR instruction as dpcpp for the
543543
`atomic_ref::fetch_and` function.
@@ -566,8 +566,7 @@ def ol_fetch_and_impl(atomic_ref, val):
566566

567567
@overload_method(AtomicRefType, "fetch_or", target=DPEX_KERNEL_EXP_TARGET_NAME)
568568
def ol_fetch_or(atomic_ref, val):
569-
"""SPIR-V overload for
570-
:meth:`numba_dpex.experimental.kernel_iface.AtomicRef.fetch_or`.
569+
"""SPIR-V overload for :meth:`numba_dpex.kernel_api.AtomicRef.fetch_or`.
571570
572571
Generates the same LLVM IR instruction as dpcpp for the
573572
`atomic_ref::fetch_or` function.
@@ -596,8 +595,7 @@ def ol_fetch_or_impl(atomic_ref, val):
596595

597596
@overload_method(AtomicRefType, "fetch_xor", target=DPEX_KERNEL_EXP_TARGET_NAME)
598597
def ol_fetch_xor(atomic_ref, val):
599-
"""SPIR-V overload for
600-
:meth:`numba_dpex.experimental.kernel_iface.AtomicRef.fetch_xor`.
598+
"""SPIR-V overload for :meth:`numba_dpex.kernel_api.AtomicRef.fetch_xor`.
601599
602600
Generates the same LLVM IR instruction as dpcpp for the
603601
`atomic_ref::fetch_xor` function.
@@ -626,8 +624,7 @@ def ol_fetch_xor_impl(atomic_ref, val):
626624

627625
@overload_method(AtomicRefType, "load", target=DPEX_KERNEL_EXP_TARGET_NAME)
628626
def ol_load(atomic_ref): # pylint: disable=unused-argument
629-
"""SPIR-V overload for
630-
:meth:`numba_dpex.experimental.kernel_iface.AtomicRef.load`.
627+
"""SPIR-V overload for :meth:`numba_dpex.kernel_api.AtomicRef.load`.
631628
632629
Generates the same LLVM IR instruction as dpcpp for the
633630
`atomic_ref::load` function.
@@ -643,8 +640,7 @@ def ol_load_impl(atomic_ref):
643640

644641
@overload_method(AtomicRefType, "store", target=DPEX_KERNEL_EXP_TARGET_NAME)
645642
def ol_store(atomic_ref, val):
646-
"""SPIR-V overload for
647-
:meth:`numba_dpex.experimental.kernel_iface.AtomicRef.store`.
643+
"""SPIR-V overload for :meth:`numba_dpex.kernel_api.AtomicRef.store`.
648644
649645
Generates the same LLVM IR instruction as dpcpp for the
650646
`atomic_ref::store` function.
@@ -669,8 +665,7 @@ def ol_store_impl(atomic_ref, val):
669665

670666
@overload_method(AtomicRefType, "exchange", target=DPEX_KERNEL_EXP_TARGET_NAME)
671667
def ol_exchange(atomic_ref, val):
672-
"""SPIR-V overload for
673-
:meth:`numba_dpex.experimental.kernel_iface.AtomicRef.exchange`.
668+
"""SPIR-V overload for :meth:`numba_dpex.kernel_api.AtomicRef.exchange`.
674669
675670
Generates the same LLVM IR instruction as dpcpp for the
676671
`atomic_ref::exchange` function.

numba_dpex/experimental/_kernel_dpcpp_spirv_overloads/_spv_atomic_inst_helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
from numba.core import types
1010

11-
from ..kernel_iface import MemoryOrder, MemoryScope
11+
from numba_dpex.kernel_api import MemoryOrder, MemoryScope
1212

1313

1414
class _SpvScope(IntEnum):

numba_dpex/experimental/dpcpp_types.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

5-
"""Collection of numba-dpex typing classes for kernel_iface Python classes.
5+
"""Collection of numba-dpex typing classes for kernel_api Python classes.
66
"""
77

88
from numba.core.types import Type
99

1010

1111
class AtomicRefType(Type):
1212
"""numba-dpex internal type to represent a Python object of
13-
:class:`numba_dpex.experimental.kernel_iface.AtomicRef`.
13+
:class:`numba_dpex.kernel_api.AtomicRef`.
1414
"""
1515

1616
def __init__(
@@ -38,21 +38,21 @@ def __init__(
3838
@property
3939
def memory_order(self) -> int:
4040
"""Returns the integer value for a memory order that corresponds to
41-
kernel_iface.MemoryOrder.
41+
kernel_api.MemoryOrder.
4242
"""
4343
return self._memory_order
4444

4545
@property
4646
def memory_scope(self) -> int:
4747
"""Returns the integer value for a memory order that corresponds to
48-
kernel_iface.MemoryScope.
48+
kernel_api.MemoryScope.
4949
"""
5050
return self._memory_scope
5151

5252
@property
5353
def address_space(self) -> int:
5454
"""Returns the integer value for a memory order that corresponds to
55-
kernel_iface.AddressSpace.
55+
kernel_api.AddressSpace.
5656
"""
5757
return self._address_space
5858

numba_dpex/experimental/typeof.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@
99

1010
from numba.extending import typeof_impl
1111

12+
from numba_dpex.kernel_api import AtomicRef
13+
1214
from .dpcpp_types import AtomicRefType
13-
from .kernel_iface import AtomicRef
1415

1516

1617
@typeof_impl.register(AtomicRef)

numba_dpex/experimental/kernel_iface/__init__.py renamed to numba_dpex/kernel_api/__init__.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
#
33
# SPDX-License-Identifier: Apache-2.0
44

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
5+
"""
6+
The kernel_api module provides a set of Python classes and functions that are
7+
analogous to the C++ SYCL API. The kernel_api module is meant to allow
78
prototyping SYCL-like kernels in pure Python before compiling them using
8-
numba_dpex.kernel.
9+
numba_dpex.
910
"""
1011

1112
from .atomic_ref import AtomicRef

numba_dpex/tests/experimental/kernel_iface/spv_overloads/test_atomic_fetch_phi.py renamed to numba_dpex/tests/experimental/kernel_api_overloads/spv_overloads/test_atomic_fetch_phi.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
import numba_dpex as dpex
1010
import numba_dpex.experimental as dpex_exp
11-
from numba_dpex.experimental.kernel_iface import AtomicRef
11+
from numba_dpex.kernel_api import AtomicRef
1212
from numba_dpex.tests._helper import get_all_dtypes
1313

1414
list_of_supported_dtypes = get_all_dtypes(

0 commit comments

Comments
 (0)