0
votes

I am trying an implementation in MPI where I am invoking multiple slaves (upto 4) on the same machine (localhost) and distributing the computations of my for loop amongst the slaves. MPI is suited for my current application and I cannot take the openMP route. The variables that are involved are about 50 and all are uni-dimensional arrays. What would be the best way to send the 50 variables to the master process? Should I send and receive all variables or should I pack them in one 2D array and send this array across to the master? I am looking for an efficient and computationally inexpensive approach.

Thanks

1

1 Answers

0
votes

As so often: it depends. If your individual arrays are sufficiently large, such that latency gets insignificant, it would be fine to send each one individually. Otherwise, it will be better to increase the size of your message by collecting all those arrays into a single one. If your variables are of different type you could make use of MPI datatypes to describe the layout of your data.

Additionally, if you need to collect this data from multiple processes it might be a good idea to use MPI_Gather or one of its variants. It might also be, that a viable option in your scenario would be to make use of the one-sided communication facilities offered by MPI.