Skip to content

Commit abf9598

Browse files
authored
[DEBUG] Show inline stack in cuda-gdb (#7710)
Example usage: ``` DISABLE_PTXAS_OPT=1 CUDA_LAUNCH_BLOCKING=1 cuda-gdb --args python test.py ``` Caution: We can only synthesize complete inline stack when all ptxas optimizations are off.
1 parent a372a80 commit abf9598

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

third_party/nvidia/backend/compiler.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,18 @@ def make_cubin(self, src, metadata, opt, capability):
421421
fsrc.flush()
422422
fbin = fsrc.name + '.o'
423423

424-
line_info = ["-lineinfo", "-suppress-debug-info"] if knobs.compilation.disable_line_info else ["-lineinfo"]
425-
fmad = [] if opt.enable_fp_fusion else ['--fmad=false']
424+
debug_info = []
425+
if knobs.compilation.disable_line_info:
426+
# This option is ignored if used without -lineinfo
427+
debug_info += ["-lineinfo", "-suppress-debug-info"]
428+
elif knobs.nvidia.disable_ptxas_opt:
429+
# Synthesize complete debug info
430+
debug_info += ["-g"]
431+
else:
432+
# Only emit line info
433+
debug_info += ["-lineinfo"]
434+
435+
fmad = [] if opt.enable_fp_fusion else ["--fmad=false"]
426436
arch = sm_arch_from_capability(capability)
427437

428438
# Disable ptxas optimizations if requested
@@ -432,8 +442,8 @@ def make_cubin(self, src, metadata, opt, capability):
432442
ptx_extra_options = opt.ptx_options.split(" ") if opt.ptx_options else []
433443

434444
ptxas_cmd = [
435-
ptxas, *line_info, *fmad, '-v', *disable_opt, *ptx_extra_options, f'--gpu-name={arch}', fsrc.name, '-o',
436-
fbin
445+
ptxas, *debug_info, *fmad, '-v', *disable_opt, *ptx_extra_options, f'--gpu-name={arch}', fsrc.name,
446+
'-o', fbin
437447
]
438448
try:
439449
subprocess.run(ptxas_cmd, check=True, close_fds=False, stderr=flog)

0 commit comments

Comments
 (0)