# OpenACC: View Generated CUDA Code

This is going to be a short post on how one can view the actual compiler generated CUDA code when running OpenACC on NVIDIA hardware. It is a warmup to my upcoming post on where-data-goes-with-OpenACC’s-various-data-directives.

When compiling a OpenACC accelerated program, heres what a canonical compile command would look like for the PGI compiler

(Yes, this is from my first OpenACC tutorial)

With these set of options, the intermediate PTX or CUDA code is not visible to the user. However, if we add keepgpu,nollvm to the -ta=nvidia option, then the compiler dumps those for us to see. With only keepgpu, you would get only the PTX source code and binaries.

With this, ordinary OpenACC’d code like this:

Would generate an intermediate file that looks like this:

While this is legal CUDA code, its quite cluttered. With a neato perl oneliner, we can get that a bit cleaner and easier to read:

Code is now:

Much better.

Thats it! Hope this (and my next OpenACC post TODO:insert link ) helps you guys.

PS: I wonder if a screencast is a better medium for my (b)log.