reprospect.tools.binaries.elf module

This module provides tools to parse CUDA ELF files.

References:

class reprospect.tools.binaries.elf.CuInfo(note_version: int, virtual_sm: int, toolkit_version: int)View on GitHub

Bases: object

Specialized decoder for .note.nv.cuinfo section.

Here is a typical section:

.section .note.nv.cuinfo
Entry: 1
    Owner                  Data size        Description
    NVIDIA Corp            8                NVIDIA CUDA Information
        Note Version: 2
        CUDA Virtual SM: sm_100
        CUDA Tool Kit Version: 13.0

References:

__init__(note_version: int, virtual_sm: int, toolkit_version: int) None
classmethod decode(*, note: NoteSection) Generator[CuInfo, None, None]View on GitHub

Iterate the note entries and decode them.

note_version: int
toolkit_version: int
virtual_sm: int
class reprospect.tools.binaries.elf.ELF(*, file: Path)View on GitHub

Bases: object

Helper for reading ELF files and retrieve CUDA-specific information.

EF_CUDA_SM_OFFSET_POST_BLACKWELL: Final[int] = 8

Offset for compute capability field post BLACKWELL.

EF_CUDA_SM_POST_BLACKWELL: Final[int] = 65280

Mask for compute capability field post BLACKWELL.

EF_CUDA_SM_PRE_BLACKWELL: Final[int] = 255

Mask for compute capability field pre BLACKWELL.

References:

ELFABIVERSION_CUDA: Final[tuple[int, int]] = (7, 8)

References:

ELFOSABI_CUDA: Final[tuple[int, ...]] = (41, 51, 65)

References:

__enter__() SelfView on GitHub
__exit__(*args, **kwargs) NoneView on GitHub
__init__(*, file: Path) NoneView on GitHub
property arch: NVIDIAArchView on GitHub

Get compute capability encoded in header as NVIDIA architecture.

classmethod compute_capability(value) ComputeCapabilityView on GitHub

Return compute capability encoded in e_flags.

elf: ELFFile | None
file: Path

Path to the ELF file.

property header: ContainerView on GitHub
property is_cuda: boolView on GitHub

Return True if file is a valid CUDA binary file.

classmethod is_cuda_impl(*, header: Container) boolView on GitHub
nvinfo(mangled: str) NvInfoView on GitHub

Extract and parse the .nv.info.<mangled> section.

class reprospect.tools.binaries.elf.NvInfo(attributes: tuple[NvInfoEntry, ...])View on GitHub

Bases: object

Specialized decoder for a .nv.info.<mangled> section.

Here is a typical section as parsed by cuobjdump:

.nv.info._ZN6Kokkos4Impl33cuda_parallel_launch_local_memoryINS0_11ParallelForINS0_11ThenWrapperIN10reprospect8examples6kokkos5graph7FunctorINS_4ViewIiJNS_12CudaUVMSpaceEEEEEEEENS_11RangePolicyIJNS_4CudaENS0_16IsGraphKernelTagENS_12LaunchBoundsILj1ELj0EEEEEESF_EELj1ELj0EEEvT_
    <0x1>
    Attribute: EIATTR_CUDA_API_VERSION
    Format: EIFMT_SVAL
    Value: 0x82
    <0x2>
    Attribute: EIATTR_SW2861232_WAR
    Format: EIFMT_NVAL
    <0x3>
    Attribute: EIATTR_PARAM_CBANK
    Format: EIFMT_SVAL
    Value: 0x9 0x380160
    <0x4>
    Attribute: EIATTR_CBANK_PARAM_SIZE
    Format: EIFMT_HVAL
    Value: 0x38
    <0x5>
    Attribute: EIATTR_KPARAM_INFO
    Format: EIFMT_SVAL
    Value: Index : 0x0 Ordinal : 0x0 Offset  : 0x0 Size    : 0x38
        Pointee's logAlignment : 0x0 Space : 0x0 cbank : 0x1f Parameter Space : CBANK
    <0x6>
    Attribute: EIATTR_MAXREG_COUNT
    Format: EIFMT_HVAL
    Value: 0xff
    <0x7>
    Attribute: EIATTR_MERCURY_ISA_VERSION
    Format: EIFMT_HVAL
    Value: 0.0
    <0x8>
    Attribute: EIATTR_EXIT_INSTR_OFFSETS
    Format: EIFMT_SVAL
    Value: 0x60 0x170
    <0x9>
    Attribute: EIATTR_MAX_THREADS
    Format: EIFMT_SVAL
    Value: 0x1 0x1 0x1
    <0x10>
    Attribute: EIATTR_CRS_STACK_SIZE
    Format: EIFMT_SVAL
    Value: 0x0

