Pointers from const to shared

I want to set up pointers to the shared memory from the constant memory. Basically, I want a fixed array of buffer pointers in the constant memory which point to the shared memory.

To set up the constant memory, I define a structure, initialise it in Host memory, and then use cudaMemcpyToSymbol() to copy it to an identical structure into the GPU constant area. However, this means that I have have access to the address of the shared variable in the Host space, and that does not seem possible. The nvcc phase proceeeds correctly, but when I try to compile the resultant .cu.c (Microsoft Visual C++ compiler) the symbol defining the shared area is undefined and the compile fails.

How do I achieve this cross acccess?


Even if you could get one, what would a pointer to a shared memory location mean? It would point to “different” memory value in every running block on the device.

A simple solution to pull this off, though, is to simply store indices into the shared memory array instead of pointers. Of course, this only works if you only have one shared memory array you are accessing.

True - I hadn’t though about different blocks.

That sounds the right way to do it - thanks.