commit 8ad233c12e6821b8a55c28c43e586b35a21af08f Author: Tom Deakin Date: Wed Jul 15 23:16:23 2015 +0100 Add STREAM OpenCL kernels diff --git a/ocl-stream-kernels.cl b/ocl-stream-kernels.cl new file mode 100644 index 0000000..762af85 --- /dev/null +++ b/ocl-stream-kernels.cl @@ -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]; +}