Create single .ptx (or .cubin) file from multiple .cu sources

Hey there!

Is it possible to create single ptx or cubin file from multiple cu sources?
Maybe compile sources to some intermediate representation (that comes before .ptx) and then link them into single ptx somehow?

I use CUDA Driver API (via JCuda) and my .cu files contain device code only.


I think it should be possible for cubin.

nvcc -cubin -dlink -o test.cubin

That works, thanks! But with very important remark: target architecture must be set with -arch nvcc flag.

So the final working solution is
nvcc -cubin -dlink -arch=sm_XY -o test.cubin,
where X is major and Y is minor version of device architecture. These parameters can be retrieved with cudaGetDeviceProperties (docs:

More info about devices architectures flags