diff options
Diffstat (limited to 'src/com/jogamp/opencl/demos/hellojocl/VectorAdd.cl')
-rw-r--r-- | src/com/jogamp/opencl/demos/hellojocl/VectorAdd.cl | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/com/jogamp/opencl/demos/hellojocl/VectorAdd.cl b/src/com/jogamp/opencl/demos/hellojocl/VectorAdd.cl new file mode 100644 index 0000000..ac9dde2 --- /dev/null +++ b/src/com/jogamp/opencl/demos/hellojocl/VectorAdd.cl @@ -0,0 +1,15 @@ + + // OpenCL Kernel Function for element by element vector addition + kernel void VectorAdd(global const float* a, global const float* b, global float* c, int numElements) { + + // get index into global data array + int iGID = get_global_id(0); + + // bound check (equivalent to the limit on a 'for' loop for standard/serial C code + if (iGID >= numElements) { + return; + } + + // add the vector elements + c[iGID] = a[iGID] + b[iGID]; + }
\ No newline at end of file |