I have an automatic build process which creates a C# wrapper around my CUDA code.
Since I’m working also in the driver API i need to decorate each kernel with an
extern “C” global keyword.
For that reason I created a header-file in which I have defined this macro
to be used in every CUDA code to make life a little easier.
Also I have defined a lot of different method and constants. The problem is that I
always have to type the #include. Is there a way that the #include is done automatically?
At least in some config or as command line when I call NVCC?
The nvcc manual (provided in the GPU Computing Toolkit) shows sample nvcc output when run with the -v option, and apparently cudafe (called by nvcc) has an option “–preinclude”. As a quick test, I modified the vectorAdd program, changing this line:
int n = 50000;
to this:
int n = VECTOR_SIZE;
I then created a header file called vector_size_header.h with the following contents:
Compilation was successful with the --preinclude option above, and as expected, fails due to an undefined VECTOR_SIZE without it.
I’m not aware of documentation for cudafe options and I don’t know how stable that option is across CUDA versions. Perhaps there are other issues lurking, but maybe this will work for you.
thanks for the answer. The method works quite fine for me. The only problem is that I have installed some parts of my framework in “C:\Program Files” and it seems that the command line parser of NVCC does not recognize white spaces in the command line argument.
of course you are right, wen using the nvcc only I did this. But in this special situation I have to call nvcc which in turn calls cudafe.
Through the commandline argument
which is delegated to cudafe. Since internally nvcc call cudafe.exe it seems that it’s not possible to hand over arguments with a white space in it.
I have tried to escape with different methods, also of course using “…” in various combinations, escaping it with \ but nothing worked.