lil' wing
lil' wing

Reputation: 159

Which command_queue to pass to clEnqueueCopyBuffer when launching kernels simultaneously?

So I am implementing a Kmeans clustering algorithm with OpenCL that uses channels: a feature from Intel's FPGA SDK for OpenCL. To keep it succinct, this means I have two kernels that have to be enqueued on different command queues so they run simultaneously. I want to copy the cl_mem buffer from one kernel to the other every iteration (it's for the 4 clusters, so on the small side), part of which requires me to call clEnqueueCopyBuffer. This requires passing the function a command queue, but I don't know if it wants the queue of the buffer being copied or the queue of the buffer being copied to.

This is all the OpenCL Specification says for the command_queue parameter:

The command-queue in which the copy command will be queued. The OpenCL context associated with command_queue, src_buffer, and dst_buffer must be the same.

I can confirm these kernels are in fact in the same context.

Upvotes: 1

Views: 140

Answers (1)

Dithermaster
Dithermaster

Reputation: 6343

You could use either command queue but you need to get an event from the copy operation to pass to the other kernel enqueue on the other command queue. Otherwise it might start before the copy finishes.

Upvotes: 2

Related Questions