next up previous contents index
Next: Changes for ghost regions Up: Some Rules and Definitions Previous: Rules for distributed array   Contents   Index


Rules for access to distributed array elements

First we will collect together rules for distributed array element references implied or informally stated in 2.5 and subsequent sections. The first rule is part of the static semantics of the language--it can be enforced by the type checker:

Rule 4   If $a$ is a distributed array, then in the element reference

\begin{displaymath}
a \mbox{\tt [} e_0 \mbox{\tt ,}\ldots
\mbox{\tt ,} e_r \mbox{\tt ,}\ldots
\mbox{\tt ]}
\end{displaymath}

the expression $e_r$ is either an integer expression--allowed only if the corresponding dimension of $a$ has the sequential attribute--or a (possibly shifted) distributed index.

Depending on whether $e_r$ is in fact an integer, an index declared in an at construct, or an index declared in an overall construct, exactly one of the following three ``run-time''5.3rules applies. To simplify the discussion, we first ignore ghost regions. The three rules are: either

Rule 5   In the distributed array element reference:

\begin{displaymath}
a \mbox{\tt [} e_0 \mbox{\tt ,}\ldots
\mbox{\tt ,} e_r \mbox{\tt ,}\ldots
\mbox{\tt ]}
\end{displaymath}

if $e_r$ is an integer, its value must lie in the range

\begin{displaymath}
0 \le e_r < x \mbox{\tt .size()}
\end{displaymath}

where $x = a \mbox{\tt .rng(} r \mbox{\tt )}$.

or

Rule 6   The distributed array element reference in:

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
\verb$ at($$i...
...{\tt ]}$ \verb$ ...$ \\
\verb$ }$
\end{tabbing}\end{minipage}\end{displaymath}

is allowed if and only if
  1. The expression $a$ is invariant in the at construct5.4.

  2. The location $x \mbox{\tt [} n \mbox{\tt ]}$ is an element of the range $a \mbox{\tt .rng(} r \mbox{\tt )}$5.5.

or

Rule 7   The distributed array element reference in:

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
\verb$ overal...
...{\tt ]}$ \verb$ ...$ \\
\verb$ }$
\end{tabbing}\end{minipage}\end{displaymath}

is allowed if and only if
  1. The expression $a$ is invariant in the overall construct.
  2. All locations in $x \mbox{\tt [} l \mbox{\tt :} u \mbox{\tt :} s \mbox{\tt ]}$ are of elements $a \mbox{\tt .rng(} r \mbox{\tt )}$.

A subtle point to appreciate is that rules 6 and 7 are statements about the at and overall constructs as a whole, not about the array accesses in isolation. They apply unconditionally to any access that appears textually inside the constructs, even if some conditional test in the body of the construct might prevent those accesses from actually being executed. This is potentially important because it allows any associated run-time checking code to be lifted outside the constructs, and in particular to be lifted outside the local loops implied by an overall.

We should point out that the run-time rules given in this section and the following subsection are not checked by the HPJava compiler in the hpjdk 1.0 release. This is a shortcoming that we hope will be rectified in future releases.



Subsections
next up previous contents index
Next: Changes for ghost regions Up: Some Rules and Definitions Previous: Rules for distributed array   Contents   Index
Bryan Carpenter 2003-04-15