Hi,
I’m confused with the output of cutBankChecker tool from cuda_sdk.
Here is a sample code:
#define CHECK_BANK_CONFLICTS
#ifdef CHECK_BANK_CONFLICTS
#define MEM(base, index) CUT_BANK_CHECKER(base, index)
#else
#define MEM(base, index) base[index]
#endif
__global__ void test_back_conflicts() {
uint thid = threadIdx.x, half_dim = blockDim.x / 2;
__shared__ uint data[512];
if(thid < half_dim && (thid & 2)) {
uint mem_ai = thid;
uint x = MEM(data, mem_ai);
x--; // blah blah
}
}
...
dim3 threads(256, 1, 1);
test_back_conflicts<<<1, threads>>>();
Here the bank checker reports 112 bank conflicts, in the following form:
…
threadIdx.x = 14 threadIdx.y = 0 threadIdx.z = 0 :: index = 14
threadIdx.x = 30 threadIdx.y = 0 threadIdx.z = 0 :: index = 30
threadIdx.x = 46 threadIdx.y = 0 threadIdx.z = 0 :: index = 46
threadIdx.x = 62 threadIdx.y = 0 threadIdx.z = 0 :: index = 62
threadIdx.x = 78 threadIdx.y = 0 threadIdx.z = 0 :: index = 78
threadIdx.x = 94 threadIdx.y = 0 threadIdx.z = 0 :: index = 94
threadIdx.x = 110 threadIdx.y = 0 threadIdx.z = 0 :: index = 110
threadIdx.x = 126 threadIdx.y = 0 threadIdx.z = 0 :: index = 126
…
although it’s clear from the code above that the memory is accessed sequencially by the threads
with the condition (thid & 2) that causes some threads to diverge.
-------- i.e., if you remove (thid & 2) from the code you’ll get 0 bank conflicts --------------
Didn’t I understand it correctly that the threads thid and thid+16 belong to different half-warps, and therefore there cannot be bank conflicts between them ?
or threads are grouped to warps in some “non-trivial” order ?
thanks