This is a tiny C++ wrapper for OpenCL that aims to reduce some of the noise when using the OpenCL 1.0 API. The provided function interfaces take fewer, easier to handle arguments. All contained objects support full interoperability with OpenCL in case rarely used behaviour not covered by the library is needed.
The Events class simply wraps any amount of cl_event entries and returns them in the proper form (size(),data()) for use in OpenCL calls. Events objects may be merged with the + or += operator. Events objects can be trivially created from cl_event entries by calling Events(cl_event) or extended by just adding a cl_event to a Events object using the + operator.
WorkDimensions classes are also easy to integrate in any existing setup, but are even easier to use with the provided wrappers for kernel calls, as the following 4x4 example shows:
#include "OCLWrapBasics.h"
WorkDimensions dims{4,4};
dims.implementation_chooses_local_distribution();
Events kernel_finished = enqueueRange(queue,kernel,dims,wait_for_writes);
Note that wait_for_writes is of type Events, as well as the output.
Events enqueue (Read/Write)Buffer(cl_command_queue queue, cl_mem buffer, size_t size_in_bytes, T* host_ptr, const Events& wait_for)
Works just like expected, too. However there is an even more compact way of handling buffers coming up.
None of the library functions return error codes. Instead they catch them internally to throw OCLException exceptions that describe the kind of error in their what() function.
A LinkedBuffer represents and manages a buffer object. It is associated with a context, device and queue and after setup allows the usual manipulations with minimal additional input. The association with a queue may be changed at any later point. There are a variety of different constructors for the class, but the simplest one just takes a context, a size in elements and a queue. Data transfer between host and device needs to be triggered manually. The transfer returns Events to wait on and can of course also wait on Events. And that's all the parameters needed to initialize an exchange.
Example:
LinkedBuffer<float> buffer(context,10,queue);
buffer.host[0] = 1; //Set host side values
Events wait = buffer.to_device(); //transfer host side values to device