Static allocation of constant memory

Hi,

I have a question about static allocation of constant memory in OpenCL.
I can do dynamic allocation. How to perform static allocation of constant memory? Can anybody give me an example?
It’ll be really helpful.

In CUDA, I’m able to do this.

__constant unsigned short distortion_loopkup[64]=
{0, 5, 7, 9, 9, 11, 11, 11,
5, 10, 12, 14, 14, 16, 16, 16,
7, 12, 14, 16, 16, 18, 18, 18,
9, 14, 16, 18, 18, 20, 20, 20,
9, 14, 16, 18, 18, 20, 20, 20,
11, 16, 18,20, 20, 22, 22, 22,
11,16, 18, 20, 20, 22, 22, 22,
11,16, 18, 20, 20, 22, 22, 22
};

kernelfunc()
{ }

But in OpenCL, I’m not able to initialize a constant memory address space variable. There’ s build error if I try to use.
I have to pass the pointer to this variable as an argument from the host side and then use the qualifier “__constant” next to the variable in kernel function.
Can we not initialize constant memory variable like in CUDA?

According to OpenCL specification document, it says ‘__constant’ qualifier can be used with global varaibles.
“Global variables declared in the program source with the ‘__constant’ qualifier are required to be initialized”.
What do we mean by this?

Your comments will be really helpful.

Thanks

i have the same bug

if i make :

float test[10] = {0};

Compilation error

Otherwise it works with

float test[10];

for(unsigned int i = 0; i < 10; i++)

 test[i] = 0.f;