Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Beginner
772 Views

How to declare a static array in OpenCL kernel?

In the OpenCL kernel, I need to declare a static array (buffer) such that the data in the array (buffer) retains when the kernel gets launched iteratively. This is particularly useful for iterative algorithms. However, the compiler pops compilation error when the array is set static.

 

An alternative way is to dump the data in the buffer to DDR and read it from DDR in next iteration. This works but the kernel changes too much when doing software simulation.

 

Looking forward to suggestions on this.

 

Regards,

Cheng Liu

 

0 Kudos
2 Replies
Highlighted
Valued Contributor II
28 Views

Can you post a code snippet of what you are trying to do? You have to copy the array to DDR memory to be able to transfer it to the FPGA anyway, and since the array is static, it can just reside on DDR and be re-read at each kernel invocation. If you are thinking about copying the array to FPGA on-chip memory and keep it consistent between different kernel invocations, that is not going to be possible since local memory is only consistent within each kernel invocation and not across different invocations. You can, however, create a separate kernel from your main kernel and read the static array from DDR memory inside that kernel and store it on-chip and keep feeding the data to the main kernel that gets re-invoked via on-chip channels.

0 Kudos
Highlighted
Beginner
28 Views

Thanks for the reply. Yes, I am trying to make local memory in the kernel be consistent between different invocations, because this is the normal behavior in hardware. This is why I want to create a static array in the kernel.

 

Anyway, seems there is no simple way to keep the design code the same with the simulation code in this case.

0 Kudos