CUDA: How to reuse kernels in multiple files (for unit testing)

Posted by zenna on Stack Overflow See other posts from Stack Overflow or by zenna
Published on 2010-04-12T15:53:19Z Indexed on 2010/04/12 16:03 UTC
Read the original article Hit count: 529

Filed under:
|
|

How can I go about reusing the same kernel without getting fatal linking errors due to defining the symbol multiple times

In Visual Studio I get

"fatal error LNK1169: one or more multiply defined symbols found"

My current structure is as follows: Interface.h has an extern interface to a C function: myCfunction() (ala the C++ integration SDK example) Kernel.cu contains the actual __global__ kernels and is NOT included in the build: __global__ my_kernel() Wrapper.cu inlcudes Kernel.cu and Interface.h and calls my_kernel<<<...>>>

This all works fine.

But if I add another C function in another file which also includes Kernel.cu and uses those kernels, I get the errors.

So how can I reuse the kernels in Kernel.cu among many C functions in different files.

The purpose of this by the way is unit testing, and integrating my kernels with CPP unit, if there is no way to reuse kernels (there must be!) then other suggestions for unit testing kernels within my existing CPP unit framework would be appreciate.

Thanks

Zenna

© Stack Overflow or respective owner

Related posts about cuda

Related posts about kernel