Altera_Forum
Honored Contributor
8 years agoinitialize large constant array as lookup table
I need a lookup table as multiplier.
so I create an array and filled with integer multiply. and I try to implement like this. however, this takes very very long time to compile, so I thought this may be wrong to achieve what I want to implement ? Is that because 256*256 is too large ? Is there any better way to have same effect? __Kernel myKernel(__global int b,__global int c,__global int idx){ int lut[256][256]; for(int i=-128;i<128;i++){ for(int j=-128;j<128;j++){ conv[i+128][j+128] = i*j; } } int a=0;# pragma unroll 512 for(int i=0;i<idxd;i++){ // int a+=b*c; int a+=lut[b+128][c+128]; } } --------------------------------------------- So I try to implement like this, however, compiler keeps telling me "constant data must be initialized." maybe it's because constant array can't initialize by for-loop, is there any way to initialize this instead of filling 256*256 data? constant int lut[256][256]; for(int i=-128;i<128;i++){ for(int j=-128;j<128;j++){ conv[i+128][j+128] = i*j; } } __Kernel myKernel(__global int b,__global int c,__global int idx){ int a=0;# pragma unroll 512 for(int i=0;i<idxd;i++){ // int a+=b*c; int a+=lut[b+128][c+128]; } }