AnsweredAssumed Answered

What is the best approach for writing a kernel for the following task

Question asked by mushucf on Feb 12, 2012
Latest reply on Feb 12, 2012 by nou

I need to compute a function f(x,y, z, c1, c2) where x, y, z are vectors and c1 and c2 are constants and I need to repeat this calculus for many values of c1 and c2 (which are already known and with the same dimension). My question is: what is the most efficient way to write down this into an OpenCL kernel?


Sequential algorithm would be as follows:


for (int i = 0; i < c1.length;i++)


  for(int j = 0;j < x.length;j++)


     f[i][j] = x[j] * cos(y[j] + z[j]) / (c1[i] + c2[i]);




Thanks in advance.