petsc-3.14.6 2021-03-30
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:


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

Installation location: In-place or out-of-place

By default, PETSc does an in-place installation, meaning the libraries are kept in the same directories used to compile PETSc. This is particularly useful for those application developers who follow the PETSc git repository master or release branches since rebuilds for updates are very quick and painless, see easyrebuild.

Out-of-place installation with --prefix

To install the libraries and include files in another location use the --prefix option The libraries and include files needed by the users will be located in /home/userid/petsc-3.14.0/lib and /home/userid/petsc-3.14.0/include.

Installs in root location (uncommon).

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

If one prefers to use root access for the install they only need change the final line One should never run configure or make on any package using root access.

Installs for package managers: using DESTDIR (very uncommon) Multiple installs using --prefix [and DESTDIR]:

Specify a different --prefix location for each configure of different options - at configure time. For example

In-place installation

The PETSc libraries and generated included files are placed in the sub-directory off the current directory $PETSC_ARCH which is either provided by the user with, for example, or If not provided ./configure will generate a unique value automatically (for in-place non --prefix configurations only) produces the directories (on an Apple MacOS machine) arch-darwin-c-debug and arch-darwin-c-opt.

The libraries and include files needed by the users are located off the current directory in $PETSC_ARCH/lib, include and $PETSC_ARCH/include

Following master or release on Git

If you follow the master or release branches off PETSc you can update your libraries with
  • git pull
  • make libs
Most of the time this will work, if there are errors regarding compiling Fortran stubs you need to also do
  • make allfortranstubs
If there are large changes in PETSc's configure code when you pull you may need to rerun the ./configure which you can do with
  • $PETSC_ARCH/lib/petsc/conf/reconfigure-$PETSC_ARCH.py
Return to Installation Instructions

Environmental variables PETSC_DIR and PETSC_ARCH

Applications completely providing their own makefiles do not need to use PETSC_DIR or PETSC_ARCH

PETSC_DIR and PETSC_ARCH (in-place installs only) are used by the PETSc makefiles to indicate which directory and configuration of PETSc to use when compiling examples or application code. These variables can be set as envirnment variables or specified on the command line
  • specify enviornment variable for csh/tcsh [can be specified in ~/.cshrc]
    • setenv PETSC_DIR /home/balay/petsc-3.14.0
    • setenv PETSC_ARCH linux-gnu-c-debug
  • specify environment variable for bash [can be specified in ~/.bashrc]
    • export PETSC_DIR=/home/balay/petsc-3.14.0
    • export PETSC_ARCH=linux-gnu-c-debug
  • specify variable on commandline (bash) to build an example in src/ts/tutorials
    • PETSC_ARCH=linux-gnu-c-debug make PETSC_DIR=/home/balay/petsc-3.14.0 ex1

PETSC_DIR should point to the location of the PETSc installation. For out-of-place installations this is the --prefix location. For in-place installations it is the directory where you ran configure PETSc.

PETSC_ARCH is only needed for in-place installations.

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.

Note: If installing PETSc with Cygwin/GNU compilers - install additional Cygwin components.

Additional cygwin components like git cmake can be useful for installing external packages.

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 Microsoft 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 Microsoft 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 Microsoft Windows - this usually affects specifying MPI or MKL. Microsoft 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 example

$ 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

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/petsc/conf/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 machines that use the module command:

On systems where you can use modules to load packages such as HDF5, the locations of the include files and libraries are known by the compiler. Hence you simply load the appropriate module for the package and run ./configure with the option --with-package. For example


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 check 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.

Examples that use CUDA have the suffix .cu; see see src/snes/tutorials/ex47.cu

Return to Installation Instructions

Installing PETSc with Kokkos

In most cases you need only pass the configure option --download-kokkos and one of --with-cuda --with-openmp --with-pthread (or nothing to use sequential Kokkos)

Examples that use Kokkos have the suffix .kokkos.cxx; see src/snes/tutorials/ex3k.kokkos.cxx

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

  • OLCF - Oak Ridge National Laboratory - Summit machine - NVIDIA GPUs and IBM Power PC processors Return to Installation Instructions

  • Installing PETSc on an iOS or Android platform

    Return to Installation Instructions