I searched the Forum but the search engine didnt turn up with any answers. We are working on a project involving a lot of kernels which in essence belong to several C++ Objects. We wanted to put pointers to data on the GPU which is used by several kernels into the constant space. Now I understand that constant declarations are actually file-scope, so we defined them in every distinctive cuda object file seperately. Since they shall all hold the same pointer to the same data on the GPU we actually named them the same way for programming convenience (i.e. device constant float* x). Now the funny thing is that doesnt work. As soon as the same symbol name (i.e. x) is used in two different CUDA modules the whole thing breaks down. It still compiles but the x holds a value of (nil) despite copying an address to it just right before the kernel call. Indeed renaming x to xa in one of the cuda modules solves the problem for that module.
I only can guess that constant variables are to be taking literally existent on the GPU. Is there a way around this problem (something like putting an extern in front of all but one declaration or so?).
If not would it be possible to come up with some solution in a future release of cuda?
For now we can solve the problem, by writing one *.cu file where all other cu files are #included. That way we have basically only a single file and can work with a single declaration of our constants. But it also means that changing one thing in a kernel, requires recompilation of the whole cuda code - which is a bit inconvinient.