BaseIndex confusion how to calculate/determine?

Hi all-

I’m a little confused about some of the bank-conflict resolving strategies, and was hoping someone could clarify…
It is often stated that a common access pattern is:

shared char shared[32];
char data = shared[BaseIndex + 4 * tid];

Let’s assume I have 32 threads per block and (just for this example) only 1 block per grid. I understand how the stride of 4 is used to make sure the threads are accessing different banks, since 4 8-bit char’s belong to the same 32-bit word (and therefore the same bank). My question is: is it safe to assume that BaseIndex == 0 always? If not, how does one go about making sure that BaseIndex corresponds to a properly-aligned multiple of the word size?

Thanks in advance for any input/advice/suggestions!

In this particular case, you’ll get no bank conflicts no matter what baseIndex is. The key is to have every thread read from a different bank, and it doesn’t matter if thread 0 reads from bank 0 or bank 11 or whatever as long as no other thread also reads that bank. (exception, with broadcast words, but that’s a bonus.)

What you’re kind of worried about is a different but slightly similar sounding issue with base address alignment of coalesced global read requirements on old G80 hardware. That doesn’t apply to your shared memory access question.

In this particular case, you’ll get no bank conflicts no matter what baseIndex is. The key is to have every thread read from a different bank, and it doesn’t matter if thread 0 reads from bank 0 or bank 11 or whatever as long as no other thread also reads that bank. (exception, with broadcast words, but that’s a bonus.)

What you’re kind of worried about is a different but slightly similar sounding issue with base address alignment of coalesced global read requirements on old G80 hardware. That doesn’t apply to your shared memory access question.