petsc-3.5.4 2015-05-23
Report Typos and Errors

Documentation: Installation

Quick Instructions:

Invoke the following commands from the top level PETSc directory:
Check here for MS Windows Installation

Encounter problems?

Notes:


Example Usages:


PETSC_DIR and PETSC_ARCH are a couple of variables that control the configuration and build process of PETSc. These variables can be set as envirnment variables or specified on the command line [to both configure and make]

PETSC_DIR: this variable should point to the location of the PETSc installation that is used. Multiple PETSc versions can coexist on the same file-system. By changing PETSC_DIR value, one can switch between these installed versions of PETSc.

PETSC_ARCH: this variable gives a name to a configuration/build. Configure uses this value to stores the generated config makefiles in ${PETSC_DIR}/${PETSC_ARCH}/conf. And make uses this value to determine this location of these makefiles [which intern help in locating the correct include and library files].

Thus one can install multiple variants of PETSc libraries - by providing different PETSC_ARCH values to each configure build. Then one can switch between using these variants of libraries [from make] by switching the PETSC_ARCH value used.

If configure doesn't find a PETSC_ARCH value [either in env variable or command line option], it automatically generates a default value and uses it. Also - if make doesn't find a PETSC_ARCH env variable - it defaults to the value used by last successful invocation of previous configure.

Return to Installation Instructions

Compilers:

Specify compilers and compiler options used to build PETSc [and perhaps external packages]

Return to Installation Instructions

External Packages:

PETSc provides interfaces to various external packages. Blas/Lapack is a required package, MPI is not required if running sequentially. One can optionally use external solvers like Hypre, MUMPS, etc. from within PETSc aplications.

PETSc configure has the ability to download and install these external packages. Alternatively if these packages are already installed, then configure can detect and use them.

The following modes can be used to install/use external packages with configure.

Notes: Additional options: Return to Installation Instructions

BLAS/LAPACK

These packages provide some basic numeric kernels used by PETSc.

Notes: Return to Installation Instructions

MPI

This software provides the parallel functionality for PETSc.

Using MPI Compilers:

Installing without MPI:

Installing with Open MPI with shared MPI libraries:

OpenMPI defaults to building shared libraries for MPI. However, the binaries generated by MPI wrappers mpicc/mpif77 etc require LD_LIBRARY_PATH to be set to the location of these libraries.

Due to this OpenMPI restriction one has to set LD_LIBRARY_PATH correctly [per OpenMPI installation instructions], before running PETSc configure. If you do not set this environmental variables you will get messages when running ./configure such as

            UNABLE to EXECUTE BINARIES for config/configure.py
-------------------------------------------------------------------------------
            Cannot run executables created with C. If this machine uses a batch system
            to submit jobs you will need to configure using/configure.py with the additional option --with-batch.
            Otherwise there is problem with the compilers. Can you compile and run code with your C/C++ (and maybe Fortran) compilers?
        

or when running a code compiled with OpenMPI

-bash-3.3$ ./conftest
./conftest: error while loading shared libraries: libmpi.so.0: cannot open shared object file: No such file or directory

Notes:

Return to Installation Instructions

Microsoft Windows Installation:

Installation With MS/Intel/Compaq Compilers:

Microsoft Windows OS does not provide the same unix shell enviornment as the other OSes. Also the default MS/Intel/Compaq compilers behave differently than other unix compilers. So to install PETSc on Microsoft Windows - one has to install cygwin [for the unix enviornment] and use win32fe [part of PETSc sources,to interface to MS/Intel/Compaq compilers].

Install Cygwin: Please download and install cygwin package from http://www.cygwin.com. Make sure the following cygwin components are installed.

Remove Cygwin link.exe: Cygwin link.exe can conflict with Intel ifort and Comapq F90 compilers. If you are using these compilers - please do [from cygwin terminal/bash-shell]:

Setup cygwin terminal/bash-shell with Working Compilers: We require the compilers to be setup properly in a cygwin bash command shell, so that "cl foo.c" or "ifort foo.f" works from this shell. For example - if using VS2005 C and Intel 10 Fortran one can do:

Example Configure usage with Windows Compilers:

Use configure with VC2005 C and Intel Fortran 10 [With MPICH2 installed].

If fortran usage is not required, use:

Using Compaq F90:

Using Microsoft C/C++ 6.0 & Compaq Fortran 6.0 with MPICH2 configure command to use:

Note: MPICH2 mpif.h needs a fix for it to work with Compaq F90 [specifically remove line with MPI_DISPLACEMENT_CURRENT - which uses 'integer*8' - which is unsupported by Compaq F90]

