Advertisement
rasoran

Untitled

Oct 27th, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. __kernel void reassemble(__global int *in,
  2.            __global int *out,
  3.            __global int *zeros,
  4.            __global int *ones,
  5.            int k,
  6.            int n)
  7. {
  8.   size_t idx = get_global_id(0);
  9.   size_t tid = get_local_id(0);
  10.   size_t dim = get_local_size(0);
  11.   size_t gid = get_group_id(0);
  12.   int t, index;
  13.  
  14.   if (idx < n) {
  15.     t = in[idx];
  16.     /*t = (v==((t>>k)&0x1));*/
  17.     t = ((t>>k)&0x1);
  18.  
  19.     barrier(CLK_LOCAL_MEM_FENCE);
  20.  
  21.     if (t) {
  22.       index = zeros[n-1] + ones[idx] - 1;
  23.     } else {
  24.       index = zeros[idx] - 1;
  25.     }
  26.     out[index] = in[idx];
  27.  
  28.     barrier(CLK_GLOBAL_MEM_FENCE);
  29.  
  30.     if (idx == 0) {
  31.       __global int *tPtr = in;
  32.       in = out;
  33.       out = tPtr;
  34.     }
  35.   }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement