Using the C++ bindings for OpenCL

While the OpenCL API is written in C, the OpenCL 1.1 specification also comes with a specification for C++ bindings. In this post I go through how to use the C++ bindings instead of C for the simple example of vector addition from my previous post Getting started with OpenCL and GPU computing.

Download the bindings

First of all the C++ bindings for OpenCL can be downloaded directly from Khronos website. The cl.hpp file should be put in the include folder with cl.h and the other OpenCL header files. You might not need to download the bindings file as it is usually included in the include folder of the vendors SDK (ATI Stream and CUDA Toolkit). Note that you have to set up OpenCL before you can use the C++ bindings. If you haven’t set OpenCL up yet, read through my Getting started with OpenCL and GPU computing post first.

Using the bindings

To use the C++ bindings simply include the cl.hpp file instead of the cl.h file. The bindings include several useful objects like Platform, Device, Context, CommandQueue, Program etc. which will make your life easier. All of the objects are defined in the namespace cl.

API

An overview of all of the objects, functions and variables can be found in the official C++ bindings specification from Khronos

Exceptions

If you want to use exceptions instead of checking for errors after every call to a function you can do so by defining __CL_ENABLE_EXCEPTIONS to the preprocessor and then wrapping your code in a try-catch block. See the example below for more details.

The vector addition example

This is the example of vector addition from my previous post, Getting started with OpenCL and GPU computing, which simply computes the sum of two lists in parallel on the GPU. Note that though the API from above says that the context properties array in line 26 can be omitted from the context constructor and that the platform will then be selected automatically I got an error on clCreateContextFromType while trying to do so. That is why I have included lines 22-30 to select the first platform the system finds, which in my opinion shouldn’t be necessary. Compile the program using your favorite C++ compiler with the same compile options as with OpenCL C.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#define __NO_STD_VECTOR // Use cl::vector instead of STL version
#define __CL_ENABLE_EXCEPTIONS
#include <CL/cl.hpp>
#include <utility>
#include <iostream>
#include <fstream>
#include <string>
using namespace cl;
 
int main() {
    // Create the two input vectors
    const int LIST_SIZE = 1000;
    int *A = new int[LIST_SIZE]; 
    int *B = new int[LIST_SIZE];
    for(int i = 0; i < LIST_SIZE; i++) {
        A[i] = i;
        B[i] = LIST_SIZE - i;
    }
 
   try { 
        // Get available platforms
        vector<Platform> platforms;
        Platform::get(&platforms);
 
        // Select the default platform and create a context using this platform and the GPU
        cl_context_properties cps[3] = { 
            CL_CONTEXT_PLATFORM, 
            (cl_context_properties)(platforms[0])(), 
            0 
        };
        Context context( CL_DEVICE_TYPE_GPU, cps);
 
        // Get a list of devices on this platform
        vector<Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
 
        // Create a command queue and use the first device
        CommandQueue queue = CommandQueue(context, devices[0]);
 
        // Read source file
        std::ifstream sourceFile("vector_add_kernel.cl");
        std::string sourceCode(
            std::istreambuf_iterator<char>(sourceFile),
            (std::istreambuf_iterator<char>()));
        Program::Sources source(1, std::make_pair(sourceCode.c_str(), sourceCode.length()+1));
 
        // Make program of the source code in the context
        Program program = Program(context, source);
 
        // Build program for these specific devices
        program.build(devices);
 
        // Make kernel
        Kernel kernel(program, "vector_add");
 
        // Create memory buffers
        Buffer bufferA = Buffer(context, CL_MEM_READ_ONLY, LIST_SIZE * sizeof(int));
        Buffer bufferB = Buffer(context, CL_MEM_READ_ONLY, LIST_SIZE * sizeof(int));
        Buffer bufferC = Buffer(context, CL_MEM_WRITE_ONLY, LIST_SIZE * sizeof(int));
 
        // Copy lists A and B to the memory buffers
        queue.enqueueWriteBuffer(bufferA, CL_TRUE, 0, LIST_SIZE * sizeof(int), A);
        queue.enqueueWriteBuffer(bufferB, CL_TRUE, 0, LIST_SIZE * sizeof(int), B);
 
        // Set arguments to kernel
        kernel.setArg(0, bufferA);
        kernel.setArg(1, bufferB);
        kernel.setArg(2, bufferC);
 
        // Run the kernel on specific ND range
        NDRange global(LIST_SIZE);
        NDRange local(1);
        queue.enqueueNDRangeKernel(kernel, NullRange, global, local);
 
        // Read buffer C into a local list
        int *C = new int[LIST_SIZE];
        queue.enqueueReadBuffer(bufferC, CL_TRUE, 0, LIST_SIZE * sizeof(int), C);
 
        for(int i = 0; i < LIST_SIZE; i ++)
             std::cout << A[i] << " + " << B[i] << " = " << C[i] << std::endl; 
    } catch(Error error) {
       std::cout << error.what() << "(" << error.err() << ")" << std::endl;
    }
 
    return 0;
}

