Reputation: 95
In my last question, OpenCl cleanup causes segfault. , somebody hinted that missing event handling, i.e. not waiting for code to finish, could cause the seg faults. Since then I looked again into the tutorials I used, but they don't pay attention to events (Matrix Multiplication 1 (OpenCL) and NVIDIA_OpenCL_GettingStartedLinux.pdf
) or talk about it in detail and (for me) understandable.
Do you know a tutorial on where and how to wait
in OpenCL?
Merci!
Upvotes: 3
Views: 2844
Reputation: 5924
I don't have a tutorial on events in OpenCL, and I'm by no means an expert, but since no one else is responding...
As a rule of thumb, you'll need to wait for any function named clEnqueue*
. Those functions return immediately before the job is done. The easiest way to make sure your queue is finished is to call clFinish()
. It won't return until the entire queue has completed.
If you want to get a little fancier, most of the clEnqueue*
functions have an optional cl_event
parameter that you can pass in. You can check on a particular event with clGetEventInfo()
, and you can wait for a particular set of events to finish with clWaitForEvents()
.
Upvotes: 6