Shared memory declaration Simple question about shared memory


I’m trying to start using shared memory but I have to clear some problem using it.

For what I understand , shared memory is the memory shared between thread inside a block.

I can declare it in launch like this (for example):

int sh_Size = 1000 * sizeof(int);

 launchKRN<<< grid, threads, sh_Size >>>(d_srcArray);

These are my questions about these lines:

  1. shared memory Size must be lower than 16 kb?

  2. the 16 kb max size dimension for shared memory is referred to the total shared memory on the device to use or to the single block shared memory size?

(If I declare 4 blocks, I have sh_Size shared memory dimension or 4 * sh_Size?)

  1. when I declared the third parameter in launchKRN (sh_Size) it is referred to:

    A ) the size of the total shared memory on the device that I want to use ?


    B ) the size of the shared memory for block on device ?



single block shared memory

for one block

Shared memory is on-chip memory available for all threads running on one multiprocessor. There are 16 kb of shared memory on GT80 and GT200 chip for every MP.



Thank you,

grazie Luca!