constant memory size in CUDA

353 Views Asked by At

In CUDA, when I delcare an array in constant memory like below

__device__ __constant__ float A[n];

does the size n need to be a constant?

I guess is yes, because the compiler needs to know if the size n exceeds the constant memory size or not. Is that right?

1

There are 1 best solutions below

1
On BEST ANSWER

Yes, it needs to be constant. The reason for this is that it is a static allocation, so the compiler needs to know the size at compile-time.

And, yes, the compiler does check the size against what is available.