Shared memory offset


If we do static allocation of shared memory :

shared char s_char[9];
shared int s_int[5];

then, What is the offset of s_char, s_int?
Does the offset of s_int depend on the size of s_char?
Does static/Dynamic Shared allocation always start at Address that is multiple of 32bit?


If you do static allocation like this, you shouldn’t worry about offsets. You just use those arrays like any other separate C arrays. You only have to figure out offsets if you have multiple dynamic shared arrays. Since to dynamically allocate a shared array means to pass its size through the launch parameters, and you only give one size, you actually allocate one dynamic array. If you want many arrays, you have to do some pointer arithmetic to cast this single one into many through offsets (explained in the Programming Guide).