CUDA arrays and pointers


I have two versions of code for handling arrays, one works and one does not. I believe they should be equivalent.

Working code (inside a global void):

float dip[blocksize];

float djp[blocksize];

Not working code (inside a global void):

float dxp[blocksize];

float *dip = dxp;

float djp[blocksize];

Does anyone know why this could be ? Is there some special treatment of pointers in CUDA?

The arrays are used in a nested loop later, eg: dip[iIndex] += mass[iIndex] * density; etc.


The only special treatment of pointers in CUDA is that the compiler must know at compile time whether a pointer points to shared, constant, global or local memory. If it cannot figure this out, it will print out “Advisory, cannot tell what pointer points to, assuming global memory”.

Still, in your simple case, the compiler should have no trouble figuring that out. So, if you aren’t getting this message, then you’ll have to dig into the ptx and try and find out what the compiler is doing wrong. If there is a problem, your best bet is to post a small, fully compilable example along with expected and observed output so that NVIDIA can pick it up and fix the problem.