I am trying to create separate files for my kernel code and host code for the first time, and I am encountering some issues getting the files to “recognize” each other. I’ve looked at the Programming Guide, as well as the examples that ship with the SDK, and they all seem to use the same style I am using (except their work, of course!). Additionally, I didn’t find any other topics on the Forum about this, so I decided to post this.
The error message I am getting is:
nvcc -arch sm_11 myCode.cu myCode_kernel.cu -o myCode
/tmp/tmpxft_00006038_00000000-24_myCode_kernel.o: In function `temp__entry(float, float)’:
tmpxft_00006038_00000000-23_myCode_kernel.ii:(.text+0x21a): multiple definition of `temp__entry(float, float)’
/tmp/tmpxft_00006038_00000000-15_myCode.o:tmpxft_00006038_00000000-14_myCode.ii:(.text+0x470): first defined here
/tmp/tmpxft_00006038_00000000-24_myCode_kernel.o: In function `__device_stub__Z4tempff’:
tmpxft_00006038_00000000-23_myCode_kernel.ii:(.text+0x19a): multiple definition of `__device_stub__Z4tempff’
/tmp/tmpxft_00006038_00000000-15_myCode.o:tmpxft_00006038_00000000-14_myCode.ii:(.text+0x3f0): first defined here
collect2: ld returned 1 exit status
make: *** [myCode] Error 255
Here’s how I’m including my kernel code:
All that I have in that file is:
global void temp(float x, float y)
// purposely blank, I’ve had some simple things in here as well like int i = 0; ++i; (and the same thing happened)
#endif // #ifndef MYCODE_KERNEL_H[/codebox]
Here’s how I call the kernel:
[codebox]temp<<<1, 1>>>(1, 2);[/codebox]
My guess is that I’m somehow including the files incorrectly (or something like that), but I’ve tried both "#include <myCode_kernel.cu> and "#include “myCode_kernel.cu>” " and neither seems to resolve this issue.
Even if I don’t call the kernel in my host code (or reference it at all), this same issue occurs.
I tried looking for the temp files in the error message, but they don’t seem to be in the tmp folder…
I am using CUDA 2.2.
I am compiling with sm_11 (if you didn’t see that above).
Any help would be greatly appreciated!