[DBPP] previous next up contents index [Search]
Next: 7.7 Performance Issues Up: 7 High Performance Fortran Previous: 7.5 Dummy Arguments and Modularity

7.6 Other HPF Features

In this section, we discuss several miscellaneous aspects of HPF; we also list HPF features not covered in this book.

7.6.1 System Inquiry Intrinsic Functions

 

  HPF introduces a small set of intrinsic functions in addition to those defined in F90. The two most relevant to parallel program   design are the system inquiry functions NUMBER_OF_PROCESSORS and   PROCESSORS_SHAPE. These functions allow a program to obtain information about the number of physical processors on which it executes and the topology connecting these processors. This information can be used to write programs that run efficiently on varying numbers of processors and processor configuration. The functions are modeled on the F90 inquiry functions SIZE and SHAPE, respectively, and provide a view of the underlying computer as a rectilinear, multidimensional processor array. A call to NUMBER_OF_PROCESSORS has the general form NUMBER_OF_PROCESSORS(dim)

where dim is an optional argument. A call to this function returns the number of processors in the underlying array or, if the optional argument is present, the size of this array along a specified dimension. A call to PROCESSORS_SHAPE has the following general form. PROCESSORS_SHAPE()

It returns an array with rank (dimension) one and with size the rank of the underlying processor array. The i th element gives the size of the underlying array in its i th dimension.

 
Figure 7.8: Examples of values returned by HPF system inquiry intrinsic functions.  

The representation of a particular physical computer as a processor array is implementation dependent and not specified in HPF. Two representative examples are presented in Figure 7.8. System inquiry functions can be included in array declarations and HPF directives, hence permitting a program to declare abstract processor arrays that match available physical resources. For example, in the following code the first directive declares an abstract processor array P with size equal to the number of physical processors.   The F90 inquiry function SIZE is then used to declare an integer   array Q with size corresponding to the rank (dimension) of the physical processor array.

    !HPF$    PROCESSORS P(NUMBER_OF_PROCESSORS())
             integer Q(SIZE(PROCESSORS_SHAPE()))

7.6.2 Storage and Sequence Association

 

  Both F77 and F90 allow programmers to write programs that depend on a   linear storage model, that is, a view of memory as linear, one dimensional, and sequentially addressed. This is the case if a program depends on storage association, using common or equivalence statements to align storage locations. (This might be done to reuse storage, for example.) It is also the case if a   program relies on sequence association, for example, passing an array as an actual argument and then declaring the corresponding dummy argument to have a different size or shape.

Storage and sequence association are not natural concepts when data are distributed over multiple processors.   If always enforced in an HPF compiler, they could compromise performance.   Therefore, HPF states that by default, storage and sequence association are not supported. Hence, without the use of additional directives, it not possible to do the following:

  1. Pass an array element as an actual argument to a subroutine, and declare the corresponding dummy argument to be an array.

  2. Pass an array or array section as an actual argument to a subroutine, and declare the corresponding dummy argument to have a different size or shape.

  3. Pass an assumed size array (an array declared with a dimension of *, for example, DIMENSION(32,*)) as as an actual argument.

  4. Declare the same COMMON block to contain different variables in different parts of a program, or use the EQUIVALENCE statement except in certain restricted cases.

In order to support conversion of existing codes that rely on storage and sequence association to HPF, the SEQUENCE directive is   provided to request that storage and sequence association be enabled for specified variables. Because this directive is intended only to support conversion of existing Fortran 77 codes and is not directly relevant to data-parallel programming, we do not discuss it further here.

7.6.3 HPF Features Not Covered

For simplicity, we have focused on a subset of the HPF language. In particular, we have described most of the HPF subset, which is a set of HPF constructs providing sufficient functionality to permit development of useful programs, while avoiding difficult implementation problems. Of necessity, numerous subtleties have been omitted in this brief description, and the following HPF features have not been covered at all.

  1. Templates. The TEMPLATE directive allows a programmer to   declare an abstract index space that can be distributed and used as an   alignment target in the same way as an array can. This is useful when several arrays must be aligned relative to each other, but there is no need to define a single array that spans the entire index space of interest.

  2.   Mapping inquiry intrinsic functions. These functions allow a program to determine the actual mapping of an array to processors. They are useful when the extrinsic function facility (described in item 7 of this list) is used to call non-HPF subprograms.

  3. FORALL construct. This more general form of the   FORALL statement can control multiple assignments, masked array assignments, and nested FORALL statements and constructs. This construct broadens the range of algorithms that can be expressed using FORALL.

  4. PURE procedures. A function or subroutine declared to be   PURE can be called in FORALL statements. A PURE function   causes no side effects; that is, it does not perform I/O or modify   dummy arguments or global data. A PURE subroutine may modify arguments but not global variables. This facility broadens the range of algorithms that can be expressed using the FORALL statement, for example by allowing the same function to be applied to each row or column of an array.

  5.   Dynamic data distribution. The executable directives   REDISTRIBUTE and REALIGN can be used to modify the distribution   and alignment of a data structure if that data structure is declared   to have attribute DYNAMIC. The HPF compiler and runtime system perform any data movement that may be required. This facility makes it easier to use different distributions in different parts of a computation, as discussed in Section 7.5.

  6.   Computational library. For each reduction operation in F90 (e.g., SUM and MAXVAL), HPF provides corresponding combining scatter, parallel prefix, and parallel suffix operations (e.g., SUM_SCATTER, SUM_PREFIX, and SUM_SUFFIX). Functions for   sorting and for counting bits in an integer array are also provided.   This computational library broadens the set of global operations   available to the programmer. (The combining scatter operations allow   elements of one array to be scattered to the elements of another array, under the control of index arrays. A parallel   prefix using an operation of a sequence X yields a sequence Y of the same size, with each element   Y(j) = (X). That is, each element is a   function of the preceding elements. A parallel suffix is   the same as a parallel prefix except that each element is a function of the elements that follow it rather than those that precede it.)

  7. Extrinsic functions. HPF programs can call non-HPF procedures as   extrinsic procedures. The non-HPF procedure is invoked on every processor, and the local components of distributed arrays named in the interface are passed as arguments. This facility can be used to invoke MIMD procedures developed with message-passing systems such as MPI.



[DBPP] previous next up contents index [Search]
Next: 7.7 Performance Issues Up: 7 High Performance Fortran Previous: 7.5 Dummy Arguments and Modularity

© Copyright 1995 by Ian Foster