[Next] [Up] [Previous]
Next: Mapping Up: A Tutorial Introduction to Previous: Concurrency Control

Object Groups

A sheep is an animal naturally living within a group of other sheep. We can easily express such a group relationship in TACO as follows:
#include "taco/taco.h"
#include "Sheep.h"
class FlockMember: public Sheep, public GroupMember<FlockMember> { 
 public:
    FlockMember(int rank) : Sheep (...) { }
};
A FlockMember is a Sheep in a group of other flock members. Classes that are derived from a GroupMember class are so-called group aware classes. When group members are instances of a group aware class, we can instantiate entire distributed object groups as depicted in the following little TACO program:
#include "taco/tacoMain.h"
int main(int argc, char** argv)
{
   taco::init(argc,argv);  // init taco
   Cyclic mapping; // specify a mapping strategy
   GroupOf<FlockMember> flock(873, mapping);
    ...
}
These two lines of code will create a distributed group of 873 Sheep instances distributed in a cyclic fashion by rank over all available computing nodes starting at node 0. The Cyclic class controls the mapping of group members to computing nodes. Other classes such as Random implements a random mapping strategy while the BlockCyclic class implements a block-cyclic mapping.