Chapter 8. Development with C++

 

This chapter covers

  • Creating kernels with the C++ Wrapper API
  • Enqueuing commands with the CommandQueue class
  • Processing events with the Event and UserEvent classes

When I need to crunch numbers at high speed, I prefer to write code in C. This is because my favorite compilers are optimized for high-speed processing, the executables tend to be small, and there’s usually plenty of code available on the internet from which I can draw inspiration.

But when my application needs to do more than just crunch numbers, such as animate an assemblage of moving parts, I prefer an object-oriented (OO) language like C++. This gives me the benefits associated with OO programming, such as polymorphism, inheritance, and encapsulation. It also provides a wealth of capabilities through the C++ Standard Template Library (STL) and the Boost libraries.

The OpenCL Working Group provides a C++ Wrapper API that makes it possible to code full-featured OpenCL host applications in C++. This API provides many advantages over the regular C API, and three of the most important advantages are as follows:

8.1. Preliminary concerns

8.2. Creating kernels

8.3. Kernel arguments and memory objects

8.4. Command queues

8.5. Event processing

8.6. Summary