mesa  19.0.0
About: Mesa is an open-source implementation of the OpenGL specification - a system for rendering interactive 3D graphics (main library code). New development release.
  Fossies Dox: mesa-19.0.0.tar.xz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

Some Fossies usage hints in advance:

  1. To see the Doxygen generated documentation please click on one of the items in the "quick index" bar above or use the side panel at the left which displays a hierarchical tree-like index structure and is adjustable in width.
  2. If you want to search for something by keyword rather than browse for it you can use the client side search facility (using Javascript and DHTML) that provides live searching, i.e. the search results are presented and adapted as you type in the Search input field at the top right.
  3. Doxygen doesn't incorporate all member files but just a definable subset (basically the main project source code files that are written in a supported language). So to search and browse all member files you may visit the Fossies mesa-19.0.0.tar.xz contents page and use the Fossies standard member browsing features (also with source code highlighting and additionally with optional code folding).
mesa Documentation

Introduction

For many large applications C++ is the language of choice and so it seems reasonable to define C++ bindings for OpenCL.

The interface is contained with a single C++ header file cl.hpp and all definitions are contained within the namespace cl. There is no additional requirement to include cl.h and to use either the C++ or original C bindings it is enough to simply include cl.hpp.

The bindings themselves are lightweight and correspond closely to the underlying C API. Using the C++ bindings introduces no additional execution overhead.

For detail documentation on the bindings see:

The OpenCL C++ Wrapper API 1.1 (revision 04) http://www.khronos.org/registry/cl/specs/opencl-cplusplus-1.1.pdf

Example

The following example shows a general use case for the C++ bindings, including support for the optional exception feature and also the supplied vector and string classes, see following sections for decriptions of these features.

#define __CL_ENABLE_EXCEPTIONS
#if defined(__APPLE__) || defined(__MACOSX)
#include <OpenCL/cl.hpp>
#else
#include <CL/cl.hpp>
#endif
#include <cstdio>
#include <cstdlib>
#include <iostream>
const char * helloStr = "__kernel void "
"hello(void) "
"{ "
" "
"} ";
int
main(void)
{
cl_int err = CL_SUCCESS;
try {
std::vector<cl::Platform> platforms;
cl::Platform::get(&platforms);
if (platforms.size() == 0) {
std::cout << "Platform size 0\n";
return -1;
}
cl_context_properties properties[] =
{ CL_CONTEXT_PLATFORM, (cl_context_properties)(platforms[0])(), 0};
std::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
std::make_pair(helloStr,strlen(helloStr)));
program_.build(devices);
cl::Kernel kernel(program_, "hello", &err);
queue.enqueueNDRangeKernel(
kernel,
&event);
event.wait();
}
catch (cl::Error err) {
std::cerr
<< "ERROR: "
<< err.what()
<< "("
<< err.err()
<< ")"
<< std::endl;
}
return EXIT_SUCCESS;
}
cl::Platform::get
static cl_int get(VECTOR_CLASS< Platform > *platforms)
Definition: cl.hpp:1390
cl::Kernel
Kernel interface that implements cl_kernel.
Definition: cl.hpp:2289
devices
EGLDeviceEXT * devices
Definition: eglext.h:671
cl::Program
Program interface that implements cl_program.
Definition: cl.hpp:2386
cl::Context
Definition: cl.hpp:1417
CL_CONTEXT_DEVICES
#define CL_CONTEXT_DEVICES
Definition: cl.h:313
NULL
#define NULL
Definition: d3d9types.h:32
event
struct _cl_event * event
Definition: glcorearb.h:3019
cl::CommandQueue
CommandQueue interface for cl_command_queue.
Definition: cl.hpp:2559
cl::Event
Event interface for cl_event.
Definition: cl.hpp:1537
queue
static void queue(struct qblock *block, uint64_t inst)
Definition: vc4_qpu_emit.c:47
cl::NDRange
NDRange interface.
Definition: cl.hpp:2211
cl::Program::build
cl_int build(const VECTOR_CLASS< Device > &devices, const char *options=NULL, void(CL_CALLBACK *notifyFptr)(cl_program, void *)=NULL, void *data=NULL) const
Definition: cl.hpp:2459
CL_SUCCESS
#define CL_SUCCESS
Definition: cl.h:119
context
ULONG64 ULONG64 context
Definition: dbghelp.h:55
_cl_event
Definition: object.hpp:218
CL_DEVICE_TYPE_CPU
#define CL_DEVICE_TYPE_CPU
Definition: cl.h:200
install_megadrivers.main
def main()
Definition: install_megadrivers.py:30
cl.hpp
C++ bindings for OpenCL 1.0 (rev 48) and OpenCL 1.1 (rev 33)
source
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:798
cl::NullRange
static const NDRange NullRange
Definition: cl.hpp:2247
CL_CONTEXT_PLATFORM
#define CL_CONTEXT_PLATFORM
Definition: cl.h:318
cl_context_properties
intptr_t cl_context_properties
Definition: cl.h:62
cl::Program::Sources
VECTOR_CLASS< std::pair< const char *, ::size_t > > Sources
Definition: cl.hpp:2390