Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP-MPI User's Guide > Chapter 3 Understanding HP-MPI

Compilation wrapper script utilities

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

 » Index

HP-MPI provides compilation utilities for the languages shown in Table 3-1 “Compiler selection”. In general, if a particular compiler is desired, it is best to set the appropriate environment variable such as MPI_CC. Without such a setting, the utility script will search the PATH and a few default locations for a variety of possible compilers. Although in many environments this search produces the desired results, explicitly setting the environment variable is safer. Command line options take precedence over environment variables.

Table 3-1 Compiler selection

Language

Wrapper ScriptEnvironment
Variable

Command Line

C

mpiccMPI_CC-mpicc <compiler>
C++mpiCCMPI_CXX

-mpicxx <compiler>

Fortran 77

mpif77MPI_F77

-mpif77 <compiler>

Fortran 90mpif90MPI_F90

-mpif90 <compiler>

mpisyntax

MPI_WRAPPER_SYNTAX

-mpisyntax \ <windows/unix>

 

Compiling applications

The compiler you use to build HP-MPI applications depends upon which programming language you use. The HP-MPI compiler utilities are shell scripts that invoke the appropriate native compiler. You can pass the pathname of the MPI header files using the -I option and link an MPI library (for example, the diagnostic or thread-compliant library) using the -Wl, -L or -l option.

By default, HP-MPI compiler utilities include a small amount of debug information in order to allow the TotalView debugger to function. However, certain compiler options are incompatible with this debug information. Use the -notv option to exclude debug information. The -notv option will also disable TotalView usage on the resulting executable. The -notv option applies to archive libraries only.

HP-MPI offers a -show option to compiler wrappers. When compiling by hand, run as mpicc -show and a line will print displaying exactly what the job was going to do (and skips the actual build).

Fortran 90

In order to use the 'mpi' Fortran 90 module, the user must create the module file by compiling the module.F file in /opt/hpmpi/include/64/module.F for 64-bit compilers. For 32-bit compilers, compile the module.F file in /opt/hpmpi/include/32/module.F.

NOTE: Each vendor (e.g. PGI, Qlogic/Pathscale, Intel, Gfortran, etc.) has a different module file format. Since compiler implementations vary in their representation of a module file, a PGI module file is not usable with Intel and so on. Additionally, we cannot guarantee forward compatibility from older to newer versions of a specific vendor's compiler. Because of compiler version compatibility and format issues, we do not build the module files.

In each case, you will need to build (just once) the module that corresponds to 'mpi' with the compiler you intend to use.

For example, with hpmpi/bin and pgi/bin in path:

pgf90 -c  /opt/hpmpi/include/64/module.F 
cat >hello_f90.f90 program main use mpi
    implicit none
    integer :: ierr, rank, size call MPI_INIT(ierr)
    call MPI_COMM_RANK(MPI_COMM_WORLD, rank, ierr)
    call MPI_COMM_SIZE(MPI_COMM_WORLD, size, ierr)
    print *, "Hello, world, I am ", rank, " of ", size
    call MPI_FINALIZE(ierr)Endmpif90 -mpif90 pgf90 hello_f90.f90
hello_f90.f90:mpirun ./a.out
Hello, world, I am 0 of 1

C command line basics for Windows systems

The utility "%MPI_ROOT%\bin\mpicc" is included to aid in command line compilation. To compile with this utility, set MPI_CC to the path of the command line compiler you want to use. Specify -mpi32 or -mpi64 to indicate if you are compiling a 32- or 64-bit application. Specify the command line options that you would normally pass to the compiler on the mpicc command line. The mpicc utility will add additional command line options for HP-MPI include directories and libraries. The -show option can be specified to indicate that mpicc should display the command generated without actually executing the compilation command. See the mpicc man page for more information.

To compile C code and link against HP-MPI without utilizing the mpicc tool, start a command prompt that has the appropriate environment settings loaded for your compiler, and use it with the compiler option:

/I"%MPI_ROOT%\include\[32|64]"

and the linker options:

/libpath:"%MPI_ROOT%\lib" /subsystem:console ^ [libhpmpi64.lib|libhpmpi32.lib]

The above assumes the environment variable MPI_ROOT is set.

For example, to compile hello_world.c from the Help directory using Visual Studio (from a Visual Studio 2005 command prompt window):

cl hello_world.c /I"%MPI_ROOT%\include\64"
     /link /out:hello_world.exe
     /libpath:"%MPI_ROOT%\lib"
     /subsystem:console libhpmpi64.lib

The PGI compiler uses a more UNIX-like syntax. From a PGI command prompt:

pgcc hello_world.c -I"%MPI_ROOT%\include\64"
     -o hello_world.exe -L"%MPI_ROOT%\lib" -lhpmpi64

Fortran command line basics for Windows systems

The utility "%MPI_ROOT%\bin\mpif90" is included to aid in command line compilation. To compile with this utility, set MPI_F90 to the path of the command line compiler you want to use. Specify -mpi32 or -mpi64 to indicate if you are compiling a 32- or 64-bit application. Specify the command line options that you would normally pass to the compiler on the mpif90 command line. The mpif90 utility will add additional command line options for HP-MPI include directories and libraries. The -show option can be specified to indicate that mpif90 should display the command generated without actually executing the compilation command. See the mpif90 man page for more information.

To compile compute_pi.f using Intel Fortran without utilizing the mpif90 tool (from a command prompt that has the appropriate environment settings loaded for your Fortran compiler):

ifort compute_pi.f /I"%MPI_ROOT%\include\64"
     /link /out:compute_pi.exe
     /libpath:"%MPI_ROOT%\lib"
     /subsystem:console libhpmpi64.lib

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1979-2007 Hewlett-Packard Development Company, L.P.