PTX ISA v9.4

11.5.6. Debugging Directives: .nv_intermediate_source_section

.nv_intermediate_source_section

Embed intermediate IR source code in the PTX module.

Syntax

ptx
.nv_intermediate_source_section {
    .code_block {
        .ir_name:        ir-name-string
        .sourceFileName: file-index
        .source_begin
            source-text
        .source_end
    }
    [ .code_block { ... } ]*
}

ir-name-string = quoted string identifier (e.g., "TileIR")
file-index     = unsigned integer matching a .file directive
source-text    = raw text of the intermediate IR source (heredoc)

Description

The .nv_intermediate_source_section construct embeds the source code of one or more intermediate IR compilation units directly into the PTX module. Each .code_block entry associates an ir_name string (identifying the intermediate language, e.g., "TileIR") with a .file index and the raw text of that source file.

The .sourceFileName field must reference a file_index already declared by a .file directive in the same PTX module. The .source_begin and .source_end constructs indicate the start and end of the source text and may contain arbitrary text including newlines.

Each .code_block produces a separate ELF section with name based on the specified ir_name. Currently only "TileIR" is supported for ir-name. The .nv_intermediate_source_section is allowed only at module scope. Multiple .nv_intermediate_source_section blocks may appear in a single PTX module; their .code_block entries are concatenated in order.

PTX ISA Notes

Introduced in PTX ISA version 9.4.

Target ISA Notes

Supported on all target architectures.

Examples

ptx
.visible .entry _Z9vectorAddPf(
    .param .u64 .ptr .align 1 _Z9vectorAddPf_param_0
) {
    .loc 1 11 15
    .loc_intermediate 2 137 23
    ld.b64 %rd2, [%SP];
    .loc 1 12 15
    .loc_intermediate 3 24 23
    ld.b64 %rd3, [%SP];
}
.file 1 "./vectorAdd.cu"
.file 2 "./tileIR_source_A.ir"
.file 3 "./tileIR_source_B.ir"
.nv_intermediate_source_section {
    .code_block {
        .ir_name:        "TileIR"
        .sourceFileName: 2
        .source_begin
            __global__ void vectorAdd(float *v) { float a, b; *v = a + b; }
        .source_end
    }
    .code_block {
        .ir_name:        "TileIR"
        .sourceFileName: 3
        .source_begin
            __global__ void vectorSub(float *v) { float a, b; *v = a - b; }
        .source_end
    }
}
esc
Type to search across all documentation