pointers in cuda

Hi,

I have a struct which I pass as an argument to a global function. Inside the global function I pass the struct to a device function as a pointer. My question is where does the struct now reside. Will I have a pointer to shared memory since parameters are passed using shared memory or will the struct be relocated to global memory?

Thanks.

-DevMike

Usually function arguments are placed in shared memory. So, most likely the structure resides in shared memory whan the global function is called.

As far as the device function is concerned, remember that calls to device functions are inlined. So, in your case, both the structure and the pointer to it end up residing in the shared memory.

To verify this, check the .ptx file generated by nvcc (use nvcc with -keep flag to compile your .cu file). You can tell whether you’re loading from shared or device (global) memory by examining the instruction mnemonics.

Paulius

Thanks!