Once an event_wait_list pointer is passed to a clEnqueue* function (and the function returns CL_SUCCESS) can the cl_event objects pointed to by event_wait_list be re-assigned to new events, or should none of them be touched until all commands enqueued with that wait list have finished?
For example, say I wanted to enqueue pairs of kernels in a loop (kernel B depends kernel A):
cl_command_queue queue;
size_t gws, lws;
cl_kernel kernel_A, kernel_B;
...
cl_event e;
for(int i = 0; i < N; ++i) {
clEnqueueNDRangeKernel(queue, kernel_A, 1, NULL, &gws, &lws, 0, NULL, &e);
clEnqueueNDRangeKernel(queue, kernel_B, 1, NULL, &gws, &lws, 1, &e, NULL);
clReleaseEvent(e);
}
Is this code safe? Or will re-using the cl_event handle corrupt the existing wait lists?