Dimension splitting allows one to access the local blocks of distributed arrays as sequential HPJava arrays. In many cases this may be all one needs to do low level SPMD programming. But the translation scheme for HPJava actually assumes that ultimately all Fortran-like arrays are implemented in terms of the standard arrays of Java. HPJava does not attempt to conceal such things. Hence the underlying Java arrays should be available if they are needed.
The inquiry dat() can be applied to any HPJava multiarray or distributed array. It returns a reference to a Java array with the same type of elements as the target array. This is the actual array in which the local elements are stored.
This gives us yet another way to optimize the original data-parallel N-body example of Figure 7.1. We can express the compute loop in the MPI style of Figure 7.4. The code is given in Figure 7.13. This particular implementation assumes that the process grid p coincides with the MPI group associated with the COMM_WORLD communicator.
Again this simple example hides the complexities that arise if we have to deal with a general distributed array. As we saw in the previous section, the local elements of a general distributed array are effectively stored in a sequential multiarray. The detailed embedding is defined by the localBlock() inquiry on the distributed array ranges.
The mapping of the local sequential multiarray into the Java
array is defined in turn by new inquiries
bas() and str()
on an HPJava multiarray. These integer-valued methods define a base offset,
and a stride for each dimension7.4.
If an element of a sequential HPJava array,
a, has integer subscripts
it is stored in element
This formula can be extended to a formula for finding the local elements
of distributed arrays. First we note that through dimension splitting
any distributed array can be reduced to an array that has a mix of
only sequential dimensions and level 0 ranges. The level 0 ranges contribute
nothing to the total offset of the element in the local Java array.
So if the subscript list is
--a mix of
integers and level 0 distributed index symbols--the local element is
SOURCE:
TRANSLATION:
|