多个OpenCl内核 [英] Multiple OpenCl Kernels

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

问题描述

我只是想问一下,是否有人可以互相介绍使用几个简单内核时要注意什么.

I just wanted to ask, if somebody can give me a heads up on what to pay attention to when using several simple kernels after each other.

我可以使用相同的CommandQueue吗?我可以在另一个cl_program上多次运行clCreateProgramWithSource + cl_program吗?我忘记了什么?

Can I use the same CommandQueue? Can I just run several times clCreateProgramWithSource + cl_program with a different cl_program? What did I forget?

谢谢!

推荐答案

您可以创建并编译多个程序(并从中创建内核对象),也可以将所有内核放入同一程序中(clCreateProgramWithSource需要几个毕竟是字符串),然后从该内核创建所有内核.使用相同的CommandQueue都可以正常工作.无论如何,使用一个以上的CommandQueue执行应该在同一设备上串行执行的内核并不是一个好主意,因为在这种情况下,您必须手动等待事件完成,而不是异步将所有内核排队,然后等待结果(在至少某些操作应该在设备和主机上并行执行,因此在最后可能的时刻等待通常更快,更容易.

You can either create and compile several programs (and create kernel objects from those), or you can put all kernels into the same program (clCreateProgramWithSource takes several strings after all) and create all your kernels from that one. Either should work fine using the same CommandQueue . Using more then one CommandQueue to execute kernels which should execute serially on the same device is not a good idea anyways, because in that case you have to manually wait for the event completion instead of asynchronously enqueuing all kernels and then waiting on the result (at least some operations should execute in parallel on device and host, so waiting at the last possible moment is generally faster and easier).

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

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