OpenCL Kernel wait/delay

萝らか妹 提交于 2019-12-24 22:26:36

问题


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.


回答1:


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.




回答2:


Not typically. If you stall too long in a GPU kernel the driver TDRs and crashes. In general kernels aren't intended to sleep. See this question and this question.

Also, if you do want to induce a loop you'll have to be careful to make the code actually do something the compiler can't optimize away (write to a buffer).



来源:https://stackoverflow.com/questions/24297761/opencl-kernel-wait-delay

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!