This page imported from: /afs/bu.edu/cwis/webuser/web/s/c/scv/documentation/tutorials/MPI/alliance/communicators/codes/group_example.html

Example on Usages of Group Routines

Example on Usages of Group Routines

The objectives of this example is to divide the member processes of MPI_COMM_WORLD
into two new groups. One group consists of all odd-numbered processes and the other
all even-numbered processes. A table is then printed to show whether a process belongs
to the odd or even group.




Output

A negative number indicates that the calling process does not belong to
the group.
As a matter of fact, in that case the rank number would be set to
MPI_UNDEFINED which is implementation dependent and has a value of “-3”
for SGI’s MPI and “-32766” if you are running MPICH.


lego:communicators/codes % mpirun -np 5 group_example

 MPI_Group_incl/excl Usage Example

 Number of processes is                5
 Number of odd processes  is           2
 Number of even processes is           3

 MPI_UNDEFINED is set to              -3

  Current     even      odd
     rank     rank     rank
        0        0       -3
        4        2       -3
        3       -3        1
        1       -3        0
        2        1       -3