Communicators and groups

Similar to MPI, TPO++ support different communicators, corresponding to different communication layers. The communication done on different communicators does not interact in any way. On startup, TPO++ provides the predefined communicator TPO::CommWorld containing all hosts. The number of hosts and the rank of the current process in a communicator can be queried by its size() and rank() methods.

class TPO::Communicator {
  TPO::Rank rank() const;
  int       size   const;

The user can create new communicators by declaring variables of type Communicator. A newly created communicator is empty, if provided no arguments, are can be created from an existing communicator using duplication, by providing the communicator as an argument.

Communicator my_comm_1;              // creates an empty communicator
Communicator my_comm_2(CommWorld);   // creates a duplicate of CommWorld

The hosts associated with a given communicator can be modified using group calls. To do this, a communicator provides a method group() to extract the group of hosts asssociated with it.

class TPO::Communicator {
  TPO::Group group() const;

The group objects, i.e. the hosts represented by the group, can be modified on different ways. Like communicators, groups allow to query its size and the rank of the current host in a group using the size() and rank() methods.

class TPO::Group {
  Rank rank() const;
  int  size() const;


Standard set operations, like intersection, difference and merge can be used to create new group from existing groups. They are provided as overloaded operators + for union, * for intersection and - for difference.

class TPO::Group {
  Group operator+(const Group&) const;
  Group operator*(const Group&) const;
  Group operator-(const Group&) const;

The next example show, how a new group, representing the hosts in the intersection of two given groups can be created:

  TPO::Group group1, group2;
  TPO::Group new_group;

  new_group = group1 * group2;
Moreover, groups can be compared.

If a group has been modified, the application can create a new communicator for the processes defined in the group using the creation constructor of communicators:

class TPO::Communicator {
  Communicator(const TPO::Communicator&, const TPO::Group&);
Communicator my_comm_3(CommWorld, my_group);

This creates a new communicator containg the specified hosts and is a collective call over all hosts in the old communicator. The Group argument must be identical on all calling hosts, and the hosts contained in it must be a subset of the group of hosts associated with the old communicator.

Patrick Heckeler 2007-05-31