chaohuang
chaohuang

Reputation: 4115

constant memory size in CUDA

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?

Upvotes: 0

Views: 359

Answers (1)

Robert Crovella
Robert Crovella

Reputation: 152164

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.

Upvotes: 3

Related Questions