ExternalPackages: The --download-package option does not work with many external packages on Microsoft Windows.

Project Files: We cannot provide Microsoft Visual Studio project files for users as they are specific to the configure options, location of external packages, compiler versions etc. used for any given build of PETSc, so they are potentially different for each build of PETSc. So if you need a project file for use with PETSc - please do the following.

Debugger: Running PETSc probrams with -start_in_debugger is not supported on this platform, so debuggers will need to be initiated manually. Make sure your environment is properly configured to use the appropriate debugger for your compiler. The debuggers can be initiated using Microsoft Visual Studio 6: msdev ex1.exe, Microsoft Visual Studio .NET: devenv ex1.exe, Intel Enhanced Debugger: edb ex1.exe, or GNU Debugger gdb ex1.exe.

Using Cygwin gcc/g++/gfortran: One can install and use PETSc with gcc/gfortran compilers from cygwin. In this case follow the regular Unix instructions.

PETSc Win32 front end - win32fe: This tool is used as a wrapper to Microsoft/ Borland/ Intel compilers and associated tools - to enable building PETSc libraries using cygwin make and other UNIX tools. For additional info, run ${PETSC_DIR}/bin/win32/win32fe without any options.

Return to Installation Instructions

Installing PETSc in /usr/local or /opt where sudo or root privileges are required:

If one wants to install PETSc [with sources] in a common system location like /usr/local or /opt, then we suggest creating a dir for PETSc in the required location with user privileges, and then do the PETSc install [as a regular/non-root user]. i.e.

Installing with --prefix:

One can also use the GNU --prefix install mode.

Note: one has to switch to using PETSC_DIR=/opt/petsc/petsc-3.5.0 after install is done - and NOT use PETSC_ARCH anymore.

Using DESTDIR with prefix install:

One can also use the GNU DESTDIR with a prefix install. This mode is generally used by binary packagers. For example

  • ./configure --prefix=/opt/petsc/petsc-3.5.0
  • make
  • make install DESTDIR=/tmp/petsc-pkg
  • [package up /tmp/petsc-pkg The package should then be installed at /opt/petsc/petsc-3.5.0]
  • [user can now use this PETSc install with:] make PETSC_DIR=/opt/petsc/petsc-3.5.0 ex1

Multiple installs using --prefix and DESTDIR:

Sepcify a different --prefix location/option for each build - at configure time. For eg:
  • untar petsc tar ball
  • ./configure --prefix=/opt/petsc/petsc-3.5.0-mpich --with-mpi-dir=/opt/mpich
  • make
  • make install DESTDIR=/tmp/petsc-pkg
  • untar petsc tar ball
  • ./configure --prefix=/opt/petsc/petsc-3.5.0-openmpi --with-mpi-dir=/opt/openmpi
  • make
  • make install DESTDIR=/tmp/petsc-pkg

Return to Installation Instructions

PETSc ./configure automatically generates Pkgconfig and module files for each install

These can be found in ${PETSC_DIR}/${PETSC_ARCH}/lib/pkgconfig/PETSc.pc and ${PETSC_DIR}/${PETSC_ARCH}/lib/modules/${PETSC_VERSION}-${PETSC_ARCH}. The module file may need to be edited for your particular system. Note that if --prefix is used then $PETSC_ARCH is not included in the above directories nor is -${PETSC_ARCH} included in the module file name.

Return to Installation Instructions

Installing on machine requiring cross compiler or a job scheduler, such as IBM SP or IBM Blue Gene:

If one has to use a cross compiler - or go through the job scheduler to use MPI on a given machine - use the configure option --with-batch as follows:

Return to Installation Instructions

Installing with TAU Instrumentation package:

TAU package and the prerequisite PDT packages need to be installed separately [perhaps with MPI]. Now use tau_cc.sh as compiler to PETSc configure.

Return to Installation Instructions

Installing PETSc to use NVidia GPUs (aka CUDA)

Cuda build of PETSc curently works on Apple OSX, Linux [Ubuntu 10.04], Microsoft Windows [Server 2003].

Return to Installation Instructions

Installing PETSc to use GPUs and accelerators via OpenCL (NVIDIA, AMD, Intel MIC)

OpenCL/ViennaCL builds of PETSc currently work on Apple OSX, Linux, and Microsoft Windows. OpenCL is less a burden on the build system than CUDA, so installation is often easier and works with any host compiler.

Return to Installation Instructions

Installing PETSc to use Threads

petsc master (git branch)

Return to Installation Instructions