Skip to content

Conversation

@gmarkall
Copy link
Contributor

@gmarkall gmarkall commented Nov 17, 2025

One test still fails, because the C ABI wrapper generator generates no debug info, and the separate compilation seems to lead NVVM to not generate a debug section for it. This should probably be addressed by generating debug info for the C ABI wrapper.

Fixes #588.
Fixes NVBugs: 5196888, 5227483, 5639364.

One test still fails, because the C ABI wrapper generator generates no
debug info, and the separate compilation seems to lead NVVM to not
generate a debug section for it. This should probably be addressed by
generating debug info for the C ABI wrapper.
@gmarkall gmarkall added the 2 - In Progress Currently a work in progress label Nov 17, 2025
@copy-pr-bot
Copy link

copy-pr-bot bot commented Nov 17, 2025

Auto-sync is disabled for draft pull requests in this repository. Workflows must be run manually.

Contributors can view more details about this message here.

@gmarkall
Copy link
Contributor Author

/ok to test

@greptile-apps
Copy link

greptile-apps bot commented Nov 20, 2025

Greptile Overview

Greptile Summary

Modified PTX compilation to separate NVVM IR modules when generating debuginfo, reverting to pre-PR#8594 behavior for debug mode while maintaining combined compilation for lineinfo.

Key Changes:

  • Refactored get_asm_str() to call new get_asm_strs() which returns a list of PTX strings
  • When "g" option present (debug mode), each IR module compiles separately; otherwise all modules compile together
  • Updated linkage from linkonce_odr to weak_odr for debug mode to handle separate compilation
  • Modified compile_all() to use get_asm_strs() and link multiple PTX files
  • Added error handling in compile() to reject multi-PTX scenarios

Critical Issue Found:

  • Line 225 in codegen.py doesn't pass **options when compiling individual IR modules in debug mode, causing architecture and fastmath options to be dropped

Confidence Score: 2/5

  • This PR has a critical bug that will cause compilation failures or incorrect code generation in debug mode
  • Score reflects the missing **options parameter on line 225 which will cause the arch option and other compilation settings to not be passed to NVVM when compiling with debug info, likely resulting in compilation errors or incorrect target architecture
  • numba_cuda/numba/cuda/codegen.py requires immediate attention - line 225 must include **options parameter

Important Files Changed

File Analysis

Filename Score Overview
numba_cuda/numba/cuda/codegen.py 2/5 Refactored PTX compilation to support separate debug modules, but missing **options in debug path (line 225) causes arch/fastmath options to be dropped
numba_cuda/numba/cuda/compiler.py 4/5 Updated to use get_asm_strs() for multiple PTX outputs; includes error handling for compile() when multiple PTX files generated (minor typo in error message)

Sequence Diagram

sequenceDiagram
    participant User
    participant compile/compile_all
    participant CUDACodeLibrary
    participant nvvm
    participant Linker

    User->>compile/compile_all: compile with debug=True
    compile/compile_all->>CUDACodeLibrary: create library with nvvm_options["g"]
    
    alt compile_all() path
        compile/compile_all->>CUDACodeLibrary: get_asm_strs(cc)
        CUDACodeLibrary->>CUDACodeLibrary: check if "g" in options
        alt debug mode ("g" in options)
            loop for each IR module
                CUDACodeLibrary->>nvvm: compile_ir(ir, **options)
                nvvm-->>CUDACodeLibrary: PTX module
            end
        else lineinfo/no debug
            CUDACodeLibrary->>nvvm: compile_ir(all_irs, **options)
            nvvm-->>CUDACodeLibrary: single PTX
        end
        CUDACodeLibrary-->>compile/compile_all: list of PTX modules
    else compile() path
        compile/compile_all->>CUDACodeLibrary: get_asm_strs(cc)
        CUDACodeLibrary-->>compile/compile_all: list of PTX modules
        alt multiple PTX files
            compile/compile_all->>User: RuntimeError
        else single PTX file
            compile/compile_all->>User: return PTX
        end
    end

    compile/compile_all->>Linker: add_ptx() for each PTX
    Linker-->>User: linked binary
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

- logic: missing `**options` parameter - `arch` and other compilation options won't be passed when compiling with debug info
- syntax: missing space in error message

Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

2 - In Progress Currently a work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] Compilation for debug requires separate translation of each NVVM IR module

1 participant