Add STREAM OpenCL kernels

This commit is contained in:
Tom Deakin 2015-07-15 23:16:23 +01:00
commit 8ad233c12e

30
ocl-stream-kernels.cl Normal file
View File

@ -0,0 +1,30 @@
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
#define DATATYPE double
constant DATATYPE scalar = 3.0;
kernel void copy(global const DATATYPE * restrict a, global DATATYPE * restrict c)
{
const size_t i = get_global_id(0);
c[i] = a[i];
}
kernel void mul(global DATATYPE * restrict b, global const DATATYPE * restrict c)
{
const size_t i = get_global_id(0);
b[i] = scalar * c[i];
}
kernel void add(global const DATATYPE * restrict a, global const DATATYPE * restrict b, global DATATYPE * restrict c)
{
const size_t i = get_global_id(0);
c[i] = a[i] + b[i];
}
kernel void triad(global DATATYPE * restrict a, global const DATATYPE * restrict b, global const DATATYPE * restrict c)
{
const size_t i = get_global_id(0);
a[i] = b[i] + scalar * c[i];
}