Ask Your Question
0

Passsing size of a parameter to the kernel

asked 2013-09-16 18:15:01 -0500

mainul gravatar image

Hi,

I have a kernel that has a local variable __local int* sbuff as parameter. I want to set its size dynamically. In normal opencl we can do that using setkernelArg function. But in OpenCV they provides a wrapper to execute kernel and passing parameter. For example, we use openCLExecuteKernel to execute kernel and args.push_back to pass parameter.

My question is how I can pass the size of the local variable to the kernel using OpenCV's functions?

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2013-09-26 04:59:17 -0500

decision gravatar image

updated 2013-09-26 05:01:51 -0500

Use something like

size_t local_centroids_size = CENTROIDS.rows * CENTROIDS.cols * sizeof(float);
...
args.push_back( make_pair( (size_t)local_centroids_size, (void *)NULL ) );
...
OpenCLExecutreKernel( ..., args, ..);

You will want to adapt it, esp. change the number of bytes to a sizeof(int) factor. Basically, that's the same syntax as with use of setKernelArg.

HTH!

edit flag offensive delete link more

Comments

I did it in different way. I changed the kernel string before execution. And inside kernel I used a macro for size.

mainul gravatar imagemainul ( 2013-10-30 09:45:29 -0500 )edit
Login/Signup to Answer

Question Tools

Stats

Asked: 2013-09-16 18:15:01 -0500

Seen: 99 times

Last updated: Sep 26 '13