how to dynamically allocate shared memory


I have a program that will allocate block size amount of shared memory in each block.
Since I want to test my algorithm with different block size, I would like know is there a way to dynamically allocate shared memory, meaning when I change the block size, the shared array will change size as well.

You can specify shared memory sizes at kernel launch. When you launch a kernel, the three arguments to CUDA are <<number of blocks, threads per block, shared memory size>>. See Chapter 4 in the programming guide for how to use dynamically sized shared memory variables.