next up previous
Next: The server process Up: fifth.c in detail Previous: fifth.c in detail

Extraction, manipulation, and creation of process groups and communicators

 

We begin the construction of the new communicator by extracting a process group, associated with the MPI_COMM_WORLD communicator and call it world_group:

MPI_Comm_group ( MPI_COMM_WORLD, &world_group );

The next operation creates a new group, which will be called worker_group, by excluding processes declared in the array ranks from the world_group:

ranks[0] = server;
MPI_Group_excl ( world_group, 1, ranks, &worker_group );

These two new functions, MPI_Comm_group and MPI_Group_excl, are described in Chapter 5 ``Groups, Contexts, and Communicators'', of ``MPI: A Message-Passing Interface Standard''.

The number of processes to be excluded from the new group must be passed as the second parameter to function MPI_Group_excl. In our case we exclude only one process, the server.

Having created the new group, we can now create the communicator associated with that group. We shall call that communicator workers:

MPI_Comm_create ( world, worker_group, &workers );

Once the communicator has been created we can release the names of groups worker_group and world_group:

MPI_Group_free ( &worker_group );
MPI_Group_free ( &world_group );
It is important to realise that this operation only frees the names of the groups, not the groups themselves. The groups survive inside the communicators, and if needed, they can be retrieved again by calling MPI_Comm_group.

Process groups and communicators are a very important part of MPI. They make it possible to write parallel libraries, which can be accessed by user programs without colliding with their own nomenclature, and their own messages. The idea of process groups also lies at the basis of fault tolerant and virtually synchronous programming. But MPI, which is designed specifically for scientific and engineering computations, doesn't take it that far.



Zdzislaw Meglicki
Tue Feb 28 15:07:51 EST 1995