I have a file named "KernelUtil.cu" as follo开发者_Go百科ws
__device__ int add(int a, int b)
{
return a+b;
}
I have my main program which is "main.cu". I need to call the "add" function from here. How can I do it?? The following doesnt work.
#include "KernelUtil.cu"
__global__ void test()
{
int c = add(10,10);
}
int main()
{
test<<<1,1>>>();
}
giving an error add is already defined in main.cu
I expect that you have a rule that automatically compiles all .cu files, meaning KernelUtil.cu is effectively compiled twice, once on its own and once when included in main.cu, and therefore add is duplicated.
Try renaming KernelUtil.cu to KernelUtil.h (or .cuh).
加载中,请稍侯......
精彩评论