bank conflicts...?

I’m just starting out with CUDA and am trying to make sense of the some of the documentation. Can anyone explain the reason why struct type{float x,y,z;} has not bank conflict and struct type {float x,y;} does? This entire section is really confusing.
For reference it is page 57, section 5.1.2.4 of the manual.

thanks!!

A structure assignment is compiled into as many memory requests as there are members in the structure, so the following code, for example:
shared struct type shared[32];
struct type data = shared[BaseIndex + tid];
results in:

  • Three separate memory reads without bank conflicts if type is defined as
    struct type {
    float x, y, z;
    };

since each member is accessed with a stride of three 32-bit words;

  • Two separate memory reads with bank conflicts if type is defined as
    struct type {
    float x, y;
    };

since each member is accessed with a stride of two 32-bit words;

  • Two separate memory reads with bank conflicts if type is defined as
    struct type {
    float f;
    char c;
    };
    since each member is accessed with a stride of five bytes.

Consider the first 16 threads of a WARP that read “x” from the shared memory location.

The banks accessed by the 16 threads while reading “x” are as follows:

0,3,6,9,12,15,2,5,8,11,14,1,4,7,10,13

See, there is no memory conflict at all.

Consider the first 16 threads accessing “x” from shared memory.

The banks accessed by the 16 threads while reading “x” are as follows:

0,2,4,6,8,10,12,14,0,2,4,6,8,10,12,14

Here you can see that there is bank conflit between first 8 and second 8.

In this case, I am not sure how the structure is interleaved across the banks. I would guess – it would be the same as the previous case of {float x,y}

btw, NOTE that: BANK CONFLICTS ARE THE LAST THING THAT YOU SHOULD ATTEMPT TO OPTIMIZE. GLobal memory AND register latencies are far more worse AND fixing them itself will give you good performance. – This is NOT my word. Some1 in this forum (I think Mark Harris) said this. And, with my practical experience, I would agree with it.

Thanks Sarnath! That definitely clears things up for me!