References:

__init__(attributes: tuple[NvInfoEntry, ...]) None
attributes: tuple[NvInfoEntry, ...]
classmethod decode(*, section: Section) NvInfoView on GitHub
iter(eiattr: NvInfoEIATTR) Generator[NvInfoEntry, None, None]View on GitHub

Get attribute(s) of type eiattr.

classmethod parse(*, data: bytes) NvInfoView on GitHub

Parse a single .nv.info.<mangled> section according to the per-format rules.

class reprospect.tools.binaries.elf.NvInfoEIATTR(*values)View on GitHub

Bases: IntEnum

Attribute type that can be found in a .nv.info.<mangled> section.

References:

CBANK_PARAM_SIZE = 25
CRS_STACK_SIZE = 30
CUDA_API_VERSION = 55
EXIT_INSTR_OFFSETS = 28
KPARAM_INFO = 23
MAXREG_COUNT = 27
MAX_THREADS = 5
MERCURY_ISA_VERSION = 95
PARAM_CBANK = 10
SPARSE_MMA_MASK = 80
SW2861232_WAR = 53
SW_WAR = 54
VRC_CTA_INIT_COUNT = 74
WARP_WIDE_INSTR_OFFSETS = 49
class reprospect.tools.binaries.elf.NvInfoEIFMT(*values)View on GitHub

Bases: IntEnum

Attribute format in a .nv.info.<mangled> section.

References:

BVAL = 2
HVAL = 3
NVAL = 1
SVAL = 4
class reprospect.tools.binaries.elf.NvInfoEntry(eifmt: NvInfoEIFMT, eiattr: NvInfoEIATTR, value: bytes | int | tuple[int, ...] | None = None)View on GitHub

Bases: object

A single entry in a .nv.info.<mangled> section.

__init__(eifmt: NvInfoEIFMT, eiattr: NvInfoEIATTR, value: bytes | int | tuple[int, ...] | None = None) None
eiattr: NvInfoEIATTR
eifmt: NvInfoEIFMT
value: bytes | int | tuple[int, ...] | None
class reprospect.tools.binaries.elf.TkInfo(note_version: int, object_filename: str, tool_name: str, tool_version: str, tool_branch: str, tool_options: str)View on GitHub

Bases: object

Specialized decoder for .note.nv.tkinfo section.

Here is a typical section:

.section .note.nv.tkinfo
Entry: 1
    Owner                  Data size        Description
    NVIDIA Corp            140              NVIDIA CUDA Toolkit Information
        Note Version: 2
        Tool Name: ptxas
        Tool Version: Cuda compilation tools, release 13.0, V13.0.48
        Tool Branch: Build cuda_13.0.r13.0/compiler.36260728_0
        Tool Command Line Arguments: -arch sm_100 -m 64

References:

__init__(note_version: int, object_filename: str, tool_name: str, tool_version: str, tool_branch: str, tool_options: str) None
classmethod decode(*, note: NoteSection) Generator[TkInfo, None, None]View on GitHub

Iterate over the note entries and decode them.

static extract(arr: bytes, offset: int) strView on GitHub

The strings section starts at offset 24.

note_version: int
object_filename: str
tool_branch: str
tool_name: str
tool_options: str
tool_version: str