next up previous contents
Next: Equivalence and Partial Order Up: Descriptive ALIGN Directives Previous: Descriptive ALIGN Directives

Example

If the INHERIT directive is not used, explicit alignment of a dummy argument may be necessary to insure that no remapping takes place at the subprogram boundary. Here is an example:

      LOGICAL FRUG(128)
!HPF$ DISTRIBUTE (BLOCK) ONTO DANCE_FLOOR::FRUG
      CALL TERPSICHORE(FRUG(1:40:3))

The array section FRUG(1:40:3) is mapped onto abstract processors in the following manner:

12345678910111213141516
1 25
10 34
19
4 28
13 37
22
7 31
16 40

Suppose first that the interface to the subroutine TERPSICHORE looks like this:

      SUBROUTINE TERPSICHORE(FOXTROT)
      LOGICAL FOXTROT(:)
!HPF$ INHERIT FOXTROT

The template of FOXTROT is a copy of the 128 element template of the whole array FRUG. The template is mapped like this:

12345678910111213141516
191725334149576573818997105113121
2101826344250586674829098106114122
3111927354351596775839199107115123
41220283644526068768492100108116124
51321293745536169778593101109117125
61422303846546270788694102110118126
71523313947556371798795103111119127
81624324048566472808896104112120128
FOXTROT(I) is aligned with element 3*I-2 of the template.

Suppose, on the other hand, that the interface to TERPSICHORE were to look like this instead:

      SUBROUTINE TERPSICHORE(FOXTROT)
      LOGICAL FOXTROT(:)
!HPF$ DISTRIBUTE FOXTROT(BLOCK)

In this case, the template of FOXTROT is its natural template; it has the same size 14 as FOXTROT itself. The actual argument, FRUG(1:40:3) is mapped to the 16 processors in this manner:

Abstract
processor
Elements
of FRUG
11,2,3
24,5,6
37,8
49,10,11
512,13,14
6-16none

That is, the original positions (in the template of the actual argument) of the elements of the dummy are as follows:

12345678910111213141516
1 9
4 12
7
2 10
5 13
8
3 11
6 14

This layout (3 elements on the first processor, 3 on the second, 2 on the third, 3 on the fourth, ...) cannot properly be described as a BLOCK distribution. Therefore, remapping will take place at the call.

Remapping can be avoided without using INHERIT by explicitly aligning the dummy to a declared template of size 128 distributed BLOCK:

      SUBROUTINE TERPSICHORE(FOXTROT)
      LOGICAL FOXTROT(:)
!HPF$ TEMPLATE, DISTRIBUTE(BLOCK) ONTO DANCE_FLOOR::GURF(128)
!HPF$ ALIGN FOXTROT(I) WITH GURF(3*I-2)