tags:

views:

350

answers:

1

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

A: 

The solution that usually works for me is to compile a library out of all the cu files and create entry points to initialize the kernel.

Otherwise put all the common functions inside a .cuh and wrap it if #IFDEF _MYHEADER_H

fabrizioM