To simplify the build process in a project, I'd like to compile multiple source files into device PTX code, and have all those modules in a single .fatbin
file to be linked later.
I can achieve this currently through either compiling each file individually to .ptx
, or compiling all simultaneously while using --keep
to keep intermediate files, then adding each to a fatbinary explicitly:
nvcc -c --keep mysource1.cu mysource2.cu ...
fatbinary --create="mysources.fatbin" --image3=kind=ptx,file=mysource1.ptx --image3=kind=ptx,file=mysource2.ptx ...
This is quite cumbersome though, so I was wondering if there is a simpler/more terse way of doing so, perhaps in a single nvcc invocation. I've tried calling nvcc --fatbin --device-link
on multiple source files, but that does not seem to keep the ptx code in the output fatbinary (at least not when inspecting with cuobjdump
).