Skip to content

Add support for debug info.#175

Merged
maleadt merged 6 commits intomainfrom
tb/debuginfo
Apr 5, 2026
Merged

Add support for debug info.#175
maleadt merged 6 commits intomainfrom
tb/debuginfo

Conversation

@maleadt
Copy link
Copy Markdown
Member

@maleadt maleadt commented Apr 5, 2026

Demo with vadd from the README:

julia> ct.@device_code_tiled debuginfo=true ct.launch(vadd, grid, a, b, c, ct.Constant(tile_size))
// vadd(cuTile.TileArray{Float32, 1, cuTile.ArraySpec{1, 128, true, (0,), (16,)}()}, cuTile.TileArray{Float32, 1, cuTile.ArraySpec{1, 128, true, (0,), (16,)}()}, cuTile.TileArray{Float32, 1, cuTile.ArraySpec{1, 128, true, (0,), (16,)}()}, cuTile.Constant{Int64, 16})

cuda_tile.module @kernels {
  entry @vadd(%arg0: tile<ptr<f32>>, %arg1: tile<i32>, %arg2: tile<i32>, %arg3: tile<ptr<f32>>, %arg4: tile<i32>, %arg5: tile<i32>, %arg6: tile<ptr<f32>>, %arg7: tile<i32>, %arg8: tile<i32>) {
    %cst_16_i64 = constant <i64: 16> : tile<i64> loc(#loc)
    ...
  } loc(#loc23)
} loc(#loc)
#di_file = #cuda_tile.di_file<"REPL[3]" in "">
#di_file1 = #cuda_tile.di_file<"operations.jl" in "/home/tim/Julia/pkg/cuTile/src/language">
#di_file2 = #cuda_tile.di_file<"arithmetic.jl" in "/home/tim/Julia/pkg/cuTile/src/language">
#loc = loc(unknown)
#loc1 = loc("REPL[3]":2:0)
...
#loc22 = loc("/home/tim/Julia/pkg/cuTile/src/language/operations.jl":229:0)
#di_compile_unit = #cuda_tile.di_compile_unit<file = #di_file>
...
julia> @device_code_sass ct.launch(vadd, grid, a, b, c, ct.Constant(tile_size))
        .target sm_120a

        .elftype        @"ET_EXEC"


//--------------------- .text.vadd                --------------------------
        .section        .text.vadd,"ax",@progbits
        .align  128
        .global         vadd
        .type           vadd,@function
        .size           vadd,(.L_x_5 - vadd)
        .other          vadd,@"STO_CUDA_ENTRY STV_DEFAULT"
vadd:

.text.vadd:
; Location REPL[3]:2
        LDC R1, c[0x0][0x37c] ;
; Location /home/tim/Julia/pkg/cuTile/src/language/operations.jl:47
        S2UR UR5, SR_CTAID.X ;
; Location REPL[3]:2
        LDCU UR7, c[0x0][0x388] ;
; Location /home/tim/Julia/pkg/cuTile/src/language/operations.jl:47
        CS2R.32 R6, SR_CgaSize ;
        IMAD R6, R6, -0xa0, RZ ;
        R2UR UR6, R6 ;
        LDCU UR6, c[0x0][UR6+0x2b0] ;
; Location REPL[3]:2
        USHF.R.S32.HI UR4, URZ, 0x1f, UR7 ;
        ULEA.HI UR4, UR4, UR7, URZ, 0x4 ;
; Location /home/tim/Julia/pkg/cuTile/src/language/operations.jl:47
        UI2FP.F32.U32 UR5, UR5 ;
; Location REPL[3]:2
        ULOP3.LUT UR8, UR4, 0xfffffff0, URZ, 0xc0, !UPT ;
; Location /home/tim/Julia/pkg/cuTile/src/language/operations.jl:47
        UFMUL UR5, UR6, UR5 ;

It's ironic that cuTile.jl now has full debug info before CUDA.jl...

maleadt and others added 6 commits April 5, 2026 17:33
Constants, tensor views, and other operations emitted before emit_block!
now get the kernel's source location instead of loc(unknown).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
get_subprogram! now takes a SourceLocation instead of just the method,
so it always has file/line context regardless of Julia version. Previously
it created subprograms with <unknown> file on 1.11, causing
cuda-tile-translate verification failures.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
On 1.11, Core.LineInfoNode contains a Module field which cannot be
deepcopied. Sever the Block→SCI parent backref before deepcopy to
avoid pulling in debuginfo_table, then reassemble.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Follows Julia's own pattern. IRStructurizer now defines
Base.copy(::StructuredIRCode) which shares the read-only
debuginfo_table and copies the mutable block tree.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@maleadt maleadt merged commit 390fdee into main Apr 5, 2026
9 of 17 checks passed
@maleadt maleadt deleted the tb/debuginfo branch April 5, 2026 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant