FDVM2 (1158347), страница 9
Текст из файла (страница 9)
SUBROUTINE SUB2
CDVM$ DISTRIBUTE B2 ( BLOCK, BLOCK )
COMMON /COM1/ X, Y(12), B2(12,30)
Declaration in subroutine. The error is another configuration of the array.
SUBROUTINE SUB3
CDVM$ DISTRIBUTE B3 ( *, BLOCK )
COMMON /COM1/ X, Y, B(30,12)
Declaration in subroutine. There is no errors.
SUBROUTINE SUB4
CDVM$ DISTRIBUTE B4 ( *, BLOCK )
COMMON /COM1/ X, Y, B(12,30)
9.Procedures
-
Procedure call inside distributed loop.
A procedure, called inside distributed loop, must not have side effects and contains processor exchanges (purest procedure). As a consequence, the purest procedure doesn't contain:
-
input/output statements;
-
FDVM directives;
-
assignment of values of COMMON block variables.
-
Procedure call outside distributed loop.
If the actual argument is explicitly mapped array (distributed by DISTRIBUTE or ALIGN), it should be passed without shape changing. It means, that actual argument is the reference to the array beginning, and configurations of actual and corresponding formal arguments are the same.
-
Formal arguments.
If the actual argument is a distributed array, then corresponding formal argument must have explicit or inherited distribution.
Explicit distribution is described by DISTRIBUTE and ALIGN directives with the following restriction: a formal argument can be aligned only with other formal argument. The explicit distribution of formal argument means, that before the procedure call a user must provide actual argument distribution in exact correspondence with formal argument distribution.
Inherited distribution is described by the directive
| inherit-directive | is INHERIT dummy-array-name-list |
Inherited distribution means that formal argument inherits a distribution of actual argument for each procedure call. Inherited distribution doesn't require from a user to distribute actual argument in correspondence with the formal argument.
REDISTRIBUTE and REALIGN directives can be applied to formal arguments, if actual and formal arguments have DYNAMIC attribute.
-
Local arrays.
In the procedure local arrays can be distributed by DISTRIBUTE and ALIGN directives. A local array can be aligned with formal argument. The DISTRIBUTE directive distributes the local array on the processor subsystem, on which the procedure was called (current subsystem). If a processor arrangement section is specified in DISTRIBUTE directive, then the number of the processors must be equal to the number of processors of the current subsystem. The number of current subsystem processors is defined by intrinsic function ACTIVE_NUM_PROC( ).
The special case is distributed local array with SAVE attribute. The following conditions must be satisfied for the array:
-
DISTRIBUTE and ALIGN directives have the identical parameters in each procedure call.
-
The array cannot be used in REDISTRIBUTE and REALIGN directives.
Example 9.1. Distribution of the local arrays and formal arguments.
SUBROUTINE DIST( A, B, C, N )
CHPF$ PROCESSORS PA ( ACTIVE_NUM_PROC( ) )
DIMENSION A(N,N), B(N,N), C(N,N), X(N,N), Y(N,N)
C explicit distribution of formal argument
CDVM$ DISTRIBUTE A ( *, BLOCK )
C aligned formal argument
CDVM$ ALIGN B( I, J ) WITH A( I, J )
C inherited distribution of the formal argument
CDVM$ INHERIT C
C aligning local array with formal argument
CDVM$ ALIGN X( I, J ) WITH C( I, J )
C distribution of the local array
CDVM$ DISTRIBUTE Y ( *, BLOCK ) ONTO PA
. . .
END
10. Input/Output
The statements of standard Fortran77 are used for data input/output in FDVM.
FDVM allows only restricted form of input/output statements for distributed arrays:
-
An input/output list may contain only one name of distributed array and may not contain other input/output items.
-
Only «*» format specifier may be used in formatted I/O statement.
-
A control information list may not contain ERR, END and IOSTAT specifiers.
-
Any variable specified in a control information list must be replicated variable.
The statements of distributed array input/output cannot be used in distributed loop and in task region.
Input/output statements for replicated variables have the following restrictions:
-
A control information list may not contain ERR and END specifiers.
-
Only the following simplified form of the implicit loop is allowed
(A(i1,i2,...,I), I = n1,n2)
when inputting replicated assumed-size array.
Input statement, INQUIRE statement, and any other input/output statement with controlled parameter IOSTAT may not be used in a distributed loop.
Note that FDVM program performing unformatted I/O of distributed arrays is not compatible with serial Fortran 77 program in common case. Data written by one program may not be read by the other one because of difference in record length.
References
-
N.A.Konovalov, V.A.Krukov, S.N.Mihailov and A.A.Pogrebtsov, «Fortran-DVM language for portable parallel programs development», Proceedings of Software For Multiprocessors & Supercomputers: Theory, Practice, Experience (SMS-TPE 94),Inst. for System Programming RAS, Moscow, Sept. 1994.
-
ANSI X3.9-1978 Programming Language Fortran. New York 1978.
-
High Performance Fortran Forum. High Performance Fortran Language Specification. Version 2.0, January 31, 1997.
-
Y.Hu, S.L.Johnsson, S.-H.Teng. High Performance Fortran for Highly Irregular Problems. CACM, v.32, N.7, 1997, pp.13-24.
Annex 1. Syntax
2.4. Syntax of FDVM Directives
| directive-line | is CHPF$ hpf-directive |
| or *HPF$ hpf-directive | |
| or CDVM$ dvm-directive | |
| or *DVM$ dvm-directive |
| dvm-directive | is specification-directive |
| or executable-directive |
| specification-directive | is processors-directive |
| or align-directive | |
| or distribute-directive | |
| or template-directive | |
| or pointer-directive | |
| or shadow-directive | |
| or dynamic-directive | |
| or inherit-directive | |
| or remote-group-directive | |
| or indirect-group-directive |
| executable-directive | is realign-directive |
| or redistribute-directive | |
| or parallel-directive | |
| or remote-access-directive | |
| or indirect-access-directive | |
| or shadow-group-directive | |
| or shadow-start-directive | |
| or shadow-wait-directive | |
| or reduction-group-directive | |
| or reduction-start-directive | |
| or reduction-wait-directive | |
| or own-directive | |
| or prefetch-directive | |
| or reset-directive | |
| or task-directive | |
| or map-directive | |
| or task-region-directive | |
| or end-task-region-directive | |
| or on-directive | |
| or end-on-directive |
Constraints:
-
A directive-line follows the rules of fixed form comment lines.
-
A specification-directive may appear only where a specification statement may appear.
-
An executable-directive may appear only where executable statement may appear.
-
Any expression, included in specification directive, must be the specification expression.
3. Virtual Processor Arrangements. PROCESSORS Directive
| processors-directive | is PROCESSORS processors-decl-list |
| processors-decl | is processors-name [ ( explicit-shape-spec-list ) ] |
4.1. DISTRIBUTE and REDISTRIBUTE Directives
| 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 |
| or pointer-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 )] | |
| or task-name ( task-index ) | ||
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 DISTRIBUTE directive.
-
dist-format-list can be omitted in DISTRIBUTE directive only. In that case distributed array can be used after REDISTRIBUTE directive only.
| dynamic-directive | is DYNAMIC dist-array-name-list |
4.2.2. Dynamic Arrays in FDVM Model. POINTER Directive
| pointer-directive | is type , POINTER ( dimension-list ) :: pointer-name-list |
| dimension | is : |
| pointer-name | is scalar-int-variable-name |
| or int-array-name |
Constraints:
-
Only value of function ALLOCATE or a value of other variable with attribute POINTER can be assigned to the variable with POINTER attribute.
-
A number of dimensions in left and right sides of the statement assigning value to the variable with POINTER attribute must be the same.
4.3.1. ALIGN and REALIGN Directives
| align-directive | is align-action alignee align-directive-stuff |
| or align-action [ align-directive-stuff ] :: alignee‑list | |
| align-action | is ALIGN |
| or REALIGN | |
| align-directive-stuff | is ( align-source-list ) align-with-clause [, NEW_VALUE [( dist-array-name-list)] ] |
| alignee | is array-name |
| or pointer-name |
| align-source | is * |
| or align-dummy |
| align-dummy | is scalar-int-variable |















