Hello,
I am new to OpenCL and I’ve been trying to compile the following piece of code, but with no success
#define __CL_ENABLE_EXCEPTIONS
#define __NO_STD_VECTOR
#define __NO_STD_STRING
#include <CL/cl.hpp>
#include <cstdio>
#include <cstdlib>
#include <iostream>
const char * helloStr = "__kernel void hello(void) { }
";
int main(void) {
try {
cl::Context context(CL_DEVICE_TYPE_GPU, 0, NULL, NULL, &err);
cl::vector<cl::Device> devices = context.getInfo<CL_CONTEXT_DEVICES>();
cl::CommandQueue queue(context, devices[0], 0, &err);
cl::Program::Sources source(1, std::make_pair(helloStr,strlen(helloStr)));
cl::Program program_ = cl::Program(context, source);
program_.build(devices);
cl::Kernel kernel(program_, "hello", &err);
cl::KernelFunctor func = kernel.bind(queue, cl::NDRange(4, 4), cl::NDRange(2, 2));
func().wait();
} catch (cl::Error err) {
std::cerr << "ERROR: " << err.what() << "(" << err.err() << ")" << std::endl;
}
return EXIT_SUCCESS;
}
I’ve got the following errors:
/usr/include/CL/cl.hpp:3367: error: ‘pair’ is not a member of ‘cl::std’
/usr/include/CL/cl.hpp:3367: error: ‘pair’ is not a member of ‘cl::std’
/usr/include/CL/cl.hpp:3367: error: template argument 1 is invalid
/usr/include/CL/cl.hpp:3367: error: expected unqualified-id before ‘>’ token
/usr/include/CL/cl.hpp:3368: error: ‘pair’ is not a member of ‘cl::std’
/usr/include/CL/cl.hpp:3368: error: ‘pair’ is not a member of ‘cl::std’
/usr/include/CL/cl.hpp:3368: error: template argument 1 is invalid
/usr/include/CL/cl.hpp:3368: error: expected unqualified-id before ‘>’ token
/usr/include/CL/cl.hpp:3393: error: expected ‘,’ or ‘...’ before ‘&’ token
/usr/include/CL/cl.hpp:3473: error: expected ‘,’ or ‘...’ before ‘&’ token
/usr/include/CL/cl.hpp: In constructor ‘cl::Program::Program(const cl::Context&, int)’:
/usr/include/CL/cl.hpp:3398: error: ‘sources’ was not declared in this scope
/usr/include/CL/cl.hpp:3411: error: ‘err’ was not declared in this scope
/usr/include/CL/cl.hpp: In constructor ‘cl::Program::Program(const cl::Context&, const cl::vector<cl::Device, 10u>&, int)’:
/usr/include/CL/cl.hpp:3478: error: ‘binaries’ was not declared in this scope
/usr/include/CL/cl.hpp:3490: error: ‘binaryStatus’ was not declared in this scope
/usr/include/CL/cl.hpp:3495: error: ‘err’ was not declared in this scope
/usr/include/CL/cl.hpp: At global scope:
/usr/include/CL/cl.hpp:5041: error: ‘cl::std::pair’ has not been declared
/usr/include/CL/cl.hpp:5041: error: expected ‘,’ or ‘...’ before ‘<’ token
/usr/include/CL/cl.hpp: In member function ‘cl_int cl::CommandQueue::enqueueNativeKernel(void (*)(void*), int) const’:
/usr/include/CL/cl.hpp:5049: error: ‘args’ was not declared in this scope
/usr/include/CL/cl.hpp:5050: error: ‘mem_objects’ was not declared in this scope
/usr/include/CL/cl.hpp:5052: error: ‘mem_locs’ was not declared in this scope
/usr/include/CL/cl.hpp:5053: error: ‘events’ was not declared in this scope
/usr/include/CL/cl.hpp:5055: error: ‘event’ was not declared in this scope
My OS is Ubuntu 9.04, the compiler is gcc 4.3.3 and I’ve got the latest OpenCL headers installed.
Any help is appreciated. Thanks in advance