MPI + CUDAFortran and module dependencies?

Hello, I actually have two seperate questions.
First I was wondering how well CUDA played with MPI based code. I have some solver code for particle fields and much of it is written using MPI but the actual calculations for said particles are to be ported to CUDAfortran, so I was wondering more specifically how these two things acutally work together (or don;t work together).

The second question is, if I have a module that contains a subroutine that is to be run on the GPU and it depends on constants and definitions defined in another file, is that acceptable or does everything the GPU will be using need to be put in one mondo module file? If more specifics would be useful I can add some snippets.

Thanks for your help.

Hi Cattaneo,

First I was wondering how well CUDA played with MPI based code

They work well together and is my preferred way for multi-gpu programming. There are quite a few blog posts on it (just do a web search for “CUDA MPI”). Granted most are written using CUDA C or OpenACC, but the same methods would apply to CUDA Fortran.

Plus most MPI implementations are “CUDA Aware”, meaning you can pass device data to MPI calls so the data is transferred directly from device to device and by-pass the host.

While a bit old, Jiri has a nice post at https://devblogs.nvidia.com/introduction-cuda-aware-mpi/ which explains CUDA Aware MPI

The second question is, if I have a module that contains a subroutine that is to be run on the GPU and it depends on constants and definitions defined in another file, is that acceptable or does everything the GPU will be using need to be put in one mondo module file?

Device module variables can be accessed in external files. You just need to compile and link with relocatable device code (RDC) enabled, which is the default. (i.e. it will just work unless you add the flag -Mcuda=nordc).

-Mat