Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

using kernel result in another kernel in OpenCL

Tags:

kernel

opencl

I have written a code for the Convolution of image using API's clCreateImage2D for creating space,clEnqueueWriteImage to write to the device and read_imageui for reading the image in a kernel and write_imageui for writing the image back to the host.

Now i want to use the result of the convolution kernel which is pointing to a buffer in another kernel argument.Without moving the result back to host and forth to the device.Is this possible.

If the result is moved back and forth...i think it will be expensive.

Any help in this regards will be invaluable.

like image 415
SharathNaidu Avatar asked Nov 13 '12 15:11

SharathNaidu


People also ask

What's new in OpenCL 2?

OpenCL 2.0 spec added a new feature for dynamic paralelism. 6.13.17 Enqueuing Kernels OpenCL 2.0 allows a kernel to independently enqueue to the same device, without host interaction. ...

Is it possible to pass the inner pass to the host kernel?

I don't think that is possible from within the kernel, so you'd have to create the code for the "inner" pass as a separate kernel and also call that kernel separately from your host code. The output from that kernel doesn't have to be read back to the host memory, but can stay in device memory between your kernel calls.

How to parallelize kernel and helper functions?

You can call helper functions from your kernel and they will be parallelized in the same manner as the kernel, imagine them as inlined inside your kernel code. So, each work item will invoke the helper function for the working set it handles. Show activity on this post.


1 Answers

From the Host's point of view, you should be able to take the buffer object, and just pass it as an argument to another kernel. After that you just treat it like any other buffer. The only trick is making sure that when you create the buffer, it has sufficient read-write permissions that it can be both output and input to your kernels.

like image 69
Zistack Avatar answered Oct 01 '22 22:10

Zistack