MPI GROUP INCL Definition of mP group incl Used to form a new group from the processes belonging to group within specified ranks The mPl group ncl routine creates a new group from an existing group and specifles member processes int MPI Group incl( MPI Group old group, int count, int members, MPI Group new group The function returns an int error flag
MPI_GROUP_INCL • Definition of MPI_GROUP_INCL – Used to form a new group from the processes belonging to group within specified ranks. • The MPI_GROUP_INCL routine creates a new group from an existing group and specifies member processes. int MPI_Group_incl( MPI_Group old_group, int count, int *members, MPI_Group *new_group ) • The function returns an int error flag
MPI GROUP INCL Variable C Type In/Out Description Name old group MPl_Group Input Group handle count int Input Number of processes in new group members int Input Array of size count defining process ranks (in old group) to be included (in new group new_group MPL_Group*Output Group handle
MPI_GROUP_INCL Variable Name C Type In/Out Description old_group MPI_Group Input Group handle count int Input Number of processes in new_group members int * Input Array of size count defining process ranks (in old_group) to be included (in new_group) new_group MPI_Group * Output Group handle
MPI GROUP INCL EXample #include"mpi. h MPI_ Group group_ world, odd _group, even_group; int i, p, Neven, Nodd, members[8],ierr MPI Comm size(MPI COMM WORLD, &p) MPI Comm group(MPI COMM WORLD, &group world) Neven =(p+1)/2, / processes of MPI COMM WORLD are divided * Nodd=p-Neven, /into odd-and even-numbered groups/ for(i=0; i<Neven; i++i /"members"determines members of even group members[=2 MPI Group incl(group world, Neven, members, &even group);
MPI_GROUP_INCL • Example: #include "mpi.h" MPI_Group group_world, odd_group, even_group; int i, p, Neven, Nodd, members[8], ierr; MPI_Comm_size(MPI_COMM_WORLD, &p); MPI_Comm_group(MPI_COMM_WORLD, &group_world); Neven = (p+1)/2; /* processes of MPI_COMM_WORLD are divided */ Nodd = p - Neven; /* into odd- and even-numbered groups */ for (i=0; i<Neven; i++) { /* "members" determines members of even_group */ members[i] = 2*i; }; MPI_Group_incl(group_world, Neven, members, &even_group);
MPI GROUP INCL In the above example, a new group is created whose members are the even-numbered processes of the communicator mP CoMm World In the new communicator, the group members are ordered, with stride 1, in ascending order(, 1, 2, Neven-1). They are associated, one on one, with processes of the old group as specified by the array (members[o], members[1],,, members(Neven-1D) In this example, the old group consists of all processes of MPI COMM WORLD While the members array picks out the old group's even processes, i.e., members[0]=0, members[ 1]= 2, members[2=4, and so on
MPI_GROUP_INCL • In the above example, a new group is created whose members are the even-numbered processes of the communicator MPI_COMM_WORLD. • In the new communicator, the group members are ordered, with stride 1, in ascending order (0, 1, 2, ..., Neven-1). They are associated, one on one, with processes of the old group as specified by the array (members[0], members[1], ..., members[Neven-1]). • In this example, the old group consists of all processes of MPI_COMM_WORLD while the members array picks out the old group's even processes, i.e., members[0] = 0, members[1] = 2, members[2] = 4, and so on
MPI GROUP INCL Even Group Rank 0 Rank 1 Rank 2 Old Group Rank 0 Rank Rank 2 Rank 3 Rank 4 Rank 5 Odd Group Rank 0 Rank 1 Rank 2
MPI_GROUP_INCL