# 1.5 High Performance Fortran Features

Compaq Fortran includes support for High Performance Fortran.

High Performance Fortran (HPF) is an industry consensus on a small set of de facto industry standard extensions to Fortran 90. These extensions augment Fortran 90's support for architecture-independent application development and allow portable, efficient, and scalable application development for a wide variety of parallel and serial hardware architectures. Some of the HPF extensions to Fortran 90 have been included in Fortran 95. HPF features include:

- The FORALL construct

  This construct is an element-by-element generalization of data parallel array operations that augments Fortran 90 array constructs. Every data parallel array operation can be represented as a FORALL generalization. The following example, which is not expressible using array syntax, sets diagonal elements of an array to 1:

      REAL, DIMENSION(N, N) :: A
      FORALL (I=1:N)  A(I, I) = 1

  For more information on the FORALL construct, see Section 4.2.5.

- Pure procedures

  A pure procedure is restricted from having side effects. References to pure procedures can be optimized in ways that non- pure procedure references cannot. An example of a pure procedure follows:

      PURE FUNCTION DOUBLE(X)
        REAL, INTENT(IN) :: X
        DOUBLE = 2 * X
      END FUNCTION DOUBLE

  Procedures must be pure to be referenced in FORALL constructs or INDEPENDENT (TU*X only) DO loops. For more information on pure procedures, see Section 8.5.1.2.

- New intrinsic functions

  The following are new intrinsic functions (or new arguments to Fortran 90 intrinsic functions):

  - The system inquiry functions NUMBER_OF_PROCESSORS and PROCESSORS_SHAPE; see Sections 9.3.112 and 9.3.119, respectively.
  - The optional DIM argument for intrinsic functions MAXLOC and MINLOC; see Sections 9.3.96 and 9.3.101, respectively.
  - The elemental intrinsic function ILEN; see Section 9.3.68.
- Extrinsic procedures that provide an interface between High Performance Fortran's data parallel computing model and other models such as message passing and scalar models.

  Fortran 90 provides the user view of a global name space and single logical thread of control. However, modern multiprocess computer systems provide different models of execution. The following prefixes can be used to specify alternative models of execution for individual procedures:

  - EXTRINSIC(HPF_SERIAL) specifies a model in which the execution target behaves as if it were a single process executing on a scalar computer system. This is the conventional Fortran programming model.
  - EXTRINSIC(HPF) is the default for HPF programs; it specifies a regular HPF procedure. The procedure can contain HPF directives, which advise the compiler about the distribution of data across processors. The processors operate simultaneously on different portions of the data, but from the point of view of the program, there is only a single thread of control.
  - EXTRINSIC(HPF_LOCAL) specifies a model in which multiple independent copies of the same procedure execute on different data on multiple processors. This is often called the Single Program Multiple Data (or SPMD) model. Any required communication or synchronization must be programmed explicitly by the user, typically using some form of message-passing library.

  Different models can be used in a single source program. For more information on the syntax of procedures using the EXTRINSIC prefixes, see Sections 8.5.2 and 8.5.3.

- Data placement directives that provide information describing alignment and distribution of data objects on Tru64 UNIX systems:
  - The DISTRIBUTE directive specifies the partitioning of data across processors.
  - The ALIGN directive specifies that corresponding data from two or more arrays is stored on the same processor.
  - The PROCESSORS directive specifies a conceptual arrangement of the processors for use in a DISTRIBUTE directive.
  - The TEMPLATE directive defines an empty index space for use in an ALIGN directive.

  These directives describe storage allocation for data without changing the meaning or results of the original program. The compiler uses the directives to schedule efficient parallel execution of the computation. For more information on these directives, see Section 15.3.

- The [NO]SEQUENCE directive

  This directive tells the compiler whether named (or all) data objects in a procedure do (SEQUENCE) or do not (NOSEQUENCE) depend on array element order or storage association. It is available on Tru64 UNIX systems. If SEQUENCE is specified, data objects cannot be mapped by data placement directives, except for certain strictly defined cases. For more information on the [NO]SEQUENCE directive, see Section 15.3.7.

- The INDEPENDENT directive

  This directive asserts that the statements in a particular DO loop or FORALL construct do not have any dependencies requiring sequential execution. It is available on Tru64 UNIX systems.

  When properly used, it does not change the semantics of the construct, but provides information to the compiler that can allow optimization. For example, the iterations of the following loop may be executed in any order:

      !HPF$ INDEPENDENT
      DO I = 1, N
        A(I) = B(I-1) + B(I+1)
      END DO

  For more information on the INDEPENDENT directive, see Section 15.3.4.

- High Performance Fortran library routines (TU*X only)

  These routines provide some basic operations that are valuable for parallel algorithm design and allow efficient implementation of higher-level computations on Tru64 UNIX systems. They include the following:

  - Mapping inquiry subroutines to determine the actual data mapping of arrays at run time
  - Bit manipulation functions LEADZ, POPCNT, and POPPAR
  - Array reduction functions IALL, IANY, IPARITY, and PARITY
  - Array combining scatter functions, one for each reduction function
  - Array prefix and suffix functions, one each for each reduction function
  - Two array sorting functions

  For more information on these routines, see Appendix G.

Previous Page Next Page Table of Contents