0
votes

With the reference to the official documentation of the specific function:

#include <mpi.h>
int MPI_Comm_split_type(MPI_Comm comm, int split_type, int key,
    MPI_Info info, MPI_Comm *newcomm)

from here: https://www.open-mpi.org/doc/v3.0/man3/MPI_Comm_split_type.3.php

As described in the above link, the int key argument is used for the following purpose: Within each subgroup, the processes are ranked in the order defined by the value of the argument key, with ties broken according to their rank in the old group

I am not really sure I understand it, thus my question is:

Does the value under key is going to be the new rank value of each processes within the new communicator? Do I need to pass explicitly the rank/Id of each process in this way?

1
Use key if you want to control how tanks will be assigned to MPI tasks in the new communicator. If you do not need/care for a specific ranking, then simply use key=0 on all ranks. - Gilles Gouaillardet

1 Answers

2
votes

As noted in the comments the key is used to determine the rank of the process in the new communicator. The lowest key is given rank zero, the next lowest rank 1 and so on. Thus is we have 3 ranks in the old communicator using the same colour, and these ranks provide keys of 5, 167 and 19, that process providing a key of 5 will have rank 0 in the new communicator, that providing a key of 19 will have rank 1, and that providing 167 will have rank 2. Ties are broken by retaining the order of ranks as in the originally communicator. Thus if you simply provide a key of 0 and have all process calling MPI_Comm_split provide the same colour this will produce a new communicator in which the ranks are precisely the same as the old one. As a final example consider a communicator of size nproc, and each process with rank my_rank. If you then call MPI_Comm_split with each process providing the same colour, and the key being (nproc - my_rank) the new communicator will have the same size as the old one, but the order of ranks will be reversed.