Search code examples
copencldelaywaitdata-synchronization

OpenCL Kernel wait/delay


I'am new to the OpenCL. How can i make a delay in OpenCL Kernel script without making loops? I have a code that's in some circumstances needs to wait for some time and then resume execution like so

__kernel void test(uint4 value,uint4 delay)
{
    uint id = get_global_id(0);

       //some code
       for(uint i=0;i<delay;i++) { //... do nothing like this? }
}

But i suppose that the loop will make gpu busy as hell, is there something i can use like sleep maybe in the kernel CL? I looked up in the sdk documentation, but haven't found anything yet. Help please.


Solution

  • The OpenCL spec is designed for data crunching. Not for wait/sleeps. Even if you may achieve it, you will be breaking a lot of the good design rules of OpenCL.

    In fact, many GPUs will crash or kill the execution if you try to sleep them.

    Please reconsider what you need, and if it is suitable for parallel computing.