Skip to content

Commit f2d3080

Browse files
authored
Merge pull request #1420 from IntelPython/technical-debt
Code reorganization: Removes ocl kernel API, moves math, print into kernel_api_impl
2 parents 4deff1a + eb5a48b commit f2d3080

File tree

20 files changed

+449
-1552
lines changed

20 files changed

+449
-1552
lines changed

numba_dpex/__init__.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -98,23 +98,6 @@ def parse_sem_version(version_string: str) -> Tuple[int, int, int]:
9898
from .core.decorators import device_func, dpjit, kernel # noqa E402
9999
from .core.kernel_launcher import call_kernel, call_kernel_async # noqa E402
100100
from .core.targets import dpjit_target # noqa E402
101-
from .ocl.stubs import ( # noqa E402
102-
GLOBAL_MEM_FENCE,
103-
LOCAL_MEM_FENCE,
104-
atomic,
105-
barrier,
106-
get_global_id,
107-
get_global_size,
108-
get_group_id,
109-
get_local_id,
110-
get_local_size,
111-
get_num_groups,
112-
get_work_dim,
113-
local,
114-
mem_fence,
115-
private,
116-
sub_group_barrier,
117-
)
118101

119102
load_dpctl_sycl_interface()
120103
del load_dpctl_sycl_interface

numba_dpex/core/datamodel/models.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
from numba_dpex.kernel_api.memory_enums import AddressSpace as address_space
2121

2222
from ..types import (
23-
Array,
2423
DpctlSyclEvent,
2524
DpctlSyclQueue,
2625
DpnpNdArray,
@@ -335,7 +334,6 @@ def _init_kernel_data_model_manager() -> datamodel.DataModelManager:
335334
"""
336335
dmm = datamodel.default_manager.copy()
337336
dmm.register(types.CPointer, GenericPointerModel)
338-
dmm.register(Array, USMArrayDeviceModel)
339337

340338
# Register the USMNdArray type to USMArrayDeviceModel in numba_dpex's data
341339
# model manager. The dpex_data_model_manager is used by the DpexKernelTarget

numba_dpex/core/pipelines/kernel_compiler.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
NoPythonSupportedFeatureValidation,
1010
)
1111

12-
from numba_dpex.core import config
1312
from numba_dpex.core.exceptions import UnsupportedCompilationModeError
1413
from numba_dpex.core.passes.passes import (
1514
NoPythonBackend,

numba_dpex/core/types/__init__.py

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

5-
from .array_type import Array
65
from .dpctl_types import DpctlSyclEvent, DpctlSyclQueue
76
from .dpnp_ndarray_type import DpnpNdArray
87
from .kernel_api.literal_intenum import IntEnumLiteral
@@ -34,7 +33,6 @@
3433
usm_ndarray = USMNdArray
3534

3635
__all__ = [
37-
"Array",
3836
"DpctlSyclQueue",
3937
"DpctlSyclEvent",
4038
"DpnpNdArray",

numba_dpex/core/types/array_type.py

Lines changed: 0 additions & 65 deletions
This file was deleted.

numba_dpex/core/utils/cgutils_extra.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
from llvmlite import ir as llvmir
66
from numba.core import cgutils, types
77

8+
from numba_dpex.core.utils.itanium_mangler import mangle_c
9+
810

911
class LLVMTypes:
1012
"""
@@ -21,6 +23,44 @@ class LLVMTypes:
2123
void_t = llvmir.VoidType()
2224

2325

26+
def declare_function(context, builder, name, sig, cargs, mangler=mangle_c):
27+
"""Insert declaration for a opencl builtin function.
28+
Uses the Itanium mangler.
29+
30+
Args
31+
----
32+
context: target context
33+
34+
builder: llvm builder
35+
36+
name: str
37+
symbol name
38+
39+
sig: signature
40+
function signature of the symbol being declared
41+
42+
cargs: sequence of str
43+
C type names for the arguments
44+
45+
mangler: a mangler function
46+
function to use to mangle the symbol
47+
48+
"""
49+
mod = builder.module
50+
if sig.return_type == types.void:
51+
llretty = llvmir.VoidType()
52+
else:
53+
llretty = context.get_value_type(sig.return_type)
54+
llargs = [context.get_value_type(t) for t in sig.args]
55+
fnty = llvmir.FunctionType(llretty, llargs)
56+
mangled = mangler(name, cargs)
57+
fn = cgutils.get_or_insert_function(mod, fnty, mangled)
58+
from numba_dpex import spirv_kernel_target
59+
60+
fn.calling_convention = spirv_kernel_target.CC_SPIR_FUNC
61+
return fn
62+
63+
2464
def get_llvm_type(context, type):
2565
"""Returns the LLVM Value corresponding to a Numba type.
2666

numba_dpex/dpnp_iface/dpnp_ufunc_db.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
from numba.core import types
1010

1111
from numba_dpex.core.typing import dpnpdecl
12-
13-
from ..ocl import mathimpl
12+
from numba_dpex.kernel_api_impl.spirv.math import mathimpl
1413

1514
# A global instance of dpnp ufuncs that are supported by numba-dpex
1615
_dpnp_ufunc_db = None
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# SPDX-FileCopyrightText: 2024 Intel Corporation
2+
#
3+
# SPDX-License-Identifier: Apache-2.0

0 commit comments

Comments
 (0)