rethink test_cl_khr_command_buffer command_buffer_wait_for_sec_command_buffer
We should rethink how to test:
rethink test_cl_khr_command_buffer command_buffer_wait_for_sec_command_buffer
The current test has no data dependency between the two command-buffers, so I don't believe the current test is testing what it is intending to test.
If we want to have a command-buffer in one command-queue depend on a command-buffer in a different queue then we probably need a data dependency between the commands in each command-buffer. For example, in the first command-buffer we can copy from buffer A to buffer B, and then the second command buffer can copy from buffer B to buffer C, and we can check the results of buffer C. Or, perhaps the first command-buffer can modify buffer A in place (say, by adding a value to each element of buffer A), and then the second command-buffer can also modify buffer A in place (say, by adding a different value to each element of buffer A), and we can check that both updates have been applied. There are lots of options.
Here was the original PR comment that prompted this issue:
Originally posted by @bashbaug in https://github.com/KhronosGroup/OpenCL-CTS/pull/1840#discussion_r1781917261
I don't think this is necessarily wrong, but I'm having a tough time figuring out what this test is doing now.
As far as I can tell, for setup:
- There are two queues (
queueandqueue_sec), two command buffers (command_bufferandcommand_buffer_sec), two kernels (kernelandkernel_sec), and two sets of buffers used for kernel inputs and outputs (in_mem,out_mem,off_mem,in_mem_sec,out_mem_sec, andoff_mem_sec).- Note:
queue_secis exclusively in-order.queuemay be out-of-order.
- Note:
in_mem,out_mem, andoff_memare set as kernel arguments forkerneland recorded intocommand_buffer.in_mem_sec,out_mem_sec, andoff_mem_secare set as kernel arguments forkernel_secand recorded intocommand_buffer_sec.command_bufferrecordskernel, andcommand_buffer_secrecordskernel_sec.
Then, when the test executes:
- In
queue_sec, we initializein_mem_sec, then enqueuecommand_buffer_sec. We save the event forcommand_buffer_sec.- Remember:
command_buffer_secrecordedkernel_sec, which readsin_mem_secand writesout_mem_sec.
- Remember:
- In
queue, we initializein_mem, then enqueuecommand_buffer, with an event dependency on the initialization and the execution ofcommand_buffer_secinqueue_sec. We save the event forcommand_buffer.- Remember:
command_bufferrecordedkernel, which readsin_memand writesout_mem.
- Remember:
To verify the test output:
- We enqueue a read from
out_memwith an event dependency on the execution ofcommand_buffer. - We flush
queue, then finishqueue_sec, then finishqueue. - We check the results that we read.
This is all nominally fine, but we never check the results of out_mem_sec or anything that executes in command_buffer_sec, really. Is that what is intended?
Another possible solution that wouldn't require a second kernel and a second set of memory objects is to have the initialization of in_mem in step (6) depend on the execution of the command buffer in step (5). This ensures that in_mem will not be overwritten while the command buffer is executing. I'm not sure if that's any better, though...