Preserve original ranks in new group

38 views Asked by At

After a new group is created, the lowest rank id is zero. How can I preserve the original ranks of processors?

#include <boost/mpi.hpp>

namespace bmpi = boost::mpi;

int main()
{
    MPI_Init(NULL, NULL);

    bmpi::communicator comm;
    bmpi::group group = comm.group();

    std::vector<int> to_be_excluded = {0};
    group = group.exclude(to_be_excluded.begin(), to_be_excluded.end());
    comm = bmpi::communicator(comm, group);

    if (comm) {
        std::cout << comm.rank() << std::endl; // want this to be original rank which is 1 not zero.
    }

    MPI_Finalize();
    return 0;
}
0

There are 0 answers