user1235183
user1235183

Reputation: 3072

OpenCL: Returning std::future instead of blocking with clFinish

I'm new to OpenCL but there is a thing that annoys me, at the moment i end every OpenCL function with clFlush which is according to the standard blocking. Is there a way to asynchronize things with returning a std::future or to write a hand-written my::craft::future, allowing to wait only if necessary?

Upvotes: 1

Views: 105

Answers (1)

Erik Smistad
Erik Smistad

Reputation: 1019

clFlush doesn't block, clFinish does. "clFlush only guarantees that all queued commands to command_queue will eventually be submitted to the appropriate device There is no guarantee that they will be complete after clFlush returns. " https://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clFlush.html

You can use clSetEventCallback to call a function when something has finished. https://www.khronos.org/registry/cl/sdk/1.2/docs/man/xhtml/clSetEventCallback.html

Upvotes: 1

Related Questions