Skip to content

Instantly share code, notes, and snippets.

@giraldeau
Created October 23, 2015 18:40
Show Gist options
  • Save giraldeau/b09c921292e6037a9398 to your computer and use it in GitHub Desktop.
Save giraldeau/b09c921292e6037a9398 to your computer and use it in GitHub Desktop.
#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