OpenCL-examples
OpenCL-examples copied to clipboard
Current API is 2.1
The hpp file is at https://www.khronos.org/registry/OpenCL/api/2.1/cl.hpp Some changes I made to compile on a Macbook Pro:
diff --git a/example00/main.cpp b/example00/main.cpp
index 650cfda..2c20796 100644
--- a/example00/main.cpp
+++ b/example00/main.cpp
@@ -87,8 +87,12 @@ int main() {
queue.enqueueWriteBuffer(buffer_N, CL_TRUE, 0, sizeof(int), N);
// RUN ZE KERNEL
- cl::KernelFunctor simple_add(cl::Kernel(program, "simple_add"), queue, cl::NullRange, cl::NDRange(10), cl::NullRange);
- simple_add(buffer_A, buffer_B, buffer_C, buffer_N);
+ cl::Kernel simple_add(program, "simple_add");
+ simple_add.setArg(0, buffer_A);
+ simple_add.setArg(1, buffer_B);
+ simple_add.setArg(2, buffer_C);
+ simple_add.setArg(3, buffer_N);
+ queue.enqueueNDRangeKernel(simple_add, cl::NullRange, cl::NDRange(10), cl::NullRange);
int C[n];
// read result from GPU to here
diff --git a/example03/main.c b/example03/main.c
index 04f4baf..a5f8c9c 100644
--- a/example03/main.c
+++ b/example03/main.c
@@ -1,7 +1,11 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
-#include <CL/cl.h>
+#ifdef __APPLE__
+ #include <OpenCL/cl.h>
+#else
+ #include <CL/cl.h>
+#endif
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
const char *kernelSource =
@stroucki maybe you could publish your fork?
@Foadsf done: https://github.com/stroucki/OpenCL-examples