Cuda 5 issue with MemcpyToSymbol Not working when symbol is in a namespace

Hi,

I am currently testing Cuda 5 and encountered this issue when compiling a code like the one below

file1.cu

namespace file1 {

__device__ __constant__ float f;

}

// Kernels and kernel calling functions

main.cc

main()

{

....

 cudaMemcpyToSymbol("file1:f", &var, sizeof(float));

....

}

Until Cuda 5 this code compiled and worked perfectly. On Cuda 5 the code compiles but i got a “Invalid device symbol” at the cudaMemcpyToSymbol call.

Obviously with the new linking feature of nvcc 5 i have a workaround:

main.cc

namespace file1 {

extern __device__ __constant__ float f;

}

main()

{

....

 cudaMemcpyToSymbol((const char *) &file1:f, &var, sizeof(float));

....

}

but obviously this new version did not compile with Cuda < 5.

My code is quite big so i want to avoid creating a Cuda < 5 and a Cuda 5 branch only for that. So my questions are:

this problem is a bug in Cuda 5 ? a momentary missing feature ? there is a simpler workaround for all version of Cuda ?

You could file it as a bug, maybe they can fix it for the cuda 5 release version.

In the interim, you don’t need a full separate branch of your code for cuda 5. You can use #if’s on CUDA_VERSION. They aren’t elegant, but assuming you only use a small number of constants that is a small price to pay for compatibility.

Please note that CUDA 5.0 is currently in “preview”, meaning it should not be expected to have the stability of a release candidate. It is helpful when registered developers file bug reports for any functional regressions they encounter. There is a link to the bug reporting form procided on the registered developer website. Thank you for your help.