OpenCL User Events / Cant Release Objects?-Collection of common programming errors
Consider the example that they give.
We have an in-order queue and we create a user event:
ev1 = clCreateUserEvent(ctx, NULL); // (1)
We then want to enqueue a write to a buffer, but we want it to wait for our event:
clEnqueueWriteBuffer(cq, buf1, CL_FALSE, ..., 1, &ev1, NULL); // (2)
We want to write another buffer after the buffer in the previous one (which is waiting on our event):
clEnqueueWriteBuffer(cq, buf2, CL_FALSE,...); // (3)
We release the buffer from the second clEnqueueWriteBuffer
which hasn’t gone through yet because we are still waiting for the user event. In this case (4) happens before (3), so we don’t know what will happen as the memory object is freed.
clReleaseMemObject(buf2); //