ccudagpu-shared-memory

Creating a shared vector with block size?


I need to create a shared vector, with the same size as the block.

__global__ func()
{   
    const int size = blockDim.x;
    __shared__ float* Vec[size];
..
}

I get this error

error : expression must have a constant value

I cannot understand where the problem is, since blockDim.x is "constant" for each block of threads?


Solution

  • Here's how you do it

    __shared__ float Vec[size];
    

    remove the star (*)