next up previous
Next: Translation of the overall Up: Basic translation scheme Previous: Basic translation scheme

Translation of distributed arrays

Figure 4: Translation of a distributed-array-valued variable declaration.


SOURCE:

\begin{displaymath}
T \verb$ [[$ \mbox{\it attr}_0 \verb$, $ \ldots \verb$, $ \mbox{\it attr}_{R-1} \verb$]] $ a \verb$ ;$
\end{displaymath}

TRANSLATION:

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
$T$\verb$ [] ...
...ht)$\verb$ $$a'_{R-1}$\verb$ ;$ \\
\end{tabbing}\end{minipage}\end{displaymath}


Figure 4 gives a schema for translating a distributed array declaration in the source HPJava program. Here $T$ is some Java type, $a'_{\mbox{\small dat}}$, $a'_{\mbox{\small bas}}$ and $a'_0 \ldots a'_{R-1}$ are new identifiers, typically derived from $a$ by adding some suffixes, the strings $\mbox{\it attr}_r$ are each either a hyphen, -, or an asterisk, *, and the ``macro'' DIMENSION_TYPE is defined as

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
$\mbox{\it DI...
...r}_r\right) \equiv$ \verb$ArrayDim$
\end{tabbing}\end{minipage}\end{displaymath}

if the term $\mbox{\it attr}_r$ is a hyphen, or

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
$\mbox{\it DI...
..._r\right) \equiv$\verb$SeqArrayDim$
\end{tabbing}\end{minipage}\end{displaymath}

if the term $\mbox{\it attr}_r$ is an asterisk.

If, for example, a class in the source program has a field:

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\small\begin{verbatim}float [[-,-,*]] bar ;\end{verbatim}\end{minipage}\end{displaymath}

the translated class may be assumed to have the five fields:

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\small\begin{verbatim}floa...
...im bar__$1 ;
SeqArrayDim bar__$2 ;\end{verbatim}\end{minipage}\end{displaymath}

In general a rank-$r$ distributed array in the source program is converted to $2 + r$ variables in the translated program. The first variable is an ordinary, one-dimensional, Java array holding local elements. A simple ``struct''-like object of type ArrayBase contains a base offset in this array and an HPJava Group object (the distribution group of the array). $r$ further simple objects of type ArrayDim each contain an integer stride in the local array and an HPJava Range object describing the dimensions of the distributed array. The class SeqArrayDim is a subclass of ArrayDim, specialized to parameterize sequential dimensions conveniently.

One thing to note is that a class file generated by compiling the translated code will contain the generated field names. These follow a fixed prescription, so that when a pre-compiled class file (from some library package, say) is read by the HPJava translator, it can reconstruct the original distributed array signature of the field from the $2 + r$ fields in the class file. It can then correctly check usage of the external class. By design, the translator can always reconstruct the HPspmd class signatures from the standard Java class file of the translated code.


next up previous
Next: Translation of the overall Up: Basic translation scheme Previous: Basic translation scheme
Bryan Carpenter 2002-07-12