You may also like...

32 Responses

  1. Sam says:

    Thanks, this was a great tutorial.

  2. Lucas says:

    Do you know why adding
    #define __NO_STD_VECTOR
    to the top line would return a massive error?


    /usr/include/CL/cl.hpp:677:1: error: expected unqualified-id before ‘{’ token
    {
    ^
    /usr/include/CL/cl.hpp:1093:28: error: ‘cl::vector’ is not a template
    struct GetInfoHelper<Func, VECTOR_CLASS >
    ^
    /usr/include/CL/cl.hpp:1093:8: error: template parameters not used in partial specialization:
    struct GetInfoHelper<Func, VECTOR_CLASS >
    ^
    /usr/include/CL/cl.hpp:1093:8: error: ‘T’
    /usr/include/CL/cl.hpp:1115:28: error: ‘cl::vector’ is not a template
    struct GetInfoHelper<Func, VECTOR_CLASS >
    ^
    /usr/include/CL/cl.hpp:1117:45: error: ‘cl::vector’ is not a template
    static cl_int get(Func f, cl_uint name, VECTOR_CLASS* param)
    ^
    /usr/include/CL/cl.hpp: In static member function ‘static cl_int cl::detail::GetInfoHelper::get(Func, cl_uint, cl::vector*)’:
    /usr/include/CL/cl.hpp:1131:14: error: invalid use of incomplete type ‘class cl::vector’
    param->assign(&value[0], &value[required/sizeof(cl_device_id)]);
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: At global scope:
    /usr/include/CL/cl.hpp:1138:28: error: ‘cl::vector’ is not a template
    struct GetInfoHelper<Func, VECTOR_CLASS >
    ^
    /usr/include/CL/cl.hpp:1138:8: error: redefinition of ‘struct cl::detail::GetInfoHelper’
    struct GetInfoHelper<Func, VECTOR_CLASS >
    ^
    /usr/include/CL/cl.hpp:1115:8: error: previous definition of ‘struct cl::detail::GetInfoHelper’
    struct GetInfoHelper<Func, VECTOR_CLASS >
    ^
    /usr/include/CL/cl.hpp:1411:1: error: ‘cl::vector’ is not a template
    __PARAM_NAME_INFO_1_0(__CL_DECLARE_PARAM_TRAITS)
    ^
    /usr/include/CL/cl.hpp:1411:1: error: ‘cl::vector’ is not a template
    __PARAM_NAME_INFO_1_0(__CL_DECLARE_PARAM_TRAITS)
    ^
    /usr/include/CL/cl.hpp:1411:1: error: ‘cl::vector’ is not a template
    __PARAM_NAME_INFO_1_0(__CL_DECLARE_PARAM_TRAITS)
    ^
    /usr/include/CL/cl.hpp:1411:1: error: ‘cl::vector’ is not a template
    __PARAM_NAME_INFO_1_0(__CL_DECLARE_PARAM_TRAITS)
    ^
    /usr/include/CL/cl.hpp:1411:1: error: ‘cl::vector’ is not a template
    __PARAM_NAME_INFO_1_0(__CL_DECLARE_PARAM_TRAITS)
    ^
    /usr/include/CL/cl.hpp:1411:1: error: ‘cl::vector’ is not a template
    __PARAM_NAME_INFO_1_0(__CL_DECLARE_PARAM_TRAITS)
    ^
    /usr/include/CL/cl.hpp:1416:1: error: ‘cl::vector’ is not a template
    __PARAM_NAME_INFO_1_2(__CL_DECLARE_PARAM_TRAITS)
    ^
    /usr/include/CL/cl.hpp:1416:1: error: ‘cl::vector’ is not a template
    __PARAM_NAME_INFO_1_2(__CL_DECLARE_PARAM_TRAITS)
    ^
    /usr/include/CL/cl.hpp:1935:9: error: ‘cl::vector’ is not a template
    VECTOR_CLASS* devices)
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::Device::createSubDevices(const cl_device_partition_property*, cl::vector*)’:
    /usr/include/CL/cl.hpp:1949:16: error: invalid use of incomplete type ‘class cl::vector’
    devices->assign(&ids[0], &ids[n]);
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: At global scope:
    /usr/include/CL/cl.hpp:2068:9: error: ‘cl::vector’ is not a template
    VECTOR_CLASS* devices) const
    ^
    /usr/include/CL/cl.hpp:2171:9: error: ‘cl::vector’ is not a template
    VECTOR_CLASS* platforms)
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::Platform::getDevices(cl_device_type, cl::vector*) const’:
    /usr/include/CL/cl.hpp:2085:16: error: invalid use of incomplete type ‘class cl::vector’
    devices->assign(&ids[0], &ids[n]);
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In static member function ‘static cl_int cl::Platform::get(cl::vector*)’:
    /usr/include/CL/cl.hpp:2191:18: error: invalid use of incomplete type ‘class cl::vector’
    platforms->assign(&ids[0], &ids[n]);
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: At global scope:
    /usr/include/CL/cl.hpp:2317:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS& devices,
    ^
    /usr/include/CL/cl.hpp:2535:9: error: ‘cl::vector’ is not a template
    VECTOR_CLASS* formats) const
    ^
    /usr/include/CL/cl.hpp: In constructor ‘cl::Context::Context(const cl::vector&, cl_context_properties*, void (*)(const char*, const void*, size_t, void*), void*, cl_int*)’:
    /usr/include/CL/cl.hpp:2329:38: error: invalid use of incomplete type ‘const class cl::vector’
    ::size_t numDevices = devices.size();
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:2332:46: error: no match for ‘operator[]’ (operand types are ‘const cl::vector’ and ‘size_t {aka long unsigned int}’)
    deviceIDs[deviceIndex] = (devices[deviceIndex])();
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::Context::getSupportedImageFormats(cl_mem_flags, cl_mem_object_type, cl::vector*) const’:
    /usr/include/CL/cl.hpp:2562:16: error: invalid use of incomplete type ‘class cl::vector’
    formats->assign(&value[0], &value[numEntries]);
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In static member function ‘static cl::Device cl::Device::getDefault(cl_int*)’:
    /usr/include/CL/cl.hpp:2581:54: error: invalid use of incomplete type ‘cl::detail::param_traits::param_type {aka class cl::vector}’
    device = context.getInfo()[0];
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘cl::detail::param_traits::param_type {aka class cl::vector}’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: At global scope:
    /usr/include/CL/cl.hpp:2742:25: error: ‘cl::vector’ is not a template
    waitForEvents(const VECTOR_CLASS& events)
    ^
    /usr/include/CL/cl.hpp: In static member function ‘static cl_int cl::Event::waitForEvents(const cl::vector&)’:
    /usr/include/CL/cl.hpp:2746:33: error: invalid use of incomplete type ‘const class cl::vector’
    (cl_uint) events.size(), (cl_event*)&events.front()),
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:2746:60: error: invalid use of incomplete type ‘const class cl::vector’
    (cl_uint) events.size(), (cl_event*)&events.front()),
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: At global scope:
    /usr/include/CL/cl.hpp:2813:21: error: ‘cl::vector’ is not a template
    WaitForEvents(const VECTOR_CLASS& events)
    ^
    /usr/include/CL/cl.hpp: In function ‘cl_int cl::WaitForEvents(const cl::vector&)’:
    /usr/include/CL/cl.hpp:2817:29: error: invalid use of incomplete type ‘const class cl::vector’
    (cl_uint) events.size(), (cl_event*)&events.front()),
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:2817:56: error: invalid use of incomplete type ‘const class cl::vector’
    (cl_uint) events.size(), (cl_event*)&events.front()),
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: At global scope:
    /usr/include/CL/cl.hpp:4494:13: error: ‘cl::vector’ is not a template
    typedef VECTOR_CLASS<std::pair > Binaries;
    ^
    /usr/include/CL/cl.hpp:4495:13: error: ‘cl::vector’ is not a template
    typedef VECTOR_CLASS<std::pair > Sources;
    ^
    /usr/include/CL/cl.hpp:4627:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS& devices,
    ^
    /usr/include/CL/cl.hpp:4629:9: error: ‘cl::vector’ is not a template
    VECTOR_CLASS* binaryStatus = NULL,
    ^
    /usr/include/CL/cl.hpp:4669:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS& devices,
    ^
    /usr/include/CL/cl.hpp:4717:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS& devices,
    ^
    /usr/include/CL/cl.hpp:4821:26: error: ‘cl::vector’ is not a template
    cl_int createKernels(VECTOR_CLASS* kernels)
    ^
    /usr/include/CL/cl.hpp: In constructor ‘cl::Program::Program(const cl::Context&, const Sources&, cl_int*)’:
    /usr/include/CL/cl.hpp:4607:45: error: invalid use of incomplete type ‘const Sources {aka const class cl::vector}’
    const ::size_t n = (::size_t)sources.size();
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const Sources {aka const class cl::vector}’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:4612:33: error: no match for ‘operator[]’ (operand types are ‘const Sources {aka const cl::vector}’ and ‘int’)
    strings[i] = sources[(int)i].first;
    ^
    /usr/include/CL/cl.hpp:4613:33: error: no match for ‘operator[]’ (operand types are ‘const Sources {aka const cl::vector}’ and ‘int’)
    lengths[i] = sources[(int)i].second;
    ^
    /usr/include/CL/cl.hpp: In constructor ‘cl::Program::Program(const cl::Context&, const cl::vector&, const Binaries&, cl::vector*, cl_int*)’:
    /usr/include/CL/cl.hpp:4633:36: error: invalid use of incomplete type ‘const Binaries {aka const class cl::vector}’
    const ::size_t n = binaries.size();
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const Binaries {aka const class cl::vector}’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:4638:55: error: no match for ‘operator[]’ (operand types are ‘const Binaries {aka const cl::vector}’ and ‘int’)
    images[i] = (const unsigned char*)binaries[(int)i].first;
    ^
    /usr/include/CL/cl.hpp:4639:34: error: no match for ‘operator[]’ (operand types are ‘const Binaries {aka const cl::vector}’ and ‘int’)
    lengths[i] = binaries[(int)i].second;
    ^
    /usr/include/CL/cl.hpp:4642:38: error: invalid use of incomplete type ‘const class cl::vector’
    ::size_t numDevices = devices.size();
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:4645:46: error: no match for ‘operator[]’ (operand types are ‘const cl::vector’ and ‘size_t {aka long unsigned int}’)
    deviceIDs[deviceIndex] = (devices[deviceIndex])();
    ^
    /usr/include/CL/cl.hpp:4649:41: error: invalid use of incomplete type ‘const class cl::vector’
    context(), (cl_uint) devices.size(),
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:4652:41: error: invalid use of incomplete type ‘class cl::vector’
    ? (cl_int*) &binaryStatus->front()
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In constructor ‘cl::Program::Program(const cl::Context&, const cl::vector&, const STRING_CLASS&, cl_int*)’:
    /usr/include/CL/cl.hpp:4676:38: error: invalid use of incomplete type ‘const class cl::vector’
    ::size_t numDevices = devices.size();
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:4679:46: error: no match for ‘operator[]’ (operand types are ‘const cl::vector’ and ‘size_t {aka long unsigned int}’)
    deviceIDs[deviceIndex] = (devices[deviceIndex])();
    ^
    /usr/include/CL/cl.hpp:4684:30: error: invalid use of incomplete type ‘const class cl::vector’
    (cl_uint) devices.size(),
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::Program::build(const cl::vector&, const char*, void (*)(cl_program, void*), void*) const’:
    /usr/include/CL/cl.hpp:4722:38: error: invalid use of incomplete type ‘const class cl::vector’
    ::size_t numDevices = devices.size();
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:4725:46: error: no match for ‘operator[]’ (operand types are ‘const cl::vector’ and ‘size_t {aka long unsigned int}’)
    deviceIDs[deviceIndex] = (devices[deviceIndex])();
    ^
    /usr/include/CL/cl.hpp:4732:24: error: invalid use of incomplete type ‘const class cl::vector’
    devices.size(),
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::Program::createKernels(cl::vector*)’:
    /usr/include/CL/cl.hpp:4836:16: error: invalid use of incomplete type ‘class cl::vector’
    kernels->assign(&value[0], &value[numKernels]);
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: At global scope:
    /usr/include/CL/cl.hpp:4878:5: error: ‘cl::vector’ is not a template
    VECTOR_CLASS inputPrograms,
    ^
    /usr/include/CL/cl.hpp: In function ‘cl::Program cl::linkProgram(cl::vector, const char*, void (*)(cl_program, void*), void*, cl_int*)’:
    /usr/include/CL/cl.hpp:4877:16: error: ‘inputPrograms’ has incomplete type
    inline Program linkProgram(
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: At global scope:
    /usr/include/CL/cl.hpp:4932:8: error: ‘cl::vector’ is not a template
    inline VECTOR_CLASS cl::Program::getInfo(cl_int* err) const
    ^
    /usr/include/CL/cl.hpp: In member function ‘typename cl::detail::param_traits::param_type cl::Program::getInfo(cl_int*) const [with int name = 4454; typename cl::detail::param_traits::param_type = cl::vector; cl_int = int]’:
    /usr/include/CL/cl.hpp:4932:84: error: return type ‘class cl::vector’ is incomplete
    inline VECTOR_CLASS cl::Program::getInfo(cl_int* err) const
    ^
    /usr/include/CL/cl.hpp:4934:5: error: ‘cl::vector’ is not a template
    VECTOR_CLASS sizes = getInfo();
    ^
    /usr/include/CL/cl.hpp:4934:29: error: variable ‘cl::vector sizes’ has initializer but incomplete type
    VECTOR_CLASS sizes = getInfo();
    ^
    /usr/include/CL/cl.hpp:4934:70: error: invalid use of incomplete type ‘cl::detail::param_traits::param_type {aka class cl::vector}’
    VECTOR_CLASS sizes = getInfo();
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘cl::detail::param_traits::param_type {aka class cl::vector}’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:4935:5: error: ‘cl::vector’ is not a template
    VECTOR_CLASS binaries;
    ^
    /usr/include/CL/cl.hpp:4935:26: error: aggregate ‘cl::vector binaries’ has incomplete type and cannot be defined
    VECTOR_CLASS binaries;
    ^
    /usr/include/CL/cl.hpp:4936:10: error: ‘cl::vector’ is not a template
    for (VECTOR_CLASS::iterator s = sizes.begin(); s != sizes.end(); ++s)
    ^
    /usr/include/CL/cl.hpp:4936:35: error: invalid use of qualified-name ‘::iterator’
    for (VECTOR_CLASS::iterator s = sizes.begin(); s != sizes.end(); ++s)
    ^
    /usr/include/CL/cl.hpp:4936:44: error: expected ‘;’ before ‘s’
    for (VECTOR_CLASS::iterator s = sizes.begin(); s != sizes.end(); ++s)
    ^
    /usr/include/CL/cl.hpp:4936:44: error: ‘s’ was not declared in this scope
    /usr/include/CL/cl.hpp:4936:79: error: expected ‘)’ before ‘;’ token
    for (VECTOR_CLASS::iterator s = sizes.begin(); s != sizes.end(); ++s)
    ^
    /usr/include/CL/cl.hpp:4936:83: error: ‘s’ was not declared in this scope
    for (VECTOR_CLASS::iterator s = sizes.begin(); s != sizes.end(); ++s)
    ^
    /usr/include/CL/cl.hpp:4936:84: error: expected ‘;’ before ‘)’ token
    for (VECTOR_CLASS::iterator s = sizes.begin(); s != sizes.end(); ++s)
    ^
    /usr/include/CL/cl.hpp: At global scope:
    /usr/include/CL/cl.hpp:5128:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp:5153:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp:5178:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp:5207:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp:5246:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp:5284:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp:5324:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp:5356:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp:5383:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp:5408:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp:5440:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp:5474:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp:5508:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp:5537:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp:5562:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp:5587:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp:5614:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp:5638:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp:5669:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS *events = 0,
    ^
    /usr/include/CL/cl.hpp:5699:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS *events = 0,
    ^
    /usr/include/CL/cl.hpp:5722:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS &memObjects,
    ^
    /usr/include/CL/cl.hpp:5724:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp:5759:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp:5782:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp:5803:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* mem_objects = NULL,
    ^
    /usr/include/CL/cl.hpp:5804:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* mem_locs = NULL,
    ^
    /usr/include/CL/cl.hpp:5805:15: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp:5861:16: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* mem_objects = NULL,
    ^
    /usr/include/CL/cl.hpp:5862:16: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp:5883:16: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* mem_objects = NULL,
    ^
    /usr/include/CL/cl.hpp:5884:16: error: ‘cl::vector’ is not a template
    const VECTOR_CLASS* events = NULL,
    ^
    /usr/include/CL/cl.hpp: In constructor ‘cl::CommandQueue::CommandQueue(cl_command_queue_properties, cl_int*)’:
    /usr/include/CL/cl.hpp:4991:65: error: invalid use of incomplete type ‘cl::detail::param_traits::param_type {aka class cl::vector}’
    Device device = context.getInfo()[0];
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘cl::detail::param_traits::param_type {aka class cl::vector}’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In static member function ‘static cl::CommandQueue cl::CommandQueue::getDefault(cl_int*)’:
    /usr/include/CL/cl.hpp:5055:65: error: invalid use of incomplete type ‘cl::detail::param_traits::param_type {aka class cl::vector}’
    Device device = context.getInfo()[0];
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘cl::detail::param_traits::param_type {aka class cl::vector}’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::CommandQueue::enqueueReadBuffer(const cl::Buffer&, cl_bool, size_t, size_t, void*, const cl::vector*, cl::Event*) const’:
    /usr/include/CL/cl.hpp:5136:52: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL) ? (cl_uint) events->size() : 0,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5137:42: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5137:77: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::CommandQueue::enqueueWriteBuffer(const cl::Buffer&, cl_bool, size_t, size_t, const void*, const cl::vector*, cl::Event*) const’:
    /usr/include/CL/cl.hpp:5161:52: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL) ? (cl_uint) events->size() : 0,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5162:42: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5162:77: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::CommandQueue::enqueueCopyBuffer(const cl::Buffer&, const cl::Buffer&, size_t, size_t, size_t, const cl::vector*, cl::Event*) const’:
    /usr/include/CL/cl.hpp:5185:52: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL) ? (cl_uint) events->size() : 0,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5186:42: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5186:77: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::CommandQueue::enqueueReadBufferRect(const cl::Buffer&, cl_bool, const cl::size_t&, const cl::size_t&, const cl::size_t&, size_t, size_t, size_t, size_t, void*, const cl::vector*, cl::Event*) const’:
    /usr/include/CL/cl.hpp:5224:52: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL) ? (cl_uint) events->size() : 0,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5225:42: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5225:77: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::CommandQueue::enqueueWriteBufferRect(const cl::Buffer&, cl_bool, const cl::size_t&, const cl::size_t&, const cl::size_t&, size_t, size_t, size_t, size_t, void*, const cl::vector*, cl::Event*) const’:
    /usr/include/CL/cl.hpp:5263:52: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL) ? (cl_uint) events->size() : 0,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5264:42: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5264:77: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::CommandQueue::enqueueCopyBufferRect(const cl::Buffer&, const cl::Buffer&, const cl::size_t&, const cl::size_t&, const cl::size_t&, size_t, size_t, size_t, size_t, const cl::vector*, cl::Event*) const’:
    /usr/include/CL/cl.hpp:5300:52: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL) ? (cl_uint) events->size() : 0,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5301:42: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5301:77: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::CommandQueue::enqueueFillBuffer(const cl::Buffer&, PatternType, size_t, size_t, const cl::vector*, cl::Event*) const’:
    /usr/include/CL/cl.hpp:5336:52: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL) ? (cl_uint) events->size() : 0,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5337:42: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5337:77: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::CommandQueue::enqueueReadImage(const cl::Image&, cl_bool, const cl::size_t&, const cl::size_t&, size_t, size_t, void*, const cl::vector*, cl::Event*) const’:
    /usr/include/CL/cl.hpp:5364:52: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL) ? (cl_uint) events->size() : 0,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5365:42: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5365:77: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::CommandQueue::enqueueWriteImage(const cl::Image&, cl_bool, const cl::size_t&, const cl::size_t&, size_t, size_t, void*, const cl::vector*, cl::Event*) const’:
    /usr/include/CL/cl.hpp:5391:52: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL) ? (cl_uint) events->size() : 0,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5392:42: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5392:77: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::CommandQueue::enqueueCopyImage(const cl::Image&, const cl::Image&, const cl::size_t&, const cl::size_t&, const cl::size_t&, const cl::vector*, cl::Event*) const’:
    /usr/include/CL/cl.hpp:5416:52: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL) ? (cl_uint) events->size() : 0,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5417:42: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5417:77: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::CommandQueue::enqueueFillImage(const cl::Image&, cl_float4, const cl::size_t&, const cl::size_t&, const cl::vector*, cl::Event*) const’:
    /usr/include/CL/cl.hpp:5451:52: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL) ? (cl_uint) events->size() : 0,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5452:42: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5452:77: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::CommandQueue::enqueueFillImage(const cl::Image&, cl_int4, const cl::size_t&, const cl::size_t&, const cl::vector*, cl::Event*) const’:
    /usr/include/CL/cl.hpp:5485:52: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL) ? (cl_uint) events->size() : 0,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5486:42: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5486:77: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::CommandQueue::enqueueFillImage(const cl::Image&, cl_uint4, const cl::size_t&, const cl::size_t&, const cl::vector*, cl::Event*) const’:
    /usr/include/CL/cl.hpp:5519:52: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL) ? (cl_uint) events->size() : 0,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5520:42: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5520:77: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::CommandQueue::enqueueCopyImageToBuffer(const cl::Image&, const cl::Buffer&, const cl::size_t&, const cl::size_t&, size_t, const cl::vector*, cl::Event*) const’:
    /usr/include/CL/cl.hpp:5545:52: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL) ? (cl_uint) events->size() : 0,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5546:42: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5546:77: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::CommandQueue::enqueueCopyBufferToImage(const cl::Buffer&, const cl::Image&, size_t, const cl::size_t&, const cl::size_t&, const cl::vector*, cl::Event*) const’:
    /usr/include/CL/cl.hpp:5570:52: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL) ? (cl_uint) events->size() : 0,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5571:42: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5571:77: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘void* cl::CommandQueue::enqueueMapBuffer(const cl::Buffer&, cl_bool, cl_map_flags, size_t, size_t, const cl::vector*, cl::Event*, cl_int*) const’:
    /usr/include/CL/cl.hpp:5594:48: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL) ? (cl_uint) events->size() : 0,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5595:38: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5595:73: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘void* cl::CommandQueue::enqueueMapImage(const cl::Image&, cl_bool, cl_map_flags, const cl::size_t&, const cl::size_t&, size_t*, size_t*, const cl::vector*, cl::Event*, cl_int*) const’:
    /usr/include/CL/cl.hpp:5623:48: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL) ? (cl_uint) events->size() : 0,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5624:38: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5624:73: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::CommandQueue::enqueueUnmapMemObject(const cl::Memory&, void*, const cl::vector*, cl::Event*) const’:
    /usr/include/CL/cl.hpp:5645:52: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL) ? (cl_uint) events->size() : 0,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5646:42: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5646:77: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::CommandQueue::enqueueMarkerWithWaitList(const cl::vector*, cl::Event*)’:
    /usr/include/CL/cl.hpp:5676:52: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL) ? (cl_uint) events->size() : 0,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5677:42: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5677:77: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::CommandQueue::enqueueBarrierWithWaitList(const cl::vector*, cl::Event*)’:
    /usr/include/CL/cl.hpp:5706:52: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL) ? (cl_uint) events->size() : 0,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5707:42: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5707:77: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    In file included from /usr/include/stdlib.h:491:0,
    from /usr/lib/gcc/x86_64-redhat-linux/4.8.2/include/mm_malloc.h:27,
    from /usr/lib/gcc/x86_64-redhat-linux/4.8.2/include/xmmintrin.h:38,
    from /usr/include/CL/cl_platform.h:355,
    from /usr/include/CL/cl.h:30,
    from /usr/include/CL/opencl.h:42,
    from /usr/include/CL/cl.hpp:176,
    from compute.cpp:4:
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::CommandQueue::enqueueMigrateMemObjects(const cl::vector&, cl_mem_migration_flags, const cl::vector*, cl::Event*)’:
    /usr/include/CL/cl.hpp:5730:56: error: invalid use of incomplete type ‘const class cl::vector’
    cl_mem* localMemObjects = static_cast(alloca(memObjects.size() * sizeof(cl_mem)));
    ^
    In file included from compute.cpp:4:0:
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5731:44: error: invalid use of incomplete type ‘const class cl::vector’
    for( int i = 0; i size() : 0,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5743:42: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5743:77: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::CommandQueue::enqueueNDRangeKernel(const cl::Kernel&, const cl::NDRange&, const cl::NDRange&, const cl::NDRange&, const cl::vector*, cl::Event*) const’:
    /usr/include/CL/cl.hpp:5769:52: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL) ? (cl_uint) events->size() : 0,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5770:42: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5770:77: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp: In member function ‘cl_int cl::CommandQueue::enqueueTask(const cl::Kernel&, const cl::vector*, cl::Event*) const’:
    /usr/include/CL/cl.hpp:5789:52: error: invalid use of incomplete type ‘const class cl::vector’
    (events != NULL) ? (cl_uint) events->size() : 0,
    ^
    /usr/include/CL/cl.hpp:676:45: error: forward declaration of ‘const class cl::vector’
    class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED vector CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED
    ^
    /usr/include/CL/cl.hpp:5790:42: error: invalid use of incomplete type ‘const cl

    • Lucas says:

      Turns out you should add these to a header file if you are using one. I’m not sure why that is needed.

      • Graham says:

        Could you be a bit more specific about what you mean by ‘add these’? I’m getting the same error.

      • Mateusz says:

        I have the same error. (Ubuntu, AMD SDK)

        • Anon says:

          I’m not entirely sure anymore what i did to fix that error but i think it had to do with the fact that either i used the old hpp bindings file (prior to 1.2) or that the enable vectore define did not work.

  3. Miguel Algaba says:

    Hi Erik, first of all thank you for your very useful posts! I have compiled your OpenCL C++ binding example and it runs perfectly on my NVIDIA GPU. However, when I try to execute the same code in the CPU, the program fails creating the context and launches this error:

    clCreateContextFromType(-1)

    I have only replaced this line:
    Context context( CL_DEVICE_TYPE_GPU, cps);
    by the following:
    Context context( CL_DEVICE_TYPE_CPU, cps);

    Do I need to do something more? My CPU is an Intel core 2 Duo P7350.

    Thanks a lot for your help!

    • Erik Smistad says:

      Hi Miguel

      This error occurs because the NVIDIA OpenCL platform only support NVIDIA GPUs and not CPUs. AMDs OpenCL implementation supports both CPUs and GPUs. You should download intels OpenCL implementation and use that for running OpenCL code on your Intel CPU.

      http://software.intel.com/en-us/vcsource/tools/opencl-sdk

      • Miguel Algaba says:

        Hi Erik,

        Thanks a lot! I didn’t knew about this limitation with NVIDIA OpenCL implementation. Thank you very much again for your very useful posts!

        Best regards,
        Miguel Algaba.

  4. Rialgar says:

    Did you know google still spits out your pages when looking for opencl tutorials? They are really a good start, but I have some questions:

    1. Why don’t you retrieve the lists of devices via Plattform::getDevices?

    2. What exactly does (cl_context_properties)(platforms[0])() do? I figured it somehow creates a cl_context_properties referencing the platform, but I would really like to understand what exactly happens.

    • Erik Smistad says:

      Hi,
      to answer your questions:
      1) You could probably do that, but then you might get some devices that are not valid for the context. For instance if you create a context for GPUs using the AMD platform and you select the CPU using the Plattform::getDevices. By fetching devices from the context object you only get valid devices.

      2) (cl_context_properties)(platforms[0])(): this says that the context should use the first platform (so if you have several platforms, NVIDIA, AMD, Intel… etc., it will select which ever comes first)

      Hope that makes things more clear 😉
      – Erik

  5. James says:

    Figured it out the icd in Bumblebee arent linked properly so one must copy/link the intel and nvidia icd for bumblee with cuda4.1

    sudo echo “libintelocl.so” > /etc/OpenCL/vendors/intelocl64.icd
    sudo ln -s /usr/share/nvidia-current/nvidia.icd /etc/OpenCL/vendors/nvidia.icd

  6. James says:

    Forgot to add that the version without the c plus plus bindings works fully except for the error checking. Great tutorial by the way.

  7. James says:

    Has anyone tried this under an optimus laptop with bumblebee.

    I get it to compile fine but
    when I run using optirun ./host

    I get the following error
    clGetPlatformIDs(-1001)

  8. Richard says:

    Thanks for sharing.
    It helped me getting started with OpenCL.
    I compiled it with cmake.
    If you’re interested:
    https://github.com/ulrichard/ai-class-NLP/tree/master/OpenCL/FirstTry

    As for the driver and cuda stuff: I didn’t have to install anything other than:
    sudo apt-get install nvidia-current-dev

  9. znakes says:

    Thanks, this helps a lot. The C API can be pretty annoying with all the error checks and gazillions of arguments for every function.

    I saw you don’t explicitly release any resources, do they all clean up after themselves in the destructors?

    • Erik Smistad says:

      It seems so. The wrapper class that all the other classes inherit from have the following desctructor defined:

      ~Wrapper()
      {
      if (object_ != NULL) { release(); }
      }

      Where release calls the corresponding release function like clReleaseKernel.

  10. Jesse says:

    I meant it gives the error in Windows under Visual Studio 2010

    • Erik Smistad says:

      Not sure whats wrong. Myabe it could be that it can’t find the OpenCL file. Visual studio often puts the binary file in another folder than the source code, so you might have to copy the kernel source code (the .cl file) to the folder with the binary (probably a folder called bin or something).

  11. Jesse says:

    Sorry I wasnt very detailed. It runs fine on Ubuntu but doesnt seems to give the error in windows with visual studio.

  12. Jesse says:

    I get clcreatekernel(-46) error when I try to run this code I checked the file name and kernel name but still get it

  13. Lior says:

    Hi. It’s great that you input all of this. i am a newbieto opencl, and rusty on my C++ skills.
    I have noticed that you do not inlude

    using namespace std;

    Which gave me a compilation error.
    After that, I am getting that a lot of functions are misreferenced.
    I am using Nvidia’s cpp
    See one of them below:

    sample_program.cpp:(.text._ZN2cl6BufferC2ERKNS_7ContextEmmPvPi[_ZN2cl6BufferC5ERKNS_7ContextEmmPvPi]+0x50): undefined reference to `clCreateBuffer'

    I am using Nvidia’s GE force, and CentOS 5.5
    The line for compilation is:
    gcc -cpp -Wall -I /usr/local/cuda/include/ sample_program.cpp -o sample_program.opencl
    Thanks,
    -Lior

    • Erik Smistad says:

      First of all “using namespace std” is not included by purpose, as it may conflict with the cl namespace. That is why I use std::cout and std::string instead.

      The misreferenced functions are because you have not linked to the OpenCL library. You should add the library flags to your compiling command: -L /path-to-the-lib-folder-with-OpenCL.lib-file/ -l OpenCL
      Note that the last flag is a small L and not a big i.

      • Lior says:

        Hi, I have been away from the project, now came back. I have used g++, everything compiled, but when I try to run the host, I get:

        clBuildProgram(-11)

        I have looked and found nothing.
        I use fedora 15 and GEFORCE 570, i3.

        • Erik Smistad says:

          -11 means CL_BUILD_PROGRAM_FAILURE. You should check the build log for errors like this:
          std::cout < < "Build log:" << std::endl << program.getBuildInfo(devices[0]) << std::endl;

          • kasun says:

            I am try to get build information with program.get
            BuildInfo(devices_gpu[0]); but in visual studio 2013 it says
            no instance of overloaded function Program::getBuildInfo support argument list types are (cl::devices)

            how to fix this. in my code devices_gpu is vector devices_gpu;

            • Erik Smistad says:

              It seems some of the code was removed in the previous comment. It should be like this:
              program.getBuildInfo< CL_PROGRAM_BUILD_LOG >(devices[0])

  14. Hi,
    I have developped an OpenCl small program. I know the user has to have Opencl drivers installed on his machine depending his graphic card. I have two questions :

    1) I would like to developp a method (C++ or C) that will inform if Opencl can be supported in the machine. This information has to be done even when none driver is installed.

    2) As my program asks opencl..dll on startup if not present, I’ve included a default opencl.dll file taken from my nvidia cards driver.
    Is there another solution (other than GetProcAddress(…) ) ?
    Thank you
    Thomas

    • Erik Smistad says:

      Hi

      1) If the machine doesn’t supports OpenCL, Platform::get(&platforms); will return no available platforms. So just check if the size of the platforms vector is 0.

      2) Not completely sure what you mean by this

      – Erik

Leave a Reply

Your email address will not be published.