Reputation: 459
I'm working to produce a plugin for a 3d application , this plugin uses that application SDK
in normal cases "personal test projects" , I separate .cu file and make its item type to CUDA C/C++ , and .cpp file to item type C/C++ compiler
here I want the whole code inside .cpp file and compile it without problems,
also I want to make the code (binary) so that I can hide the ptx (or kernels)
Upvotes: 0
Views: 187
Reputation: 152249
It's not entirely clear why you want to put CUDA code in a .cpp file. If the reason is due to some requirements of the SDK you are using, and you don't want to use nvcc
, that won't work.
If you simply want to allow a .cpp file to contain device code and go through nvcc
instead of directly to the host compiler, you can use the -x cu
option on your nvcc
compile command:
nvcc -x cu t264.cpp -o t264
The above command will generate the same executable just as if you had done this:
nvcc t264.cu -o t264
(assuming t264.cu
and t264.cpp
were identical files.)
If you want to strip out the ptx, you can compile like this:
nvcc -gencode arch=compute_10,code=sm_10 -gencode arch=compute_20,code=sm_20 -gencode arch=compute_30,code=sm_30 ....
This will tell nvcc to create a fatbinary that contains executable binaries for sm_10, sm_20, or sm_30 devices, but no PTX.
Upvotes: 1