In HPF, variants of the innocent-looking assignment,

A = Bhide a variety of interesting communication patterns. The terms

As a first example consider:

!HPF$ PROCESSORS P(4) REAL A(50), B(50) !HPF$ DISTRIBUTE A(BLOCK) ONTO P !HPF$ DISTRIBUTE B(BLOCK) ONTO P A (1:49) = B (2:50)The assignment variable and expression are sections of arrays with the same distribution. But the alignments of their elements are shifted by one place relative to each another. In translating this assignment, some communication between neighbouring processes will be needed. The situation is illustrated in Figure 1. In a translation to a SPMD program, the communications might be implemented using the point-to-point primitives

The ``shift'' pattern of communication is actually quite common in
practical situations, and the next subsection will discuss it in
more detail. But it is slightly contrived as an example of an array
assignment. Usually the right- and left-hand-side arrays will not
have such a simple alignment relationship.
Here is another example involving array sections^{1}:

!HPF$ PROCESSORS P(4) REAL A(50,50), B(50) !HPF$ DISTRIBUTE A(*, BLOCK) ONTO P !HPF$ DISTRIBUTE B(BLOCK) ONTO P A (:, 1) = BIn this case the first dimension of

B = A (:, 1)then the communication pattern would correspond to the MPI operation

REAL A(50,50), B(50), C(50) !HPF$ DISTRIBUTE A(*, BLOCK) ONTO P !HPF$ DISTRIBUTE B(BLOCK) ONTO P !HPF$ ALIGN C(I) WITH A(I, *) C = Bthe communication pattern would be to broadcast all elements of the distributed array

Finally we can easily write assignments that behave like `MPI_ALLTOALL`
or `MPI_ALLTOALLV`. As an exercise the student may wish to verify
that the following example qualifies:

REAL A(50,50), B(50,50) !HPF$ DISTRIBUTE A(*, BLOCK) ONTO P !HPF$ DISTRIBUTE B(BLOCK, *) ONTO P A = Bas does:

REAL A(50), B(50) !HPF$ DISTRIBUTE A(BLOCK) ONTO P !HPF$ DISTRIBUTE B(CYCLIC) ONTO P A = B

On the one hand these examples illustrate the power of the HPF language. The effect of a complicated collective call in MPI can often be expressed very concisely in HPF as a simple array assignment. On the other hand, we get an idea of how complicated the communication patterns implied by simple-looking HPF statements can be.