Reputation: 261
I was wondering how to declare a volatile pointer to two dimensional shared memory and if this would have the same effect as for one dimensional arrays.
__shared__ float 2d_array[32][32];
// not working: volatile T ** smem = sdata;
Upvotes: 1
Views: 453
Reputation: 72349
Note that your "two dimensional" shared memory array is, in fact, only one dimensional. So something like this:
__shared__ volatile float array_2d[32][32];
volatile float *smem = &array_2d[0][0];
float val = *(smem + y + 32*x) // address of s2_array[x][y]
is what you want. The static array array_2d
is stored in row major order and can be accessed as I have shown.
Upvotes: 3