Advertisement
Guest User

opencl bug?

a guest
May 11th, 2010
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.42 KB | None | 0 0
  1. __kernel void add(__constant float *a, __global float *answer)
  2. {
  3.     const int id_x = (int)get_global_id(0);
  4.     int i,j;
  5.     float sum = 0;
  6.    
  7.     for(i = 0; i < 3; i++)
  8.     {
  9.         for(j = 0; j < 3; j++)
  10.         {
  11.             //This will not work
  12.             sum +=  a[i+j];
  13.             /*
  14.             This will work:
  15.             sum += a[j*i];
  16.            
  17.             So will this:
  18.             sum += a[j];
  19.            
  20.             And this:
  21.             sum += a[i];
  22.             */
  23.            
  24.         }
  25.     }
  26.     //Write result
  27.     answer[id_x] = sum;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement