next up previous contents
Next: A DAD Up: Issues in Translation of Previous: Restricted process groups   Contents


Figure 6: A hierarchy of ranges.

Inside our DAD a range object will describe the extent and distribution format of one dimension of a distributed array. We can expect a class hierarchy of different kinds of range object (Figure 6). Each subclass represents a different kind of distribution format for an array dimension. The simplest distribution format is collapsed (sequential) format. Other distribution formats include regular block and simple cyclic decomposition. We will see later that some range classes allow ghost extensions to support stencil-based computations.

Figure 7: Interface of the Range class.
\begin{figure}\small\begin{verbatim}class Range {
int size() const ...
...tion* loc, const int glb) const ;
} ;\end{verbatim}\normalsize\end{figure}

Figure 7 gives a possible interface of a Range class in C++. To understand this API, let's give an example of its use. Our original HPF example and a possible translation to C++ as shown in Figure 8. We declare a process grid p as described in the previous section, then create a Range object, x, of subclass BlockRange. The arguments of the constructor are the process dimension over which the range is to be distributed, and the extent of the range. The value previously called BLK_SIZE is returned by the method call x.volume(), and a local array segment is allocated with this size. In any process that is a member of p we call the method block, passing it the local process coordinate. This initializes a Block structure which has fields:

    struct Block {
        int count ;

        int glb_bas ;
        int glb_stp ;

        int sub_bas ;
        int sub_stp ;
    } ;
The fields define the count of the local loop and the base and step for the local subscript and global index7.

Figure 8: C++ translation of simple HPF program.
\small\begin{verbatim}!HPF$ PROCESSORS P(4)...
...i ;
}... do some global finalization\end{verbatim}\normalsize\end{figure}

Figure 8 is shorter and (arguably) more readable than the original translation in Figure 1. It also has the interesting property that if we change the distribution directive in the HPF code to

the only change needed in the C++ translation is that the declaration of x becomes
    CyclicRange x(p.dim(0), 50);
This suggests we are making progress towards the goal of being able to produce generic code that works for data with any distribution format.

next up previous contents
Next: A DAD Up: Issues in Translation of Previous: Restricted process groups   Contents
Bryan Carpenter 2002-07-12