The principle is approximatly similar to matrix multiplication (actually I do the difference instead of the multiplication).
I use shared memory for managing non colesced read and write.
See, blockDim is just 16 (you should atleast have 32 to fill a warp)… What speed up are you expecting???
You are just avoiding 16 branch statements. Are you expecting 16 branch statements to cause “millisecond” delay… You might save at the max 1 or 2 microseconds and thats about it.
Ok, I understand. But I have seen some unroll example (as in reduction example) and the unroll was not more longer… However the gain was approximately 1.5.
My guess would be that, if you know the value of BLOCK_DIM as it probably is a hard-coded constant, the compiler knows it as well and unrolls the loop anyway, resulting in you not beeing able to gain any performance by manually doing this.
qUiXui’s guess could be checked with -ptx option given for nvvc. After that both asm codes with useful comments and human-readable labels will be available in <your_source_code>.ptx.