2013-10-01 54 views
0

可以在同一個GPU上有效地共享渲染作業和數字運算作業(OpenCL上的f.ex.)嗎?例如,使用GPU同時進行數字運算和並行渲染

  1. 線程A上運行的OpenCL任務,以生成圖像
  2. 然後,當圖像是準備好了,線程A通知另一個線程B(圖像準備好),並繼續新圖像計算
  3. 線程B開始給定的圖像上的一些顯示前的活動(如使用GDI疊加計算),結合了最終的圖像,並使其顯示

能這樣的GPU資源和分享以獲得性能的提高,或者相反,將導致計算和渲染任務整體放緩?

謝謝

回答

0

這裏涉及很多因素,但一般來說,你不應該看到放緩。

直接回答你的問題的問題:

  • 的OpenCL可以用你的CPU爲好,這取決於你如何設置它
  • 你GFX東西可以主要做了CPU或的不同部分GPU,取決於你顯示的內容;例如,許多GDI實現使用CPU進行渲染,並且只在GPU上使用非常簡單的2D加速技術,主要是爲了最終合成圖像。
  • 它可能取決於您使用的GPU,GPU驅動程序,圖形堆棧等。

大多數情況下,您可以通過試用或至少對不同部件進行基準測試來獲得最佳答案。畢竟,如果您的計算過於簡單或者圖像渲染部分太簡單,您將不會獲得太多好處。

此外,你可能會嘗試更進一步,並使用着色器或類似的渲染結果 - 在這種情況下,你可以防止必須將數據從gpu內存移回主內存,根據你的情況,給你提速。

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 
+0

如果我得到你的權利,1)對於非重或計算簡單,運行GPU-在一個線程中進行基於計算的計算並在另一個線程中進行渲染 - 不應該看到任何放緩,2)對於GPU計算繁重 - 最好使用相同的線程進行計算和渲染。正確? – user2156173

+0

不,渲染和計算都在同一個線程中:thread-0 :)所以沒有在它們之間等待。但是需要在線程0和其他線程之間進行同步。對於繁重的版本,只改變運算/渲染的比率,並且吸氣/發送器處於不同的線程中。 –