Improving Performance with MPI in Fortran90

In summary, using MPI_BCAST and un-blocked sends may be faster than using MPI_SEND to send each task one by one.
  • #1
SFA10
2
0
I'm just starting to use MPI in Fortran90 and have some questions on improving performance.

At the start of a calculation, I run a stage to distribute all required data to the slave nodes. This is a one-off step, but seems to be taking a long time.

The code running on the master node looks something like:

DO i_node = 1, nnodes
CALL MPI_SEND(...)
...
CALL MPI_SEND(...)
END DO

The number of data items, and hence calls to MPI_SEND, is of order 50.

Would it better to use MPI_BCAST instead of including the MPI_SENDs in a loop over i_node? If so, do the slaves need to use MPI_RECV or MPI_BCAST to receive the data?

Would using un-blocked sends be better? I am assuming I'd then need to include several MPI_WAIT statements after the loop. If I were to use un-blocked sends, would each call in the loop need a different process id number, to be later referred to in a unique call to MPI_WAIT?

Are there any benefits of using MPI_PACK to combine all the data items, then using a single send to transmit that (with it being unpacked when reaching the slave nodes)?

Apologies if the above seems like a lot of questions! Any help very much appreciated!
 
Technology news on Phys.org
  • #2
Are you sure this is what is taking a long time? I use MPI in C, not Fortran, but what is slow in a MPI program is starting all the processes. This can take up to a minute sometimes when there's a lot of them.

Try adding a Barrier before the Send loop, and after the barrier print something on the screen.

Also, if the number of tasks you are distributing isn't equal to the number of slave processes, then this isn't a very good way to do it, it's better to send each process one task, then use Iprobe in a loop to check when a process has finished, Recv the result and send it another task, and do this until you get all the results (I'm assuming the tasks are independent of each other).

I just hope those 50 sends aren't different pieces of the same task that you are sending 1 by 1 instead of putting them in a single package...
 
Last edited:
  • #3
I believe our in-house CFD code uses a BCAST at the start of the run. I'm not sure how exactly your sending your messages, but make sure they're in 1D packed arrays. MUCH faster
 

1. How does MPI improve performance in Fortran90?

MPI (Message Passing Interface) is a parallel computing library that allows for efficient communication and coordination between multiple processors. By utilizing MPI, programs written in Fortran90 can be divided into smaller tasks that can be executed simultaneously on different processors, resulting in improved performance compared to running the program on a single processor.

2. Can any Fortran90 program benefit from using MPI?

No, not all programs are suitable for parallelization using MPI. Programs that involve a lot of sequential computations or have a small number of tasks may not see a significant improvement in performance. Additionally, programs with complex data dependencies may be difficult to parallelize using MPI.

3. Are there any disadvantages to using MPI in Fortran90?

One potential disadvantage of using MPI is the added complexity it introduces to the program. Parallelizing a program using MPI requires careful consideration and design, and may require additional programming skills. Additionally, the performance gains from MPI may not always be significant enough to justify the added complexity.

4. How can I determine if my Fortran90 program is suitable for parallelization using MPI?

There are several factors to consider when determining if your program can benefit from MPI. These include the size of the problem, the amount of parallelism in the algorithm, and the data dependencies within the program. Conducting a performance analysis and benchmarking different parallelization strategies can also help determine if MPI is a suitable option for your program.

5. Are there any tips for optimizing performance when using MPI in Fortran90?

Yes, there are several tips for optimizing performance when using MPI in Fortran90. These include minimizing communication between processes, balancing the workload across processors, and using non-blocking communication whenever possible. It is also important to consider the memory usage and data layout when designing the parallel algorithm.

Similar threads

  • Programming and Computer Science
Replies
1
Views
2K
  • Programming and Computer Science
Replies
4
Views
2K
  • Programming and Computer Science
Replies
15
Views
1K
  • Programming and Computer Science
Replies
12
Views
3K
  • General Discussion
Replies
5
Views
624
  • Programming and Computer Science
Replies
2
Views
8K
  • Programming and Computer Science
Replies
1
Views
921
Replies
2
Views
1K
  • Programming and Computer Science
Replies
4
Views
662
  • Programming and Computer Science
Replies
5
Views
3K
Back
Top