Next: Element Types. Ver Up: Collections. Ver 1.0+ Previous: DistributionsAlignments, and

Collection as a Template TEClass. Ver 2.0

Template TEClass objects are not supported in pC++ version 1.0. This section is a preview for version 2.0.

The most direct approach to building a collection is to define it as a template TEClass, where we supply the type of the collection element as the first template parameter. The template structure can be derived from a parent template TECLASS which will provide the data structures to manage the set of element on each processor thread according to the alignment and distribution specifications. We call this data structure manager collection the SuperKernel. The basic Template TEClass takes the following form.


template<Class ElementType> TEClass C: SuperKernel<ElementType> 
{
     C(Distribution *D, Align *A, n, m): SuperKernel(D, A) { ... }
     ...
     int alpha();
};

Given an element class E defined by


class E{
 public:
   float x, y;
   void f( int i);
   double g();
  };

and a distribution D and alignment A, one can create a collection X of type C with element type E with a declaration of the form:


   C<E> X(&D, &A);
There are a number of different parallel operators that can be applied to the collection X. The simplest is the evaluation of TEClass member functions, such as alpha() in the collection C above, on each thread associated with the distribution. Because the collection is, at heart, a TEClass this is nothing new and the expression

  X.alpha();
behaves exactly as described in the previous chapter.

However, with a collection there is another form of parallelism. Given a member function of element class, f(), one can apply the function to every element of the collection with the expression


X.f(1);
Alternatively, one can index a subset of elements in a collection with the expression

   X[i:j:k].f()
which will invoke the function f() on elements with index in the range from i to j with step size k. (For multi-dimensional collections, the array notation extends in the obvious manner, but this is not reliable in Version 1.0.)

It is also possible to cause an element member function to be invoked on a single element of a collection by using the SuperKernel overloaded operator (...).



Next: Element Types. Ver Up: Collections. Ver 1.0+ Previous: DistributionsAlignments, and


beckman@cica.indiana.edu
Mon Nov 21 09:49:54 EST 1994