Keywords: slug

Next: Quick Reference Guides Up: Example Programs Previous: Example Program #2

# HPF Interface to ScaLAPACK

We are investigating issues related to interfacing ScaLAPACK with High Performance Fortran (HPF) [91]. As a part of this effort, we have provided prototype interfaces to some of the ScaLAPACK routines. We are collecting user feedback on these codes, as well as allowing additional time for compiler maturation, before providing a more complete interface.

Initially, interfaces are provided for the following ScaLAPACK routines: the general and symmetric positive definite linear equation solvers (PxGESV and PxPOSV), the linear least squares solver (PxGELS), and the PBLAS matrix multiply routine (PxGEMM).

          LA_GESV(A, B, IPIV, INFO)
             TYPE, intent(inout), dimension(:,:) :: A, B
             integer, optional, intent(out) :: IPIV(:), INFO

          LA_POSV(A, B, UPLO, INFO)
             TYPE, intent(inout), dimension(:,:) :: A, B
             character(LEN=1), optional, intent(in) :: UPLO
             integer, optional, intent(out) :: INFO

          LA_GELS(A, B, TRANS, INFO)
             TYPE, intent(inout), dimension(:,:) :: A, B
             character(LEN=1), optional, intent(in) :: TRANS
             integer, optional, intent(out) :: INFO

          LA_GEMM(A, B, C, transA, transB, alpha, beta)
             TYPE, intent(in), dimension(:,:) :: A, B
             TYPE, intent(inout), dimension(:,:) :: C
             character(LEN=1), optional, intent(in) :: transA, transB
             TYPE, optional, intent(in) :: alpha, beta

With this interface, all matrices are inherited, and query functions are used to determine the distribution of the matrices. Only when ScaLAPACK cannot handle the user's distribution are the matrices redistributed. In such a case, it is done transparently to the user, and only performance will show that it has occurred.

The prototype interfaces can be downloaded from netlib at the following URL:

> `http://www.netlib.org/scalapack/prototypes/slhpf.tar.gz`

Questions or comments on these routines may be mailed to `scalapack@cs.utk.edu`.

The following example code is a complete HPF code calling and testing the ScaLAPACK LU factorization/solve in HPF.

This program is also available in the scalapack directory on netlib
(http://www.netlib.org/scalapack/examples/sample_hpf_gesv.f).

          program simplegesv
          use HPF_LAPACK
          integer, parameter :: N=500, NRHS=20, NB=64, NBRHS=64, P=1, Q=3
          integer, parameter :: DP=kind(0.0D0)
          integer :: IPIV(N)
          real(DP) :: A(N, N), X(N, NRHS), B(N, NRHS)
    !HPF$ PROCESSORS PROC(P,Q)
    !HPF$ DISTRIBUTE A(cyclic(NB), cyclic(NB)) ONTO PROC
    !HPF$ DISTRIBUTE (cyclic(NB), cyclic(NBRHS)) ONTO PROC :: B, X

    !
    !     Randomly generate the coefficient matrix A and the solution
    !     matrix X.  Set the right hand side matrix B such that B = A * X.
    !
          call random_number(A)
          call random_number(X)
          B = matmul(A, X)
    !
    !     Solve the linear system; the computed solution overwrites B
    !
          call la_gesv(A, B, IPIV)
    !
    !     As a simple test, print the largest difference (in absolute value)
    !     between the computed solution (B) and the generated solution (X).
    !
          print*,'MAX( ABS(X~ - X) ) = ',maxval( abs(B - X) )
    !
    !     Shutdown the ScaLAPACK system, I'm done
    !
          call SLhpf_exit()

          stop
          end