Created by Vladimir Kuznetsov / @grandrust
Пусть 3 блока назначены на SM. В каждом блоке 256 нитей.
Сколько warp'ов в SM
__shared__ double array[64];
__shared__ float variable;
extern __shared__ float array[];
kernel <<< nBlock, nThread, 64 * sizeof(float) >>>(...)
__syncthreads()
__global__ void kernel(float *dA, float *dB, float *dC, int size)
{
int i = threadIdx.x;
// выделение shared memory
__shared float as [BLOCK_SIZE]; // #define BLOCK_SIZE 32
as[i] = dA[i + blockIdx.x * BLOCK_SIZE];
__syncthreads();
// вычисление велечины res зависящей от as
{ ... }
dC[i + blockIdx.x * BLOCK_SIZE] = res;
__syncthreads(); // если res - shared
}
N x N = 2048 * 2048
BLOCK_SIZE = 32
(tx, ty) - (32, 32) - размерность block'a
(bx, by) - (?, ?) - размерность grid'a