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.