dakkers / opencl-examples Goto Github PK
View Code? Open in Web Editor NEWbasic examples of OpenCL with the C++ API
basic examples of OpenCL with the C++ API
The link to https://github.com/Dakkers/OpenCL-examples/blob/master/simpleopencl.blogspot.ca/2013/06/tutorial-simple-start-with-opencl-and-c.html in example 1 is dead
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 =
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.