Initializer not allowed for __shared__ variable for cuda

I do the following:

__shared__ int exForBlockLessThanP = totalElementLessThanPivotEntireBlock[blockIdx.x];

where totalElementLessThanPivotEntireBlock is an array on the GPU. The compiler throws an error as indicated in the title of the question. I really don't understand why this is a problem?

+5
source share
1 answer

Static initialization of shared variables is illegal in CUDA. The problem is that the semantics of how each thread should handle the static initialization of shared memory are undefined in the programming model. What stream should write? What happens if the value is not evenly between threads? How should the compiler emit code for such a case and how to run it?

- .

+7

All Articles