how to initialize a constant variable of array?

Discussion created by edwen on Aug 23, 2010
Latest reply on May 25, 2011 by donnervogel80
constant memory initialization

I am trying to modify a CUDA program into OpenCL and I met a problem. In my "market.cl" file, I need to declare and initialize some constant variables. for example, "__constant int v1 = 5;" This works fine. However, I need to declare some arrays, such as "__constant float delta[5][80]". In my CUDA program, I used the function "cudaMemcpyToSymbol" to copy all constants into constant memory, and the code in the "market.cu" is something like:

#define NumFactors 8

float delta_[5][80];

float weight = sqrt(1.0f/float)NumFactors);

for (int i = 0; i < 5; i++)

{  for (int j = 0; j < 80; j++)

         delta_[j] = weight;


cudaMemcpyToSymbol (delta, &delta_, sizeof(delta_);


How can I realize this in OpenCL? Thank you very much for your advice.