linker names of device functions are colliding (best workaround?)

Hi!

I have a problem.

Often, I need the same function compiled for both device and host. But since CUDA 3.0, it seems to me that nvcc gives the same external (linker) name to device function as it is given to a host function by VC++ (also causing some other problems…).

So, if I have something like:

DEVICE int test1(int a)
{
return a*a;
}

, where DEVICE is defied as:
#define DEVICE (when compiling with VC++)
and as
#define DEVICE device (when compiling with nvcc)

, then I get a linker error that ‘the name is already defined’ … because I want test1 to be both a host function and a device function, but it seems that this is not possible…

The problem is that I have something like 40 of such ‘shared’ functions spread around 20000 line code.

So:

  1. Am I correct?
  2. Ideas for best workaround
  3. (whining) WHY didn’t nVidia just prepend device function names with some unused symbol like @ for external linking? Any logical explanations? Anyways, I don’t get it.

Thanks

Forgot to mention:

I’m Using:

Cuda 3.1 (32-bit)
Visual Studio 2008 SP1
Windows 7 64 bit

you can declare the function as host device inside a .cu file.
This will give you a host and a device copy of the routine with the same
name

you can declare the function as host device inside a .cu file.
This will give you a host and a device copy of the routine with the same
name