我想知道是否可以从不同的 .cu 文件调用相同的内核函数。我的意思是,我的程序有不同的类,它们都有一些共同的功能,但内存大小不同;例如:
void Bitmap8::Or(const Bitmap8 &b1, const Bitmap8 &b2);
// the function above is as same as this one (of course they are in two different files)
void Bitmap4::Or(const Bitmap4 &b1, const Bitmap4 &b2);
它们都有不同的内存大小分配。我为他们创建了一个独特的 CUDA 内核来执行这些操作。在我编译程序时是否可能存在一些冲突?因为我一直有这样的错误:
1>Bitmap8.cu.obj : error LNK2005: "void * __cdecl big_random_block(int)" (?big_random_block@@YAPAXH@Z) already defined in Bitmap4.cu.obj
还有很多
提前致谢
最佳答案
是的,可以从不同的文件调用相同的函数。我的错误与标题的双重包含有关!问题解决了
关于c++ - 多个文件中的 Cuda 内核函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10028891/