I am trying to solve this problem myself but I can’t.
So I want to get yours advice.
I am writing kernel code like this. VGA is GTX 580.
xxxx <<< blockNum, threadNum, SharedSize >>> (... threadNum ...)
(note. SharedSize is set 2*threadNum)
__global__ void xxxx(..., int threadNum, ...)
{
extern __shared__ int shared[];
int* sub_arr = &shared[0];
int* sub_numCounting = &shared[threadNum];
...
}
My program creates about 1085 blocks and 1024 threads per block (I am trying to handle a huge array).
So the size of shared memory per block is 8192 (1024*2*4) bytes, right?
I figured out that I can use maximum 49152 bytes in shared memory per block on GTX 580 by using cudaDeviceProp.
And I know that the GTX 580 has 16 processors, thread block can be implemented on processor.
But my program returns an error (8192 bytes < 49152 bytes).
I used printf in the kernel to see whether it operates well or not but several blocks do not operate: Even though I create 1085 blocks, actually only 50~100 blocks operate.
And I want to know whether blocks which operate on the same processor share the same shared memory address or not. If not, do they allocate other memory for shared memory?
I can’t quite understand what maximum size of shared memory per block means.
Give me advice.
Yes, blocks on the same multiprocessor shared the same amount of shared memory, which is 48KB per multiprocessor for your GPU card (compute capability 2.0). So if you have N blocks on the same multiprocessor, the maximum size of shared memory per block is (48/N) KB.