Skip to content

Instantly share code, notes, and snippets.

@eholk
Forked from anonymous/gist:4362601
Created December 23, 2012 08:42
Show Gist options
  • Save eholk/4362602 to your computer and use it in GitHub Desktop.
Save eholk/4362602 to your computer and use it in GitHub Desktop.
__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);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment