CDVM2 (1158340), страница 5
Текст из файла (страница 5)
DVM(OWN) X[J] = A[J][N] / A[J][J]
}
Note, that A[J][N+1] and A[J][J] are localized on the processor, where X[J] is allocated.
6. Access to remote data
Remote data can be used in the distributed loop or in statements of own computations. Distributed loop iteration is executed exclusively on single processor. If in the loop iteration (in statement) the values of array elements, allocated on the other processors, are used, then these values are called remote data. The references to such elements are called remote references. The similar notions are defined for own computation statement. It is necessary to distinguish two kinds of remote references:
-
remote regular references - distributed dimensions are indexed by expressions of the form a*I + b;
-
remote irregular references - distributed dimensions are indexed by elements of matrix ME[I][J].
Note that local (non-distributed) array dimension indexing can be arbitrary.
The access to remote data requires the following operations performing
-
buffer distribution.
-
replacement of references to the array by references to the buffer,
-
organization of data exchange between processors to fill the buffers.
Low level models of message passing (like MPI) requires "manual" programming of all these operations. Data parallel systems (like HPF[2]) assume automatic execution of the operations. DVM supposes compromise model: high level model of specifications of remote data and group exchange operations and a possibility for a user to optimize remote data access.
6.1. Regular remote references
6.1.1. Shadow edges group. SHADOW_RENEW specification.
Remote data access may be organized using shadow edges of the array local section, if the indexes of remote references has the form I d , where d is a constant.
Consider the following example
float A[100], B[100];
for(i=1; i<98, i++)
A[I] = (B[I-1] + B[I+1] + B[I+2] ) / 3.;
In this example it is impossible to align the arrays in such a way, that all elements, used in I-th iteration, were allocated on the same processor. Consider distribution of array B with shadow edges on the three neighbor processors.
| P-1 | P | P+1 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| V | V | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| | | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Fig.6.1. Distribution of array with shadow edges.
Two buffers, that are continuous prolongation of the array local section, are distributed on each processor. The left shadow edge width is equal to 1 element (for B[I-1]), right shadow edge width is equal to 2 elements ( for B[I+1] and B[I+2]). If before loop entering to perform processor exchange according to scheme on fig. 6.1, then the loop can be executed on each processor without replacing references to arrays by references to the buffer.
To specify remote access through shadow edges CDVM provides the following directives.
Description of maximal size of shadow edges.
| shadow-directive | ::= SHADOW shadow-array-string |
| shadow-array | ::= array-name shadow-edge-string |
| shadow-edge | ::= [ width ] |
| | [ low-width : high-width ] |
| width | ::= int-expr |
| low-width | ::= int-expr |
| high-width | ::= int-expr |
Constraint. Left shadow edge width (low-width) and right shadow edge width (high-width) must be non-negative integer constants.
Specification [width] of shadow edge width is equivalent to the specification [width : width].
The width of the both shadow edges of a distributed array is equal to 1 by default for each array dimension.
If it is needed to update shadow edges prior to a distributed loop execution, then SHADOW_RENEW clause is specified in PARALLEL directive.
| shadow-renew-clause | ::= SHADOW_RENEW renewee‑string |
| renewee | ::= dist-array-name [ shadow-edge-string ] [ CORNER ] |
Constraints:
-
Width of the shadow edges filled by values must not exceed the maximal width specified initially in the SHADOW directive.
-
If shadow edge widths is not specified, then the maximal widths are used.
Example 6.1. Remote access through shadow edges.
DVM(DISTRIBUTE [BLOCK]) float A[100];
DVM(ALIGN [I] WITH A[ I] ; SHADOW B[1:2]) float B[100];
. . .
DVM(PARALLEL [I] ON A[I]; SHADOW_RENEW B )
DO(I,1, 97,1)
A[I] = (B[I-1] + B[I+1] + B[I+2] ) / 3.;
When renewing shadow edges the maximal widths 1:2 specified in SHADOW directive are used.
Shadow edges for multidimensional distributed arrays can be distributed along each dimension. A special case is when remote reference points to "a corner" of shadow edges. In such a case it is needed to specify additional parameter CORNER.
Example 6.2. Remote access through "corners of shadow edges.
DVM(DISTRIBUTE [BLOCK][BLOCK]) float A[100][100];
DVM(ALIGN [i][j] WITH A[i][j]) float B[100][100];
. . .
DVM(PARALLEL [I][J] ON A[I][J]; SHADOW_RENEW B (CORNER))
DO( I, 1, 98, 1)
DO( J, 1, 98, 1)
A[I][J] = (B[I][J+1] + B[I+1][J] + B[I+1][J+1] ) / 3.;
The widths of shadow edges of the array B are equal to 1 element for all dimensions by default. As "corner" reference B[I+1][J+1] exists, the CORNER parameter is specified.
The other way to access through shadow edges is described in section 6.4.1.
6.1.2. Group of regular remote references. REMOTE_ACCESS directive
If the indexes of remote references have the form a*I b, then these references must be specified in REMOTE_ACCESS directive.
| remote-access-directive | ::= REMOTE_ACCESS [ remote-group-name : ] regular-reference-string |
| regular-reference | ::= dist-array-name [ regular-subscript-string ] |
| regular-subscript | ::= [ int-expr ] |
| | [ do-variable-use ] | |
| | [] | |
| remote-access-clause | ::= remote-access-directive |
REMOTE_ACCESS directive can be used as a separate directive prior to own computation statement or as additional specification in PARALLEL directive.
If remote reference is specified as array name without index list, then all references to the array in a distributed loop (and in own computation statement) are regular remote references.
If symbol [] is specified as dimension index regular-subscript then any index along this dimension causes remote access.
A set of references in REMOTE_ACCESS directive without specification of group name (remote-group-name) is called unnamed reference group.
Semantics of the directive performing for unnamed reference group is to read the remote data in the buffer and replace remote references by references to the buffer.
Example 6.3. Using unnamed group of regular remote references.
DVM(DISTRIBUTE [][BLOCK]) float A[100][100], B[100][100];
. . .
DVM(REMOTE_ACCESS A[50][50] ) X = A[50][50];
. . .
DVM( REMOTE_ACCESS B[100][100] )
{DVM(OWN) A[1][1] = B[100][100];}
. . .
DVM(PARALLEL [I][J] ON A[I][J] ; REMOTE_ACCESS B[][N] )
FOR(I, 100)
FOR(J, 100)
A[I][J] = B[I][J] + B[I][N];
Two first REMOTE_ACCESS directives specify remote references for own computation statements. REMOTE_ACCESS directive in distributed loop specifies remote data (matrix column) as the array section for all loop iterations.
The following optimization of remote data access is possible:
-
loading remote data in advance to overlap computations and data exchange,
-
loading remote data for several loops in advance,
A named group of regular remote references is defined for these purposes.
Group name definition.
| remote-group-directive | ::= REMOTE_GROUP |
The identifier, specified in the directive, can be used only in REMOTE_ACCESS, PREFETCH and RESET directives.
| prefetch-directive | ::= PREFETCH group-name |
| reset-directive | ::= RESET group-name |
| group-name | ::= remote-group-name |
| | indirect-group-name |
Semantics of the directive execution.
An initial value of variable, declared as remote references group, is undefined.















