Skip to content

Commit 3e9e705

Browse files
jiel-nvgmarkall
authored andcommitted
Fix the debug info of GridGroup type
The customized CUDA front end type 'GridGroup' maps to the back end type 'ir.IntType(64)' which is defined in numba.cuda.models. The numba DIBuilder emit variable types for simple numeric types by looking into back end type which falls through the 'DW_ATE_float' because the 'datamodel.fe_type' is not 'types.Integer'. So emitting this type through the CUDADIBuilder is needed. Since the type represents the handle of a group object, giving it the encoding of 'DW_ATE_unsigned' should be reasonable. A test is also added in this change. This change addresses #107
1 parent 6296664 commit 3e9e705

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

numba_cuda/numba/cuda/debuginfo.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from llvmlite import ir
22
from numba.core import types
33
from numba.core.debuginfo import DIBuilder
4+
from numba.cuda.types import GridGroup
45

56
_BYTE_SIZE = 8
67

@@ -9,21 +10,29 @@ class CUDADIBuilder(DIBuilder):
910

1011
def _var_type(self, lltype, size, datamodel=None):
1112
is_bool = False
13+
is_grid_group = False
1214

1315
if isinstance(lltype, ir.IntType):
1416
if datamodel is None:
1517
if size == 1:
1618
name = str(lltype)
1719
is_bool = True
18-
elif isinstance(datamodel.fe_type, types.Boolean):
20+
else:
1921
name = str(datamodel.fe_type)
20-
is_bool = True
22+
if isinstance(datamodel.fe_type, types.Boolean):
23+
is_bool = True
24+
elif isinstance(datamodel.fe_type, GridGroup):
25+
is_grid_group = True
2126

22-
# Booleans should use our implementation until upstream Numba is fixed
23-
if is_bool:
27+
if is_bool or is_grid_group:
2428
m = self.module
2529
bitsize = _BYTE_SIZE * size
26-
ditok = "DW_ATE_boolean"
30+
# Boolean type workaround until upstream Numba is fixed
31+
if is_bool:
32+
ditok = "DW_ATE_boolean"
33+
# GridGroup type should use numba.cuda implementation
34+
elif is_grid_group:
35+
ditok = "DW_ATE_unsigned"
2736

2837
return m.add_debug_info('DIBasicType', {
2938
'name': name,

numba_cuda/numba/cuda/tests/cudapy/test_debuginfo.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,19 @@ def f(x, y):
110110
match = re.compile(pat).search(llvm_ir)
111111
self.assertIsNotNone(match, msg=llvm_ir)
112112

113+
def test_grid_group_type(self):
114+
sig = (types.int32,)
115+
116+
@cuda.jit(sig, debug=True, opt=False)
117+
def f(x):
118+
grid = cuda.cg.this_grid() # noqa: F841
119+
120+
llvm_ir = f.inspect_llvm(sig)
121+
122+
pat = r'!DIBasicType\(.*DW_ATE_unsigned, name: "GridGroup", size: 64'
123+
match = re.compile(pat).search(llvm_ir)
124+
self.assertIsNotNone(match, msg=llvm_ir)
125+
113126
@unittest.skip("Wrappers no longer exist")
114127
def test_wrapper_has_debuginfo(self):
115128
sig = (types.int32[::1],)

0 commit comments

Comments
 (0)