保留新组中的原始排名

时间:2020-04-04 11:16:23

标签: mpi boost-mpi

创建新组后,最低等级ID为零。如何保留处理器的原始等级?

#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 个答案:

没有答案