How can I map PTX instructions to SASS instructions?

I need to find out which SASS instructions correspond to a specific PTX instruction. Is there a tool available that can accomplish this? Thank you.

Hello!

Thank you very much for the question.

Can you use NVIDIA Nsight Visual Studio Edition | NVIDIA Developer ? It has the PTX/SASS/mixed disassembly, so if that tool could be used, it should provide the required correlation.

Thank you for your response. I’d like to ask if there is a way to automatically generate comparison files for CUDA code - PTX instructions - SASS instructions using the command line, without using a GUI.I also wanted to ask if the Jetson AGX Xavier can use the NVIDIA Nsight Visual Studio Edition that you mentioned?Thank you for your explanation.

Hi!

I’d like to ask if there is a way to automatically generate comparison files for CUDA code - PTX instructions - SASS instructions using the command line, without using a GUI.

This functionality is not available in the debugging tools. I have moved the question to the general CUDA programming forum branch, so it can reach wider audience.

I also wanted to ask if the Jetson AGX Xavier can use the NVIDIA Nsight Visual Studio Edition that you mentioned?

At the moment NVIDIA Nsight Visual Studio Edition only support CUDA debugging on desktop Windows, so it cannot be used for Jetson AGX.

I don’t know of tools that do exactly what you describe. The closest I can think of would be nsight compute, which can display corresponding source, PTX, and SASS in the GUI via the source page. That particular picture shows source and SASS, but you can select other combinations such as source and PTX. You’ll need to compile with arch switches that specify an appropriate PTX in the binary, as well as -lineinfo. There is a also a similar “standalone” variant (still uses GUI). Yes, nsight compute can be used with jetson. You will probably need to operate in the mode where you collect the profiler file on the jetson, then import it into nsight compute running elsewhere (e.g. on your desktop/laptop computer).

But since you say you don’t want a GUI, the only other thing that comes to mind is the binary utilities which can be run from the command line. Both nvdisasm and cuobjdump can show PTX and SASS, but they are not side-by-side or lined up with the source. However nvdisasm (with -g or -gi) can refer you to specific lines of source code for each section of SASS. Coupled with that, nvcc has a source-in-ptx option. Not sure if any of that will meet your CLI needs. You can find forum posts asking about nearly all of these topics/tools/uses.

In isolation or in context? In general, this is difficult to do in the context of actual kernel code compiled with optimizations due to the fairly extensive transformations the ptxas optimizing compiler applies to code when it translates PTX to SASS (machine code).

A specific operation performed by a PTX instruction may disappear (e.g. through strength reduction) or may be combined with another instruction into a single SASS instruction. If the PTX instruction maps to an emulation sequence, the constituent SASS instructions of that emulation sequence could be spread out in the machine code, and they could be partially modified or eliminated (e.g. through constant propagation).