FDVM2 (1158347), страница 2
Текст из файла (страница 2)
Syntax.
| processors-directive | is PROCESSORS processors-decl-list |
| processors-decl | is processors-name [ ( explicit-shape-spec-list ) ] |
The intrinsic function NUMBER_OF_PROCESSORS ( ) can be used to determine a number of real processors, provided to a program.
It is possible to use several virtual processor arrangements of different shape if the number of processors in every arrangement is equal to the value of function NUMBER_OF_PROCESSORS ( ). If two virtual processor arrangements have the same shape, then corresponding elements of the arrangements are referred to the same virtual processor.
Example 3.1. Declaration of virtual processor arrangements.
CHPF$ PROCESSORS P( N )
CHPF$ PROCESSORS Q( NUMBER_OF_PROCESSORS( ) ),
CHPF$*R(2, NUMBER_OF_PROCESSORS( )/2)
The value N has to be equal to the value of the function NUMBER_OF_PROCESSORS ( ).
The processor arrangements are local objects of the procedure. Data arrays with COMMON and SAVE attributes can be mapped on the local processor arrangements, if whenever the procedure is called, the local processor arrangement has the same shape.
4.Data Mapping
FDVM supports distribution by blocks (equal and non-equal), inherited distribution, dynamic array distribution and distribution via alignment.
4.1. DISTRIBUTE and REDISTRIBUTE Directives
Syntax.
| distribute-directive | is dist-action distributee dist-directive-stuff |
| or dist-action [ dist-directive-stuff ] :: distributee-list |
| dist-action | is DISTRIBUTE |
| or REDISTRIBUTE |
| dist-directive-stuff | is dist-format-list [ dist-onto-clause ] [, NEW_VALUE [( dist-array-name-list)] ] |
| distributee | is array-name |
| dist-format | is BLOCK |
| or GEN_BLOCK ( block-array-name ) | |
| or * |
| dist-onto-clause | is ONTO dist-target |
| dist-target | is processors-name [( section-subscript-list )] |
Constraints:
-
A length of list dist-format-list must be equal to the array rank. That is, distribution format must be specified for every dimension.
-
A number of distributed dimensions of the array (format is not specified as *) has to be equal to the number of dimensions of dist-target.
-
The array block-array-name in GEN_BLOCK specification must be one-dimensional integer array, with size equal to the size of corresponding dimension of processor arrangement, and a sum of its element values is equal to the size of distributed dimension.
-
NEW_VALUE specification can not be used in directive DISTRIBUTE.
-
dist-format-list can be omitted in DISTRIBUTE directive only. In that case distributed array can be used after REDISTRIBUTE directive only.
The ONTO clause specifies the virtual processor arrangement or its section. If ONTO clause is omitted, than array distribution is performed by base virtual processor arrangement, that is a parameter of program startup.
The array with DISTRIBUTE specification can be redistributed by REDISTRIBUTE directive, if to specify the array by DYNAMIC directive.
Syntax.
| dynamic-directive | is DYNAMIC dist-array-name-list |
If the array will be renewed after redistribution the array must be specified in NEW_VALUE specification.
Let us consider distribution formats for one dimension of the array (one-dimensional array A(N)) and for one dimension of the processor arrangement (one-dimensional array R(P)). Multi-dimensional distributions are considered in section 4.1.4.
4.1.1. BLOCK Format
An array dimension is split onto P blocks. The block sizes can differ from each other maximally by N/P elements. The first P-1 blocks contains N/P elements and the last one contains the rest.
Example 4.1. Distribution by BLOCK format.
| A | B | C | ||||
| R(1) | 1 | 1 | 1 | |||
| 2 | 2 | 2 | ||||
| CHPF$ PROCESSORS R( 4 ) | 3 | 3 | 3 | |||
| 4 | ||||||
| REAL A (12), B(13), C(11) | R(2) | 4 | 5 | 4 | ||
| 5 | 6 | 5 | ||||
| 6 | 7 | 6 | ||||
| CHPF$ DISTRIBUTE A (BLOCK) ONTO R | 8 | |||||
| R(3) | 7 | 9 | 7 | |||
| CHPF$ DISTRIBUTE (BLOCK) ONTO R :: B | 8 | 10 | 8 | |||
| 9 | 11 | 9 | ||||
| 12 | ||||||
| CHPF$ DISTRIBUTE C (BLOCK) | ||||||
| R(4) | 10 | 13 | 10 | |||
| 11 | 11 | |||||
| 12 | ||||||
4.1.2. GEN_BLOCK Format
Distribution by blocks of different sizes allows affecting on processor loading balance for algorithms performing different volume of computations for different parts of data area.
Let NB( 1:P ) be an integer array. The following directive
CHPF$ DISTRIBUTE A( GEN_BLOCK(NB)) ONTO R
splits array A on P blocks. The block i of size NB( i ) is mapped on processor R( i ).
Here
| P | |
| NB( i ) N | |
| i=1 |
Example 4.2. Distribution by blocks of different size.
| A | ||
| R(1) | 1 | |
| CHPF$ PROCESSORS R( 4 ) | 2 | |
| R(2) | 3 | |
| INTEGER BS(4) | 4 | |
| 5 | ||
| 6 | ||
| DATA BS / 2, 4, 4, 2 / | ||
| R(3) | 7 | |
| 8 | ||
| REAL A(12) | 9 | |
| 10 | ||
| CHPF$ DISTRIBUTE A ( GEN_BLOCK( BS ) ) ONTO R | R(4) | 11 |
| 12 | ||
4.1.3. Format of *
Format of “*” means, that a dimension is localized on each processor (non-distributed or local dimension).
4.1.4. Multidimensional Distributions
For multidimensional distributions mapping format is specified for each dimension. The following correspondence is established between dimensions of the array to be distributed and the processor arrangement.
Let the processor arrangement has n dimensions. Number the dimensions not formatted as * from left to right d1, ..., dk. Then dimension di will be mapped on i-th dimension of processor arrangement. The condition k=n must be satisfied.
Example 4.3. One-dimensional distribution.
| CHPF$ PROCESSORS R1( 2 ) | Blocks A | Processors | ||||
| REAL A(100,100) | ||||||
| CHPF$ DISTRIBUTE A (BLOCK, *) ONTO R1 | 1 | 1 | 1 | |||
| 2 | 2 | 2 | ||||
Example 4.4. Two-dimensional distribution.
| CHPF$ PROCESSORS R2( 2, 2 ) | Blocks A | Processors | |||
| REAL A(100,100) | 1 | 2 | |||
| CHPF$ DISTRIBUTE A (BLOCK,BLOCK) | 1 | 2 | 1 | 1 | 3 |
| CHPF$*ONTO R2 | 3 | 4 | 2 | 2 | 4 |
4.2. Distribution of Dynamic Arrays
4.2.1. Dynamic Arrays in Fortran 77 Program
There are no features to deal with dynamic arrays in Fortran 77. So a user is forced to simulate dynamic memory by so called working arrays. The dynamic memory is described as a one-dimensional array of large size. The dynamic arrays of different shape are defined as continuous segments in the working array.
Example 4.5. Working array usage.
REAL W(100000)
READ (6 , *) N, M
C the arrays of size N N и M M are required in the program
CALL SUB1(W(1), N, W(1+N*N), M)
END
SUBROUTINE SUB1(A, N, B, M)
DIMENSION A(N , N), B(M , M)
. . .















