Papaya
Papaya

Reputation: 332

How to dedicate DirectX to a GPU and dedicate CUDA to another GPU?

In my application, the GUI thread uses Direct2D to display images, allowing the user to pan and zoom, while another thread uses CUDA to do image processing. To prevent the image processing thread to be disturbed by the GUI thread and to speed things up, choice was made to add a separate graphic card for the CUDA computing, with the following setup:

However, this did not work as expected, as when the user pans an image, thus causing several updates of the display in a row, the CUDA execution time jumps from typical 20ms to some 800ms. Using GPUView (which I discovered investigating this issue and don't master at all), I was able to see that the CUDA thread seems to be waiting for the display to finish updating before queuing its commands to the GPU. In the mean time, Direct2D leaves the GPU unused most of the time (1ms of work for a 16ms VSync period). It looks like my calls to Direct2D are blocking all GPU's for 16ms and then the GUI thread lets the CUDA thread starve (although these threads are not synchronized in any way other than the GPU accesses).

So the questions are:

Upvotes: 0

Views: 967

Answers (1)

kalbr
kalbr

Reputation: 182

If you use the ID2D1DeviceContext render target instead of ID2D1HWndRenderTarget, during it's initialization, you pick what adapter you want to use for Direct3D.

http://msdn.microsoft.com/en-us/library/windows/desktop/hh780339(v=vs.85).aspx

See the docs for D3D11CreateDevice or D3D11CreateDeviceAndSwapChain. The first parameter specifies which adapter to use. http://msdn.microsoft.com/en-us/library/windows/desktop/ff476082(v=vs.85).aspx

Upvotes: 1

Related Questions