-
-
Save eholk/4362602 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__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