Reputation: 953
To wait for kernel termination on the host side I can do this:
error = clEnqueueNDRangeKernel(..., &event);
CHECK_ERROR(error);
clWaitForEvents(1, &event);
But is there a way to precise some maximal time of waiting? That is, if my kernel is not finished after, let's say, 10 seconds I'd like to continue, but if it takes only one second of execution I don't want to wait for the 9 remaining seconds.
Upvotes: 0
Views: 449
Reputation: 8410
There is no way to wait only for a given amount of time, however you can:
clGetEventInfo()
and a loop.clSetEventCallback()
to define a function that will be called when the event completes. Sleep the current thread for 10 seconds, and make the event callback wake the thread if it finishes quicker than 10 seconds.Upvotes: 1