Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move the kernel_iface module from experimental into a top-level module #1304

Merged
merged 2 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# SPDX-License-Identifier: Apache-2.0

"""
Implements the SPIR-V overloads for the kernel_api.atomic_ref class methods.
Implements the SPIR-V overloads for the kernel_api.AtomicRef class methods.
"""

from llvmlite import ir as llvmir
Expand All @@ -15,9 +15,14 @@
from numba_dpex.core.targets.kernel_target import CC_SPIR_FUNC, LLVM_SPIRV_ARGS
from numba_dpex.core.types import USMNdArray
from numba_dpex.experimental.flag_enum import FlagEnum
from numba_dpex.kernel_api import (
AddressSpace,
AtomicRef,
MemoryOrder,
MemoryScope,
)

from ..dpcpp_types import AtomicRefType
from ..kernel_iface import AddressSpace, AtomicRef, MemoryOrder, MemoryScope
from ..target import DPEX_KERNEL_EXP_TARGET_NAME
from ._spv_atomic_inst_helper import (
get_atomic_inst_name,
Expand Down Expand Up @@ -358,7 +363,7 @@ def ol_atomic_ref(
address_space=AddressSpace.GLOBAL,
):
"""Overload of the constructor for the class
class:`numba_dpex.experimental.kernel_iface.AtomicRef`.
class:`numba_dpex.kernel_api.AtomicRef`.

Raises:
errors.TypingError: If the `ref` argument is not a UsmNdArray type.
Expand Down Expand Up @@ -436,8 +441,7 @@ def ol_atomic_ref_ctor_impl(

@overload_method(AtomicRefType, "fetch_add", target=DPEX_KERNEL_EXP_TARGET_NAME)
def ol_fetch_add(atomic_ref, val):
"""SPIR-V overload for
:meth:`numba_dpex.experimental.kernel_iface.AtomicRef.fetch_add`.
"""SPIR-V overload for :meth:`numba_dpex.kernel_api.AtomicRef.fetch_add`.

Generates the same LLVM IR instruction as dpcpp for the
`atomic_ref::fetch_add` function.
Expand All @@ -461,8 +465,7 @@ def ol_fetch_add_impl(atomic_ref, val):

@overload_method(AtomicRefType, "fetch_sub", target=DPEX_KERNEL_EXP_TARGET_NAME)
def ol_fetch_sub(atomic_ref, val):
"""SPIR-V overload for
:meth:`numba_dpex.experimental.kernel_iface.AtomicRef.fetch_sub`.
"""SPIR-V overload for :meth:`numba_dpex.kernel_api.AtomicRef.fetch_sub`.

Generates the same LLVM IR instruction as dpcpp for the
`atomic_ref::fetch_sub` function.
Expand All @@ -486,8 +489,7 @@ def ol_fetch_sub_impl(atomic_ref, val):

@overload_method(AtomicRefType, "fetch_min", target=DPEX_KERNEL_EXP_TARGET_NAME)
def ol_fetch_min(atomic_ref, val):
"""SPIR-V overload for
:meth:`numba_dpex.experimental.kernel_iface.AtomicRef.fetch_min`.
"""SPIR-V overload for :meth:`numba_dpex.kernel_api.AtomicRef.fetch_min`.

Generates the same LLVM IR instruction as dpcpp for the
`atomic_ref::fetch_min` function.
Expand All @@ -511,8 +513,7 @@ def ol_fetch_min_impl(atomic_ref, val):

@overload_method(AtomicRefType, "fetch_max", target=DPEX_KERNEL_EXP_TARGET_NAME)
def ol_fetch_max(atomic_ref, val):
"""SPIR-V overload for
:meth:`numba_dpex.experimental.kernel_iface.AtomicRef.fetch_max`.
"""SPIR-V overload for :meth:`numba_dpex.kernel_api.AtomicRef.fetch_max`.

Generates the same LLVM IR instruction as dpcpp for the
`atomic_ref::fetch_max` function.
Expand All @@ -536,8 +537,7 @@ def ol_fetch_max_impl(atomic_ref, val):

@overload_method(AtomicRefType, "fetch_and", target=DPEX_KERNEL_EXP_TARGET_NAME)
def ol_fetch_and(atomic_ref, val):
"""SPIR-V overload for
:meth:`numba_dpex.experimental.kernel_iface.AtomicRef.fetch_and`.
"""SPIR-V overload for :meth:`numba_dpex.kernel_api.AtomicRef.fetch_and`.

Generates the same LLVM IR instruction as dpcpp for the
`atomic_ref::fetch_and` function.
Expand Down Expand Up @@ -566,8 +566,7 @@ def ol_fetch_and_impl(atomic_ref, val):

@overload_method(AtomicRefType, "fetch_or", target=DPEX_KERNEL_EXP_TARGET_NAME)
def ol_fetch_or(atomic_ref, val):
"""SPIR-V overload for
:meth:`numba_dpex.experimental.kernel_iface.AtomicRef.fetch_or`.
"""SPIR-V overload for :meth:`numba_dpex.kernel_api.AtomicRef.fetch_or`.

Generates the same LLVM IR instruction as dpcpp for the
`atomic_ref::fetch_or` function.
Expand Down Expand Up @@ -596,8 +595,7 @@ def ol_fetch_or_impl(atomic_ref, val):

@overload_method(AtomicRefType, "fetch_xor", target=DPEX_KERNEL_EXP_TARGET_NAME)
def ol_fetch_xor(atomic_ref, val):
"""SPIR-V overload for
:meth:`numba_dpex.experimental.kernel_iface.AtomicRef.fetch_xor`.
"""SPIR-V overload for :meth:`numba_dpex.kernel_api.AtomicRef.fetch_xor`.

Generates the same LLVM IR instruction as dpcpp for the
`atomic_ref::fetch_xor` function.
Expand Down Expand Up @@ -626,8 +624,7 @@ def ol_fetch_xor_impl(atomic_ref, val):

@overload_method(AtomicRefType, "load", target=DPEX_KERNEL_EXP_TARGET_NAME)
def ol_load(atomic_ref): # pylint: disable=unused-argument
"""SPIR-V overload for
:meth:`numba_dpex.experimental.kernel_iface.AtomicRef.load`.
"""SPIR-V overload for :meth:`numba_dpex.kernel_api.AtomicRef.load`.

Generates the same LLVM IR instruction as dpcpp for the
`atomic_ref::load` function.
Expand All @@ -643,8 +640,7 @@ def ol_load_impl(atomic_ref):

@overload_method(AtomicRefType, "store", target=DPEX_KERNEL_EXP_TARGET_NAME)
def ol_store(atomic_ref, val):
"""SPIR-V overload for
:meth:`numba_dpex.experimental.kernel_iface.AtomicRef.store`.
"""SPIR-V overload for :meth:`numba_dpex.kernel_api.AtomicRef.store`.

Generates the same LLVM IR instruction as dpcpp for the
`atomic_ref::store` function.
Expand All @@ -669,8 +665,7 @@ def ol_store_impl(atomic_ref, val):

@overload_method(AtomicRefType, "exchange", target=DPEX_KERNEL_EXP_TARGET_NAME)
def ol_exchange(atomic_ref, val):
"""SPIR-V overload for
:meth:`numba_dpex.experimental.kernel_iface.AtomicRef.exchange`.
"""SPIR-V overload for :meth:`numba_dpex.kernel_api.AtomicRef.exchange`.

Generates the same LLVM IR instruction as dpcpp for the
`atomic_ref::exchange` function.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

from numba.core import types

from ..kernel_iface import MemoryOrder, MemoryScope
from numba_dpex.kernel_api import MemoryOrder, MemoryScope


class _SpvScope(IntEnum):
Expand Down
10 changes: 5 additions & 5 deletions numba_dpex/experimental/dpcpp_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
#
# SPDX-License-Identifier: Apache-2.0

"""Collection of numba-dpex typing classes for kernel_iface Python classes.
"""Collection of numba-dpex typing classes for kernel_api Python classes.
"""

from numba.core.types import Type


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

def __init__(
Expand Down Expand Up @@ -38,21 +38,21 @@ def __init__(
@property
def memory_order(self) -> int:
"""Returns the integer value for a memory order that corresponds to
kernel_iface.MemoryOrder.
kernel_api.MemoryOrder.
"""
return self._memory_order

@property
def memory_scope(self) -> int:
"""Returns the integer value for a memory order that corresponds to
kernel_iface.MemoryScope.
kernel_api.MemoryScope.
"""
return self._memory_scope

@property
def address_space(self) -> int:
"""Returns the integer value for a memory order that corresponds to
kernel_iface.AddressSpace.
kernel_api.AddressSpace.
"""
return self._address_space

Expand Down
3 changes: 2 additions & 1 deletion numba_dpex/experimental/typeof.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@

from numba.extending import typeof_impl

from numba_dpex.kernel_api import AtomicRef

from .dpcpp_types import AtomicRefType
from .kernel_iface import AtomicRef


@typeof_impl.register(AtomicRef)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
#
# SPDX-License-Identifier: Apache-2.0

"""The kernel_iface provides a set of Python classes and functions that are
analogous to the C++ SYCL API. The kernel_iface API is meant to allow
"""
The kernel_api module provides a set of Python classes and functions that are
analogous to the C++ SYCL API. The kernel_api module is meant to allow
prototyping SYCL-like kernels in pure Python before compiling them using
numba_dpex.kernel.
numba_dpex.
"""

from .atomic_ref import AtomicRef
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import numba_dpex as dpex
import numba_dpex.experimental as dpex_exp
from numba_dpex.experimental.kernel_iface import AtomicRef
from numba_dpex.kernel_api import AtomicRef
from numba_dpex.tests._helper import get_all_dtypes

list_of_supported_dtypes = get_all_dtypes(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import numba_dpex as dpex
import numba_dpex.experimental as dpex_exp
from numba_dpex.experimental.kernel_iface import AtomicRef
from numba_dpex.kernel_api import AtomicRef
from numba_dpex.tests._helper import get_all_dtypes

list_of_supported_dtypes = get_all_dtypes(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import numba_dpex as dpex
import numba_dpex.experimental as dpex_exp
from numba_dpex.experimental.kernel_iface import AddressSpace, AtomicRef
from numba_dpex.kernel_api import AddressSpace, AtomicRef


def test_atomic_ref_compilation():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@

import numba_dpex.experimental as exp_dpex
from numba_dpex import Range
from numba_dpex.experimental.kernel_iface import (
AddressSpace,
MemoryOrder,
MemoryScope,
)
from numba_dpex.kernel_api import AddressSpace, MemoryOrder, MemoryScope


def test_compilation_of_memory_order():
Expand Down
Loading