Reputation: 79
I've started learning heterogeneous parallel programming using CUDA (desktop will be used, in the case it matters), and have a question for which I couldn't find the answer yet. Can the gpu card be used for gpgpu while playing 3D game? If yes, how big a performance costs would be? And how to measure them? Running my app with and without game in the background doesn't seem like a trustworthy solution.
AFAIK, gpu card is busy in rendering scenes and other stuff, but I don't know how exactly it works. Is the device locked by the game application from being used for gpgpu until user exits the game? Or it just receive asynchronous calls to do tasks like so:
As the other solution: is it possible to use separate gpu card for this purpose only (maybe I need to prevent it from being used by game app)?
Upvotes: 1
Views: 658
Reputation: 151799
Can the gpu card be used for gpgpu while playing 3D game?
Yes. (Try it.)
If yes, how big a performance costs would be?
This can't really be answered without a lot of specifics, like how memory and compute-intensive the cuda app is, what kind of GPU, what game, etc.
And how to measure them?
It shouldn't be difficult to measure any general impacts. Memory size can be monitored with a tool like GPU-Z or nvidia-smi. You can monitor the framerate in your game, perhaps, to assess performance impact there. And you can benchmark your compute app with and without the game running.
Is the device locked by the game application from being used for gpgpu until user exits the game?
No, but the GPU must context-switch between game tasks and compute tasks. So, for example, your game will stop running while CUDA kernels are being executed. Due to this, if you wanted to run a game simultaneously with a compute app, you should be sure to keep your compute kernels very short in duration. In between kernel calls, the game engine will "catch up".
Upvotes: 3