next up previous contents
Next: Aligning Allocatable Arrays Up: Alignment Syntax Previous: Reverse Strided Alignment Example

 

Practical Example of Alignment

Consider the following Fortran 90 program:

    PROGRAM Warty
     IMPLICIT NONE
     REAL, DIMENSION(4) :: C
     REAL, DIMENSION(8) :: D
     REAL, DIMENSION(2) :: E
      C = 1; D = 2
      E = D(::4) + C(::2)
    END PROGRAM Warty

Given the patterns of array references in the program Warty, we would make the decision to align the arrays as stated on the slide. Our main concern is to minimise the communications in a program.

The main assignment combines E(1) with D(1) and C(1); E(2) with D(5) and C(3); E(3) with D(9) and C(5) and so on. We can use the subscript-triplet expressions in the assignment as the basis for our alignment specification:

should be given these HPF directives to ensure minimal (zero) communications:

!HPF$ ALIGN C(:) WITH D(::2)
!HPF$ ALIGN E(:) WITH D(::4)
!HPF$ DISTRIBUTE (BLOCK) :: D

This alignment that is given will result in zero communications.

(Clearly this is an artificial example. In the real world, there will be many different assignments and it will be much tougher to choose a good alignment. This is one of the most difficult area of HPF programming.)

Return to corresponding overview page gif


next up previous contents
Next: Aligning Allocatable Arrays Up: Alignment Syntax Previous: Reverse Strided Alignment Example

©University of Liverpool, 1997
Wed May 28 20:20:27 BST 1997
Not for commercial use.