What should I use instead of cl::KernelFunctor?
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();
As @Michael Dorner said, you can replace the code by a step by step approach. Create the kernel, set the args, and then queue it.
The KernelFunctor is to funct-ify the kernel code so you can call it as a function. Since usually that is not the case, is rarely used in real applications, but it may be useful for some cases.
With this code you are saying:
cl::KernelFunctor simple_add(cl::Kernel(program, "simple_add"), queue, cl::NullRange, cl::NDRange(10), cl::NullRange);
- Create a functor of kernel "simple_add".
- Launching in the queue "queue"
- With these NDRanges.
Then when you call the functor you pass the only remaining things, the arguments:
simple_add(buffer_A, buffer_B, buffer_C);
The good thing is that you can later on launch it with different arguments in an easy way, by just:
simple_add(buffer_B, buffer_C, buffer_D);
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();