Toothery
Toothery

Reputation: 185

Using nvdisasm to generate control flow image of PTX code

I have a single file of CUDA code compiled to intermediate language PTX code, example.ptx. I would be interested to start poking around with this short file, trying to understand how it works.

I don't have previous experience fiddling around with intermediate code representation, but what I gather is that I can some how print out a figure of the control flow, to support me trying to reverse engineer this. Cuda Binary Utilities mention nvdisasm and shows nice Graphviz figures of the control flow, but it seems to work only for cubin files. I understand that these cubin files are optimized further from PTX, depending on the current GPU architecture.

My question is: Can I use nvdisasm to generate control flow image from example.ptx, or compile the ptx file to a cubin file, and use that to generate the image?

Upvotes: 1

Views: 492

Answers (1)

Robert Crovella
Robert Crovella

Reputation: 151849

or compile the ptx file to a cubin file, and use that

Yes, you can do that. Compile your ptx file to a cubin with:

nvcc example.ptx -cubin 

(the result will be in example.cubin or you could add e.g. -o myfile.cubin to name it something else)

This cubin file can be fed to nvdisasm for processing.

Upvotes: 2

Related Questions