aboutsummaryrefslogtreecommitdiff
path: root/handcoded-opencl/sql13.cl.works
diff options
context:
space:
mode:
Diffstat (limited to 'handcoded-opencl/sql13.cl.works')
-rw-r--r--handcoded-opencl/sql13.cl.works27
1 files changed, 27 insertions, 0 deletions
diff --git a/handcoded-opencl/sql13.cl.works b/handcoded-opencl/sql13.cl.works
new file mode 100644
index 0000000..13965db
--- /dev/null
+++ b/handcoded-opencl/sql13.cl.works
@@ -0,0 +1,27 @@
+__kernel void x1_search_kernel(int totalRows,
+ int stride,
+ __global int *data,
+ __global int *resultArray) {
+
+ int i = get_global_id(0);
+ int workingSet = totalRows/4;
+ int startRow = i * workingSet;
+ int endOffset = (startRow + workingSet)*stride;
+ size_t offset = (startRow*stride)+2;
+ int maxI = data[offset];
+ int minI = data[offset];
+
+ if (i == 3)
+ endOffset = totalRows * stride;
+ for(;offset < endOffset; offset+=stride) {
+ if (data[offset] > maxI) {
+ maxI = data[offset];
+ }
+ else if (minI > data[offset]) {
+ minI = data[offset];
+ }
+ }
+
+ resultArray[i] = maxI;
+ resultArray[i+1] = minI;
+}