[Next] [Up] [Previous]
Next: Scatter and Gather Up: Object Groups Previous: Cloning of Groups

Basic Collective Operations

All members in a group can be collectively addressed by collective operations. Thus the basic method invocation paradigm is appropriately extended to method invocations on entire object groups. The following code then invokes the feed() method on all members of the group and sums up the individual results.

Cyclic mapping;
GroupOf<FlockMember> flock(128, mapping);


int total;
total = flock.reduce( m2f(&Sheep::feed,12), plus<int>() );

The synchronous reduce() operation first applies the specified functor to all group members in parallel and then applies an associative and commutative binary reduce-functor to combine all results. Note, that the binary plus functor used in this example is provided by the standard template library (STL) for C++ and most other STL functors like multiplies can be used, too.

TACO provides several other collective operations in addition to the reduction. An asynchronous global map() operation is provided to initiate data parallel computations and apply a void-functor to all group members. Furthermore, we provide a step() operation, that resembles a synchronously executed map() as well as a a gather operation that collects the individual results by member ranks.


GroupOf<Member> group(...);
Result* resultByRank = new Result[group.size()];
Result r;


group.map(void-functor);
group.step(void-functor);
group.gather(functor,resultByRank);
r = group.reduce(functor,red-functor);

Note, the functors are following the same rules as the functors for the basic RMI mechanisms.


[Next] [Up] [Previous]
Next: Scatter and Gather Up: Object Groups Previous: Cloning of Groups