hpfLDe (Раздаточные материалы)
Описание файла
Файл "hpfLDe" внутри архива находится в следующих папках: Раздаточные материалы, stage-fin. Документ из архива "Раздаточные материалы", который расположен в категории "". Всё это находится в предмете "модели параллельных вычислений и dvm технология разработки параллельных программ" из 7 семестр, которые можно найти в файловом архиве МГУ им. Ломоносова. Не смотря на прямую связь этого архива с МГУ им. Ломоносова, его также можно найти и в других разделах. .
Онлайн просмотр документа "hpfLDe"
Текст из документа "hpfLDe"
10
Keldysh Institute of Applied Mathematics
Russian Academy of Sciences
Enhanced Subset of High Performance Fortran
(HPF-DVM)
Language specification
April, 2001
Contents
1 Introduction 3
2 HPF features in subset HPF-DVM 3
3 Syntax of directives 3
4 DISTRIBUTE and REDISTRIBUTE directives 3
5 ALIGN and REALIGN directives 4
6 PROCESSORS directive 4
7 INDEPENDENT directive 4
8 Procedures 5
9 COMMON and EQUIVALENCE statements 5
10 Input/Output statements 5
References 6
Annex. Code examples 7
Example 1. Gauss elimination algorithm 7
Example 2. Jacobi algorithm 8
Example 3. Red-black successive over-relaxation 9
1Introduction
This document specifies the enhanced subset of High Performance Fortran [1] (HPF‑DVM).
Subset HPF-DVM inludes:
-
All Fortran 77 standard [2] conforming features except for storage and sequence association (see sections 8,9).
-
Subset of HPF directives (see section 2).
The HPF features included in HPF-DVM are a subset of the full HPF language chosen for their performance and their broad portability and ease of use.
Fortran 77 was selected as a base language to provide multi-machine portability, since Fortran 90 compilers are not available on all platforms.
HPF-DVM implementation is made using DVM model.
2HPF features in subset HPF-DVM
Subset HPF-DVM is based on Fortran 77 standard and includes the following HPF1 directives.
Directives | Constraints |
PROCESSORS | section 6 |
DISTRIBUTE | section 4 |
REDISTRIBUTE | section 4 |
ALIGN | section 5 |
REALIGN | section 5 |
INHERIT | no |
DYNAMIC | no |
TEMPLATE | no |
INDEPENDENT | section 7 |
Other HPF1 directives and language extensions are not included in the subset HPF‑DVM.
3Syntax of directives
A hpf-directive-line follows the rules of fixed form comment lines only.
4DISTRIBUTE and REDISTRIBUTE directives
The following restrictions are imposed on DISTRIBUTE and REDISTRIBUTE directives:
-
An dist-format is BLOCK or *.
-
An dist-target may not be * processors-name or * (see section 8).
5ALIGN and REALIGN directives
The following restrictions are imposed on ALIGN and REALIGN directives:
-
Reversing axes, as
CHPF$ ALIGN A(I) WITH B(100–I)
is not permitted.
-
An align-spec may not be * align-target (see section 8).
-
An align-subscript-use expression must follow the syntax rules:
align-subscript-use | is [ primary-expr * ] align‑dummy | ||
primary-expr | is int-constant | ||
or int-variable | |||
or ( int-expr ) |
6PROCESSORS directive
An explicit-shape-spec-list must be always specified in PROCESSORS directive.
Only the intrinsic function NUMBER_OF_PROCESSORS() may be used to inquire about the total number of physical processors.
7INDEPENDENT directive
The INDEPENDENT directives may be applied only to tightly nested loops.
The iteration space of INDEPENDENT loop nest must be rectangular. That is, the lower loop bound, the upper loop bound, and the step expression for each INDEPENDENT loop must be invariant with regard to INDEPENDENT nest.
Left side of each assignment statement in INDEPENDENT nest may be only a variable with DISTRIBUTE, ALIGN, INHERIT, NEW or REDUCTION attribute.
Left sides of assignment statements of one loop iteration must be allocated at the same processor and, therefore, the loop iteration is executed on the processor entirely.
A DO-variable of INDEPENDENT loop may index distributed dimension of array only by expression of the form
a * DO-variable ± b
The integer values a and b must be invariant with regard to the INDEPENDENT loop nest.
Private (not INDEPENDENT) loops may occur inside or outside of the INDEPENDENT loop nest. A DO-variable of inside loop may index only local dimension of an array.
Syntax and semantics of REDUCTION specification correspond to HPF2 [3].
8Procedures
-
Procedure call inside the INDEPENDENT loop.
A procedure, called inside INDEPENDENT loop, must be free of side-effects and must not cause communication (pure procedure).
-
Procedure call outside INDEPENDENT loop.
If the actual argument is explicitly mapped array (distributed by DISTRIBUTE or ALIGN directive), it should be passed without reshaping. 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 inherited distribution.
9COMMON and EQUIVALENCE statements
The arrays, distributed by default, can be used in COMMON blocks and EQUIVALENCE statements without restrictions.
The arrays, distributed by DISTRIBUTE or ALIGN directive, can't be used in EQUIVALENCE statements. Moreover, these arrays can't be associated with other data objects. Explicitly distributed arrays can be the components of COMMON block under the following conditions:
-
COMMON block must be described in main program unit.
-
Every occurrence of the COMMON block must have the same number of components and each corresponding component must have a storage sequences of the same size;
-
If explicitly mapped array is the component of the COMMON block, then the array declarations in different program units must specify the same data type and shape. The DISRIBUTE and ALIGN directives, applied to the array, must have the identical parameters.
10Input/Output statements
HPF-DVM allows only restricted form of input/output statements for distributed arrays:
-
An input/output list may contain only one name of explicitly 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 variable distributed by default.
The statements of distributed array input/output cannot be used in INDEPENDENT loop.
Input/output statements for variables distributed by default 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 assumed-size array distributed by default.
Input statement, INQUIRE statement, and any other input/output statement with parameter IOSTAT may not be used in an INDEPENDENT loop.
References
-
High Performance Fortran Forum. High Performance Fortran Language Specification. Version 1.0
-
ANSI X3.9-1978 Programming Language Fortran. New York 1978.
-
High Performance Fortran Forum. High Performance Fortran Language Specification. Version 2.0.
-
Annex. Code examples
Three small scientific programs are presented to illustrate HPF-DVM language features. They are intended for solving a system of linear equations:
A x = b
where: A - matrix of coefficients,
b - vector of free members,
x - vector of unknowns.
The following basic methods are used for solving this system.
Direct methods. The well-known Gaussian Elimination method is the most commonly used algorithm of this class. The main idea of this algorithm is to reduce the matrix A to upper triangular form and then to use backward substitution to diagonalize the matrix.
Explicit iteration methods. Jacobi Relaxation is the most known algorithm of this class. The algorithm perform the following computation iteratively
xi,jnew = (xi-1,jold + xi,j-1old + xi+1,jold + xi,j+1old ) / 4
Implicit iteration methods. Successive Over Relaxation (SOR) refers to this class. The algorithm performs the following calculation iteratively
xi,jnew = ( w / 4 ) * (xi-1,jnew + xi,j-1new + xi+1,jold + xi,j+1old ) + (1-w) * xi,jold
By using «red-black» coloring of variables each step of SOR consists of two half Jacobi steps. One processes «red»variables and the other processes «black» variables. The half Jacobi step calculations are data-independent.
Example 1. Gauss elimination algorithm
PROGRAM GAUSS
C Solving linear equation system Ax = b
PARAMETER ( N = 100 )
REAL A( N, N+1 ), X( N )
C A : Coefficient matrix with dimension (N,N+1)
C Right hand side vector of linear equations is stored
C in last (N+1)-th column of matrix A
C X : Vector of unknowns
C N : Number of linear equations
*HPF$ DISTRIBUTE A (BLOCK,*)
*HPF$ ALIGN X(I) WITH A(I,N+1)
C Initialization
*HPF$ INDEPENDENT
DO 100 I = 1, N
DO 100 J = 1, N+1
IF (( I .EQ. J ) THEN
A(I,J) = 2.0
ELSE
IF ( J .EQ. N+1) THEN
A(I,J) = 0.0
ENDIF
ENDIF
100 CONTINUE
C
C Elimination
C
DO 1 I = 1, N
*HPF$ INDEPENDENT
DO 5 J = I+1, N
DO 5 K = I+1, N+1
A(J,K) = A(J,K) - A(J,I) * A(I,K) / A(I,I)
5 CONTINUE
1 CONTINUE
C First calculate X(N)
X(N) = A(N,N+1) / A(N,N)
C
C Solve X(N-1), X(N-2), ...,X(1) by backward substitution
C
DO 6 J = N-1, 1, -1
*HPF$ INDEPENDENT
DO 7 I = 1, J
A(I,N+1) = A(I,N+1) - A(I,J+1) * X(J+1)
7 CONTINUE
X(J) = A(J,N+1) / A(J,J)
6 CONTINUE
PRINT *, X
END
Example 2. Jacobi algorithm
PROGRAM JACOBI
PARAMETER (K=8, ITMAX=20)
REAL A(K,K), B(K,K)
*HPF$ DISTRIBUTE A (BLOCK, BLOCK)
*HPF$ ALIGN B(I,J) WITH A(I,J)
C arrays A and B with block distribution
PRINT *, '******** TEST_JACOBI_HPF ********'
C nest of two independent loops, iteration (i,j) will be executed
C on processor, which is owner of element A(i,j)
*HPF$ INDEPENDENT