petsc-3.12.5 2020-03-29
Report Typos and Errors

Documentation: Installation

Quick Instructions:

Don't need Fortran, use --with-fortran-bindings=0 to reduce the build times. If you are not using external packages that use Fortran (for example, MUMPS requires Fortran) you can use --with-fc=0 for even faster build times.

Encounter problems?

Notes:

Table of Contents:


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}. 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 applications.

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.

If you are behind a firewall and cannot use a proxy for the downloads or have a very slow network use the additional option --with-packages-download-dir=/adirectory. This will trigger ./configure to print the URLs of all the packages you must download this directory (do not uncompress or untar the files) and then use these copies of the packages instead of trying to download them directly from the internet.

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/mpif90 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:

Are you sure you want to use Microsoft Windows? We recommend using Linux if possible [and minimize troubleshooting Microsoft windows related issues].

Installation With GNU gcc/g++/gfortran compilers:

The following configurations are much like regular Linux systems. Our regular [Linux] instructions should work with them. Most externalpackages will also work. The configure option --download-mpich should work for these systems. (These do not support Microsoft/Intel Windows compilers; nor can you use MS-MPI, Intel-MPI or MPICH2).

Installation With Microsoft/Intel Windows Compilers:

Microsoft Windows does not provide the same unix shell enviornment as the other OSes. Also the default Microsoft/Intel 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 Microsoft/Intel 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 compiler. If you are using ifort - 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 [Without MPI].

If fortran, c++ usage is not required, use:

Using MPI: We support both MS-MPI [64-bit] and Intel MPI on Windows (MPICH2 does not work, do not use it). For example usages, check config/examples/arch-mswin*.py

Avoiding spaces in PATHs: Its best to avoid spaces or similar special chars when specifying configure options. On windows - this usually affects specifying MPI or MKL. Windows supports dos short form for dir names - so its best to use this notation. And cygwin tool cygpath can be used to get paths in this notation. for ex:

$ cygpath -u `cygpath -ms '/cygdrive/c/Program Files (x86)/Microsoft SDKs/MPI'`
/cygdrive/c/PROGRA~2/MICROS~2/MPI
$ cygpath -u `cygpath -ms '/cygdrive/c/Program Files (x86)/IntelSWTools/compilers_and_libraries/windows/mkl/lib/intel64'`
/cygdrive/c/PROGRA~2/INTELS~1/COMPIL~2/windows/mkl/lib/intel64

i.e use:

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.

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

Using MinGW with Microsoft/Intel Windows Compilers:

Users report that it is possible to build to build PETSc using MinGW and link against them using the Microsoft/Intel Windows Compilers. We have no experience with this, nor knowledge on how it can be accomplished. Let us know your experience.

Notes on using other systems besides Cygwin to compile with Microsoft and Intel compilers

For any alternate system, we would have to redo win32fe functionality for that system. This includes 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: (we don't recommend this for users building PETSc for their own use)

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

Note: one has to switch to using PETSC_DIR=/opt/petsc/petsc-3.12.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.12.0
  • make
  • make install DESTDIR=/tmp/petsc-pkg
  • [package up /tmp/petsc-pkg The package should then be installed at /opt/petsc/petsc-3.12.0]
  • [user can now use this PETSc install with:] make PETSC_DIR=/opt/petsc/petsc-3.12.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.12.0-mpich --with-mpi-dir=/opt/mpich
  • make
  • make install DESTDIR=/tmp/petsc-pkg
  • untar petsc tar ball
  • ./configure --prefix=/opt/petsc/petsc-3.12.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 packages that utilize OpenMP:

Some external packages include MKL BLAS/LAPACK, OpenBLAS, SuperLU_DIST, and Hypre support using OpenMP for thread level parallelism in addition to the MPI parallelism in PETSc. To utilize this insure your compilers support OpenMP and use the additional configure option --with-openmp

To control the number of OpenMP threads each MPI process utilizes you can set the environmental variable OMP_NUM_THREADS n or the PETSc command line option -omp_num_threads n.

Return to Installation Instructions

Installing on machine requiring cross compiler or a job scheduler (Batch systems):

On systems where you need to use a job scheduler or batch submission to run jobs use the configure option --with-batch. On such systems the make test option will not work

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 currently works on Mac OS X, Linux, Microsoft Windows.

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 Mac OS X, Linux, and Microsoft Windows.

Return to Installation Instructions

Installing on Large Scale DOE Systems

Return to Installation Instructions

Installing PETSc on an iOS or Android platform

Return to Installation Instructions