Doubts about Sharedmemory.

I am having some doubts about dynamic shared memory allocation.Can anyone help me.
1)if i have two shared memory array , can i define
extern shared int a_int;
extern shared int b_int;
Here a and b will point to the same memory or not?Whether it will create any coflict?

2)If i write a kernel function as follows
kernel<<<gd,bd,sharedMemSize>>> How can i decide the size of sharedmemory ?Whether the size of shared memory is for one block or entire grid?

3)If i am having 2 arrays ,each having 100000elements and if i give sharedmemorysize=16kB. What will be the size of sharedmemory allocated for each array?

Can anyone please clear my doubts…

1)Yes, they will point to exactly the same memory per each block. a_int==b_int. However for two different blocks will have two different arrays.

  1. sharedMemSize is shared memory size for one block. When we talk about shared memory in any context, it is always in respect to one block (unless stated otherwise)

  2. I do not fully understand. Do you mean an array like this?

__shared__ int mySharedArray[100000]

If so - it will generate a compile error.