MPI_Group_excl

MPI_Group_excl


MPI_Group_excl
creates new group from existing group and specifies member processes
(by exclusion).

Fortran Syntax

Subroutine MPI_Group_excl(group, count, nonmembers, new_group, ierr)

C Syntax

int MPI_Group_excl(MPI_Group group, int count, int *nonmembers,
MPI_Group *new_group
)


Example in Fortran


include "mpif.h"
implicit none
integer group_world, odd_group, even_group
integer i, p, Neven, Nodd, members(0:7), ierr

call MPI_Comm_size(MPI_COMM_WORLD, p, ierr)
call MPI_Comm_group(MPI_COMM_WORLD, group_world, ierr)

Neven = (p + 1)/2 ! processes of MPI_COMM_WORLD are divided
Nodd = p - Neven ! into odd- and even-numbered groups
do i=0,Neven - 1 ! "members" determines members of the even_group
members(i) = 2*i
enddo

call MPI_Group_excl(group_world, Neven, members, odd_group, ierr)

Example in C


  #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&#060Neven; i++) {   /* "members" determines members of the even_group */
    members[i] = 2*i;
  };

  MPI_Group_excl(group_world, Neven, members, &odd_group);

In the above example, we create a new group whose members are the odd-numbered processes of the communicator MPI_COMM_WORLD. Contrary to MPI_Group_incl, this routine takes the complement of the provided process list, members, as group members. These group member ranks are ranked in ascending order (0, 1, 2, ..., Nodd-1). In this example, these correspond to the process ranks (1, 3, 5, ...) in the original group. Count is the number in the exclusion list, not member count in the new group. The same task could also be accomplished by a similar routine, MPI_Group_incl.