OpenCL内核等待/延迟 [英] OpenCL Kernel wait/delay

查看:248
本文介绍了OpenCL内核等待/延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是OpenCL的新手.如何在不进行循环的情况下延迟OpenCL内核脚本?我的代码在某些情况下需要等待一段时间,然后再像这样恢复执行

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? }
}

但是我想这个循环会让gpu像地狱一样忙碌,在内核CL中有什么我可以使用的,例如sleep吗?我在sdk文档中查找,但还没有找到任何东西.请帮助.

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.

推荐答案

OpenCL规范旨在处理数据.不用于等待/睡眠.即使您可以实现它,您也将违反许多OpenCL的良好设计规则.

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.

实际上,如果您尝试使它们休眠,许多GPU将会崩溃或终止执行.

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.

这篇关于OpenCL内核等待/延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