void Sheep::feed(ArrayPtr<int> food) { my_weight+=food[rank()]; } ...; GroupOf<Sheep> flock(128, ...); int food[128]; for (int i = 0; i < 128; i++) food[i] = random(); flock.map( m2f(&Sheep::feed, food) );
The ArrayPtr class resembles global pointers that provide pointer arithmetic as well as subscripting. Thus, each Sheep instance accesses its individual amount of food by accessing a remote array located at the node that initiated the map operation. Note, that the local pointer to the food array is automatically expanded to its corresponding ArrayPtr type, since the feed() method sketched above declares its formal parameter to be an ArrayPtr. Thus we can export local references automatically into TACO's global space and methods might easily have several remotely indexable arguments.
Note, that parallel group operations like the feed() method sketched above are inherently sequentialized, because all accesses to that array need to be handled on a single node. Therefore, provided the input data array is not excessively large, even on low latency networks the (parallel) copy overhead of passing an array by value is often faster as a global pointer access. Arrays cannot be passed directly by value because arrays themselves are not objects in C++. However, instances of classes containing fixed-size arrays, can easily be passed.