Anyway to view ptx code of OpenCl kernel?

In CUDA I was able to look at the ptx code by using nvcc -ptx switch when compiling.

In openCL the kernels are compiled at runtime, is there anyway I can view the ptx code of the kernel?

I tried searching around and reading some docs but couldn’t find any way to do this.

This took me a while to figure out as well.

The ptx code is the “binary” to the OpenCL implementation. So to get at the ptx code you need to get the OpenCL api to give you the “binaries” of your compiled program. You do this with the function clGetProgramInfo() and the two constants CL_PROGRAM_BINARY_SIZES and CL_PROGRAM_BINARIES.

Details on how to use these should be pretty easy to find in the documentation once you know what to look for.