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
Parallel Programming Guide for HP-UX Systems > Chapter 2 MPI

Compiling and Linking

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Glossary

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 2.0 now 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.

Compilation utilities

HP MPI provides separate compilation utilities and default compilers for the languages shown in the following tables.

Table 2-1 Default compilers for HP-UX

LanguageUtilityDefault compiler
Cmpicc/opt/ansic/bin/cc
C++mpiCC/opt/aCC/bin/aCC
Fortran 77mpif77

/opt/fortran/bin/f77

Fortran 90mpif90/opt/fortran90/bin/f90

 

If aCC is not available, mpiCC uses CC as the default C++ compiler.

Table 2-2 Default compilers for Linux Itanium2

LanguageUtilityDefault compiler if /opt/intel/compiler70 exists

Default compiler if /opt/intel/compiler70 does not exist

Cmpiccecc

/usr/bin/gcc

C++mpiCCecc

/usr/bin/g++

Fortran 77mpif77efc

/usr/bin/g77

Fortran 90mpif90efcf90

 

Table 2-3 Default compilers for Linux IA-32

LanguageUtilityDefault compiler if /opt/intel/compiler70 exists

Default compiler if /opt/intel/compiler70 does not exist

Cmpiccicc

/usr/bin/gcc

C++mpiCCicc

/usr/bin/g++

Fortran 77mpif77ifc

/usr/bin/g77

Fortran 90mpif90ifcf90

 

Table 2-4 Default compilers for Tru64UNIX

LanguageUtility

Default compiler

Cmpicc

/usr/bin/cc

C++mpiCC

/usr/bin/cxx

Fortran 77mpif77

/usr/bin/f77

Fortran 90mpif90/usr/bin/f90

 

Even though the mpiCC and mpif90 compilation utilities are shipped with HP MPI, all C++ and Fortran 90 applications use C and Fortran 77 bindings respectively.

If you want to use a compiler other than the default one assigned to each utility, set the corresponding environment variables shown in Table 2-5 “Compilation environment variables”.

Table 2-5 Compilation environment variables

UtilityEnvironment variable
mpiccMPI_CC
mpiCCMPI_CXX
mpif77MPI_F77
mpif90MPI_F90

 

Autodouble functionality

HP MPI 2.0 supports Fortran programs compiled 64-bit with any of the following options:

For HP-UX:

  • +i8

  • +r8

  • +autodbl4

  • +autodbl

For Linux Itanium2:

  • -i2

    Set default KIND of integer variables is 2.

  • -i4

    Set default KIND of integer variables is 4.

  • -i8

    Set default KIND of integer variables is 8.

  • -r8

    Set default size of REAL to 8 bytes.

  • -r16

    Set default size of REAL to 16 bytes.

  • -autodouble

    Same as -r8.

For Tru64UNIX:

  • -r8

    Defines REAL declarations, constants, functions, and intrinsics as DOUBLE PRECISION (REAL*8), and defines COMPLEX declarations, constants, functions, and intrinsics as DOUBLE COMPLEX (COMPLEX*16). This option is the same as the -real_size 64 option.

  • -r16

    Defines REAL and DOUBLE PRECISION declarations, constants, functions, and intrinsics as REAL*16. For f90, it also defines COMPLEX and DOUBLE COMPLEX declarations, constants, functions, and intrinsics as COMPLEX*32. This option is the same as the -real_size 128 option.

  • -i8

    Makes default integer and logical variables 8-bytes long (same as the -integer_size 64 option). The default is -integer_size 32.

The decision of how the Fortran arguments will be interpreted by the MPI library is made at link time.

If the mpif90 compiler wrapper is supplied with one of the above options at link time, the necessary object files will automatically link, informing MPI how to interpret the Fortran arguments.

NOTE: This autodouble feature is supported in the regular and multithreaded MPI libraries, but not in the diagnostic library.

The following MPI functions accept user-defined functions:

  • MPI_Op_create()

  • MPI_Errhandler_create()

  • MPI_Keyval_create()

  • MPI_Comm_create_errhandler()

  • MPI_Comm_create_keyval()

  • MPI_Win_create_errhandler()

  • MPI_Win_create_keyval()

The user-defined callback passed to these functions should accept normal-sized arguments. These functions are called internally by the library where normally-sized data types will be passed to them.

64-bit support

HP-UX 11.i and higher is available as a 32- and 64-bit operating system. You must run 64-bit executables on the 64-bit system (though you can build 64-bit executables on the 32-bit system).

HP MPI supports a 64-bit version of the MPI library on platforms running HP-UX 11.i and higher. Both 32- and 64-bit versions of the library are shipped with HP-UX 11i and higher. For HP-UX 11i and higher, you cannot mix 32-bit and 64-bit executables in the same application.

The mpicc and mpiCC compilation commands link the 64-bit version of the library if you compile with the +DA2.0W or +DD64 options. Use the following syntax:

[mpicc | mpiCC] [+DA2.0W | +DD64] -o filename filename.c

When you use mpif90, compile with the +DA2.0W option to link the 64-bit version of the library. Otherwise, mpif90 links the 32-bit version. For example, to compile the program myprog.f90 and link the 64-bit library enter:

% mpif90 +DA2.0W -o myprog myprog.f90

Thread-compliant library

HP MPI provides a thread-compliant library. By default, the non thread-compliant library (libmpi) is used when running HP MPI jobs. Linking to the thread-compliant library (libmtmpi) is now required only for applications that have multiple threads making MPI calls simultaneously. In previous releases, linking to the thread-compliant library was required for multithreaded applications even if only one thread was making a MPI call at a time.

Application types that no longer require linking to the thread-compliant library include:

  • Implicit compiler-generated parallelism (e.g. +O3 +Oparallel in HP-UX)

  • Thread parallel MLIB applications

  • OpenMP

  • pthreads (Only if no two threads call MPI at the same time. Otherwise, use the thread-compliant library for pthreads.)

NOTE: In HP Fortran 3.2 and higher versions, the +Oparallel option is not supported on Integrity systems. You must use +Oautopar instead of +Oparallel for Fortran applications on Integrity systems.

Building Applications

This example shows how to build hello_world.c prior to running.

  1. Change to a writable directory.

  2. Compile the hello_world executable.

    For shared libraries:

    % $MPI_ROOT/bin/mpicc -o hello_world $MPI_ROOT/help/
       hello_world.c

    For archive libraries:

    On HP-UX:

    % $MPI_ROOT/bin/mpicc -o hello_world $MPI_ROOT/help/
       hello_world.c -Wl,-aarchive_shared

    On Linux:

    % $MPI_ROOT/bin/mpicc -o hello_world $MPI_ROOT/help/
       hello_world.c -static

    On Tru64UNIX:

    % $MPI_ROOT/bin/mpicc -o hello_world $MPI_ROOT/help/
       hello_world.c -non_shared

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