PGI High Performance Fortran (HPF) compiler Version 2.2 Available on HKUSUB

We are pleased to announce that the Portland Group (PGI)'s High Performance Fortran (HPF) compiler version 2.2 is available on hkusub.

HPF is a new standard programming language for supporting parallel programming. The advantage of using parallel programming over the traditional serial programming is to reduce the run time of a program by distributing its loads to more than one processor. There are experienced support staff in Computer Centre who can help you in using this parallel programming language. So, users are advised to consult the HPF support staff of Computer Centre before they start to use the language. 


What is HPF ?

High Performance Fortran (HPF) is a set of extensions to the Fortran 90 language. It allows systems of interconnected processors to be easily programmed:

It has been said that the comparsion between explicit message-passing programs and those developed with HPF is similar to the comparsion between assembler programs and programs developed with high level languages. This analogy is appropriate as HPF programs are simple to write but will not be as efficient as an explicit message-passing equivalent.

The HPF directives specify the location (or layout) of the data and the parallel array syntax, intrinsic functions, HPF library calls and HPF FORALL or INDEPENDENT DO loops specify the parallelism.

In theory, a Fortran 90 program can be passed unaltered through an HPF compiler and will be parallelised using the system defaults. This will not be the most effective way to parallelise code but in some cases will increase the speed significantly.


How to use the compiler

The compiler is available on hkusub, so you have to compile your programs there. However, the executable files it produces can be run on hkusua also.

To compile a HPF program, use the following command :

pghpf -Msmp -Mfreeform program.hpf -o program.exe
OR
npghpf program.hpf -o program.exe
Note: npghpf has the following option as default.

To run a program, use the following command :

program.exe -pghpf -np 4 -heapz 8m

Where -np 4 means using 4 processors.

There are 8 and 12 processors in hkusub and hkusua respectively, so users may use 1 to 8 processors in hkusub or 1 to 12 processors in hkusua.

Click here for the user manual of the compiler. 


A sample HPF program

Following is a sample program taken from the Fortran 90 standard manual, pp 296-298.  The code has been modified to make it a main program instead of a subroutine. The algorithm used is the Ising model. HPF directive has been added in the code so that the HPF compiler would know how to parallelize the program.

The sample program is for a 3-D Monte Carlo simulation of state transition. Each gridpoint is a logical variable whose value can be interpreted as spin-up or spin-down. The transition between states is governed by a local probabilistic process where all points change state at the same time. Each spin either flips to the opposite state or not depending on the state of its six nearest neighbours. Gridpoints on the edge of the cube are defined by cubic periodicity - in other words the grid is taken to be replicated in all dimensions in space.

This sample program has been tested on hkusub. Following is a comparsion of the elaspe running time using different number of processors.

Elapse time of running HPF Ising program on hkusub

This is the program code which will perform the desired transitions.

      MODULE Funkt
      CONTAINS
       FUNCTION RAND (m)
        INTEGER m
        REAL, DIMENSION(m,m,m) :: RAND
!The following directive tells HPF compiler how to distribute the array "RAND".
!HPF$ DISTRIBUTE RAND(BLOCK, BLOCK, BLOCK)
         CALL RANDOM_NUMBER(HARVEST = RAND)
        RETURN
       END FUNCTION RAND
      END MODULE Funkt
      PROGRAM TRANSITION
      USE Funkt
      IMPLICIT NONE
       INTEGER, PARAMETER :: n = 64
       INTEGER            :: iterations, i
       LOGICAL, DIMENSION(n,n,n) :: ising,     flips
       INTEGER, DIMENSION(n,n,n) :: ones,      count
       REAL, DIMENSION(n,n,n)    :: threshold
       REAL, DIMENSION(6)        :: p
!The following directive tells HPF compiler the relative position of elements of
!"ising", "flips", "ones", "threshold" with respect to "count".
!HPF$ ALIGN WITH count :: ising, flips, ones, threshold
!HPF$ DISTRIBUTE count(BLOCK,BLOCK,BLOCK)

       p = (/ 0.4, 0.5, 0.6, 0.7, 0.8, 0.9 /)

       iterations  = 100
       ising = RAND(n) .LE. 0.5

       DO i = 1,iterations
        ones = 0
        WHERE (ising) ones = 1
        count = CSHIFT(ones, -1, 1) + CSHIFT(ones, 1, 1) &
              + CSHIFT(ones, -1, 2) + CSHIFT(ones, 1, 2) &
              + CSHIFT(ones, -1, 3) + CSHIFT(ones, 1, 3)

        WHERE (.NOT.ising) count = 6 - count
        threshold = 1.0
        WHERE (count == 4) threshold = p(4)
        WHERE (count == 5) threshold = p(5)
        WHERE (count == 6) threshold = p(6)
        flips = RAND(n) .LE. threshold
        WHERE (flips) ising = .NOT. ising
       ENDDO
      END PROGRAM TRANSITION










Futher information

Training material on HPF is available from Computer Centre .

The HPF User Group is a place for High Performance Fortran users to share ideas and experience, and get up-to-date information about implementation and future directions.

The HKUSP2 parallel computer also has the PGI HPF compiler


If you have any further queries on the HPF compiler, please contact the undersigned.
 
 
 
 

Nick Chi 
Tel: 2859 8936 
E-mail: nhychi@hkusua.hku.hk
Woo Chat Ming 
Tel: 2857 8632 
E-mail: cmwoo@hkusua.hku.hk



[Contents] [Next] [Previous]