0
votes

I have split MPI_COMM_WORLD into two sub-communicators and I want to transfer an array of data distributed over MPI_COMM_WORLD to two sub-communicators. What is the best way to do that within MPI-1.1?

For example, there is an array A = [1 2 3 4 5 6 7 8] distributed among four MPI processes in MPI_COMM_WORLD as follows

rank 0: [1 2] 
rank 1: [3 4] 
rank 2: [5 6] 
rank 3: [7 8]

I split MPI_COMM_WORLD into two sub-communicators constsing of two MPI processes each and want to have my data being like:

subcommunicator1:

    rank 0: [1 2 3 4]
    rank 1: [5 6 7 8]

subcommunicator2:

    rank 0: [1 2 3 4]
    rank 1: [5 6 7 8]
1

1 Answers

3
votes

There isn't a way to send data from one communicator to another. In MPI, communicators specifically are designed to contain communication within groups. In your case, you'll need to distribute your data before you split up MPI_COMM_WORLD. How you do that will be dependent on your data and desired distribution. You'll probably need to look at MPI_SCATTER, MPI_GATHER, or both.