fix(cuda.core): let cuda-gdb display source for JIT-compiled kernels - #2678
fix(cuda.core): let cuda-gdb display source for JIT-compiled kernels#2678brandon-b-miller wants to merge 6 commits into
Conversation
|
NVIDIAgh-2385 and NVIDIAgh-2422 were filed for the same NVBug (6420444) and assigned to two people. NVIDIA#2679 landed the temp-file fix from NVIDIAgh-2422 first, so this branch's parallel implementation is dropped in favor of the one on main: keeping both would have left two mechanisms writing a source file on every debug compile, with the NVRTC name deciding which one was actually used. Resolved by taking main's side for every overlapping file and removing _jit_source.py, leaving this branch identical to main. What remains of NVIDIAgh-2385 is handled in follow-up commits.
Redirecting the NVRTC program name at a temp .cu (NVIDIA#2679) left two problems. Quoted includes stopped resolving. NVRTC searches the directory of the name it is handed for #include "...", so moving that name into the temp dir moved the search with it, and merely enabling debug or lineinfo broke a compile that worked without it. The directory the name used to denote is now passed back as --include-path. It is added to the compile options only, never to ProgramOptions, so the program cache key is unchanged; the cwd was already an unkeyed input to these compiles before the redirect. Teardown deleted files it did not create. The name given to NVRTC doubled as the cleanup target, but that slot still holds the caller's options.name whenever the source was not redirected, so a name like "matmul.cu" matching a real file meant close() or collection deleted the caller's own source. The temp path is tracked separately now and is the only path unlinked. Removal on close() is left as it was, since NVIDIAgh-2422 asked for it and the tests added with NVIDIA#2679 assert it.
|
I hadn't realized this overlapped with #2679 by @lijinf2 . The issue that one closes and the issue this one targets are effectively circling the same thing. I've repurposed this PR to keep the implementation that already landed on |
Indeed, the two issues look highly relevant and involve similar code/files. Thanks for repurposing. I will prioritize the PR review and help merge soon. |
NVRTC appears to treat the program
namepassed as the path of the source file which it then propagates to the cubins dwarf table. However, Program compiles a string. So there's not actually a file at that path. cuda-gdb needs this to exist to show the source lines.This PR proposes to fix this issue by creating a temporary file when debug is passed that exists for the process lifetime. This fix targets the use case of running the program containing the compilation through a
cuda-gdbsession and not any post-hoc debugging of such a program.Closes #2385