Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
7 years ago

Two kernels on the same Device

Hi again!

I want to have two kernels that one starts over the other (not parallel/concurrent). This restriction is imposed because kernel1 and kernel will share the same buffer.

So, kernel1 starts do its operations and update the buffer, then instead of coming back to the host, i want to send a flag from kernel1 to the kernel2 by a channel saying that kernel1 finished and kernel2 must start. Do i have to got two command queues for each kernel?

Thanks in advance

2 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    If the two kernels are not going to overlap, then there is no need to do this. Just enqueue both kernels in the same queue one after the other, and the second kernel will automatically launch after the first one finishes execution in which case the shared buffer will have been fully updated by the time the second kernel starts.

    Note that global memory consistency in OpenCL is only guaranteed *after* kernel execution; trying to synchronize global memory between two kernels using messages sent via channels will *not* work (I tried it once, got incorrect results).
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    If the two kernels are not going to overlap, then there is no need to do this. Just enqueue both kernels in the same queue one after the other, and the second kernel will automatically launch after the first one finishes execution in which case the shared buffer will have been fully updated by the time the second kernel starts.

    Note that global memory consistency in OpenCL is only guaranteed *after* kernel execution; trying to synchronize global memory between two kernels using messages sent via channels will *not* work (I tried it once, got incorrect results).

    --- Quote End ---

    Thanks HRZ, case solved :cool: