|
overall construct is another control construct of
HPJava. It represents a distributed parallel loop, sharing some
characteristics of the forall construct of HPF. The index
tripletoverall construct represents a lower bound, an upper
bound, and a step, all of which are integer expressions, as follows:
l, is 0 and the default of
the upper bound, u, is for keyword.
Thus,
i, in the range x''
from figure 3.5.
An HPJava range object can be thought of as a collection of abstract
locations. From Figure 3.5, the two lines
x and y has N locations.
The symbol i scoped by the overall construct is called
a distributed index. Its value is a location, rather an
abstract element of a distributed range than an integer value. It is
important that with a few exceptions we will mention later, the
subscript of a multiarray must be a distributed index, and the
location should be an element of the range associated with the array
dimension. This restriction is a important feature, ensuring that
referenced array elements are locally held.
Figure 3.6 is an attempt to visualize the mapping of
locations from x and y. We will write the locations of
x as x[0], x[1], ..., x[N -1]. Each
location is mapped to a particular group of processes. Location
x[1] is mapped to the three processes with coordinates y[4] is mapped to the two
processes with coordinates overall construct, there is an at
construct in HPJava that defines a distributed index when we want to
update or access a single element of a multiarray rather than
accessing a whole set of elements in parallel. When we want to update
a[1, 4], we can write:
at construct is similar to
that of the on construct. It limits
control to processes in the collection that hold the given location.
Referring again to Figure 3.6, the outer
a[1,4]. The restriction that
subscripts must be distributed indices helps ensure that processes only
manipulate array elements stored locally.
If a process has to access elements non-locally held, some explicit
library call should be used to fetch them.
We often need to get the integer global index associated with a
distributed index. But, using a distributed index as an integer value
is not allowed in HPJava. To get the integer global index
value for the distributed loop, we use the backquote symbol
as a postfix operator on a distributed index, for example, i`,
read ``i-primed''. The following nested overall loop is an
example using an integer global index value:
|