aboutsummaryrefslogtreecommitdiffstats
path: root/src/com/mbien/opencl/demos/hellojocl/VectorAdd.cl
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/mbien/opencl/demos/hellojocl/VectorAdd.cl')
-rw-r--r--src/com/mbien/opencl/demos/hellojocl/VectorAdd.cl12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/com/mbien/opencl/demos/hellojocl/VectorAdd.cl b/src/com/mbien/opencl/demos/hellojocl/VectorAdd.cl
new file mode 100644
index 0000000..b53fc41
--- /dev/null
+++ b/src/com/mbien/opencl/demos/hellojocl/VectorAdd.cl
@@ -0,0 +1,12 @@
+
+ // OpenCL Kernel Function for element by element vector addition
+ __kernel void VectorAdd(__global const int* a, __global const int* b, __global int* c, int iNumElements) {
+ // 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 >= iNumElements) {
+ return;
+ }
+ // add the vector elements
+ c[iGID] = a[iGID] + b[iGID];
+ }