OpenCL C++ Bindings

Some members of the OpenCL Working Group have developed an experimental set of C++ bindings to OpenCL 1.0. The bindings have been posted to the OpenCL Registry. Feedback on the bindings should ideally be reported through Bugzilla, as described in the Registry, but can also be posted in this thread.

I’m Mac OS user (Intel Core Duo2 + NVIDIA GeForce 9400M ), and I understand Snow Leopard will include OpenCL. I browsed the OpenCL overview brochure, but perhaps an experienced person could give me an idea of whether OpenCL will have any benefit for me. I do mainly numeric computation with C++. A lot of vectorized operations (STL) and cmath.

Is OpenCL relevant for my line of work?
What efficiency gains can I expect (x2, x10)?
What would be the best way to learn OpenCL?

The file cl.hpp that is on the official site contains bindings for the revision 33; do you have updated one for newer revisions? (namely 48?)

I’ve asked about updates - but do remember that these are not official Khronos products.

I have an updated version for rev .43 and i’m planning to update to .48 over the next few days. As soon as it is done I request for it to be posted on along side the updated headers.

  1. yes
  2. probably more than x10 if the problem is well suited. this is usually the case if you have a lot of vector operations and coalesced memory access. but a concretely answer to this question cannot be given without knowing the problem.
  3. read the opencl reference guide and the nvidia cuda informations.

…) please open a new thread next time because this is off topic!

Jon,

I have posted an updated C++ bindings header for 1.0 rev 43 and would be greatful if you could post it to the website.

Regards,

Ben

Where we can find it? I want to use the C++ binding, but current version of cl.hpp seems to be incompatible with cl.h

Sorry for the delay but I forgot to build the corrsponding documentation and this is done now and hopefully the updated bindings and documentation should be up by tommorrow.

Benedict’s updated C++ bindings are linked from the OpenCL Registry now.

Thanks! But one note: ::clEnqueueAcquireExternalObjects isn’t found nowhere.

Sorry for the delay but I have updated the C++ bindings:

http://www.khronos.org/registry/cl/

This includes removing the call to ::clEnqueueAcquireExternalObjects but also have added two new types cl::vector and cl:string that are alternatives too STL versions. See the documentation for details.

Ben

A new verison of the C++ bindings has been uploaded that fixes a bug introduced with the cl::vector class and its use with NDRange. It can be found here:

http://www.khronos.org/registry/cl/

I’ve been trying to compile the C++ bindings files with no success. Has anyone done this successfully on an intel iMac osx 10.5.8. I get the following errors:
cl.h:452: error: expected initializer before ‘AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER’

any ideas?

When handling multiple devices it would be handy to be able to maintain a vector of kernel functors, where each functor is associated with a command queue:

std::vector<cl::KernelFunctor> kernelFunctors;
for (int d = 0 ; d < commandQueues.size() ; d++)
{
    kernelFunctors.push_back(kernel.bind(commandQueues[d], globalNDRange, localNDRange));
}

Any ideas for how to implement something like this, given that this won’t work without being able to copy KernelFunctors?

Regarding my post above, I opened http://www.khronos.org/bugzilla/show_bug.cgi?id=200.

I have updated the C++ bindings to provide copy constructor for KernelFunctor and the following program now compiles without error:


#include <CL/cl.hpp>

int main(void)
{
    std::vector<cl::CommandQueue> commandQueues;
    cl::Kernel kernel;

    cl::NDRange globalNDRange;
    cl::NDRange localNDRange;

    std::vector<cl::KernelFunctor> kernelFunctors;
    for (int d = 0 ; d < commandQueues.size() ; d++) {
        kernelFunctors.push_back(
            kernel.bind(
                commandQueues[d], 
                globalNDRange,
                localNDRange));
    }
}

Please let me know if you have any problems using it and thanks for the feedback.

> I’ve been trying to compile the C++ bindings files with no success. Has anyone done this successfully on an intel iMac osx 10.5.8. I get > the following errors:
> cl.h:452: error: expected initializer before ‘AVAILABLE_MAC_OS_X_VERSION_10_6_AND_LATER’
> …
> …

> any ideas?

I think the issue is that OpenCL will not be supported by Apple until the release of Snow Leopard, version 10.6 of its popular OS X. You can find out more details about Snow Leopard on Apple’s website with notice that it will be publicly available August 28. Once you have this upgrade there should be no problem using the C++ bindings.

Awesome, thanks!

bgaster: Could you please put the bindings under version control (SourceForge, Google Code, GitHub, etc) ?