How to split huge cu?


I want to split huge .cu file, But got troubled.
I did the following steps

  1. Made multiple .ptx files by nvcc with “–relocatable-device-code=true” option.
  2. Load ptx files by optix::Context::createProgramFromPTXFiles(), but I got RT_ERROR_INVALID_SOURCE error.

I confirmed that the functions remains in ptx.

Q1. Can I link ptx by createProgramFromPTXFiles()?
Q2. What is the best solution to spliting huge .cu file?


Please always provide the following system configuration information when asking about OptiX issues:
OS version, installed GPU(s), VRAM amount, display driver version, OptiX major.minor.micro version, CUDA toolkit version used to generate the input PTX, host compiler version.

What streaming multiprocessor version did you target during the compilation (e.g. SM 3.0)?
How big are the “huge” files in code lines or bytes?
What’s in them?
What’s the reason you need to split them?
Does it work when not splitting them?

One simple approach would be to put each program (ray generation, any hit, closest hit, miss, exception, callables) into separate *.cu file per domain or even per individual program.
E.g. like this:

If that is still huge for individual programs, you need to work on your program architecture.

Oh, sorry.
Specs are following.

  • Win10 pro
  • Quadro RTX6000, driver is
  • Optix 6.5.0
  • nvcc is “release 10.0, V10.0.130”

.cu and .cuh has thousands of lines, I have to wait that compile everytime.
I wish I could compile *.cu separarely like as *.cpp.

Then searched on github but no-one use createProgramFromPTXFiles().
And I can’t find any examples…

Separate .cu for each program is good idea and easy to use.
But if there is a better way, I want to use it.