Skip to content

Commit 040747f

Browse files
Support Numba 0.55 (including #7177 for GDB) (#585)
* Support mark_subprogram() changes and DIBuilder.__init__() changes * Support abi-tags in mangler * Support mark_subprogram changes in numba(master) * Remove sending abi-tags for debuginfo * Fix import TargetConfigurationStack * Make abi_tags support optional * Keep compatibility w/ numba 0.54 * Make DPPYDIBuilder compatible w/ numba 0.54 and 0.55 * Test w/ numba 0.55.0dev0=*_782 * Use different numba packages for py38 and py39 Co-authored-by: Vladislav Perevezentsev <vladislav.perevezentsev@intel.com>
1 parent 5b01214 commit 040747f

File tree

7 files changed

+75
-17
lines changed

7 files changed

+75
-17
lines changed

.github/workflows/conda-package.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,9 @@ jobs:
122122
strategy:
123123
matrix:
124124
python: [3.8, 3.9]
125-
numba: [0.54, "0.55.0dev0=*_469"]
125+
numba: ["0.54"]
126126
integration_channels: [""]
127-
experimental: [true] # packages are not available on -c intel yet
127+
experimental: [false]
128128
artifact_name: [""]
129129
dependencies: [""]
130130
include:
@@ -134,6 +134,18 @@ jobs:
134134
artifact_name: -c dppy_label_dev
135135
experimental: false # current stable
136136
dependencies: ""
137+
- python: "3.8"
138+
numba: "0.55.0dev0=*_782"
139+
integration_channels:
140+
artifact_name: ""
141+
experimental: false # current stable
142+
dependencies: ""
143+
- python: "3.9"
144+
numba: "0.55.0dev0=*_778"
145+
integration_channels: ""
146+
artifact_name: ""
147+
experimental: false # current stable
148+
dependencies: ""
137149
continue-on-error: ${{ matrix.experimental }}
138150
env:
139151
# conda-forge: llvm-spirv 11 not on intel channel yet

numba_dppy/core/passes/dppy_lowerer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1301,6 +1301,7 @@ def _lower(self, context, library, fndesc, func_ir, metadata):
13011301
module=lower.module,
13021302
filepath=func_ir.loc.filename,
13031303
linkage_name=mangled_qualname,
1304+
cgctx=context,
13041305
)
13051306

13061307
return lower

numba_dppy/core/passes/dppy_passes.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,12 @@ def run_pass(self, state):
296296
state.func_id.func_name,
297297
)
298298
with fallback_context(state, msg):
299+
kwargs = {}
300+
301+
# for support numba 0.54 and <=0.55.0dev0=*_469
302+
if hasattr(flags, "get_mangle_string"):
303+
kwargs["abi_tags"] = flags.get_mangle_string()
304+
299305
# Lowering
300306
fndesc = (
301307
funcdesc.PythonFunctionDescriptor.from_specialized_function(
@@ -306,6 +312,7 @@ def run_pass(self, state):
306312
mangler=targetctx.mangler,
307313
inline=flags.forceinline,
308314
noalias=flags.noalias,
315+
**kwargs,
309316
)
310317
)
311318

numba_dppy/dppy_debuginfo.py

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,48 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import numba as nb
1516
from llvmlite import ir
1617
from numba.core.debuginfo import DIBuilder
1718

19+
numba_version = tuple(map(int, nb.__version__.split(".")[:2]))
20+
1821

1922
class DPPYDIBuilder(DIBuilder):
20-
def __init__(self, module, filepath, linkage_name):
21-
DIBuilder.__init__(self, module, filepath)
23+
def __init__(self, module, filepath, linkage_name, cgctx):
24+
args = []
25+
26+
if numba_version > (0, 54):
27+
args.append(cgctx)
28+
29+
DIBuilder.__init__(self, module, filepath, *args)
2230
self.linkage_name = linkage_name
2331

24-
def mark_subprogram(self, function, name, line):
25-
di_subp = self._add_subprogram(
26-
name=name, linkagename=self.linkage_name, line=line
27-
)
28-
function.set_metadata("dbg", di_subp)
29-
# disable inlining for this function for easier debugging
30-
function.attributes.add("noinline")
32+
if numba_version > (0, 54):
33+
34+
def mark_subprogram(self, function, qualname, argnames, argtypes, line):
35+
name = qualname
36+
argmap = dict(zip(argnames, argtypes))
37+
di_subp = self._add_subprogram(
38+
name=name,
39+
linkagename=self.linkage_name,
40+
line=line,
41+
function=function,
42+
argmap=argmap,
43+
)
44+
function.set_metadata("dbg", di_subp)
45+
# disable inlining for this function for easier debugging
46+
function.attributes.add("noinline")
47+
48+
else:
49+
50+
def mark_subprogram(self, function, name, line):
51+
di_subp = self._add_subprogram(
52+
name=name, linkagename=self.linkage_name, line=line
53+
)
54+
function.set_metadata("dbg", di_subp)
55+
# disable inlining for this function for easier debugging
56+
function.attributes.add("noinline")
3157

3258
def _di_compile_unit(self):
3359
di = super()._di_compile_unit()

numba_dppy/extended_numba_itanium_mangler.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,18 @@ def mangle_args(argtys):
5757
return "".join([mangle_type_or_value(t) for t in argtys])
5858

5959

60-
def mangle(ident, argtys):
60+
def mangle(ident, argtys, *, abi_tags=()):
6161
"""
62-
Mangle identifier with Numba type objects and arbitrary values.
62+
Mangle identifier with Numba type objects and abi-tags.
6363
"""
64+
kwargs = {}
65+
66+
# for support numba 0.54 and <=0.55.0dev0=*_469
67+
if abi_tags:
68+
kwargs["abi_tags"] = abi_tags
69+
6470
return (
6571
itanium_mangler.PREFIX
66-
+ itanium_mangler.mangle_identifier(ident)
72+
+ itanium_mangler.mangle_identifier(ident, **kwargs)
6773
+ mangle_args(argtys)
6874
)

numba_dppy/retarget.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@
1616

1717
import dpctl
1818
from numba import njit
19-
from numba.core.dispatcher import TargetConfig
19+
20+
try:
21+
from numba.core.dispatcher import TargetConfigurationStack
22+
except ImportError:
23+
# for support numba 0.54 and <=0.55.0dev0=*_469
24+
from numba.core.dispatcher import TargetConfig as TargetConfigurationStack
25+
2026
from numba.core.retarget import BasicRetarget
2127

2228
from numba_dppy.target import DPPY_TARGET_NAME
@@ -54,7 +60,7 @@ def _retarget(sycl_queue):
5460
def _retarget_context_manager(sycl_queue):
5561
"""Return context manager for retargeting njit offloading."""
5662
retarget = _retarget(sycl_queue)
57-
return TargetConfig.switch_target(retarget)
63+
return TargetConfigurationStack.switch_target(retarget)
5864

5965

6066
def _register_context_factory():

numba_dppy/target.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ def codegen(self):
370370
def target_data(self):
371371
return self._target_data
372372

373-
def mangler(self, name, argtypes):
373+
def mangler(self, name, argtypes, abi_tags=()):
374374
def repl(m):
375375
ch = m.group(0)
376376
return "_%X_" % ord(ch)

0 commit comments

Comments
 (0)