I need to declare three LUT's in an OpenCL kernel, so:
What is the optimal way to declare a LUT in Intel OpenCL FPGA?
I have saw examples about this, but in the examples they used a switch/case
structure. I think the best way is declare an array for each LUT, as in the following example (example taken from: how to declare a constant array of float2 vectors?):
__constant float2 foo[2] = {1.0f, 0.0f};
You only need switch/case
if you cannot address the elements in the LUT array directly, i.e. if your lookup positions do not follow 0,1,2,...,N
. It's more elegant to implement the LUT as an array and do direct addressing with lut[position];
.
If the LUT is small enough and you only need it in one place, you can have it in private
memory space within the kernel. If the LUT is larger (than several hundred entries), you need to divert to constant
memory space; element accessing remains identical.