可以在同一个GPU上有效地共享渲染作业和数字运算作业(OpenCL上的f.ex.)吗?例如,使用GPU同时进行数字运算和并行渲染
- 线程A上运行的OpenCL任务,以生成图像
- 然后,当图像是准备好了,线程A通知另一个线程B(图像准备好),并继续新图像计算
- 线程B开始给定的图像上的一些显示前的活动(如使用GDI叠加计算),结合了最终的图像,并使其显示
能这样的GPU资源和分享以获得性能的提高,或者相反,将导致计算和渲染任务整体放缓?
谢谢
可以在同一个GPU上有效地共享渲染作业和数字运算作业(OpenCL上的f.ex.)吗?例如,使用GPU同时进行数字运算和并行渲染
能这样的GPU资源和分享以获得性能的提高,或者相反,将导致计算和渲染任务整体放缓?
谢谢
这里涉及很多因素,但一般来说,你不应该看到放缓。
直接回答你的问题的问题:
大多数情况下,您可以通过试用或至少对不同部件进行基准测试来获得最佳答案。毕竟,如果您的计算过于简单或者图像渲染部分太简单,您将不会获得太多好处。
此外,你可能会尝试更进一步,并使用着色器或类似的渲染结果 - 在这种情况下,你可以防止必须将数据从gpu内存移回主内存,根据你的情况,给你提速。
如果数据/运算比大,如果你还需要从CPU的数据发送到GPU:
紧缩--->紧缩---->渲染
GPU th0 : crunch for (t-1) crunch for (t) rendering
CPU th1 : send data for t send data for t+1 send data for t+2
CPU th2 : get data of t-2 get data of t-1 get data of t
CPU th3-th7 : Other things independent of crunching or rendering.
At the same time: crunching&comm. crunching&comm. rendering&communication
and other things and other things and other things
如果数据/捣鼓比大,此外,如果你没有从CPU发送数据到GPU:
use interoperatability of CL (example: cl-gl interop)
如果数据/运算比小
should not see any slowdown.
中的数据/运算比:紧缩 - >渲染 - >紧缩--->渲染
GPU th0 : crunch for (t) rendering crunch for (t+1) render again! and continue cycling like this
CPU th1 : get data of (t-1) send data for t+1 get data of (t)
CPU th2-th7 : Other things independent of crunching or rendering.
At the same time: crunching&getting. rendering&sending. crunching&getting
and other things and other things and other things
如果我得到你的权利,1)对于非重或计算简单,运行GPU-在一个线程中进行基于计算的计算并在另一个线程中进行渲染 - 不应该看到任何放缓,2)对于GPU计算繁重 - 最好使用相同的线程进行计算和渲染。正确? – user2156173
不,渲染和计算都在同一个线程中:thread-0 :)所以没有在它们之间等待。但是需要在线程0和其他线程之间进行同步。对于繁重的版本,只改变运算/渲染的比率,并且吸气/发送器处于不同的线程中。 –