How to convert single-GPU code to double-GPU ?


I am very new to CUDA programming. I have an opensource code, DualSPHysics, which can run only on single-GPU. DualSPHysics is written in C++ and the CPU version can run only on single-node (OpenMP) and the GPU version only on single-GPU (CUDA). But, the node I use for computing has two GPU cards (K20’s).

I want to convert this DualSPHysics code to run on the two GPU’s. Please enlighten me on what should I do to make this happen.

Thank you very much,

Best regards,


You can run 1 program with 2 cards, by using cudasetdevice and manually divide the work between the gpus using streams.


Hi Cristian,

Thank you very much for your reply.

Can you please point me to some online material which explains with examples how I can “manually divide the work between the gpus using streams” ?

Best Regards,


I would suggest to read the book CUDA by Example

There are also good articles about streams on the nvidia Parallel for all blog.

The basic ideea is to divide the work in 2 equal parts (if the cards are identical) have them perform the calcuations, then collect the data. The biggest problem is the communication between the cards.

Maybe this will help: