public
Created — forked from /gist:4362601

  • Download Gist
gistfile1.cl
OpenCL
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
__kernel void MyAdd_col(const double __global *A,
const double __global *B,
double __global *C,
unsigned long int N)
{
unsigned long int i = get_global_id(0);
 
for(unsigned long int j = 0; j < N; j++) {
if (j % 2 == 0)
get(C, N, i, j) = get(A, N, i, j) + get(A, N, i, j);
else
get(C, N, i, j) = get(A, N, i, j) - get(A, N, i, j);
}
}
 
 
__kernel void MyAdd_2D_col(const double __global *A,
const double __global *B,
double __global *C,
unsigned long int N)
{
unsigned long int i = get_global_id(0);
unsigned long int j = get_global_id(1);
 
if (j % 2 == 0)
get(C, N, i, j) = get(A, N, i, j) + get(A, N, i, j);
else
get(C, N, i, j) = get(A, N, i, j) - get(A, N, i, j);
}
 
 
__kernel void MyAdd_2D_unweave_col(const double __global *A,
const double __global *B,
double __global *C,
unsigned long int N)
{
unsigned long int i = get_global_id(0);
unsigned long int j = get_global_id(1);
 
if(j < N / 2) {
unsigned long int j = 2 * j;
get(C, N, i, j) = get(A, N, i, j) + get(A, N, i, j);
}
else {
unsigned long int j = 2 * (j - N / 2) + 1;
get(C, N, i, j) = get(A, N, i, j) - get(A, N, i, j);
}
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.