0

渲染作业和数字运算作业(例如 OpenCL 上的 f.ex.)能否在同一个 GPU 上有效共享?例如,

  1. 线程 A 运行 OpenCL 任务以生成图像
  2. 然后,当图像准备好时,线程A通知另一个线程B(图像准备好)并继续进行新的图像计算
  3. 线程 B 在给定图像上启动一些预显示活动(如使用 GDI 进行叠加计算),组合最终图像并将其渲染以显示

这种 GPU 资源共享能否提高性能,或者相反,会导致计算和渲染任务的整体速度变慢?

谢谢

4

2 回答 2

0

如果数据/运算比率很大,并且您必须将数据从 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
于 2013-10-01T14:49:15.373 回答
0

这里涉及到许多因素,但一般来说,你不应该看到放缓。

直接回答您的问题的问题:

  • OpenCL 也可能正在使用您的 CPU,具体取决于您的设置方式
  • 您的 gfx 内容可以主要在 CPU 或 GPU 的不同部分完成,具体取决于您显示的内容;例如,许多 GDI 实现使用 CPU 进行渲染,并且只在 GPU 上使用非常简单的 2D 加速技术,主要用于对最终合成的图像进行 blit。
  • 它可能取决于您使用的 GPU、GPU 驱动程序、图形堆栈等。

在大多数情况下,您将通过尝试或至少对不同部分进行基准测试来获得最佳答案。毕竟,如果您的计算太简单或图像渲染部分太简单,您将不会真正获得太多好处。

此外,您可能会尝试更进一步并使用着色器等渲染结果 - 在这种情况下,您可以避免将数据从 gpu 内存移回主内存,这可能 - 根据您的情况 - 也可以为您提供速度促进。

于 2013-10-01T14:27:31.517 回答