Confusion about shared memory variables declaration

Hi There,

I was checking someone else’s CUDA program and it came to my attention that in the global section of the program he declared this:

device shared float coefyl[256];

As far as I knew (because I read it on some CUDA refence), variables in shared memory should be declared inside a kernel o device function, which is not the case for the “shared” memory declared in this program. One extra detail: this variable is used in 2 kernels in that program.

Question is: is this variable stored in shared memory for each of the 2 kernels ? how can I exactly know where this variable is stored ?


A careful reading of Appendix B.2.1-3 in the programming guide suggests that device shared has the same meaning as just shared.

Thanks, I know that. My question is regarding the location of the declaration and the effect on the type of memory used for storing the variable, caz I read a shared variable should be declared inside a kernel o device function.