Forum Discussion
hiratz
Occasional Contributor
6 years agoThanks, HRZ.
I just tested this with emulator (with the option "-emulator-channel-depth-model=strict"). My host code is very simple and no kernels are waiting for any events. I show the key code as follows (you can see I put Producer and Consumer into two different command queues, respectively). It is really weird.
#define MAX_CMD_QUEUES 4
#define N_KERNEL 2
void run_kernel(cl_command_queue cmd_queue[MAX_CMD_QUEUES], cl_kernel (&kernel)[N_KERNEL], size_t n_thread)
{
size_t global_work_size[1] = {(size_t)n_thread};
size_t local_work_size[1] = {(size_t)n_thread};
cl_event event_write[1], event_exec[2];
cl_int status;
cl_command_queue &rcmd_queue0 = cmd_queue[0], &rcmd_queue1 = cmd_queue[1], &rcmd_queue2 = cmd_queue[2];
// Write data into buf_in from h_in
status = clEnqueueWriteBuffer(rcmd_queue0, buf_in, CL_TRUE, 0, bufsize, h_in, 0, NULL, event_write);
error_check(status, "Write buf_in failed!\n");
// Launch the kernel Producer
status = clEnqueueNDRangeKernel(rcmd_queue0, kernel[0], 1, NULL, global_work_size, local_work_size, 1, event_write, NULL);
error_check(status, "Run kernel Producer error!\n");
// Launch the kernel Consumer
status = clEnqueueNDRangeKernel(rcmd_queue1, kernel[1], 1, NULL, global_work_size, local_work_size, 0, NULL, NULL);
error_check(status, "Run kernel Consumer error!\n");
// Read results back to h_out from buf_out
read_back_results(rcmd_queue1, bufsize, buf_out, (char*)h_out, NULL);
clReleaseEvent(event_write[0]);
clReleaseEvent(event_exec[0]);
clReleaseEvent(event_exec[1]);
}
HRZ
Frequent Contributor
6 years agoHave you tried commenting the error_check functions? Depending on its implementation, that function could be serializing the kernel launches. If you provide the full code for your example so that I can compile it on my own machine, I might be able to find the source of the problem.