mpi-process-groups
Table of Contents
MPI Process groups
Process groups form subsets with explicit rank lists. MPI_Group_incl builds from a list; MPI_Group_excl excludes.
MPI_Group world_group, sub_group; MPI_Comm sub_comm; MPI_Comm_group(MPI_COMM_WORLD, &world_group); int ranks[] = {0, 2, 4}; MPI_Group_incl(world_group, 3, ranks, &sub_group); MPI_Comm_create(MPI_COMM_WORLD, sub_group, &sub_comm); if (sub_comm != MPI_COMM_NULL) { // ranks 0, 2, 4 enter here with new ranks 0, 1, 2 in sub_comm do_work(sub_comm); MPI_Comm_free(&sub_comm); } MPI_Group_free(&sub_group); MPI_Group_free(&world_group);
MPI_Comm_create is collective over the parent communicator: every process must call it, and those excluded receive MPI_COMM_NULL. MPI_Comm_create_group (MPI-3) is collective only over the group itself, which is more efficient when the subset is small. Groups are lightweight objects; they do not enable communication on their own and have no communication context until wrapped in a communicator.
mpi-process-groups.md · Last modified: by 127.0.0.1
