next up previous contents
Next: Translation of multiarray creation Up: Basic Translation Scheme Previous: Basic Translation Scheme   Contents

Translation of a multiarray declaration

Figure 4.9: Translation of a multiarray-valued variable declaration.

SOURCE:

$\displaystyle T \verb$ [[$$   attr$\displaystyle _0 \verb$, $ \ldots \verb$, $$   attr$\displaystyle _{R-1}
\verb$]] $ a \verb$ ;$
$

TRANSLATION:

$\displaystyle \begin{minipage}[t]{\linewidth}\small\begin{tabbing}
$T$\verb$ [...
...r}_{R-1}\right)$\verb$ $$a'_{R-1}$\verb$ ;$ \\
\end{tabbing}
\end{minipage}
$


Figure 4.9 represents a schema for translating a multiarray declaration in a source HPJava program. $ T$ is some Java type, and $ 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 attr$ _r$ are each either a hyphen, -, or an asterisk, *, and the ``macro'' DIMENSION_TYPE is defined as:

if the term attr$ _r$ is a hyphen, or

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\small\begin{tabbing}
$\mbo...
...ht) \equiv$
\verb$SeqArrayDim$
\end{tabbing}
\end{minipage}
\end{displaymath}

if the term attr$ _r$ is an asterisk. For instance, if a class in the source program has a field:

$\displaystyle \begin{minipage}[t]{\linewidth}\small\begin{verbatim}
float [[-,*]] var ;\end{verbatim}\end{minipage}
$

the translated class may be supposed to have the four fields as:

$\displaystyle \begin{minipage}[t]{\linewidth}\small\begin{verbatim}
float [] va...
...$bas ;
ArrayDim var__$0 ;
SeqArrayDim var__$1 ;\end{verbatim}\end{minipage}
$

Generally a rank-$ r$ multiarray in the source program is translated to $ 2 + r$ variables in the ordinary Java program. The first variable is an ordinary, one-dimensional, Java array holding local elements. A struct-like object of type ArrayBase holds a base offset in this array and an HPJava Group object--the distribution group of the array. Simple ArrayDim and SeqArrayDim[*] objects each contain an integer stride in the local array and an HPJava Range object describing the dimensions of the distributed array.

Figure 4.10: Translation of multiarray creation expression.

SOURCE:

$\displaystyle \begin{minipage}[t]{\linewidth}\small\begin{tabbing}
$a$\ \verb$ = new $$T$\verb$ [[$$e_0$\verb$, $ \ldots
\verb$, $$e_{R-1}$\verb$]] $$$bras$\displaystyle $\verb$ on $$p$\verb$ ;$
\end{tabbing}
\end{minipage}
$

TRANSLATION:

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\small\begin{tabbing}
\verb...
...($$p$\verb$, $$b$\verb$) ;$ \\
\end{tabbing}
\end{minipage}
\end{displaymath}

where:

\begin{displaymath}
\begin{array}{l}
\mbox{$T$\ is a Java type,} \\
\mbox{$R...
...{\it DEFINE\_DIMENSION} is defined in the text.}
\end{array}
\end{displaymath}



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