I'm following some tutorials on OpenCL and they mention a type called cl::KernelFunctor
. However, that type isn't found and when I looked at the headers of the AMD APP SDK, I saw that the declaration of the cl::KernelFunctor
class is commented out.
What am I supposed to use in place of this code to run a kernel?
//run the kernel
cl::KernelFunctor simple_add(cl::Kernel(program, "simple_add"), queue, cl::NullRange, cl::NDRange(10), cl::NullRange);
simple_add(buffer_A, buffer_B, buffer_C);
You are probably following this tutorial just as I do. I figured out based on this, that files CL/cl.hpp for OpenCL 1.1 and CL/cl.hpp for OpenCL 1.2 differ in that cl::KernelFunctor is removed in the later.
The solution is to use the function cl::make_kernel that takes as template arguments types of your functor. In that particular case the template parameter is thus cl::Buffer. The code that compiles for me using OpenCL 1.2 header is:
cl::make_kernel<cl::Buffer, cl::Buffer, cl::Buffer> simple_add(cl::Kernel(program, "simple_add"));
cl::EnqueueArgs eargs(queue, cl::NullRange, cl::NDRange(10), cl::NullRange);
simple_add(eargs, buffer_A, buffer_B, buffer_C).wait();
cl::Kernel simple_add(program, "simple_add");
simple_add.setArg(0, buffer_A);
simple_add.setArg(1, buffer_B);
simple_add.setArg(2, buffer_C);
queue.enqueueNDRangeKernel(simple_add,cl::NullRange,cl::NDRange(10),cl::NullRange);
queue.finish();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With