Reputation: 12175
I am unsure if this is necessary. I have two kernels which I need to launch in serial. Do I need to create an event for the first one and then have the second kernel launch wait for that event or can I assume that everything is the queue executes in the order in which I placed it? Is my use of cl_event in the code bellow nessary?
cl_event acceleration_finished;
cl_check(clEnqueueNDRangeKernel(cmdq, acceleration_kernel, 1, NULL, &acceleration_blocks,
&acceleration_threads, 0, NULL, &acceleration_finished));
cl_event stepper_finished;
cl_check(clEnqueueNDRangeKernel(cmdq, stepper_kernel, 1, NULL, &N,
NULL, 1, &acceleration_finished, &stepper_finished));
cl_double3* positions_mapped = clEnqueueMapBuffer(cmdq, positions, CL_TRUE, CL_MAP_READ, 0,
sizeof(cl_double3) * N, 1, &stepper_finished, NULL, &error);
cl_check(error);
Upvotes: 2
Views: 587
Reputation: 8410
For your case, you can just assume full in-order execution (if you did not manually enabled out-of-order).
There a re 2 types of queues in OpenCL:
In-order (default):
Out-of-order (created with the flag CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE
):
Tasks execute as soon as they are ready to be consumed (all the events they depend on are CL_COMPLETED
).
This does not mean that N tasks can run in parallel in a single queue if they do not depend on each other. Some hardware does not support that behavior, and requires to create a separate queue to allow parallel execution of tasks. Some other hardware will only support 1 task at a time. That is implementation dependent.
https://www.khronos.org/registry/cl/sdk/1.0/docs/man/xhtml/clCreateCommandQueue.html
Upvotes: 3