Search code examples
parallel-processingmpimpichparallel-arraysmpic++

Is MPI_Gather compulsory after MPI_Scatter?


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.


Solution

  • 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.