Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What should I use instead of cl::KernelFunctor?

Tags:

c++

opencl

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);
like image 373
Theodoros Chatzigiannakis Avatar asked Jun 02 '14 10:06

Theodoros Chatzigiannakis


2 Answers

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();
like image 163
VojtaK Avatar answered Sep 19 '22 15:09

VojtaK


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();
like image 36
Michael Dorner Avatar answered Sep 20 '22 15:09

Michael Dorner