Skip to content

Improve debug info for kernel arguments#242

Merged
gmarkall merged 3 commits intoNVIDIA:mainfrom
jiel-nv:dbg-arg-match
May 20, 2025
Merged

Improve debug info for kernel arguments#242
gmarkall merged 3 commits intoNVIDIA:mainfrom
jiel-nv:dbg-arg-match

Conversation

@jiel-nv
Copy link
Contributor

@jiel-nv jiel-nv commented May 6, 2025

In order to leverage more accurate debug info tracking from the nvvm compiler, kernel argument name need to be exact matching the name from the metadata, which is using source level user symbol.

(1) Change the CUDACallConv on CUDA target to not prefix "arg." on argument name;
(2) Call CUDA DIBuilder to build up customized DISubroutineType which is different than the parent method;
(3) Add a debug info unit test to guard this change.

This fixes nvbug#5027369.

@gmarkall gmarkall added the 3 - Ready for Review Ready for review by team label May 7, 2025
"""
assert not noalias
arginfo = self._get_arg_packer(fe_argtypes)
# Do not prefix "arg." on argument name, so that nvvm compiler
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that it's OK not to prefix arg. onto the name - as far as I can tell it's a convention that was added that has not become load-bearing in any way - I don't think a duplicate name will appear inside a function body.


# Create metadata type for return value
if len(llfunc.args) > 0:
lltype = llfunc.args[0].type
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does omitting the replacement of . with $ compared to the original implementation not cause issues for GDB? I note the comment in the original version:

name = llarg.name.replace('.', '$')    # for gdb to work correctly

I thought that a dot in a name might be problematic for it? (c.f. the same syntax for traversing the members of a struct or union)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That . versioned name used to be written to the metadata node as the value of 'name' of DILocalVariable. But currently the . versioned variable nodes are merged to the unversioned / user symbol named metadata node. Therefore, they are no longer to be present in DWARF entry.
And when represented as member of a struct or union, their names in the metadata are also unversioned names with corresponding types, so there won't be issues omitting this original replacement.
In short, neither . nor $ will show up in debugger.

Copy link
Contributor

@gmarkall gmarkall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good in general - I do have one question on the diff, and I'd like to understand if / why it's OK.

@gmarkall gmarkall added 4 - Waiting on author Waiting for author to respond to review and removed 3 - Ready for Review Ready for review by team labels May 20, 2025
@gmarkall gmarkall added 5 - Ready to merge Testing and reviews complete, ready to merge and removed 4 - Waiting on author Waiting for author to respond to review labels May 20, 2025
@gmarkall gmarkall merged commit 427aa0d into NVIDIA:main May 20, 2025
37 checks passed
@isVoid isVoid mentioned this pull request May 21, 2025
isVoid added a commit that referenced this pull request May 21, 2025
- Allow External Code to Use Cooperative Group (#240)
- Improve debug info for kernel arguments (#242)
- Allow Numba NVRTC Binding Search Additional Paths (#254)
- Add Bfloat16 High Level API, Documentation (#245)
- add a test to use bf16 bindings inside device functions (#244)
- Change CI to only be manually triggered to save on CI runs (#252)
- Simplify the CI build and test matrix (#249)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

5 - Ready to merge Testing and reviews complete, ready to merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments