I am very new to OpenCL (started today). I am having a hard time in realizing the kernel code for adding numbers of an array in the following fashion: If A[]=[1,2,3,4,5,6,7,8,9,10], then the sum should be sum[]=[4,10,16];
i.e, sum[i]=A[i]+A[i+2];
i=i+3;
I have tried the following code but it does not seem to work.
std::string kernel_code =
" void kernel simple_add(global const int* A, global const int* B, global int* C){ "
" int x =0;"
" int i =get_global_id(0);"
" SUM[x]=A[i]+A[i+2];"
" i=i+3;
" x++;"
" } ";
I am certain this is not the way to do it. Suggestions in this regard would be appreciated.