1

Is MPI_Gather compulsory after MPI_Scatter or can we just scatter and leave data on the nodes.

I scattered a 2D array and counted the evens and odds. the program is working fine without gather. I think since gather only returns the scattered items, it would be fine if I do not gather it in my case.

Rayan Ali
  • 13
  • 4
  • 2
    Well, if you do not need a gather, don't do it. This is not mandatory (or otherwise the collective would have been different). This is dependent of the applications. It is not rare for large scale applications to do a scatter and then write the result on the distributed file system since a gather would not scale. Also sometime few collectives like alltoall are needed before a gather (eg. for FFTs). – Jérôme Richard Oct 30 '22 at 19:05
  • Some times `MPI_Scatter()` then followed by `MPI_Reduce()` is all you need. FWIW, you would ideally not scatter the data but have the data distributed on the nodes in the first place (e.g. each rank read its chunk (and nothing else) of the 2D array from a file). – Gilles Gouaillardet Oct 30 '22 at 23:54

1 Answers1

0

No, it is not compulsory (or MPI doesn't even care). In theory, there is no relation between MPI_Scatter and MPI_Gather. Both are separate, independent collective operations. Because of its opposite behaviour scatter scatters and gather gathers data, it can be used after one another to send and collect data.

Only point to point communication needs a corresponding receive for a send because point-to-point communication sends messages between two different MPI processes.

Collectives on the other hand involves all the processes and hence it doesn't need a pair.

j23
  • 3,139
  • 1
  • 6
  • 13