Generating ptx code using OptiX 7.4 and CMake

target_compile_options(${output_var}_lib PRIVATE --generate-line-info -use_fast_math -arch=sm_60 --keep)

If these are all your NVCC command line options, you’re missing the --ptx flag which is telling the compiler to only translate from *.cu to *.ptx code. You’ve most likely compiled to cubins. Simply look at your *.ptx output files in a text editor. If that is not human readable PTX assembly text, you’re doing it wrong.

In my OptiX applications I’m using a custom build rule for each *.cu file which is implemented here. That predates the newer native CMake support for CUDA which I haven’t looked at.
Note the commented message instruction in line 45 which will print the actual NVCC command line to the CMake output window. Compare that to the command lines you’re using.
https://github.com/NVIDIA/OptiX_Apps/blob/master/3rdparty/CMake/nvcuda_compile_ptx.cmake
Usage is shown here:
https://github.com/NVIDIA/OptiX_Apps/blob/master/apps/nvlink_shared/CMakeLists.txt#L168

We had that discussion before: https://forums.developer.nvidia.com/t/simple-ptx-shader-optix-7/165303

(Mind that payload and attribute registers are of type unsigned int. For cleaner code, use __uint_as_float and __float_as_uint for the reinterpret casts. The next OptiX SDK release is going to correct that in its examples.)

1 Like