next up previous contents
Next: Translation of the on Up: Basic Translation Scheme Previous: Translation of a multiarray   Contents

Translation of multiarray creation

Figure 4.10 represents a schema for translating the most general form of distributed array creation with an on clause. The pre-translator makes sure that multiarray creation only appears on the right-hand-side of a top-level assignment. If the expression $ e_r$ is a range the macro DEFINE_DIMENSION is defined as follows:

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\small\begin{tabbing}
$\mbo...
...$.remove($$e_r$\verb$.dim()) ;$
\end{tabbing}
\end{minipage}
\end{displaymath}

As each dimension is processed, the memory stride for the next dimension is computed by multiplying the variable $ s$ by the number of locally held range elements in the current dimension. The variable $ b$ is incremented to allow space for lower ghost regions, below the base of the physical array, if this is required for the ranges involved. If the expression $ e_r$ is an integer then $\mbox{\it DEFINE\_DIMENSION}\left(a'_r, e_r, s, b, t\right)$ is evaluated the same as $\mbox{\it DEFINE\_DIMENSION}\left(a'_r, e_r, s\right)$ in the previous subsection. The call to checkContained() throws a GroupNotContainedException runtime exception if $ p$ is not contained in the current APG. The variable $ t$ is also introduced for run-time checking of correct usage. The calls to remove() will throw a DimensionNotInGroupException runtime exception if any range specified for the array is not distributed over a dimension in $ p$, or if any two specified ranges are distributed over the same dimension. The method arrayDim() on the Range class creates an instance of ArrayDim, with the memory stride specified in its argument. It is used in place of a call to the ArrayDim constructor because arrayDim() has the property that if the range is actually a collapsed range, the returned object will be an instance of the SeqArrayDim subclass. This allows a new array created with a collapsed range to be cast to an array with a sequential dimension, should it prove necessary at a later stage.

Figure 4.11: Translation of on construct.

SOURCE:

$\displaystyle \begin{minipage}[t]{\linewidth}\small\begin{tabbing}
\verb$on ($$e_{\mbox{\small grp}}$\verb$) $$S$\ \\
\end{tabbing}
\end{minipage}
$

TRANSLATION:

$\displaystyle \begin{minipage}[t]{\linewidth}\small\begin{tabbing}
\verb$final...
...[{S}\left\vert{p}\right.\right]$\ \\
\verb$}$
\end{tabbing}
\end{minipage}
$

where:

\begin{displaymath}
\begin{array}{l}
\mbox{$e_{\mbox{\small grp}}$\ is an expr...
...mbox{$S$\ is a statement in the source program.}
\end{array}
\end{displaymath}



next up previous contents
Next: Translation of the on Up: Basic Translation Scheme Previous: Translation of a multiarray   Contents
Bryan Carpenter 2004-06-09