References:
Groups and communicators are dynamic objects that can be created and destroyed during program execution. In terms of programming, groups and communicators are equivalent.
Identifies a group associated with a specific communicator. It is necessary to identify a group to create new ones.
int MPI_Comm_group(
MPI_Comm comm, //Communicator
MPI_Group *group //MPI_Group address
);
int MPI_Group_size(
MPI_Group group, //Group
int *size //Size address
);
#include <iostream>
#include <mpi.h>
using namespace std;
int main(int argc, char* argv[]) {
int rank;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Group group;
MPI_Comm_group(MPI_COMM_WORLD, &group);
int size;
MPI_Group_size(group, &size);
if(rank == 0) {
cout << "Group: " << group << endl;
cout << "Size: " << size << endl;
}
MPI_Finalize();
return 0;
}
Output:
Create a new group from an existing group, including specified process ranks from the existing group.
Function prototype: