xref: /petsc/doc/install/install.md (revision 51619389660697cb6ab811d9eb05c4522bec4803)
19b92b1d3SBarry Smith(doc_config_faq)=
29b92b1d3SBarry Smith
39b92b1d3SBarry Smith# Configuring PETSc
49b92b1d3SBarry Smith
59b92b1d3SBarry Smith:::{important}
69b92b1d3SBarry SmithObtain PETSc via the repository or download the latest tarball: {ref}`download documentation <doc_download>`.
79b92b1d3SBarry Smith
89b92b1d3SBarry SmithSee {ref}`quick-start tutorial <tut_install>` for a step-by-step walk-through of the installation process.
99b92b1d3SBarry Smith:::
109b92b1d3SBarry Smith
119b92b1d3SBarry Smith```{contents} Table of Contents
129b92b1d3SBarry Smith:backlinks: entry
139b92b1d3SBarry Smith:depth: 1
149b92b1d3SBarry Smith:local: true
159b92b1d3SBarry Smith```
169b92b1d3SBarry Smith
179b92b1d3SBarry Smith## Common Example Usages
189b92b1d3SBarry Smith
199b92b1d3SBarry Smith:::{attention}
209b92b1d3SBarry SmithThere are many example `configure` scripts at `config/examples/*.py`. These cover a
219b92b1d3SBarry Smithwide variety of systems, and we use some of these scripts locally for testing. One can
229b92b1d3SBarry Smithmodify these files and run them in lieu of writing one yourself. For example:
239b92b1d3SBarry Smith
249b92b1d3SBarry Smith```console
259b92b1d3SBarry Smith$ ./config/examples/arch-ci-osx-dbg.py
269b92b1d3SBarry Smith```
279b92b1d3SBarry Smith
289b92b1d3SBarry SmithIf there is a system for which we do not yet have such a `configure` script and/or
299b92b1d3SBarry Smiththe script in the examples directory is outdated we welcome your feedback by submitting
309b92b1d3SBarry Smithyour recommendations to <mailto:petsc-maint@mcs.anl.gov>. See bug report {ref}`documentation
319b92b1d3SBarry Smith<doc_creepycrawly>` for more information.
329b92b1d3SBarry Smith:::
339b92b1d3SBarry Smith
349b92b1d3SBarry Smith- If you do not have a Fortran compiler or [MPICH](https://www.mpich.org/) installed
359b92b1d3SBarry Smith  locally (and want to use PETSc from C only).
369b92b1d3SBarry Smith
379b92b1d3SBarry Smith  ```console
389b92b1d3SBarry Smith  $ ./configure --with-cc=gcc --with-cxx=0 --with-fc=0 --download-f2cblaslapack --download-mpich
399b92b1d3SBarry Smith  ```
409b92b1d3SBarry Smith
419b92b1d3SBarry Smith- Same as above - but install in a user specified (prefix) location.
429b92b1d3SBarry Smith
439b92b1d3SBarry Smith  ```console
449b92b1d3SBarry Smith  $ ./configure --prefix=/home/user/soft/petsc-install --with-cc=gcc --with-cxx=0 --with-fc=0 --download-f2cblaslapack --download-mpich
459b92b1d3SBarry Smith  ```
469b92b1d3SBarry Smith
479b92b1d3SBarry Smith- If [BLAS/LAPACK], MPI sources (in "-devel" packages in most Linux distributions) are already
489b92b1d3SBarry Smith  installed in default system/compiler locations and `mpicc`, `mpif90`, mpiexec are available
499b92b1d3SBarry Smith  via `$PATH` - configure does not require any additional options.
509b92b1d3SBarry Smith
519b92b1d3SBarry Smith  ```console
529b92b1d3SBarry Smith  $ ./configure
539b92b1d3SBarry Smith  ```
549b92b1d3SBarry Smith
559b92b1d3SBarry Smith- If [BLAS/LAPACK], MPI are already installed in known user location use:
569b92b1d3SBarry Smith
579b92b1d3SBarry Smith  ```console
589b92b1d3SBarry Smith  $ ./configure --with-blaslapack-dir=/usr/local/blaslapack --with-mpi-dir=/usr/local/mpich
599b92b1d3SBarry Smith  ```
609b92b1d3SBarry Smith
619b92b1d3SBarry Smith  or
629b92b1d3SBarry Smith
639b92b1d3SBarry Smith  ```console
649b92b1d3SBarry Smith  $ ./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
659b92b1d3SBarry Smith  ```
669b92b1d3SBarry Smith
679b92b1d3SBarry Smith:::{admonition} Note
689b92b1d3SBarry Smith:class: yellow
699b92b1d3SBarry Smith
709b92b1d3SBarry SmithThe configure options `CFLAGS`, `CXXFLAGS`, and `FFLAGS` overwrite most of the flags that PETSc would use by default. This is generally undesirable. To
719b92b1d3SBarry Smithadd to the default flags instead use `COPTFLAGS`, `CXXOPTFLAGS`, and `FOPTFLAGS` (these work for all uses of ./configure). The same holds for
729b92b1d3SBarry Smith`CUDAFLAGS`, `HIPFLAGS`, and `SYCLFLAGS`.
739b92b1d3SBarry Smith:::
749b92b1d3SBarry Smith
759b92b1d3SBarry Smith:::{admonition} Note
769b92b1d3SBarry Smith:class: yellow
779b92b1d3SBarry Smith
789b92b1d3SBarry SmithDo not specify `--with-cc`, `--with-fc` etc for the above when using
799b92b1d3SBarry Smith`--with-mpi-dir` - so that `mpicc`/ `mpif90` will be picked up from mpi-dir!
809b92b1d3SBarry Smith:::
819b92b1d3SBarry Smith
829b92b1d3SBarry Smith- Build Complex version of PETSc (using c++ compiler):
839b92b1d3SBarry Smith
849b92b1d3SBarry Smith  ```console
859b92b1d3SBarry Smith  $ ./configure --with-cc=gcc --with-fc=gfortran --with-cxx=g++ --with-clanguage=cxx --download-fblaslapack --download-mpich --with-scalar-type=complex
869b92b1d3SBarry Smith  ```
879b92b1d3SBarry Smith
889b92b1d3SBarry Smith- Install 2 variants of PETSc, one with gnu, the other with Intel compilers. Specify
899b92b1d3SBarry Smith  different `$PETSC_ARCH` for each build. See multiple PETSc install {ref}`documentation
909b92b1d3SBarry Smith  <doc_multi>` for further recommendations:
919b92b1d3SBarry Smith
929b92b1d3SBarry Smith  ```console
939b92b1d3SBarry Smith  $ ./configure PETSC_ARCH=linux-gnu --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-mpich
949b92b1d3SBarry Smith  $ make PETSC_ARCH=linux-gnu all test
959b92b1d3SBarry Smith  $ ./configure PETSC_ARCH=linux-gnu-intel --with-cc=icc --with-cxx=icpc --with-fc=ifort --download-mpich --with-blaslapack-dir=/usr/local/mkl
969b92b1d3SBarry Smith  $ make PETSC_ARCH=linux-gnu-intel all test
979b92b1d3SBarry Smith  ```
989b92b1d3SBarry Smith
999b92b1d3SBarry Smith(doc_config_compilers)=
1009b92b1d3SBarry Smith
1019b92b1d3SBarry Smith## Compilers
1029b92b1d3SBarry Smith
1039b92b1d3SBarry Smith:::{important}
1049b92b1d3SBarry SmithIf no compilers are specified - configure will automatically look for available MPI or
1059b92b1d3SBarry Smithregular compilers in the user's `$PATH` in the following order:
1069b92b1d3SBarry Smith
1079b92b1d3SBarry Smith1. `mpicc`/`mpicxx`/`mpif90`
1089b92b1d3SBarry Smith2. `gcc`/`g++`/`gfortran`
1099b92b1d3SBarry Smith3. `cc`/`CC` etc..
1109b92b1d3SBarry Smith:::
1119b92b1d3SBarry Smith
1129b92b1d3SBarry Smith- Specify compilers using the options `--with-cc`/`--with-cxx`/`--with-fc` for c,
1139b92b1d3SBarry Smith  c++, and fortran compilers respectively:
1149b92b1d3SBarry Smith
1159b92b1d3SBarry Smith  ```console
1169b92b1d3SBarry Smith  $ ./configure --with-cc=gcc --with-cxx=g++ --with-fc=gfortran
1179b92b1d3SBarry Smith  ```
1189b92b1d3SBarry Smith
1199b92b1d3SBarry Smith:::{important}
1209b92b1d3SBarry SmithIt's best to use MPI compiler wrappers [^id9]. This can be done by either specifying
1219b92b1d3SBarry Smith`--with-cc=mpicc` or `--with-mpi-dir` (and not `--with-cc=gcc`)
1229b92b1d3SBarry Smith
1239b92b1d3SBarry Smith```console
1249b92b1d3SBarry Smith$ ./configure --with-cc=mpicc --with-cxx=mpicxx --with-fc=mpif90
1259b92b1d3SBarry Smith```
1269b92b1d3SBarry Smith
1279b92b1d3SBarry Smithor the following (but **without** `--with-cc=gcc`)
1289b92b1d3SBarry Smith
1299b92b1d3SBarry Smith```console
1309b92b1d3SBarry Smith$ ./configure --with-mpi-dir=/opt/mpich2-1.1
1319b92b1d3SBarry Smith```
1329b92b1d3SBarry Smith
1339b92b1d3SBarry SmithSee {any}`doc_config_mpi` for details on how to select specific MPI compiler wrappers or the
1349b92b1d3SBarry Smithspecific compiler used by the MPI compiler wrapper.
1359b92b1d3SBarry Smith:::
1369b92b1d3SBarry Smith
1379b92b1d3SBarry Smith- If a Fortran compiler is not available or not needed - disable using:
1389b92b1d3SBarry Smith
1399b92b1d3SBarry Smith  ```console
1409b92b1d3SBarry Smith  $ ./configure --with-fc=0
1419b92b1d3SBarry Smith  ```
1429b92b1d3SBarry Smith
1439b92b1d3SBarry Smith- If a c++ compiler is not available or not needed - disable using:
1449b92b1d3SBarry Smith
1459b92b1d3SBarry Smith  ```console
1469b92b1d3SBarry Smith  $ ./configure --with-cxx=0
1479b92b1d3SBarry Smith  ```
1489b92b1d3SBarry Smith
1499b92b1d3SBarry Smith`configure` defaults to building PETSc in debug mode. One can switch to optimized
1509b92b1d3SBarry Smithmode with the `configure` option `--with-debugging=0` (we suggest using a different
1519b92b1d3SBarry Smith`$PETSC_ARCH` for debug and optimized builds, for example arch-debug and arch-opt, this
1529b92b1d3SBarry Smithway you can switch between debugging your code and running for performance by simply
1539b92b1d3SBarry Smithchanging the value of `$PETSC_ARCH`). See multiple install {ref}`documentation
1549b92b1d3SBarry Smith<doc_multi>` for further details.
1559b92b1d3SBarry Smith
1569b92b1d3SBarry SmithAdditionally one can specify more suitable optimization flags with the options
1579b92b1d3SBarry Smith`COPTFLAGS`, `FOPTFLAGS`, `CXXOPTFLAGS`. For example when using gnu compilers with
1589b92b1d3SBarry Smithcorresponding optimization flags:
1599b92b1d3SBarry Smith
1609b92b1d3SBarry Smith```console
1619b92b1d3SBarry Smith$ ./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
1629b92b1d3SBarry Smith```
1639b92b1d3SBarry Smith
1649b92b1d3SBarry Smith:::{warning}
1659b92b1d3SBarry Smith`configure` cannot detect compiler libraries for certain set of compilers. In this
1669b92b1d3SBarry Smithcase one can specify additional system/compiler libraries using the `LIBS` option:
1679b92b1d3SBarry Smith
1689b92b1d3SBarry Smith```console
1699b92b1d3SBarry Smith$ ./configure --LIBS='-ldl /usr/lib/libm.a'
1709b92b1d3SBarry Smith```
1719b92b1d3SBarry Smith:::
1729b92b1d3SBarry Smith
1739b92b1d3SBarry Smith(doc_config_externalpack)=
1749b92b1d3SBarry Smith
1759b92b1d3SBarry Smith## External Packages
1769b92b1d3SBarry Smith
1779b92b1d3SBarry Smith:::{admonition} Note
1789b92b1d3SBarry Smith:class: yellow
1799b92b1d3SBarry Smith
1809b92b1d3SBarry Smith[BLAS/LAPACK] is the only **required** {ref}`external package <doc_externalsoftware>`
1819b92b1d3SBarry Smith(other than of course build tools such as compilers and `make`). PETSc may be built
1829b92b1d3SBarry Smithand run without MPI support if processing only in serial.
1839b92b1d3SBarry Smith
1849b92b1d3SBarry SmithFor any {ref}`external packages <doc_externalsoftware>` used with PETSc we highly
1859b92b1d3SBarry Smithrecommend you have PETSc download and install the packages, rather than you installing
1869b92b1d3SBarry Smiththem separately first. This insures that:
1879b92b1d3SBarry Smith
1889b92b1d3SBarry Smith- The packages are installed with the same compilers and compiler options as PETSc
1899b92b1d3SBarry Smith  so that they can work together.
1909b92b1d3SBarry Smith- A **compatible** version of the package is installed. A generic install of this
1919b92b1d3SBarry Smith  package might not be compatible with PETSc (perhaps due to version differences - or
1929b92b1d3SBarry Smith  perhaps due to the requirement of additional patches for it to work with PETSc).
1939b92b1d3SBarry Smith- Some packages have bug fixes, portability patches, and upgrades for dependent
1949b92b1d3SBarry Smith  packages that have not yet been included in an upstream release, and hence may not
1959b92b1d3SBarry Smith  play nice with PETSc.
1969b92b1d3SBarry Smith:::
1979b92b1d3SBarry Smith
1989b92b1d3SBarry SmithPETSc provides interfaces to various {ref}`external packages <doc_externalsoftware>`. One
1999b92b1d3SBarry Smithcan optionally use external solvers like [HYPRE], [MUMPS], and others from within PETSc
2009b92b1d3SBarry Smithapplications.
2019b92b1d3SBarry Smith
2029b92b1d3SBarry SmithPETSc `configure` has the ability to download and install these {ref}`external packages
2039b92b1d3SBarry Smith<doc_externalsoftware>`. Alternatively if these packages are already installed, then
2049b92b1d3SBarry Smith`configure` can detect and use them.
2059b92b1d3SBarry Smith
2069b92b1d3SBarry SmithIf you are behind a firewall and cannot use a proxy for the downloads or have a very slow
2079b92b1d3SBarry Smithnetwork, use the additional option `--with-packages-download-dir=/path/to/dir`. This
2089b92b1d3SBarry Smithwill trigger `configure` to print the URLs of all the packages you must download. You
2099b92b1d3SBarry Smithmay then download the packages to some directory (do not uncompress or untar the files)
2109b92b1d3SBarry Smithand then point `configure` to these copies of the packages instead of trying to download
2119b92b1d3SBarry Smiththem directly from the internet.
2129b92b1d3SBarry Smith
2139b92b1d3SBarry SmithThe following modes can be used to download/install {ref}`external packages
2149b92b1d3SBarry Smith<doc_externalsoftware>` with `configure`.
2159b92b1d3SBarry Smith
2169b92b1d3SBarry Smith- `--download-PACKAGENAME`: Download specified package and install it, enabling PETSc to
2179b92b1d3SBarry Smith  use this package. **This is the recommended method to couple any external packages with PETSc**:
2189b92b1d3SBarry Smith
2199b92b1d3SBarry Smith  ```console
2209b92b1d3SBarry Smith  $ ./configure --download-fblaslapack --download-mpich
2219b92b1d3SBarry Smith  ```
2229b92b1d3SBarry Smith
2239b92b1d3SBarry Smith- `--download-PACKAGENAME=/path/to/PACKAGENAME.tar.gz`: If `configure` cannot
2249b92b1d3SBarry Smith  automatically download the package (due to network/firewall issues), one can download
2259b92b1d3SBarry Smith  the package by alternative means (perhaps wget, curl, or scp via some other
2269b92b1d3SBarry Smith  machine). Once the tarfile is downloaded, the path to this file can be specified to
2279b92b1d3SBarry Smith  configure with this option. `configure` will proceed to install this package and then
2289b92b1d3SBarry Smith  configure PETSc with it:
2299b92b1d3SBarry Smith
2309b92b1d3SBarry Smith  ```console
2319b92b1d3SBarry Smith  $ ./configure --download-mpich=/home/petsc/mpich2-1.0.4p1.tar.gz
2329b92b1d3SBarry Smith  ```
2339b92b1d3SBarry Smith
2349b92b1d3SBarry Smith- `--with-PACKAGENAME-dir=/path/to/dir`: If the external package is already installed -
2359b92b1d3SBarry Smith  specify its location to `configure` (it will attempt to detect and include relevant
2369b92b1d3SBarry Smith  library files from this location). Normally this corresponds to the top-level
2379b92b1d3SBarry Smith  installation directory for the package:
2389b92b1d3SBarry Smith
2399b92b1d3SBarry Smith  ```console
2409b92b1d3SBarry Smith  $ ./configure --with-mpi-dir=/home/petsc/software/mpich2-1.0.4p1
2419b92b1d3SBarry Smith  ```
2429b92b1d3SBarry Smith
2439b92b1d3SBarry Smith- `--with-PACKAGENAME-include=/path/to/include/dir` and
2449b92b1d3SBarry Smith  `--with-PACKAGENAME-lib=LIBRARYLIST`: Usually a package is defined completely by its
2459b92b1d3SBarry Smith  include file location and library list. If the package is already installed one can use
2469b92b1d3SBarry Smith  these two options to specify the package to `configure`. For example:
2479b92b1d3SBarry Smith
2489b92b1d3SBarry Smith  ```console
2499b92b1d3SBarry Smith  $ ./configure --with-superlu-include=/home/petsc/software/superlu/include --with-superlu-lib=/home/petsc/software/superlu/lib/libsuperlu.a
2509b92b1d3SBarry Smith  ```
2519b92b1d3SBarry Smith
2529b92b1d3SBarry Smith  or
2539b92b1d3SBarry Smith
2549b92b1d3SBarry Smith  ```console
2559b92b1d3SBarry Smith  $ ./configure --with-parmetis-include=/sandbox/balay/parmetis/include --with-parmetis-lib="-L/sandbox/balay/parmetis/lib -lparmetis -lmetis"
2569b92b1d3SBarry Smith  ```
2579b92b1d3SBarry Smith
2589b92b1d3SBarry Smith  or
2599b92b1d3SBarry Smith
2609b92b1d3SBarry Smith  ```console
2619b92b1d3SBarry Smith  $ ./configure --with-parmetis-include=/sandbox/balay/parmetis/include --with-parmetis-lib=[/sandbox/balay/parmetis/lib/libparmetis.a,libmetis.a]
2629b92b1d3SBarry Smith  ```
2639b92b1d3SBarry Smith
2649b92b1d3SBarry Smith:::{note}
2659b92b1d3SBarry Smith- Run `./configure --help` to get the list of {ref}`external packages
2669b92b1d3SBarry Smith  <doc_externalsoftware>` and corresponding additional options (for example
2679b92b1d3SBarry Smith  `--with-mpiexec` for [MPICH]).
2689b92b1d3SBarry Smith- Generally one would use either one of the above installation modes for any given
2699b92b1d3SBarry Smith  package - and not mix these. (i.e combining `--with-mpi-dir` and
2709b92b1d3SBarry Smith  `--with-mpi-include` etc. should be avoided).
2719b92b1d3SBarry Smith- Some packages might not support certain options like `--download-PACKAGENAME` or
2729b92b1d3SBarry Smith  `--with-PACKAGENAME-dir`. Architectures like Microsoft Windows might have issues
2739b92b1d3SBarry Smith  with these options. In these cases, `--with-PACKAGENAME-include` and
2749b92b1d3SBarry Smith  `--with-PACKAGENAME-lib` options should be preferred.
2759b92b1d3SBarry Smith:::
2769b92b1d3SBarry Smith
2779b92b1d3SBarry Smith- `--with-packages-build-dir=PATH`: By default, external packages will be unpacked and
2789b92b1d3SBarry Smith  the build process is run in `$PETSC_DIR/$PETSC_ARCH/externalpackages`. However one
2799b92b1d3SBarry Smith  can choose a different location where these packages are unpacked and the build process
2809b92b1d3SBarry Smith  is run.
2819b92b1d3SBarry Smith
2829b92b1d3SBarry Smith(doc_config_blaslapack)=
2839b92b1d3SBarry Smith
2849b92b1d3SBarry Smith## BLAS/LAPACK
2859b92b1d3SBarry Smith
2869b92b1d3SBarry SmithThese packages provide some basic numeric kernels used by PETSc. `configure` will
2879b92b1d3SBarry Smithautomatically look for [BLAS/LAPACK] in certain standard locations, on most systems you
2889b92b1d3SBarry Smithshould not need to provide any information about [BLAS/LAPACK] in the `configure`
2899b92b1d3SBarry Smithcommand.
2909b92b1d3SBarry Smith
2919b92b1d3SBarry SmithOne can use the following options to let `configure` download/install [BLAS/LAPACK]
2929b92b1d3SBarry Smithautomatically:
2939b92b1d3SBarry Smith
2949b92b1d3SBarry Smith- When fortran compiler is present:
2959b92b1d3SBarry Smith
2969b92b1d3SBarry Smith  ```console
2979b92b1d3SBarry Smith  $ ./configure --download-fblaslapack
2989b92b1d3SBarry Smith  ```
2999b92b1d3SBarry Smith
3009b92b1d3SBarry Smith- Or when configuring without a Fortran compiler - i.e `--with-fc=0`:
3019b92b1d3SBarry Smith
3029b92b1d3SBarry Smith  ```console
3039b92b1d3SBarry Smith  $ ./configure --download-f2cblaslapack
3049b92b1d3SBarry Smith  ```
3059b92b1d3SBarry Smith
3069b92b1d3SBarry SmithAlternatively one can use other options like one of the following:
3079b92b1d3SBarry Smith
3089b92b1d3SBarry Smith```console
3099b92b1d3SBarry Smith$ ./configure --with-blaslapack-lib=libsunperf.a
3109b92b1d3SBarry Smith$ ./configure --with-blas-lib=libblas.a --with-lapack-lib=liblapack.a
3119b92b1d3SBarry Smith$ ./configure --with-blaslapack-dir=/soft/com/packages/intel/13/079/mkl
3129b92b1d3SBarry Smith```
3139b92b1d3SBarry Smith
3149b92b1d3SBarry Smith### Intel MKL
3159b92b1d3SBarry Smith
3169b92b1d3SBarry SmithIntel provides [BLAS/LAPACK] via the [MKL] library. One can specify it
3179b92b1d3SBarry Smithto PETSc `configure` with `--with-blaslapack-dir=$MKLROOT` or
3189b92b1d3SBarry Smith`--with-blaslapack-dir=/soft/com/packages/intel/13/079/mkl`. If the above option does
3199b92b1d3SBarry Smithnot work - one could determine the correct library list for your compilers using Intel
3209b92b1d3SBarry Smith[MKL Link Line Advisor] and specify with the `configure` option
3219b92b1d3SBarry Smith`--with-blaslapack-lib`
3229b92b1d3SBarry Smith
3239b92b1d3SBarry Smith### IBM ESSL
3249b92b1d3SBarry Smith
3259b92b1d3SBarry SmithSadly, IBM's [ESSL] does not have all the routines of [BLAS/LAPACK] that some
3269b92b1d3SBarry Smithpackages, such as [SuperLU] expect; in particular slamch, dlamch and xerbla. In this
3279b92b1d3SBarry Smithcase instead of using [ESSL] we suggest `--download-fblaslapack`. If you really want
3289b92b1d3SBarry Smithto use [ESSL], see <https://www.pdc.kth.se/hpc-services>.
3299b92b1d3SBarry Smith
3309b92b1d3SBarry Smith(doc_config_mpi)=
3319b92b1d3SBarry Smith
3329b92b1d3SBarry Smith## MPI
3339b92b1d3SBarry Smith
3349b92b1d3SBarry SmithThe Message Passing Interface (MPI) provides the parallel functionality for PETSc.
3359b92b1d3SBarry Smith
3369b92b1d3SBarry SmithMPI might already be installed. IBM, Intel, NVIDIA, and Cray provide their own and Linux and macOS package
3379b92b1d3SBarry Smithmanagers also provide open-source versions called MPICH and Open MPI. If MPI is not already installed use
3389b92b1d3SBarry Smiththe following options to let PETSc's `configure` download and install MPI.
3399b92b1d3SBarry Smith
3409b92b1d3SBarry Smith- For [MPICH]:
3419b92b1d3SBarry Smith
3429b92b1d3SBarry Smith  ```console
3439b92b1d3SBarry Smith  $ ./configure --download-mpich
3449b92b1d3SBarry Smith  ```
34507a956dcSJunchao Zhang  If `--with-cuda` or `--with-hip` is also specified, MPICH will automatically be built to be GPU-aware.
34607a956dcSJunchao Zhang
3479b92b1d3SBarry Smith
3489b92b1d3SBarry Smith- For [Open MPI]:
3499b92b1d3SBarry Smith
3509b92b1d3SBarry Smith  ```console
3519b92b1d3SBarry Smith  $ ./configure --download-openmpi
3529b92b1d3SBarry Smith  ```
35307a956dcSJunchao Zhang  If `--with-cuda` is also specified, then Open MPI will automatically be built to be CUDA-aware. However to build ROCm-aware Open MPI, specify `--with-hip` and `--download-ucx` (or specify a prebuilt ROCm-enabled ucx with `--with-ucx-dir=<DIR>`).
35407a956dcSJunchao Zhang
3559b92b1d3SBarry Smith
3569b92b1d3SBarry Smith- To not use MPI:
3579b92b1d3SBarry Smith
3589b92b1d3SBarry Smith  ```console
3599b92b1d3SBarry Smith  $ ./configure --with-mpi=0
3609b92b1d3SBarry Smith  ```
3619b92b1d3SBarry Smith
3629b92b1d3SBarry Smith- To use an installed version of MPI
3639b92b1d3SBarry Smith
3649b92b1d3SBarry Smith  ```console
3659b92b1d3SBarry Smith  $ ./configure --with-cc=mpicc --with-cxx=mpicxx --with-fc=mpif90
3669b92b1d3SBarry Smith  ```
3679b92b1d3SBarry Smith
3689b92b1d3SBarry Smith- The Intel MPI library provides MPI compiler wrappers with compiler specific names.
3699b92b1d3SBarry Smith
3709b92b1d3SBarry Smith  GNU compilers: `gcc`, `g++`, `gfortran`:
3719b92b1d3SBarry Smith
3729b92b1d3SBarry Smith  ```console
3739b92b1d3SBarry Smith  $ ./configure --with-cc=mpigcc --with-cxx=mpigxx --with-fc=mpif90
3749b92b1d3SBarry Smith  ```
3759b92b1d3SBarry Smith
3769b92b1d3SBarry Smith  "Old" Intel compilers: `icc`, `icpc`, and `ifort`:
3779b92b1d3SBarry Smith
3789b92b1d3SBarry Smith  ```console
3799b92b1d3SBarry Smith  $ ./configure --with-cc=mpiicc --with-cxx=mpiicpc --with-fc=mpiifort
3809b92b1d3SBarry Smith  ```
3819b92b1d3SBarry Smith
3829b92b1d3SBarry Smith  they might not work with some Intel MPI library versions. In those cases, use
3839b92b1d3SBarry Smith
3849b92b1d3SBarry Smith  ```console
3859b92b1d3SBarry Smith  $ export I_MPI_CC=icc && export I_MPI_CXX=icpc && export I_MPI_F90=ifort
3869b92b1d3SBarry Smith  $ ./configure --with-cc=mpicc --with-cxx=mpicxx --with-fc=mpif90
3879b92b1d3SBarry Smith  ```
3889b92b1d3SBarry Smith
3899b92b1d3SBarry Smith- "New" oneAPI Intel compilers: `icx`, `icpx`, and `ifx`:
3909b92b1d3SBarry Smith
3919b92b1d3SBarry Smith  ```console
3929b92b1d3SBarry Smith  $ ./configure --with-cc=mpiicx --with-cxx=mpiicpx --with-fc=mpiifx
3939b92b1d3SBarry Smith  ```
3949b92b1d3SBarry Smith
3959b92b1d3SBarry Smith  they might not work with some Intel MPI library versions. In those cases, use
3969b92b1d3SBarry Smith
3979b92b1d3SBarry Smith  ```console
3989b92b1d3SBarry Smith  $ export I_MPI_CC=icx && export I_MPI_CXX=icpx && export I_MPI_F90=ifx
3999b92b1d3SBarry Smith  $ ./configure --with-cc=mpicc --with-cxx=mpicxx --with-fc=mpif90
4009b92b1d3SBarry Smith  ```
4019b92b1d3SBarry Smith
4029b92b1d3SBarry Smith- On Cray systems, after loading the appropriate MPI module, the regular compilers `cc`, `CC`, and `ftn`
4039b92b1d3SBarry Smith  automatically become MPI compiler wrappers.
4049b92b1d3SBarry Smith
4059b92b1d3SBarry Smith  ```console
4069b92b1d3SBarry Smith  $ ./configure --with-cc=cc --with-cxx=CC --with-fc=ftn
4079b92b1d3SBarry Smith  ```
4089b92b1d3SBarry Smith
4099b92b1d3SBarry Smith- Instead of providing the MPI compiler wrappers, one can provide the MPI installation directory, where the MPI compiler wrappers are available in the bin directory,
4109b92b1d3SBarry Smith  (without additionally specifying `--with-cc` etc.) using
4119b92b1d3SBarry Smith
4129b92b1d3SBarry Smith  ```console
4139b92b1d3SBarry Smith  $  ./configure --with-mpi-dir=/absolute/path/to/mpi/install/directory
4149b92b1d3SBarry Smith  ```
4159b92b1d3SBarry Smith
4169b92b1d3SBarry Smith- To control the compilers selected by `mpicc`, `mpicxx`, and `mpif90` one may use environmental
4179b92b1d3SBarry Smith  variables appropriate for the MPI libraries. For Intel MPI, MPICH, and Open MPI they are
4189b92b1d3SBarry Smith
4199b92b1d3SBarry Smith  ```console
4209b92b1d3SBarry Smith  $ export I_MPI_CC=c_compiler && export I_MPI_CXX=c++_compiler && export I_MPI_F90=fortran_compiler
4219b92b1d3SBarry Smith  $ export MPICH_CC=c_compiler && export MPICH_CXX=c++_compiler && export MPICH_FC=fortran_compiler
4229b92b1d3SBarry Smith  $ export OMPI_CC=c_compiler && export OMPI_CXX=c++_compiler && export OMPI_FC=fortran_compiler
4239b92b1d3SBarry Smith  ```
4249b92b1d3SBarry Smith
4259b92b1d3SBarry Smith  Then, use
4269b92b1d3SBarry Smith
4279b92b1d3SBarry Smith  ```console
4289b92b1d3SBarry Smith  $ ./configure --with-cc=mpicc --with-fc=mpif90 --with-cxx=mpicxx
4299b92b1d3SBarry Smith  ```
4309b92b1d3SBarry Smith
4319b92b1d3SBarry Smith  We recommend avoiding these environmental variables unless absolutely necessary.
4329b92b1d3SBarry Smith  They are easy to forget or they may be set and then forgotten, thus resulting in unexpected behavior.
4339b92b1d3SBarry Smith
4349b92b1d3SBarry Smith  And avoid using the syntax `--with-cc="mpicc -cc=icx"` - this can break some builds (for example: external packages that use CMake)
4359b92b1d3SBarry Smith
4369b92b1d3SBarry Smith  :::{note}
4379b92b1d3SBarry Smith  The Intel environmental variables `I_MPI_CC`, `I_MPI_CXX`, and `I_MPI_F90` also changing the
4387f296bb3SBarry Smith  behavior of the compiler-specific MPI compiler wrappers `mpigcc`, `mpigxx`, `mpif90`, `mpiicx`,
4399b92b1d3SBarry Smith  `mpiicpx`, `mpiifx`, `mpiicc`, `mpiicpc`, and `mpiifort`. These variables may be automatically
4409b92b1d3SBarry Smith  set by certain modules. So one must be careful to ensure they are using the desired compilers.
4419b92b1d3SBarry Smith  :::
4429b92b1d3SBarry Smith
4439b92b1d3SBarry Smith### Installing With Open MPI With Shared MPI Libraries
4449b92b1d3SBarry Smith
4459b92b1d3SBarry Smith[Open MPI] defaults to building shared libraries for MPI. However, the binaries generated
4469b92b1d3SBarry Smithby MPI compiler wrappers `mpicc`/`mpif90` etc. require `$LD_LIBRARY_PATH` to be set to the
4479b92b1d3SBarry Smithlocation of these libraries.
4489b92b1d3SBarry Smith
4499b92b1d3SBarry SmithDue to this [Open MPI] restriction one has to set `$LD_LIBRARY_PATH` correctly (per [Open MPI] [installation instructions]), before running PETSc `configure`. If you do not set this environmental variables you will get messages when running `configure` such as:
4509b92b1d3SBarry Smith
4519b92b1d3SBarry Smith```text
4529b92b1d3SBarry SmithUNABLE to EXECUTE BINARIES for config/configure.py
4539b92b1d3SBarry Smith-------------------------------------------------------------------------------
4549b92b1d3SBarry SmithCannot run executables created with C. If this machine uses a batch system
4559b92b1d3SBarry Smithto submit jobs you will need to configure using/configure.py with the additional option --with-batch.
4569b92b1d3SBarry SmithOtherwise there is problem with the compilers. Can you compile and run code with your C/C++ (and maybe Fortran) compilers?
4579b92b1d3SBarry Smith```
4589b92b1d3SBarry Smith
4599b92b1d3SBarry Smithor when running a code compiled with [Open MPI]:
4609b92b1d3SBarry Smith
4619b92b1d3SBarry Smith```text
4629b92b1d3SBarry Smitherror while loading shared libraries: libmpi.so.0: cannot open shared object file: No such file or directory
4639b92b1d3SBarry Smith```
4649b92b1d3SBarry Smith
4659b92b1d3SBarry Smith(doc_macos_install)=
4669b92b1d3SBarry Smith
4679b92b1d3SBarry Smith## Installing On macOS
4689b92b1d3SBarry Smith
4699b92b1d3SBarry SmithFor development on macOS we recommend installing **both** the Apple Xcode GUI development system (install from the Apple macOS store) and the Xcode Command Line tools [^id10] install with
4709b92b1d3SBarry Smith
4719b92b1d3SBarry Smith```console
4729b92b1d3SBarry Smith$ xcode-select --install
4739b92b1d3SBarry Smith```
4749b92b1d3SBarry Smith
4759b92b1d3SBarry SmithThe Apple compilers are `clang` and `clang++` [^id11]. Apple also provides `/usr/bin/gcc`, which is, confusingly, a link to the `clang` compiler, not the GNU compiler.
4769b92b1d3SBarry Smith
4779b92b1d3SBarry SmithWe also recommend installing the package manager [homebrew](https://brew.sh/). To install `gfortran` one can use
4789b92b1d3SBarry Smith
4799b92b1d3SBarry Smith```console
4809b92b1d3SBarry Smith$ brew update
4819b92b1d3SBarry Smith$ brew list            # Show all packages installed through brew
4829b92b1d3SBarry Smith$ brew upgrade         # Update packages already installed through brew
4839b92b1d3SBarry Smith$ brew install gcc
4849b92b1d3SBarry Smith```
4859b92b1d3SBarry Smith
4869b92b1d3SBarry SmithThis installs gfortran, gcc, and g++ with the compiler names
4879b92b1d3SBarry Smith`gfortran-version` (also available as `gfortran`), `gcc-version` and `g++-version`, for example `gfortran-12`, `gcc-12`, and `g++-12`.
4889b92b1d3SBarry Smith
4899b92b1d3SBarry SmithAfter upgrading macOS, you generally need to update the Xcode GUI development system (using the standard Apple software update system),
4909b92b1d3SBarry Smithand the Xcode Command Line tools (run `xcode-select --install` again).
4919b92b1d3SBarry Smith
4929b92b1d3SBarry SmithIts best to update `brew` after all macOS or Xcode upgrades (use `brew upgrade`). Sometimes gfortran will not work correctly after an upgrade. If this happens
4939b92b1d3SBarry Smithit is best to reinstall all `brew` packages using, for example,
4949b92b1d3SBarry Smith
4959b92b1d3SBarry Smith```console
4969b92b1d3SBarry Smith$ brew leaves > list.txt         # save list of formulae to re-install
4979b92b1d3SBarry Smith$ brew list --casks >> list.txt  # save list of casks to re-install
4989b92b1d3SBarry Smith$ emacs list.txt                 # edit list.txt to remove any unneeded formulae or casks
4999b92b1d3SBarry Smith$ brew uninstall `brew list`     # delete all installed formulae and casks
5009b92b1d3SBarry Smith$ brew cleanup
5019b92b1d3SBarry Smith$ brew update
5029b92b1d3SBarry Smith$ brew install `cat list.txt`    # install needed formulae and casks
5039b92b1d3SBarry Smith```
5049b92b1d3SBarry Smith
5059b92b1d3SBarry Smith(doc_config_install)=
5069b92b1d3SBarry Smith
5079b92b1d3SBarry Smith## Installation Location: In-place or Out-of-place
5089b92b1d3SBarry Smith
5099b92b1d3SBarry SmithBy default, PETSc does an in-place installation, meaning the libraries are kept in the
5109b92b1d3SBarry Smithsame directories used to compile PETSc. This is particularly useful for those application
5119b92b1d3SBarry Smithdevelopers who follow the PETSc git repository main or release branches since rebuilds
5129b92b1d3SBarry Smithfor updates are very quick and painless.
5139b92b1d3SBarry Smith
5149b92b1d3SBarry Smith:::{note}
5159b92b1d3SBarry SmithThe libraries and include files are located in `$PETSC_DIR/$PETSC_ARCH/lib` and
5169b92b1d3SBarry Smith`$PETSC_DIR/$PETSC_ARCH/include`
5179b92b1d3SBarry Smith:::
5189b92b1d3SBarry Smith
5199b92b1d3SBarry Smith### Out-of-place Installation With `--prefix`
5209b92b1d3SBarry Smith
5219b92b1d3SBarry SmithTo install the libraries and include files in another location use the `--prefix` option
5229b92b1d3SBarry Smith
5239b92b1d3SBarry Smith```console
5249b92b1d3SBarry Smith$ ./configure --prefix=/home/userid/my-petsc-install --some-other-options
5259b92b1d3SBarry Smith```
5269b92b1d3SBarry Smith
5279b92b1d3SBarry SmithThe libraries and include files will be located in `/home/userid/my-petsc-install/lib`
5289b92b1d3SBarry Smithand `/home/userid/my-petsc-install/include`.
5299b92b1d3SBarry Smith
5309b92b1d3SBarry Smith### Installation in Root Location, **Not Recommended** (Uncommon)
5319b92b1d3SBarry Smith
5329b92b1d3SBarry Smith:::{warning}
5339b92b1d3SBarry SmithOne should never run `configure` or make on any package using root access. **Do so at
5349b92b1d3SBarry Smithyour own risk**.
5359b92b1d3SBarry Smith:::
5369b92b1d3SBarry Smith
5379b92b1d3SBarry SmithIf one wants to install PETSc in a common system location like `/usr/local` or `/opt`
5389b92b1d3SBarry Smiththat requires root access we suggest creating a directory for PETSc with user privileges,
5399b92b1d3SBarry Smithand then do the PETSc install as a **regular/non-root** user:
5409b92b1d3SBarry Smith
5419b92b1d3SBarry Smith```console
5429b92b1d3SBarry Smith$ sudo mkdir /opt/petsc
5439b92b1d3SBarry Smith$ sudo chown user:group /opt/petsc
5449b92b1d3SBarry Smith$ cd /home/userid/petsc
5459b92b1d3SBarry Smith$ ./configure --prefix=/opt/petsc/my-root-petsc-install --some-other-options
5469b92b1d3SBarry Smith$ make
5479b92b1d3SBarry Smith$ make install
5489b92b1d3SBarry Smith```
5499b92b1d3SBarry Smith
5509b92b1d3SBarry Smith### Installs For Package Managers: Using `DESTDIR` (Very uncommon)
5519b92b1d3SBarry Smith
5529b92b1d3SBarry Smith```console
5539b92b1d3SBarry Smith$ ./configure --prefix=/opt/petsc/my-root-petsc-install
5549b92b1d3SBarry Smith$ make
5559b92b1d3SBarry Smith$ make install DESTDIR=/tmp/petsc-pkg
5569b92b1d3SBarry Smith```
5579b92b1d3SBarry Smith
5589b92b1d3SBarry SmithPackage up `/tmp/petsc-pkg`. The package should then be installed at
5599b92b1d3SBarry Smith`/opt/petsc/my-root-petsc-install`
5609b92b1d3SBarry Smith
5619b92b1d3SBarry Smith### Multiple Installs Using `--prefix` (See `DESTDIR`)
5629b92b1d3SBarry Smith
5639b92b1d3SBarry SmithSpecify a different `--prefix` location for each configure of different options - at
5649b92b1d3SBarry Smithconfigure time. For example:
5659b92b1d3SBarry Smith
5669b92b1d3SBarry Smith```console
567*51619389SSatish Balay$ ./configure --prefix=/opt/petsc/petsc-3.24.0-mpich --with-mpi-dir=/opt/mpich
5689b92b1d3SBarry Smith$ make
5699b92b1d3SBarry Smith$ make install [DESTDIR=/tmp/petsc-pkg]
570*51619389SSatish Balay$ ./configure --prefix=/opt/petsc/petsc-3.24.0-openmpi --with-mpi-dir=/opt/openmpi
5719b92b1d3SBarry Smith$ make
5729b92b1d3SBarry Smith$ make install [DESTDIR=/tmp/petsc-pkg]
5739b92b1d3SBarry Smith```
5749b92b1d3SBarry Smith
5759b92b1d3SBarry Smith### In-place Installation
5769b92b1d3SBarry Smith
5779b92b1d3SBarry SmithThe PETSc libraries and generated included files are placed in the sub-directory off the
5789b92b1d3SBarry Smithcurrent directory `$PETSC_ARCH` which is either provided by the user with, for example:
5799b92b1d3SBarry Smith
5809b92b1d3SBarry Smith```console
5819b92b1d3SBarry Smith$ export PETSC_ARCH=arch-debug
5829b92b1d3SBarry Smith$ ./configure
5839b92b1d3SBarry Smith$ make
5849b92b1d3SBarry Smith$ export PETSC_ARCH=arch-opt
5859b92b1d3SBarry Smith$ ./configure --some-optimization-options
5869b92b1d3SBarry Smith$ make
5879b92b1d3SBarry Smith```
5889b92b1d3SBarry Smith
5899b92b1d3SBarry Smithor
5909b92b1d3SBarry Smith
5919b92b1d3SBarry Smith```console
5929b92b1d3SBarry Smith$ ./configure PETSC_ARCH=arch-debug
5939b92b1d3SBarry Smith$ make
5949b92b1d3SBarry Smith$ ./configure --some-optimization-options PETSC_ARCH=arch-opt
5959b92b1d3SBarry Smith$ make
5969b92b1d3SBarry Smith```
5979b92b1d3SBarry Smith
5989b92b1d3SBarry SmithIf not provided `configure` will generate a unique value automatically (for in-place non
5999b92b1d3SBarry Smith`--prefix` configurations only).
6009b92b1d3SBarry Smith
6019b92b1d3SBarry Smith```console
6029b92b1d3SBarry Smith$ ./configure
6039b92b1d3SBarry Smith$ make
6049b92b1d3SBarry Smith$ ./configure --with-debugging=0
6059b92b1d3SBarry Smith$ make
6069b92b1d3SBarry Smith```
6079b92b1d3SBarry Smith
6089b92b1d3SBarry SmithProduces the directories (on an Apple macOS machine) `$PETSC_DIR/arch-darwin-c-debug` and
6099b92b1d3SBarry Smith`$PETSC_DIR/arch-darwin-c-opt`.
6109b92b1d3SBarry Smith
6119b92b1d3SBarry Smith## Installing On Machine Requiring Cross Compiler Or A Job Scheduler
6129b92b1d3SBarry Smith
6139b92b1d3SBarry SmithOn systems where you need to use a job scheduler or batch submission to run jobs use the
6149b92b1d3SBarry Smith`configure` option `--with-batch`. **On such systems the make check option will not
6159b92b1d3SBarry Smithwork**.
6169b92b1d3SBarry Smith
6179b92b1d3SBarry Smith- You must first ensure you have loaded appropriate modules for the compilers etc that you
6189b92b1d3SBarry Smith  wish to use. Often the compilers are provided automatically for you and you do not need
6199b92b1d3SBarry Smith  to provide `--with-cc=XXX` etc. Consult with the documentation and local support for
6209b92b1d3SBarry Smith  such systems for information on these topics.
6219b92b1d3SBarry Smith- On such systems you generally should not use `--with-blaslapack-dir` or
6229b92b1d3SBarry Smith  `--download-fblaslapack` since the systems provide those automatically (sometimes
6239b92b1d3SBarry Smith  appropriate modules must be loaded first).
6249b92b1d3SBarry Smith- Some package's `--download-package` options do not work on these systems, for example
6259b92b1d3SBarry Smith  [HDF5]. Thus you must use modules to load those packages and `--with-package` to
6269b92b1d3SBarry Smith  configure with the package.
6279b92b1d3SBarry Smith- Since building {ref}`external packages <doc_externalsoftware>` on these systems is often
6289b92b1d3SBarry Smith  troublesome and slow we recommend only installing PETSc with those configuration
6299b92b1d3SBarry Smith  packages that you need for your work, not extras.
6309b92b1d3SBarry Smith
6319b92b1d3SBarry Smith(doc_config_tau)=
6329b92b1d3SBarry Smith
6339b92b1d3SBarry Smith## Installing With TAU Instrumentation Package
6349b92b1d3SBarry Smith
6359b92b1d3SBarry Smith[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:
6369b92b1d3SBarry Smith
6379b92b1d3SBarry Smith```console
6389b92b1d3SBarry Smith$ export TAU_MAKEFILE=/home/balay/soft/linux64/tau-2.20.3/x86_64/lib/Makefile.tau-mpi-pdt
6399b92b1d3SBarry Smith$ ./configure CC=/home/balay/soft/linux64/tau-2.20.3/x86_64/bin/tau_cc.sh --with-fc=0 PETSC_ARCH=arch-tau
6409b92b1d3SBarry Smith```
6419b92b1d3SBarry Smith
6429b92b1d3SBarry Smith(doc_config_accel)=
6439b92b1d3SBarry Smith
6449b92b1d3SBarry Smith## Installing PETSc To Use GPUs And Accelerators
6459b92b1d3SBarry Smith
6469b92b1d3SBarry SmithPETSc is able to take advantage of GPU's and certain accelerator libraries, however some require additional `configure` options.
6479b92b1d3SBarry Smith
6486c572908SJunchao Zhang(doc_config_accel_openmp)=
6499b92b1d3SBarry Smith
6509b92b1d3SBarry Smith### `OpenMP`
6519b92b1d3SBarry Smith
6529b92b1d3SBarry SmithUse `--with-openmp` to allow PETSc to be used within an OpenMP application; this also turns on OpenMP for all the packages that
6539b92b1d3SBarry SmithPETSc builds using `--download-xxx`. If your application calls PETSc from within OpenMP threads then also use `--with-threadsafety`.
6549b92b1d3SBarry Smith
6559b92b1d3SBarry SmithUse `--with-openmp-kernels` to have some PETSc numerical routines use OpenMP to speed up their computations. This requires `--with-openmp`.
6569b92b1d3SBarry Smith
6579b92b1d3SBarry SmithNote that using OpenMP within MPI code must be done carefully to prevent too many OpenMP threads that overload the number of cores.
6589b92b1d3SBarry Smith
6596c572908SJunchao Zhang(doc_config_accel_cuda)=
6606c572908SJunchao Zhang
6619b92b1d3SBarry Smith### [CUDA]
6629b92b1d3SBarry Smith
6639b92b1d3SBarry Smith:::{important}
6649b92b1d3SBarry SmithAn NVIDIA GPU is **required** to use [CUDA]-accelerated code. Check that your machine
6659b92b1d3SBarry Smithhas a [CUDA] enabled GPU by consulting <https://developer.nvidia.com/cuda-gpus>.
6669b92b1d3SBarry Smith:::
6679b92b1d3SBarry Smith
6689b92b1d3SBarry SmithOn Linux - verify [^id12] that CUDA compatible [NVIDIA driver](https://www.nvidia.com/en-us/drivers) is installed.
6699b92b1d3SBarry Smith
6709b92b1d3SBarry SmithOn Microsoft Windows - Use either [Cygwin] or [WSL] the latter of which is entirely untested right
6719b92b1d3SBarry Smithnow. If you have experience with [WSL] and/or have successfully built PETSc on Microsoft Windows
6729b92b1d3SBarry Smithfor use with [CUDA] we welcome your input at <mailto:petsc-maint@mcs.anl.gov>. See the
6739b92b1d3SBarry Smithbug-reporting {ref}`documentation <doc_creepycrawly>` for more details.
6749b92b1d3SBarry Smith
6759b92b1d3SBarry SmithIn most cases you need only pass the configure option `--with-cuda`; check
6769b92b1d3SBarry Smith`config/examples/arch-ci-linux-cuda-double.py` for example usage.
6779b92b1d3SBarry Smith
6789b92b1d3SBarry SmithCUDA build of PETSc currently works on Mac OS X, Linux, Microsoft Windows with [Cygwin].
6799b92b1d3SBarry Smith
6809b92b1d3SBarry SmithExamples that use CUDA have the suffix .cu; see `$PETSC_DIR/src/snes/tutorials/ex47cu.cu`
6819b92b1d3SBarry Smith
6829b92b1d3SBarry Smith(doc_config_accel_kokkos)=
6839b92b1d3SBarry Smith
6849b92b1d3SBarry Smith### [Kokkos]
6859b92b1d3SBarry Smith
6869b92b1d3SBarry SmithIn most cases you need only pass the configure option `--download-kokkos` `--download-kokkos-kernels`
6876c572908SJunchao Zhangand one of `--with-cuda`, `--with-hip`, `--with-sycl`, `--with-openmp`, or `--with-pthread` (or nothing to use sequential
6889b92b1d3SBarry Smith[Kokkos]). See the {ref}`CUDA installation documentation <doc_config_accel_cuda>`,
6896c572908SJunchao Zhang{ref}`OpenMP installation documentation <doc_config_accel_openmp>` for further reference on
6906c572908SJunchao Zhangrespective requirements of some installations.
6919b92b1d3SBarry Smith
6929b92b1d3SBarry SmithExamples that use [Kokkos] at user-level have the suffix .kokkos.cxx; see
6939b92b1d3SBarry Smith`src/snes/tutorials/ex3k.kokkos.cxx`. More examples use [Kokkos] through options database;
6949b92b1d3SBarry Smithsearch them with `grep -r -l "requires:.*kokkos_kernels" src/`.
6959b92b1d3SBarry Smith
6969b92b1d3SBarry Smith(doc_config_accel_opencl)=
6979b92b1d3SBarry Smith
6989b92b1d3SBarry Smith### [OpenCL]/[ViennaCL]
6999b92b1d3SBarry Smith
7009b92b1d3SBarry SmithRequires the [OpenCL] shared library, which is shipped in the vendor graphics driver and
7019b92b1d3SBarry Smiththe [OpenCL] headers; if needed you can download them from the Khronos Group
7029b92b1d3SBarry Smithdirectly. Package managers on Linux provide these headers through a package named
7039b92b1d3SBarry Smith'opencl-headers' or similar. On Apple systems the [OpenCL] drivers and headers are always
7049b92b1d3SBarry Smithavailable and do not need to be downloaded.
7059b92b1d3SBarry Smith
7069b92b1d3SBarry SmithAlways make sure you have the latest GPU driver installed. There are several known issues
7079b92b1d3SBarry Smithwith older driver versions.
7089b92b1d3SBarry Smith
7099b92b1d3SBarry SmithRun `configure` with `--download-viennacl`; check
7109b92b1d3SBarry Smith`config/examples/arch-ci-linux-viennacl.py` for example usage.
7119b92b1d3SBarry Smith
7129b92b1d3SBarry Smith[OpenCL]/[ViennaCL] builds of PETSc currently work on Mac OS X, Linux, and Microsoft Windows.
7139b92b1d3SBarry Smith
7149b92b1d3SBarry Smith(doc_emcc)=
7159b92b1d3SBarry Smith
7169b92b1d3SBarry Smith## Installing To Run in Browser with Emscripten
7179b92b1d3SBarry Smith
7189b92b1d3SBarry SmithPETSc can be used to run applications in the browser using <https://emscripten.org>, see <https://emscripten.org/docs/getting_started/downloads.html>,
7199b92b1d3SBarry Smithfor instructions on installing Emscripten. Run
7209b92b1d3SBarry Smith
7219b92b1d3SBarry Smith```console
7229b92b1d3SBarry Smith$  ./configure --with-cc=emcc --with-cxx=0 --with-fc=0 --with-ranlib=emranlib --with-ar=emar --with-shared-libraries=0 --download-f2cblaslapack=1 --with-mpi=0 --with-batch
7239b92b1d3SBarry Smith```
7249b92b1d3SBarry Smith
7259b92b1d3SBarry SmithApplications may be compiled with, for example,
7269b92b1d3SBarry Smith
7279b92b1d3SBarry Smith```console
7289b92b1d3SBarry Smith$  make ex19.html
7299b92b1d3SBarry Smith```
7309b92b1d3SBarry Smith
7319b92b1d3SBarry SmithThe rule for linking may be found in <a href="PETSC_DOC_OUT_ROOT_PLACEHOLDER/lib/petsc/conf/rules">lib/petsc/conf/rules></a>
7329b92b1d3SBarry Smith
7339b92b1d3SBarry Smith(doc_config_hpc)=
7349b92b1d3SBarry Smith
7359b92b1d3SBarry Smith## Installing On Large Scale DOE Systems
7369b92b1d3SBarry Smith
7379b92b1d3SBarry SmithThere are some notes on our [GitLab Wiki](https://gitlab.com/petsc/petsc/-/wikis/Installing-and-Running-on-Large-Scale-Systems)
7389b92b1d3SBarry Smithwhich may be helpful in installing and running PETSc on large scale
7399b92b1d3SBarry Smithsystems. Also note the configuration examples in `config/examples`.
7409b92b1d3SBarry Smith
7419b92b1d3SBarry Smith```{rubric} Footnotes
7429b92b1d3SBarry Smith```
7439b92b1d3SBarry Smith
7449b92b1d3SBarry Smith[^id9]: All MPI implementations provide convenience scripts for compiling MPI codes that internally call regular compilers, they are commonly named `mpicc`, `mpicxx`, and `mpif90`. We call these "MPI compiler wrappers".
7459b92b1d3SBarry Smith
7469b92b1d3SBarry Smith[^id10]: The two packages provide slightly different (though largely overlapping) functionality which can only be fully used if both packages are installed.
7479b92b1d3SBarry Smith
7489b92b1d3SBarry Smith[^id11]: Apple provides customized `clang` and `clang++` for its system. To use the unmodified LLVM project `clang` and `clang++`
7499b92b1d3SBarry Smith    install them with brew.
7509b92b1d3SBarry Smith
7519b92b1d3SBarry Smith[^id12]: To verify CUDA compatible Nvidia driver on Linux - run the utility `nvidia-smi` - it should provide the version of the Nvidia driver currently installed, and the maximum CUDA version it supports.
7529b92b1d3SBarry Smith
7539b92b1d3SBarry Smith[blas/lapack]: https://www.netlib.org/lapack/lug/node11.html
7549b92b1d3SBarry Smith[cuda]: https://developer.nvidia.com/cuda-toolkit
7559b92b1d3SBarry Smith[cygwin]: https://www.cygwin.com/
7569b92b1d3SBarry Smith[essl]: https://www.ibm.com/support/knowledgecenter/en/SSFHY8/essl_welcome.html
7579b92b1d3SBarry Smith[hdf5]: https://www.hdfgroup.org/solutions/hdf5/
7589b92b1d3SBarry Smith[hypre]: https://computing.llnl.gov/projects/hypre-scalable-linear-solvers-multigrid-methods
7599b92b1d3SBarry Smith[installation instructions]: https://www.open-mpi.org/faq/?category=building
7609b92b1d3SBarry Smith[kokkos]: https://github.com/kokkos/kokkos
7619b92b1d3SBarry Smith[metis]: http://glaros.dtc.umn.edu/gkhome/metis/metis/overview
7629b92b1d3SBarry Smith[mkl]: https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/onemkl.html
7639b92b1d3SBarry Smith[mkl link line advisor]: https://software.intel.com/content/www/us/en/develop/articles/intel-mkl-link-line-advisor.html
7649b92b1d3SBarry Smith[modules]: https://www.alcf.anl.gov/support-center/theta/compiling-and-linking-overview-theta-thetagpu
7659b92b1d3SBarry Smith[mpich]: https://www.mpich.org/
7669b92b1d3SBarry Smith[mumps]: https://mumps-solver.org/
7679b92b1d3SBarry Smith[open mpi]: https://www.open-mpi.org/
7689b92b1d3SBarry Smith[opencl]: https://www.khronos.org/opencl/
7699b92b1d3SBarry Smith[parmetis]: http://glaros.dtc.umn.edu/gkhome/metis/parmetis/overview
7709b92b1d3SBarry Smith[pdt]: https://www.cs.uoregon.edu/research/pdt/home.php
7719b92b1d3SBarry Smith[superlu]: https://portal.nersc.gov/project/sparse/superlu/
7729b92b1d3SBarry Smith[superlu_dist]: https://github.com/xiaoyeli/superlu_dist
7739b92b1d3SBarry Smith[tau]: https://www.cs.uoregon.edu/research/tau/home.php
7749b92b1d3SBarry Smith[viennacl]: http://viennacl.sourceforge.net/
7759b92b1d3SBarry Smith[wsl]: https://docs.microsoft.com/en-us/windows/wsl/install-win10
776