Next: The Structure of
Up: Collections. Ver 1.0+
Previous: Collection as a
There are several restrictions on the classes that are allowed as
element types of a collection. We list here some of these restrictions
and try to explain why they exist and which restrictions will be lifted.
- An ElementType in a collection must not contain pointers to
heap based data. The reason for this is that the basic communication mechanism
in a pC++ program is to make a copy of an element. Though pC++ maintains
a global name space for elements in a collection, there is no global name
space other than program global data. In particular, the heap and stack
of each processor object thread is for the private and exclusive use by
that thread. This is because on distributed memory
machines without shared address spaces, pointers cannot be moved across
the machine and still have meaning as pointers.
Future versions of pC++ will have the concept of a global pointer that
will help ease the pain of this restriction.
- An ElementType in a template TEClass collection can be a basic
type like int, float, etc. It can even be a global pointer to an
element in version 2.0. However, the type of an element must be a
full C++ class in form of the collection described below. In other words,
in version 1.0, if you want a collection of element of type int
you must declare a class of the form
class Int{
int data;
// constructor (see next item) and
// any overloaded integer operators you need
// would be here.
};
In most cases this restriction is not serious.
Elements that are fine grained are discouraged because the overhead
of member function calls will far outweigh the advantage of parallel
arithmetic.
- In version 1.0 an ElementType must have a constructor with
no arguments.
class Int{
int data;
public:
Int(){ data = 0; }
...
};
This constructor is used by the SuperKernel collection to allocate
the elements. In the future this rule will be relaxed to allow more
general constructors so that one may build collections from elements
with arbitrary initializations.
Next: The Structure of
Up: Collections. Ver 1.0+
Previous: Collection as a