Created
October 23, 2015 18:40
-
-
Save giraldeau/b09c921292e6037a9398 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
#define __kernel | |
#define __global | |
void saxpy_cpu(float *y, | |
float *x, | |
float a, | |
int n) | |
{ | |
for (int i = 0; i < n; i++) { | |
y[i] = a * x[i] + y[i]; | |
} | |
} | |
__kernel | |
void saxpy_gpgpu(__global float *y, | |
__global float *x, | |
float a) | |
{ | |
int i = get_global_id(0); | |
y[i] = a * x[i] + y[i]; | |
} | |
__kernel | |
void vecAdd(__global float *a, | |
__global float *b, | |
__global float *c) | |
{ | |
size_t i = get_global_id(0); | |
float4 r = vload4(i, a) + vload4(i, b); | |
double4 rsq = r * r; | |
vstore4(rsq, i, c); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment