petsc-3.12.4 2020-02-04
Report Typos and Errors

# Documentation: Installation

### Quick Instructions:

- On systems where MPI and BLAS/LAPACK are installed.
  - ./configure
  - make all test
- Or to specify compilers and have PETSc download and install MPI and BLAS/LAPACK (when they are not already on your machine)
  - ./configure --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-mpich --download-fblaslapack
  - make all test
- Check here for MS Windows installation and here for DOE large scale systems installation

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?

- Read the error message from ./configure!
- Read help `./configure --help`
- Refer to example usages (e.g., build PETSc without a Fortran compiler)
- make problems? Just copy/paste make command printed by configure including PETSC_DIR and PETSC_ARCH options
- Check the bug-reporting section

### Notes:

- Please obtain PETSc via the repository or download the latest patched tarball
- To extract the sources use: `gunzip -c petsc-<version number>.tar.gz | tar -xof -`
- We highly recommend installing PETSc as a regular/non-root user, perhaps in /home/username/soft

### Table of Contents:

- Example usages
- Specify compilers and compiler options used to build PETSc [and perhaps external packages]
- External packages
- BLAS and LAPACK problems
- MPI problems / I don't want MPI
- Microsoft Windows installation
- Installing PETSc in system directories where sudo or root privileges are required / For package managers
- PETSc ./configure automatically generates Pkgconfig and module files for each install
- Installing on machine requiring cross compiler or a job scheduler, such as IBM SP or IBM Blue Gene
- Installing with TAU instrumentation package
- Installing PETSc to use NVIDIA GPUs (aka CUDA)
- Installing PETSc to use GPUs and accelerators via OpenCL (NVIDIA, AMD, Intel MIC)
- Installing on large scale DOE systems
- Installing PETSc on an iOS or Android platform

### Example Usages:

- Examples are at config/examples/*.py. We use some of these scripts locally for testing - for example one can update these files and run as:
  - ./config/examples/arch-osx-10.6.py
- Assuming BLAS, LAPACK, MPICH are not currently installed `./configure` will download & install BLAS, LAPACK, MPICH if they are not already installed on the system):
  - ./configure --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-fblaslapack --download-mpich
- Same as above - but do not have a fortran compiler [and want to use PETSc from C only].
  - ./configure --with-cc=gcc --with-cxx=0 --with-fc=0 --download-f2cblaslapack --download-mpich
- If BLAS, LAPACK, MPI sources (in "-devel" packages in most distros) are already installed in default system/compiler locations and mpicc, mpif90, mpiexec are available via PATH - configure does not require any additional options.
  - ./configure
- If BLAS, LAPACK, MPI are already installed in known user location use:
  [Note: Do not specify --with-cc --with-fc etc when using --with-mpi-dir - so that mpicc/mpif90 can be picked up from mpi-dir]
  - ./configure --with-blaslapack-dir=/usr/local/blaslapack --with-mpi-dir=/usr/local/mpich
  or
  - ./configure --with-blaslapack-dir=/usr/local/blaslapack --with-cc=/usr/local/mpich/bin/mpicc --with-mpi-f90=/usr/local/mpich/bin/mpif90 --with-mpiexec=/usr/local/mpich/bin/mpiexec
- Build Complex version of PETSc [using c++ compiler]:
  - ./configure --with-cc=gcc --with-fc=gfortran --with-cxx=g++ --with-clanguage=cxx --download-fblaslapack --download-mpich --with-scalar-type=complex
- Install 2 variants of PETSc, one with gnu, the other with intel compilers. Specify different PETSC_ARCH for each build.
  - ./configure PETSC_ARCH=linux-gnu --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-mpich
  - make PETSC_ARCH=linux-gnu all test
  - ./configure PETSC_ARCH=linux-gnu-intel --with-cc=icc --with-cxx=icpc --with-fc=ifort --download-mpich --with-blaslapack-dir=/usr/local/mkl
  - make PETSC_ARCH=linux-gnu-intel all test

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]

- specify enviornment variable for csh/tcsh [can be specified in ~/.cshrc]
  - setenv PETSC_DIR /home/balay/petsc-3.12.0
  - setenv PETSC_ARCH linux-gnu-c-debug
- specify enviornment variable for bash [can be specified in ~/.bashrc]
  - export PETSC_DIR=/home/balay/petsc-3.12.0
  - export PETSC_ARCH=linux-gnu-c-debug
- specify variable on commandline to configure
  - ./configure PETSC_DIR=/home/balay/petsc-3.12.0 PETSC_ARCH=linux-gnu-c-debug [other configure options]
- specify variables on command line to make
  - make PETSC_DIR=/home/balay/petsc-3.12.0 PETSC_ARCH=linux-gnu-c-debug [other make options]

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]

- Specify compilers using the options `--with-cc --with-cxx --with-fc` for c, c++, and fortran compilers
  - --with-cc=mpicc --with-cxx=mpicxx --with-fc=mpif90
  - --with-cc=gcc --with-cxx=g++ --with-fc=gfortran
  - --with-cc=gcc --with-cxx=g++ --with-fc=gfortran
- If fortran compiler is not available or not needed - then disabling using fortran
  - --with-fc=0
- If a C++ compiler is not available or not needed - disable configuring with it
  - --with-cxx=0
- If no compilers are specified - configure will automatically look for available MPI or regular compilers in the user's PATH
  - mpicc/mpiCC/mpif90
  - gcc/g++/gfortran
  - cc/CC etc..
- It's best to use MPI compilers as this will avoid the situation where MPI is compiled with one set of compilers [like gcc/gfortran] and user specified incompatible compilers to PETSc [perhaps icc/ifort]. This can be done by either specifying --with-cc=mpicc or --with-mpi-dir [and not --with-cc=gcc]
  - --with-cc=mpicc --with-cxx=mpicxx --with-fc=mpif90
  - --with-mpi-dir=/opt/mpich2-1.1 [but *no* --with-cc=gcc]
- Configure defaults to building PETSc in debug mode. One can switch to using optimzed mode with the configure option --with-debugging=0 (We suggest using a different PETSC_ARCH for debug and optimized builds, for example arch-debug and arch-opt, this way you can switch between debugging your code and running for performance by simply changing the value of PETSC_ARCH. Additionally one can specify more suitable optimization flags with the options COPTFLAGS, FOPTFLAGS, CXXOPTFLAGS. For ex: when using gnu compilers with corresponding optimization flags:
  - ./configure --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --with-debugging=0 COPTFLAGS='-O3 -march=native -mtune=native' CXXOPTFLAGS='-O3 -march=native -mtune=native' FOPTFLAGS='-O3 -march=native -mtune=native' --download-mpich
- Configure cannot detect compiler libraries for certain set of compilers. In this case one can specify additional system/compiler libraries using the LIBS option
  - ./configure --LIBS='-ldl /usr/lib/libm.a'

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.

- --download-PACKAGENAME: Download specified package and install it and configure PETSc to use this package.
  - --download-fblaslapack --download-mpich
  - --download-scalapack --download-mumps
- --download-PACKAGENAME=/PATH/TO/package.tar.gz: If ./configure cannot automatically download the package [due to network/firewall issues], one can download the package by alternative means [perhaps wget, curl, or scp via some other machine]. Once the tarfile is downloaded, the path to this file can be specified to configure with this option. Configure will proceed to install this package and then configure PETSc with it.
  - --download-mpich=/home/petsc/mpich2-1.0.4p1.tar.gz
- --with-PACKAGENAME-dir=PATH: If the external package is already installed - specify its location to configure [it will attempt to detect, include, library files from this location.] Normally this corresponds to the top-level installation dir for the package.
  - --with-mpi-dir=/home/petsc/software/mpich2-1.0.4p1
  Note that we hightly recommend you have PETSc download and install the external packages rather than you installing them separately first. The reason is that this insures the packages are installed with the same compilers and compiler options etc as PETSc so that they can work together.
- --with-PACKAGENAME-include=INCLUDEPATH --with-PACKAGENAME-lib=LIBRARYLIST: Usually a package is defined completely by its include file location - and library list. [If the package is already installed] - then one can use these two options to specify the package to configure. For eg:
  - --with-superlu-include=/home/petsc/software/superlu/include --with-superlu-lib=/home/petsc/software/superlu/lib/libsuperlu.a
  - --with-parmetis-include=/sandbox/balay/parmetis/include --with-parmetis-lib="-L/sandbox/balay/parmetis/lib -lparmetis -lmetis"
  - --with-parmetis-include=/sandbox/balay/parmetis/include --with-parmetis-lib=[/sandbox/balay/parmetis/lib/libparmetis.a,libmetis.a]

Notes:

- Run `./configure --help` to get the list of external packages and corresponding additional options [for example `--with-mpiexec` for MPICH]
- Generally one would use either one of the above 4 modes for any given package - and not mix these. [i.e mixing `--with-mpi-dir` and `--with-mpi-include` etc.. should be avoided]
- Some packages might not support certain options like `--download-PACKAGENAME` or `--with-PACKAGENAME-dir`. Architectures like Microsoft Windows might have issues with these options. In these cases, `--with-PACKAGENAME-include --with-PACKAGENAME-lib` options should be preferred.
- It's best to install some external packages like SuperLU_DIST, MUMPS, Hypre, METIS, and ParMETIS with the option `--download-PACKAGENAME`. [the correct options for these packages are `--download-superlu_dist --download-mumps --download-hypre`]
  - This will install the COMPATIBLE version of the external package. A generic install of this package might not be compatible with PETSc [perhaps due to version differences - or perhaps due to the requirement of additional patches for it to work with PETSc]
  - Some packages have bug fixes, portability patches, and upgrades for dependent packages that have not yet been included in an upstream release.
  - All packages will be installed with the same set of compilers - this avoids problems [for example weird link time errors] with mixing code compiled with multiple compilers [for example mixing gfortran and ifort compiled code].
- If you want to download a compatible external package manually, then the URL for this package is listed in configure source for this package. For example, check `config/BuildSystem/config/packages/SuperLU.py` for the url for download this package.

Additional options:

- --with-packages-build-dir=PATH: By default, external packages will be unpacked and the build process is run in `${PETSC_DIR}/${PETSC_ARCH}/externalpackages`. However one can choose a different location where these packages are unpacked and the build process is run.

Return to Installation Instructions

### BLAS/LAPACK

These packages provide some basic numeric kernels used by PETSc.

- Configure will automatically look for blas/lapack in certain standard locations, on most systems you should not need to provide any information about BLAS/LAPACK in the ./configure command.
- One can use the following options to let configure download/install blas/lapack automatically.
  - --download-fblaslapack [when fortran compiler is present]
  - --download-f2cblaslapack [when configuring without a fortran compiler - i.e --with-fc=0]
- Alternatively one can use other options like one of the following.
  - --with-blaslapack-lib=libsunperf.a
  - --with-blas-lib=libblas.a --with-lapack-lib=liblapack.a
  - --with-blaslapack-dir=/soft/com/packages/intel/13/079/mkl

Notes:

- #### Intel MKL

  Intel provides blas/lapack via MKL library. It usually works from GNU/Intel compilers on Linux and MS/Intel compilers on Windows. One can specify it to PETSc configure with for eg: `--with-blaslapack-dir=/soft/com/packages/intel/13/079/mkl`
  If the above option does not work - one could determine the correct library list for your compilers using Intel MKL Link Line Advisor and specify with the configure option `--with-blaslapack-lib`

- #### IBM ESSL

  Sadly, IBM's ESSL does not have all the routines of BLAS and LAPACK that some packages, such as SuperLU expect; in particular slamch, dlamch and xerbla. In this case instead of using ESSL we suggest `--download-fblaslapack`. If you really want to use ESSL, see https://www.pdc.kth.se/hpc-services.

Return to Installation Instructions

### MPI

This software provides the parallel functionality for PETSc.

- Configure will automatically look for MPI compilers mpicc/mpif90 etc and use them if found in your PATH.
- One can use the following options to let configure download/install MPI automatically
  - --download-mpich [install and use MPICH]
  - --download-openmpi [Install and use Open MPI]
- See externalpackages for other installation options.

#### Using MPI Compilers:

- It's best to install PETSc with MPI compiler wrappers (often called mpicc, mpicxx, mpif90) - this way, the SAME compilers used to build MPI are used to build PETSc [this avoids incompatibilities which might crop up - when using libraries compiled with different c or fortran compilers.]. This can be achieved with the following modes.
  - Vendor provided MPI might already be installed. IBM, SGI, Cray etc provide their own:
    `./config/confiure.py --with-cc=mpcc --with-fc=mpf90`
  - If using MPICH which is already installed [perhaps using myrinet/gm] then use [without specifying --with-cc=gcc etc.so that configure picks up mpicc from mpi-dir]:
    `./configure --with-mpi-dir=/path-to-mpich-install`

#### Installing without MPI:

- You can build (sequential) PETSc without an MPI. This is useful for quickly installing PETSc [if MPI is not available - for whatever reason]. However - if there is any MPI code in user application, then its best to install a full MPI - even if the usage is currently limited to uniprocessor mode.
  - ./configure --with-mpi=0

#### 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:

- Avoid specifing compilers [with options `--with-cc` or `--with-fc`] when using the option `--with-mpi-dir`. [Option`--with-mpi-dir` specifies using MPI compilers - so its best to use them - and not overwride them with user specified `--with-cc`].
- One can specify mpiexec or mpiexec with the options `--with-mpiexec`

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

- Cygwin Unix emulator for Microsoft Windows. See the instructions below for installing Cygwin for PETSc. Be sure to install the GNU compilers, do not use the win32fe script.
- Windows Subsystem for Linux 2 (WLS2). Untested, let us know your experience.
- Docker for Windows. Untested, let us know your experience.
- Git bash. You must also install the GNU compilers via MinGW. Untested, let us know your experience.
- Linux virtual machine via VirtualBox. One sample tutorial is at https://www.psychocats.net/ubuntu/virtualbox. Google can provide more tutorials. Untested, let us know your experience.

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

- python
- make
- [default selection should already have `diff` and other tools]

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]:

- `mv /usr/bin/link.exe /usr/bin/link-cygwin.exe`

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:

- Start -> Programs -> Intel Software Development Tools -> Intel Fortran Compiler 10 -> Visual Fortran Build Enviornment [32bit or 64bit depending on your usage]. This should start a 'dos cmd' shell.
- Within this shell - run Cygwin terminal/bash-shell mintty.exe as: `c:\cygwin\bin\mintty.exe`
- Within mintty.exe - run:`/usr/bin/bash --login`
- verify if the compilers are useable [by running cl, ifort in this Cygwin terminal/bash-shell]
- Now run configure with win32fe and then build the libraries with make [as per the usual instructions]

Example Configure usage with Windows Compilers:

Use configure with VC2005 C and Intel Fortran 10 [Without MPI].

- `./configure --with-cc='win32fe cl' --with-fc='win32fe ifort' --with-cxx='win32fe cl' --with-mpi=0 --download-fblaslapack`

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

- `./configure --with-cc='win32fe cl' --with-fc=0 --with-cxx=0 --download-f2cblaslapack`

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:

- `./configure --with-cc='win32fe cl' --with-fc='win32fe ifort' --with-cxx='win32fe cl' --with-shared-libraries=0 \
  --with-mpi-include='[/cygdrive/c/PROGRA~2/MICROS~2/MPI/Include,/cygdrive/c/PROGRA~2/MICROS~2/MPI/Include/x64]' \
  --with-mpi-lib='-L/cygdrive/c/PROGRA~2/MICROS~2/MPI/lib/x64 msmpifec.lib msmpi.lib' \
  --with-mpiexec=/cygdrive/c/PROGRA~1/MICROS~2/Bin/mpiexec \
  --with-blaslapack-lib='-L/cygdrive/c/PROGRA~2/INTELS~1/COMPIL~2/windows/mkl/lib/intel64 mkl_intel_lp64_dll.lib mkl_sequential_dll.lib mkl_core_dll.lib'`

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.

- create an empty project file with one of the examples say `src/ksp/ksp/examples/tutorials/ex2.c`
- try compiling the example from Cygwin bash shell - using makefile - for eg:
  - cd src/ksp/ksp/examples/tutorials
  - make ex2
- if the above works - then make sure all the compiler/linker options used by make are also present in the project file in the correct notation.
- if errors - redo the above step. [if all the options are correctly specified - then the example should compile from MSDev.

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

- Marshal unix type compiler options to Cl (Microsoft compiler).
- Convert paths in some of these options from this system (for example Cygwin paths) to Windows paths.
- Have python that works with system path notation.
- Have the ability equivalent to Windows process spawning; Cygwin process spawning produces Windows processes. WSL1 lacked this.

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.

- sudo mkdir /opt/petsc
- sudo chown user:group /opt/petsc
- cd /opt/petsc
- tar -xzf petsc-3.12.0.tar.gz
- cd petsc-3.12.0
- ./configure
- make

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

- ./configure --prefix=/opt/petsc/petsc-3.12.0 [other configure options]
- make
- [sudo] make install
- [user can now use this PETSc install with:] make PETSC_DIR=/opt/petsc/petsc-3.12.0 ex1

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

- You must first insure you have loaded appropriate modules for the compilers etc that you wish to use. Often the compilers are provided automatically for you and you do not need to provide `--with-cc=XXX` etc Consult with the documentation and local support for such systems for information on these topics.
- On such systems you generally should not provide `--with-blaslapack-dir` or `--download-fblaslapack` since the systems provide those automatically (sometimes appropriate modules must be loaded first)
- Some packages `--download-package` options do not work on these systems, for example HDF5. Thus you must use modules to load those packages and `--with-package` to configure with the package.
- Since building external packages on these systems is often troublesome and slow we recommend only installing PETSc with those configuration packages that you need for your work, not extras.

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.

- export TAU_MAKEFILE=/home/balay/soft/linux64/tau-2.20.3/x86_64/lib/Makefile.tau-mpi-pdt
- ./configure CC=/home/balay/soft/linux64/tau-2.20.3/x86_64/bin/tau_cc.sh --with-fc=0 PETSC_ARCH=arch-tau

Return to Installation Instructions

### Installing PETSc to use NVIDIA GPUs (aka CUDA)

- Requires CUDA,
- On Linux - make sure you have compatible NVIDIA driver installed.
- In most cases you need only pass the configure option --with-cuda; check `config/examples/arch-ci-linux-cuda-double.py` for example usage.

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)

- Requires the OpenCL shared library, which is shipped in the vendor graphics driver and the OpenCL headers; if needed you can download them from the Khronos Group directly. Package managers on Linux provide these headers through a package named 'opencl-headers' or similar. On Apple systems the OpenCL drivers and headers are always available and do not need to be downloaded.
- Always make sure you have the latest GPU driver installed. There are several known issues with older driver versions.
- Run configure with --download-viennacl; check `config/examples/arch-ci-linux-viennacl.py` for example usage.

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

- NERSC - CORI machine.
  - Project ID: m3353
  - PI: Richard Mills
  - Notes on usage:
- ALCF - Argonne National Laboratory - theta machine - Intel KNL based system
  - Project ID:
  - PI:
  - Notes on usage:
    - Log into theta.alcf.anl.gov
    - There are three compiler suites Modules
      - module load PrgEnv-intel intel
      - module load PrgEnv-gnu gcc/7.1.0/
      - module load PrgEnv-cray
    - List currently loaded modules: module list
    - List all available modules: module avail
    - Blas/lapack will automatically be found so you do not need to provide it
    - It is best not to use built-in modules for external packages (except blas/lapack) because they are often buggy. Most external packages can be built using the --download option with the intel or Gnu environment but not cray
    - You can use config/examples/arch-cray-xc40-knl-opt.py as a template for running configure but it is outdated

- OLCF - Oak Ridge National Laboratory - Summit machine - NVIDIA GPUs and IBM Power PC processors
  - Project ID: CSC314
  - PI: Barry Smith
  - Notes on usage:
    - Getting Started
    - Log into summit.olcf.ornl.gov
    - module load cmake hdf5 cuda
    - module load pgi (for PGI compilers)
    - module load essl netlib-lapack xl (for IBM compilers)
    - module load gcc (for GNU compilers)
    - Use config/examples/arch-olcf-opt.py as a template for running configure
    - You configure PETSc and build examples in your home directory, but launch them from your "work" directory.
    - Use the bsub command to submit jobs to the queue. See the "Batch Scripts" section here running jobs
    - Tools for profiling
    - -log_view that adds GPU communication and computation to the summary table
    - nvprof and nvvp from the CUDA toolkit
  Return to Installation Instructions

### Installing PETSc on an iOS or Android platform

- For iOS see systems/Apple/iOS/bin/makeall
- A thorough discussion of the installation procedure is given here.
- For Android, you must have your standalone bin folder in the path, so that the compilers are visible.
- Check `config/examples/arch-arm64-opt.py` for iOS and `config/examples/arch-armv7-opt.py` for example usage.

Return to Installation Instructions