Skip to content

Commit ae07cb6

Browse files
author
Diptorup Deb
committed
Add the mangled_Args property to kernel_api types.
1 parent 675cb79 commit ae07cb6

File tree

4 files changed

+41
-8
lines changed

4 files changed

+41
-8
lines changed

numba_dpex/core/types/kernel_api/atomic_ref.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,13 @@ def cast_python_value(self, args):
8080
AtomicRefType throws a NotImplementedError.
8181
"""
8282
raise NotImplementedError
83+
84+
@property
85+
def mangling_args(self):
86+
args = [
87+
self.dtype,
88+
self.memory_order,
89+
self.memory_scope,
90+
self.address_space,
91+
]
92+
return self.__class__.__name__, args

numba_dpex/core/types/kernel_api/index_space_ids.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ def key(self):
3131
def cast_python_value(self, args):
3232
raise NotImplementedError
3333

34+
@property
35+
def mangling_args(self):
36+
args = [self.ndim]
37+
return self.__class__.__name__, args
38+
3439

3540
class ItemType(types.Type):
3641
"""Numba-dpex type corresponding to :class:`numba_dpex.kernel_api.Item`"""
@@ -53,6 +58,11 @@ def key(self):
5358
"""Numba type specific overload"""
5459
return self._ndim
5560

61+
@property
62+
def mangling_args(self):
63+
args = [self.ndim]
64+
return self.__class__.__name__, args
65+
5666
def cast_python_value(self, args):
5767
raise NotImplementedError
5868

@@ -78,5 +88,10 @@ def key(self):
7888
"""Numba type specific overload"""
7989
return self._ndim
8090

91+
@property
92+
def mangling_args(self):
93+
args = [self.ndim]
94+
return self.__class__.__name__, args
95+
8196
def cast_python_value(self, args):
8297
raise NotImplementedError

numba_dpex/core/types/kernel_api/ranges.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ def ndim(self):
2828
def key(self):
2929
return self._ndim
3030

31+
@property
32+
def mangling_args(self):
33+
args = [self.ndim]
34+
return self.__class__.__name__, args
35+
3136

3237
class NdRangeType(types.Type):
3338
"""Numba-dpex type corresponding to
@@ -49,3 +54,8 @@ def ndim(self):
4954
@property
5055
def key(self):
5156
return self._ndim
57+
58+
@property
59+
def mangling_args(self):
60+
args = [self.ndim]
61+
return self.__class__.__name__, args

numba_dpex/kernel_api_impl/spirv/target.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import dpnp
1212
from llvmlite import binding as ll
1313
from llvmlite import ir as llvmir
14-
from numba.core import cgutils, funcdesc
14+
from numba.core import cgutils
1515
from numba.core import types as nb_types
1616
from numba.core import typing
1717
from numba.core.base import BaseContext
@@ -23,6 +23,7 @@
2323
from numba_dpex.core.datamodel.models import _init_kernel_data_model_manager
2424
from numba_dpex.core.types import IntEnumLiteral
2525
from numba_dpex.core.typing import dpnpdecl
26+
from numba_dpex.core.utils import itanium_mangler
2627
from numba_dpex.kernel_api.flag_enum import FlagEnum
2728
from numba_dpex.kernel_api.memory_enums import AddressSpace as address_space
2829
from numba_dpex.kernel_api_impl.spirv import printimpl
@@ -188,7 +189,7 @@ def _generate_spir_kernel_wrapper(self, func, argtypes):
188189
wrapper_module = self._internal_codegen.create_empty_spirv_module(
189190
"dpex.kernel.wrapper"
190191
)
191-
wrappername = func.name.replace("dpex_fn", "dpex_kernel")
192+
wrappername = func.name + ("dpex_kernel")
192193
argtys = list(arginfo.argument_types)
193194
fnty = llvmir.FunctionType(
194195
llvmir.IntType(32),
@@ -319,12 +320,9 @@ def target_data(self):
319320

320321
def mangler(self, name, types, *, abi_tags=(), uid=None):
321322
"""
322-
Generates a name for a function by appending \"dpex_fn\" to the
323-
name of the function before calling Numba's default function name
324-
mangler."""
325-
return funcdesc.default_mangler(
326-
name + "dpex_fn", types, abi_tags=abi_tags, uid=uid
327-
)
323+
Generates a mangled function name using numba_dpex's itanium mangler.
324+
"""
325+
return itanium_mangler.mangle(name, types, abi_tags=abi_tags, uid=uid)
328326

329327
def prepare_spir_kernel(self, func, argtypes):
330328
"""Generates a wrapper function with \"spir_kernel\" calling conv that

0 commit comments

Comments
 (0)