Skip to content

Honor PTX_SIM_KERNELFILE override on CUDA >= 6.0 - #136

Open
hzb0402 wants to merge 1 commit into
accel-sim:devfrom
hzb0402:fix-ptx-kernelfile-override
Open

Honor PTX_SIM_KERNELFILE override on CUDA >= 6.0#136
hzb0402 wants to merge 1 commit into
accel-sim:devfrom
hzb0402:fix-ptx-kernelfile-override

Conversation

@hzb0402

@hzb0402 hzb0402 commented Jul 11, 2026

Copy link
Copy Markdown

Problem

The PTX_SIM_USE_PTX_FILE / PTX_SIM_KERNELFILE override — documented in the
README for simulating a hand-edited PTX file without recompiling the
application — has no effect on CUDA 6.0+.

The override is only implemented in the legacy pre-CUDA-6.0 branch of
cuobjdumpParseBinary. On CUDA 6.0+ the active #if (CUDART_VERSION >= 6000)
branch loads PTX solely from the cuobjdump-extracted filename (which is
regenerated on every run via cuobjdump -xptx), so a hand-edited PTX file can
never be picked up. The misleading part is that the
"overriding embedded ptx ... (PTX_SIM_USE_PTX_FILE is set)" message is still
printed during initialization, so it looks like the override is active when it
is not.

Fix

Honor PTX_SIM_KERNELFILE in the CUDART_VERSION >= 6000 loading loop as well,
gated on both PTX_SIM_USE_PTX_FILE and PTX_SIM_KERNELFILE being set so the
default behavior is unchanged. PTXInfo (register / shared-memory usage) is still
loaded from the originally extracted file, so occupancy is unaffected.

Testing

  • Built against CUDA 12.8, gcc 13.4 (make clean && make).
  • Baseline vectoradd (no env vars) still PASSES, confirming default behavior is
    unchanged.
  • With PTX_SIM_USE_PTX_FILE=1 PTX_SIM_KERNELFILE=<edited>.ptx, a hand-edited
    PTX (e.g. changing the stored value) is now correctly picked up and changes the
    computed result, whereas on the unpatched build it was silently ignored.

Made with Cursor

The PTX_SIM_USE_PTX_FILE / PTX_SIM_KERNELFILE override, documented in the
README for simulating a hand-edited PTX file without recompiling the
application, was only implemented in the legacy pre-CUDA-6.0 PTX loading
branch of cuobjdumpParseBinary.

On CUDA 6.0+ the active #if (CUDART_VERSION >= 6000) branch loads PTX
solely from the cuobjdump-extracted filename (which is regenerated on every
run), so the override silently had no effect even though the "overriding
embedded ptx ... (PTX_SIM_USE_PTX_FILE is set)" message was still printed
during initialization.

Honor PTX_SIM_KERNELFILE in the CUDART_VERSION >= 6000 loading loop as
well, gated on both PTX_SIM_USE_PTX_FILE and PTX_SIM_KERNELFILE being set
so default behavior is unchanged. PTXInfo (register/shared-memory usage) is
still loaded from the originally extracted file.
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