next up previous contents index
Next: Translating method declarations Up: Basic translation Previous: Translation functions and schemas   Contents   Index


Translating variable declarations

The general scheme for translating declaration of a field or local variable holding a multiarray reference is illustrated in Figure A.13. The single variable in the source program is converted to $2 + R$ variables in the output program, where $R$ is the rank of the array.

The macro TRANS_ID transforms the identifier of the field in a way that encodes the dimension signature of the result. This encoding is necessary in order that the HPJava type signature of a field can be reconstructed from the class file of a translated (and compiled) class. Note that the element type of the multiarray field is known from the type of Java array in translated field--this information is automatically encoded in the Java class file.

The values returned by the TRANS_ID macro and the macros TRANS_ID_BAS and TRANS_ID_DIM all start with the the original $a$ string, followed by the suffix separator ``__$''. This is followed by a string characteristic of the individual macro, described next.

The characteristic string for TRANS_ID($a$) is a string of $R$ letters, each of which is ``D'' (for a distributed dimension) or ``S'' (for a sequential dimension). The characteristic string for TRANS_ID_BAS($a$) is ``bas''. The characteristic string for TRANS_ID_DIM($a$, $r$) is the decimal representation of the constant integer value $r$.

The variable $\mbox{\it TRANS\_ID}(a)$ will hold a reference to the Java array containing the locally held elements of the multiarray. This is the value that would be returned by the inquiry $a$.dat() in the source program.

The $\mbox{\it TRANS\_ID\_BAS}(a)$ will hold an instance of the class ArrayBase. Instances of this class contain a group object (the value that would be returned by the inquiry $a$.grp() in the source program) and an offset from the start of the Java array, where the first locally held element of the multiarray is stored (the value that would be returned by the inquiry $a$.bas() in the source program).

The $R$ variables $\mbox{\it TRANS\_ID\_DIM}(a, 0)$ ..., $\mbox{\it TRANS\_ID\_DIM}(a, R-1)$ will hold descriptors for the dimensions of the arrays. 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, *. Instances of the class ArrayDim contain a distributed range object and an associated ``memory stride''--the values that would be returned by the inquiries $a$.rng($r$) and $a$.str($r$), respectively, in the source program. These values are stored in the fields range and stride of ArrayDim. The class SeqArrayDim is a subclass of ArrayDim that contains extra information that can be used to simplify the computations associated with subscripting a sequential array dimension.

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 can 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}

Figure A.14: Translation of method declaration.
SOURCE:

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
$T$\verb$ $$f...
...rb$ $$v_{N-1}$\verb$) {$$S$\verb$}$
\end{tabbing}\end{minipage}\end{displaymath}

TRANSLATION:

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
$T$\verb$ $$f...
...f T}\left[{S}\right]$ \\
\verb$}$
\end{tabbing}\end{minipage}\end{displaymath}

or

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
$T$\verb$ $$f...
...ert{p}\right.\right]$ \\
\verb$}$
\end{tabbing}\end{minipage}\end{displaymath}

where:

\begin{displaymath}
\begin{array}{l}
\mbox{$T$ is a Java type,} \\
\mbox{the i...
... macro {\it TRANS\_PARAMS} is defined in the text.}
\end{array}\end{displaymath}

The first translation applies for non-HPspmd methods, the second for HPspmd methods.


next up previous contents index
Next: Translating method declarations Up: Basic translation Previous: Translation functions and schemas   Contents   Index
Bryan Carpenter 2003-04-15