Pointers from Shared Memory, Constant memory into global memory


I would like to do the following. Is it safe ?

constant int * constMemToGlobalMem[1024];

constMemToGlobalMem contains integer pointer in global memory space. i.e. I’m strong the address of integer arrays in global memory space in constant memory space.

global void myKernel()
shared int * myThreadBlockPtr = constMemToGlobalMem[blockId.x]; // <------------ Here the warning is produced.
// Is the above statement legal. It is a shared memory pointer pointing to an address in constant memory space that points to global memory space ?
myThreadBlockPtr[threadId.x] = 10;

When I compile my code I get the following warning ./test.cu(17): Warning: Cannot tell what pointer points to, assuming global memory space

Suresh Kumar

Yes, it’s safe. In this case, nvcc has assumed correctly – your pointers inside the constMemToGlobalMem array refer to the global memory space.

Thank you. Is there any way for the me to tell the compiler that the pointer is supposed to point to a constant space or global memory space or the shared memory space ?