xref: /petsc/doc/install/install.md (revision 9b92b1d3a7bbc5a081edc9021bfd15a36804dd1c)
1*9b92b1d3SBarry Smith(doc_config_faq)=
2*9b92b1d3SBarry Smith
3*9b92b1d3SBarry Smith# Configuring PETSc
4*9b92b1d3SBarry Smith
5*9b92b1d3SBarry Smith:::{important}
6*9b92b1d3SBarry SmithObtain PETSc via the repository or download the latest tarball: {ref}`download documentation <doc_download>`.
7*9b92b1d3SBarry Smith
8*9b92b1d3SBarry SmithSee {ref}`quick-start tutorial <tut_install>` for a step-by-step walk-through of the installation process.
9*9b92b1d3SBarry Smith:::
10*9b92b1d3SBarry Smith
11*9b92b1d3SBarry Smith```{contents} Table of Contents
12*9b92b1d3SBarry Smith:backlinks: entry
13*9b92b1d3SBarry Smith:depth: 1
14*9b92b1d3SBarry Smith:local: true
15*9b92b1d3SBarry Smith```
16*9b92b1d3SBarry Smith
17*9b92b1d3SBarry Smith## Common Example Usages
18*9b92b1d3SBarry Smith
19*9b92b1d3SBarry Smith:::{attention}
20*9b92b1d3SBarry SmithThere are many example `configure` scripts at `config/examples/*.py`. These cover a
21*9b92b1d3SBarry Smithwide variety of systems, and we use some of these scripts locally for testing. One can
22*9b92b1d3SBarry Smithmodify these files and run them in lieu of writing one yourself. For example:
23*9b92b1d3SBarry Smith
24*9b92b1d3SBarry Smith```console
25*9b92b1d3SBarry Smith$ ./config/examples/arch-ci-osx-dbg.py
26*9b92b1d3SBarry Smith```
27*9b92b1d3SBarry Smith
28*9b92b1d3SBarry SmithIf there is a system for which we do not yet have such a `configure` script and/or
29*9b92b1d3SBarry Smiththe script in the examples directory is outdated we welcome your feedback by submitting
30*9b92b1d3SBarry Smithyour recommendations to <mailto:petsc-maint@mcs.anl.gov>. See bug report {ref}`documentation
31*9b92b1d3SBarry Smith<doc_creepycrawly>` for more information.
32*9b92b1d3SBarry Smith:::
33*9b92b1d3SBarry Smith
34*9b92b1d3SBarry Smith- If you do not have a Fortran compiler or [MPICH](https://www.mpich.org/) installed
35*9b92b1d3SBarry Smith  locally (and want to use PETSc from C only).
36*9b92b1d3SBarry Smith
37*9b92b1d3SBarry Smith  ```console
38*9b92b1d3SBarry Smith  $ ./configure --with-cc=gcc --with-cxx=0 --with-fc=0 --download-f2cblaslapack --download-mpich
39*9b92b1d3SBarry Smith  ```
40*9b92b1d3SBarry Smith
41*9b92b1d3SBarry Smith- Same as above - but install in a user specified (prefix) location.
42*9b92b1d3SBarry Smith
43*9b92b1d3SBarry Smith  ```console
44*9b92b1d3SBarry Smith  $ ./configure --prefix=/home/user/soft/petsc-install --with-cc=gcc --with-cxx=0 --with-fc=0 --download-f2cblaslapack --download-mpich
45*9b92b1d3SBarry Smith  ```
46*9b92b1d3SBarry Smith
47*9b92b1d3SBarry Smith- If [BLAS/LAPACK], MPI sources (in "-devel" packages in most Linux distributions) are already
48*9b92b1d3SBarry Smith  installed in default system/compiler locations and `mpicc`, `mpif90`, mpiexec are available
49*9b92b1d3SBarry Smith  via `$PATH` - configure does not require any additional options.
50*9b92b1d3SBarry Smith
51*9b92b1d3SBarry Smith  ```console
52*9b92b1d3SBarry Smith  $ ./configure
53*9b92b1d3SBarry Smith  ```
54*9b92b1d3SBarry Smith
55*9b92b1d3SBarry Smith- If [BLAS/LAPACK], MPI are already installed in known user location use:
56*9b92b1d3SBarry Smith
57*9b92b1d3SBarry Smith  ```console
58*9b92b1d3SBarry Smith  $ ./configure --with-blaslapack-dir=/usr/local/blaslapack --with-mpi-dir=/usr/local/mpich
59*9b92b1d3SBarry Smith  ```
60*9b92b1d3SBarry Smith
61*9b92b1d3SBarry Smith  or
62*9b92b1d3SBarry Smith
63*9b92b1d3SBarry Smith  ```console
64*9b92b1d3SBarry 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
65*9b92b1d3SBarry Smith  ```
66*9b92b1d3SBarry Smith
67*9b92b1d3SBarry Smith:::{admonition} Note
68*9b92b1d3SBarry Smith:class: yellow
69*9b92b1d3SBarry Smith
70*9b92b1d3SBarry SmithThe configure options `CFLAGS`, `CXXFLAGS`, and `FFLAGS` overwrite most of the flags that PETSc would use by default. This is generally undesirable. To
71*9b92b1d3SBarry Smithadd to the default flags instead use `COPTFLAGS`, `CXXOPTFLAGS`, and `FOPTFLAGS` (these work for all uses of ./configure). The same holds for
72*9b92b1d3SBarry Smith`CUDAFLAGS`, `HIPFLAGS`, and `SYCLFLAGS`.
73*9b92b1d3SBarry Smith:::
74*9b92b1d3SBarry Smith
75*9b92b1d3SBarry Smith:::{admonition} Note
76*9b92b1d3SBarry Smith:class: yellow
77*9b92b1d3SBarry Smith
78*9b92b1d3SBarry SmithDo not specify `--with-cc`, `--with-fc` etc for the above when using
79*9b92b1d3SBarry Smith`--with-mpi-dir` - so that `mpicc`/ `mpif90` will be picked up from mpi-dir!
80*9b92b1d3SBarry Smith:::
81*9b92b1d3SBarry Smith
82*9b92b1d3SBarry Smith- Build Complex version of PETSc (using c++ compiler):
83*9b92b1d3SBarry Smith
84*9b92b1d3SBarry Smith  ```console
85*9b92b1d3SBarry Smith  $ ./configure --with-cc=gcc --with-fc=gfortran --with-cxx=g++ --with-clanguage=cxx --download-fblaslapack --download-mpich --with-scalar-type=complex
86*9b92b1d3SBarry Smith  ```
87*9b92b1d3SBarry Smith
88*9b92b1d3SBarry Smith- Install 2 variants of PETSc, one with gnu, the other with Intel compilers. Specify
89*9b92b1d3SBarry Smith  different `$PETSC_ARCH` for each build. See multiple PETSc install {ref}`documentation
90*9b92b1d3SBarry Smith  <doc_multi>` for further recommendations:
91*9b92b1d3SBarry Smith
92*9b92b1d3SBarry Smith  ```console
93*9b92b1d3SBarry Smith  $ ./configure PETSC_ARCH=linux-gnu --with-cc=gcc --with-cxx=g++ --with-fc=gfortran --download-mpich
94*9b92b1d3SBarry Smith  $ make PETSC_ARCH=linux-gnu all test
95*9b92b1d3SBarry Smith  $ ./configure PETSC_ARCH=linux-gnu-intel --with-cc=icc --with-cxx=icpc --with-fc=ifort --download-mpich --with-blaslapack-dir=/usr/local/mkl
96*9b92b1d3SBarry Smith  $ make PETSC_ARCH=linux-gnu-intel all test
97*9b92b1d3SBarry Smith  ```
98*9b92b1d3SBarry Smith
99*9b92b1d3SBarry Smith(doc_config_compilers)=
100*9b92b1d3SBarry Smith
101*9b92b1d3SBarry Smith## Compilers
102*9b92b1d3SBarry Smith
103*9b92b1d3SBarry Smith:::{important}
104*9b92b1d3SBarry SmithIf no compilers are specified - configure will automatically look for available MPI or
105*9b92b1d3SBarry Smithregular compilers in the user's `$PATH` in the following order:
106*9b92b1d3SBarry Smith
107*9b92b1d3SBarry Smith1. `mpicc`/`mpicxx`/`mpif90`
108*9b92b1d3SBarry Smith2. `gcc`/`g++`/`gfortran`
109*9b92b1d3SBarry Smith3. `cc`/`CC` etc..
110*9b92b1d3SBarry Smith:::
111*9b92b1d3SBarry Smith
112*9b92b1d3SBarry Smith- Specify compilers using the options `--with-cc`/`--with-cxx`/`--with-fc` for c,
113*9b92b1d3SBarry Smith  c++, and fortran compilers respectively:
114*9b92b1d3SBarry Smith
115*9b92b1d3SBarry Smith  ```console
116*9b92b1d3SBarry Smith  $ ./configure --with-cc=gcc --with-cxx=g++ --with-fc=gfortran
117*9b92b1d3SBarry Smith  ```
118*9b92b1d3SBarry Smith
119*9b92b1d3SBarry Smith:::{important}
120*9b92b1d3SBarry SmithIt's best to use MPI compiler wrappers [^id9]. This can be done by either specifying
121*9b92b1d3SBarry Smith`--with-cc=mpicc` or `--with-mpi-dir` (and not `--with-cc=gcc`)
122*9b92b1d3SBarry Smith
123*9b92b1d3SBarry Smith```console
124*9b92b1d3SBarry Smith$ ./configure --with-cc=mpicc --with-cxx=mpicxx --with-fc=mpif90
125*9b92b1d3SBarry Smith```
126*9b92b1d3SBarry Smith
127*9b92b1d3SBarry Smithor the following (but **without** `--with-cc=gcc`)
128*9b92b1d3SBarry Smith
129*9b92b1d3SBarry Smith```console
130*9b92b1d3SBarry Smith$ ./configure --with-mpi-dir=/opt/mpich2-1.1
131*9b92b1d3SBarry Smith```
132*9b92b1d3SBarry Smith
133*9b92b1d3SBarry SmithSee {any}`doc_config_mpi` for details on how to select specific MPI compiler wrappers or the
134*9b92b1d3SBarry Smithspecific compiler used by the MPI compiler wrapper.
135*9b92b1d3SBarry Smith:::
136*9b92b1d3SBarry Smith
137*9b92b1d3SBarry Smith- If a Fortran compiler is not available or not needed - disable using:
138*9b92b1d3SBarry Smith
139*9b92b1d3SBarry Smith  ```console
140*9b92b1d3SBarry Smith  $ ./configure --with-fc=0
141*9b92b1d3SBarry Smith  ```
142*9b92b1d3SBarry Smith
143*9b92b1d3SBarry Smith- If a c++ compiler is not available or not needed - disable using:
144*9b92b1d3SBarry Smith
145*9b92b1d3SBarry Smith  ```console
146*9b92b1d3SBarry Smith  $ ./configure --with-cxx=0
147*9b92b1d3SBarry Smith  ```
148*9b92b1d3SBarry Smith
149*9b92b1d3SBarry Smith`configure` defaults to building PETSc in debug mode. One can switch to optimized
150*9b92b1d3SBarry Smithmode with the `configure` option `--with-debugging=0` (we suggest using a different
151*9b92b1d3SBarry Smith`$PETSC_ARCH` for debug and optimized builds, for example arch-debug and arch-opt, this
152*9b92b1d3SBarry Smithway you can switch between debugging your code and running for performance by simply
153*9b92b1d3SBarry Smithchanging the value of `$PETSC_ARCH`). See multiple install {ref}`documentation
154*9b92b1d3SBarry Smith<doc_multi>` for further details.
155*9b92b1d3SBarry Smith
156*9b92b1d3SBarry SmithAdditionally one can specify more suitable optimization flags with the options
157*9b92b1d3SBarry Smith`COPTFLAGS`, `FOPTFLAGS`, `CXXOPTFLAGS`. For example when using gnu compilers with
158*9b92b1d3SBarry Smithcorresponding optimization flags:
159*9b92b1d3SBarry Smith
160*9b92b1d3SBarry Smith```console
161*9b92b1d3SBarry 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
162*9b92b1d3SBarry Smith```
163*9b92b1d3SBarry Smith
164*9b92b1d3SBarry Smith:::{warning}
165*9b92b1d3SBarry Smith`configure` cannot detect compiler libraries for certain set of compilers. In this
166*9b92b1d3SBarry Smithcase one can specify additional system/compiler libraries using the `LIBS` option:
167*9b92b1d3SBarry Smith
168*9b92b1d3SBarry Smith```console
169*9b92b1d3SBarry Smith$ ./configure --LIBS='-ldl /usr/lib/libm.a'
170*9b92b1d3SBarry Smith```
171*9b92b1d3SBarry Smith:::
172*9b92b1d3SBarry Smith
173*9b92b1d3SBarry Smith(doc_config_externalpack)=
174*9b92b1d3SBarry Smith
175*9b92b1d3SBarry Smith## External Packages
176*9b92b1d3SBarry Smith
177*9b92b1d3SBarry Smith:::{admonition} Note
178*9b92b1d3SBarry Smith:class: yellow
179*9b92b1d3SBarry Smith
180*9b92b1d3SBarry Smith[BLAS/LAPACK] is the only **required** {ref}`external package <doc_externalsoftware>`
181*9b92b1d3SBarry Smith(other than of course build tools such as compilers and `make`). PETSc may be built
182*9b92b1d3SBarry Smithand run without MPI support if processing only in serial.
183*9b92b1d3SBarry Smith
184*9b92b1d3SBarry SmithFor any {ref}`external packages <doc_externalsoftware>` used with PETSc we highly
185*9b92b1d3SBarry Smithrecommend you have PETSc download and install the packages, rather than you installing
186*9b92b1d3SBarry Smiththem separately first. This insures that:
187*9b92b1d3SBarry Smith
188*9b92b1d3SBarry Smith- The packages are installed with the same compilers and compiler options as PETSc
189*9b92b1d3SBarry Smith  so that they can work together.
190*9b92b1d3SBarry Smith- A **compatible** version of the package is installed. A generic install of this
191*9b92b1d3SBarry Smith  package might not be compatible with PETSc (perhaps due to version differences - or
192*9b92b1d3SBarry Smith  perhaps due to the requirement of additional patches for it to work with PETSc).
193*9b92b1d3SBarry Smith- Some packages have bug fixes, portability patches, and upgrades for dependent
194*9b92b1d3SBarry Smith  packages that have not yet been included in an upstream release, and hence may not
195*9b92b1d3SBarry Smith  play nice with PETSc.
196*9b92b1d3SBarry Smith:::
197*9b92b1d3SBarry Smith
198*9b92b1d3SBarry SmithPETSc provides interfaces to various {ref}`external packages <doc_externalsoftware>`. One
199*9b92b1d3SBarry Smithcan optionally use external solvers like [HYPRE], [MUMPS], and others from within PETSc
200*9b92b1d3SBarry Smithapplications.
201*9b92b1d3SBarry Smith
202*9b92b1d3SBarry SmithPETSc `configure` has the ability to download and install these {ref}`external packages
203*9b92b1d3SBarry Smith<doc_externalsoftware>`. Alternatively if these packages are already installed, then
204*9b92b1d3SBarry Smith`configure` can detect and use them.
205*9b92b1d3SBarry Smith
206*9b92b1d3SBarry SmithIf you are behind a firewall and cannot use a proxy for the downloads or have a very slow
207*9b92b1d3SBarry Smithnetwork, use the additional option `--with-packages-download-dir=/path/to/dir`. This
208*9b92b1d3SBarry Smithwill trigger `configure` to print the URLs of all the packages you must download. You
209*9b92b1d3SBarry Smithmay then download the packages to some directory (do not uncompress or untar the files)
210*9b92b1d3SBarry Smithand then point `configure` to these copies of the packages instead of trying to download
211*9b92b1d3SBarry Smiththem directly from the internet.
212*9b92b1d3SBarry Smith
213*9b92b1d3SBarry SmithThe following modes can be used to download/install {ref}`external packages
214*9b92b1d3SBarry Smith<doc_externalsoftware>` with `configure`.
215*9b92b1d3SBarry Smith
216*9b92b1d3SBarry Smith- `--download-PACKAGENAME`: Download specified package and install it, enabling PETSc to
217*9b92b1d3SBarry Smith  use this package. **This is the recommended method to couple any external packages with PETSc**:
218*9b92b1d3SBarry Smith
219*9b92b1d3SBarry Smith  ```console
220*9b92b1d3SBarry Smith  $ ./configure --download-fblaslapack --download-mpich
221*9b92b1d3SBarry Smith  ```
222*9b92b1d3SBarry Smith
223*9b92b1d3SBarry Smith- `--download-PACKAGENAME=/path/to/PACKAGENAME.tar.gz`: If `configure` cannot
224*9b92b1d3SBarry Smith  automatically download the package (due to network/firewall issues), one can download
225*9b92b1d3SBarry Smith  the package by alternative means (perhaps wget, curl, or scp via some other
226*9b92b1d3SBarry Smith  machine). Once the tarfile is downloaded, the path to this file can be specified to
227*9b92b1d3SBarry Smith  configure with this option. `configure` will proceed to install this package and then
228*9b92b1d3SBarry Smith  configure PETSc with it:
229*9b92b1d3SBarry Smith
230*9b92b1d3SBarry Smith  ```console
231*9b92b1d3SBarry Smith  $ ./configure --download-mpich=/home/petsc/mpich2-1.0.4p1.tar.gz
232*9b92b1d3SBarry Smith  ```
233*9b92b1d3SBarry Smith
234*9b92b1d3SBarry Smith- `--with-PACKAGENAME-dir=/path/to/dir`: If the external package is already installed -
235*9b92b1d3SBarry Smith  specify its location to `configure` (it will attempt to detect and include relevant
236*9b92b1d3SBarry Smith  library files from this location). Normally this corresponds to the top-level
237*9b92b1d3SBarry Smith  installation directory for the package:
238*9b92b1d3SBarry Smith
239*9b92b1d3SBarry Smith  ```console
240*9b92b1d3SBarry Smith  $ ./configure --with-mpi-dir=/home/petsc/software/mpich2-1.0.4p1
241*9b92b1d3SBarry Smith  ```
242*9b92b1d3SBarry Smith
243*9b92b1d3SBarry Smith- `--with-PACKAGENAME-include=/path/to/include/dir` and
244*9b92b1d3SBarry Smith  `--with-PACKAGENAME-lib=LIBRARYLIST`: Usually a package is defined completely by its
245*9b92b1d3SBarry Smith  include file location and library list. If the package is already installed one can use
246*9b92b1d3SBarry Smith  these two options to specify the package to `configure`. For example:
247*9b92b1d3SBarry Smith
248*9b92b1d3SBarry Smith  ```console
249*9b92b1d3SBarry Smith  $ ./configure --with-superlu-include=/home/petsc/software/superlu/include --with-superlu-lib=/home/petsc/software/superlu/lib/libsuperlu.a
250*9b92b1d3SBarry Smith  ```
251*9b92b1d3SBarry Smith
252*9b92b1d3SBarry Smith  or
253*9b92b1d3SBarry Smith
254*9b92b1d3SBarry Smith  ```console
255*9b92b1d3SBarry Smith  $ ./configure --with-parmetis-include=/sandbox/balay/parmetis/include --with-parmetis-lib="-L/sandbox/balay/parmetis/lib -lparmetis -lmetis"
256*9b92b1d3SBarry Smith  ```
257*9b92b1d3SBarry Smith
258*9b92b1d3SBarry Smith  or
259*9b92b1d3SBarry Smith
260*9b92b1d3SBarry Smith  ```console
261*9b92b1d3SBarry Smith  $ ./configure --with-parmetis-include=/sandbox/balay/parmetis/include --with-parmetis-lib=[/sandbox/balay/parmetis/lib/libparmetis.a,libmetis.a]
262*9b92b1d3SBarry Smith  ```
263*9b92b1d3SBarry Smith
264*9b92b1d3SBarry Smith:::{note}
265*9b92b1d3SBarry Smith- Run `./configure --help` to get the list of {ref}`external packages
266*9b92b1d3SBarry Smith  <doc_externalsoftware>` and corresponding additional options (for example
267*9b92b1d3SBarry Smith  `--with-mpiexec` for [MPICH]).
268*9b92b1d3SBarry Smith- Generally one would use either one of the above installation modes for any given
269*9b92b1d3SBarry Smith  package - and not mix these. (i.e combining `--with-mpi-dir` and
270*9b92b1d3SBarry Smith  `--with-mpi-include` etc. should be avoided).
271*9b92b1d3SBarry Smith- Some packages might not support certain options like `--download-PACKAGENAME` or
272*9b92b1d3SBarry Smith  `--with-PACKAGENAME-dir`. Architectures like Microsoft Windows might have issues
273*9b92b1d3SBarry Smith  with these options. In these cases, `--with-PACKAGENAME-include` and
274*9b92b1d3SBarry Smith  `--with-PACKAGENAME-lib` options should be preferred.
275*9b92b1d3SBarry Smith:::
276*9b92b1d3SBarry Smith
277*9b92b1d3SBarry Smith- `--with-packages-build-dir=PATH`: By default, external packages will be unpacked and
278*9b92b1d3SBarry Smith  the build process is run in `$PETSC_DIR/$PETSC_ARCH/externalpackages`. However one
279*9b92b1d3SBarry Smith  can choose a different location where these packages are unpacked and the build process
280*9b92b1d3SBarry Smith  is run.
281*9b92b1d3SBarry Smith
282*9b92b1d3SBarry Smith(doc_config_blaslapack)=
283*9b92b1d3SBarry Smith
284*9b92b1d3SBarry Smith## BLAS/LAPACK
285*9b92b1d3SBarry Smith
286*9b92b1d3SBarry SmithThese packages provide some basic numeric kernels used by PETSc. `configure` will
287*9b92b1d3SBarry Smithautomatically look for [BLAS/LAPACK] in certain standard locations, on most systems you
288*9b92b1d3SBarry Smithshould not need to provide any information about [BLAS/LAPACK] in the `configure`
289*9b92b1d3SBarry Smithcommand.
290*9b92b1d3SBarry Smith
291*9b92b1d3SBarry SmithOne can use the following options to let `configure` download/install [BLAS/LAPACK]
292*9b92b1d3SBarry Smithautomatically:
293*9b92b1d3SBarry Smith
294*9b92b1d3SBarry Smith- When fortran compiler is present:
295*9b92b1d3SBarry Smith
296*9b92b1d3SBarry Smith  ```console
297*9b92b1d3SBarry Smith  $ ./configure --download-fblaslapack
298*9b92b1d3SBarry Smith  ```
299*9b92b1d3SBarry Smith
300*9b92b1d3SBarry Smith- Or when configuring without a Fortran compiler - i.e `--with-fc=0`:
301*9b92b1d3SBarry Smith
302*9b92b1d3SBarry Smith  ```console
303*9b92b1d3SBarry Smith  $ ./configure --download-f2cblaslapack
304*9b92b1d3SBarry Smith  ```
305*9b92b1d3SBarry Smith
306*9b92b1d3SBarry SmithAlternatively one can use other options like one of the following:
307*9b92b1d3SBarry Smith
308*9b92b1d3SBarry Smith```console
309*9b92b1d3SBarry Smith$ ./configure --with-blaslapack-lib=libsunperf.a
310*9b92b1d3SBarry Smith$ ./configure --with-blas-lib=libblas.a --with-lapack-lib=liblapack.a
311*9b92b1d3SBarry Smith$ ./configure --with-blaslapack-dir=/soft/com/packages/intel/13/079/mkl
312*9b92b1d3SBarry Smith```
313*9b92b1d3SBarry Smith
314*9b92b1d3SBarry Smith### Intel MKL
315*9b92b1d3SBarry Smith
316*9b92b1d3SBarry SmithIntel provides [BLAS/LAPACK] via the [MKL] library. One can specify it
317*9b92b1d3SBarry Smithto PETSc `configure` with `--with-blaslapack-dir=$MKLROOT` or
318*9b92b1d3SBarry Smith`--with-blaslapack-dir=/soft/com/packages/intel/13/079/mkl`. If the above option does
319*9b92b1d3SBarry Smithnot work - one could determine the correct library list for your compilers using Intel
320*9b92b1d3SBarry Smith[MKL Link Line Advisor] and specify with the `configure` option
321*9b92b1d3SBarry Smith`--with-blaslapack-lib`
322*9b92b1d3SBarry Smith
323*9b92b1d3SBarry Smith### IBM ESSL
324*9b92b1d3SBarry Smith
325*9b92b1d3SBarry SmithSadly, IBM's [ESSL] does not have all the routines of [BLAS/LAPACK] that some
326*9b92b1d3SBarry Smithpackages, such as [SuperLU] expect; in particular slamch, dlamch and xerbla. In this
327*9b92b1d3SBarry Smithcase instead of using [ESSL] we suggest `--download-fblaslapack`. If you really want
328*9b92b1d3SBarry Smithto use [ESSL], see <https://www.pdc.kth.se/hpc-services>.
329*9b92b1d3SBarry Smith
330*9b92b1d3SBarry Smith(doc_config_mpi)=
331*9b92b1d3SBarry Smith
332*9b92b1d3SBarry Smith## MPI
333*9b92b1d3SBarry Smith
334*9b92b1d3SBarry SmithThe Message Passing Interface (MPI) provides the parallel functionality for PETSc.
335*9b92b1d3SBarry Smith
336*9b92b1d3SBarry SmithMPI might already be installed. IBM, Intel, NVIDIA, and Cray provide their own and Linux and macOS package
337*9b92b1d3SBarry Smithmanagers also provide open-source versions called MPICH and Open MPI. If MPI is not already installed use
338*9b92b1d3SBarry Smiththe following options to let PETSc's `configure` download and install MPI.
339*9b92b1d3SBarry Smith
340*9b92b1d3SBarry Smith- For [MPICH]:
341*9b92b1d3SBarry Smith
342*9b92b1d3SBarry Smith  ```console
343*9b92b1d3SBarry Smith  $ ./configure --download-mpich
344*9b92b1d3SBarry Smith  ```
345*9b92b1d3SBarry Smith
346*9b92b1d3SBarry Smith- For [Open MPI]:
347*9b92b1d3SBarry Smith
348*9b92b1d3SBarry Smith  ```console
349*9b92b1d3SBarry Smith  $ ./configure --download-openmpi
350*9b92b1d3SBarry Smith  ```
351*9b92b1d3SBarry Smith
352*9b92b1d3SBarry Smith- To not use MPI:
353*9b92b1d3SBarry Smith
354*9b92b1d3SBarry Smith  ```console
355*9b92b1d3SBarry Smith  $ ./configure --with-mpi=0
356*9b92b1d3SBarry Smith  ```
357*9b92b1d3SBarry Smith
358*9b92b1d3SBarry Smith- To use an installed version of MPI
359*9b92b1d3SBarry Smith
360*9b92b1d3SBarry Smith  ```console
361*9b92b1d3SBarry Smith  $ ./configure --with-cc=mpicc --with-cxx=mpicxx --with-fc=mpif90
362*9b92b1d3SBarry Smith  ```
363*9b92b1d3SBarry Smith
364*9b92b1d3SBarry Smith- The Intel MPI library provides MPI compiler wrappers with compiler specific names.
365*9b92b1d3SBarry Smith
366*9b92b1d3SBarry Smith  GNU compilers: `gcc`, `g++`, `gfortran`:
367*9b92b1d3SBarry Smith
368*9b92b1d3SBarry Smith  ```console
369*9b92b1d3SBarry Smith  $ ./configure --with-cc=mpigcc --with-cxx=mpigxx --with-fc=mpif90
370*9b92b1d3SBarry Smith  ```
371*9b92b1d3SBarry Smith
372*9b92b1d3SBarry Smith  "Old" Intel compilers: `icc`, `icpc`, and `ifort`:
373*9b92b1d3SBarry Smith
374*9b92b1d3SBarry Smith  ```console
375*9b92b1d3SBarry Smith  $ ./configure --with-cc=mpiicc --with-cxx=mpiicpc --with-fc=mpiifort
376*9b92b1d3SBarry Smith  ```
377*9b92b1d3SBarry Smith
378*9b92b1d3SBarry Smith  they might not work with some Intel MPI library versions. In those cases, use
379*9b92b1d3SBarry Smith
380*9b92b1d3SBarry Smith  ```console
381*9b92b1d3SBarry Smith  $ export I_MPI_CC=icc && export I_MPI_CXX=icpc && export I_MPI_F90=ifort
382*9b92b1d3SBarry Smith  $ ./configure --with-cc=mpicc --with-cxx=mpicxx --with-fc=mpif90
383*9b92b1d3SBarry Smith  ```
384*9b92b1d3SBarry Smith
385*9b92b1d3SBarry Smith- "New" oneAPI Intel compilers: `icx`, `icpx`, and `ifx`:
386*9b92b1d3SBarry Smith
387*9b92b1d3SBarry Smith  ```console
388*9b92b1d3SBarry Smith  $ ./configure --with-cc=mpiicx --with-cxx=mpiicpx --with-fc=mpiifx
389*9b92b1d3SBarry Smith  ```
390*9b92b1d3SBarry Smith
391*9b92b1d3SBarry Smith  they might not work with some Intel MPI library versions. In those cases, use
392*9b92b1d3SBarry Smith
393*9b92b1d3SBarry Smith  ```console
394*9b92b1d3SBarry Smith  $ export I_MPI_CC=icx && export I_MPI_CXX=icpx && export I_MPI_F90=ifx
395*9b92b1d3SBarry Smith  $ ./configure --with-cc=mpicc --with-cxx=mpicxx --with-fc=mpif90
396*9b92b1d3SBarry Smith  ```
397*9b92b1d3SBarry Smith
398*9b92b1d3SBarry Smith- On Cray systems, after loading the appropriate MPI module, the regular compilers `cc`, `CC`, and `ftn`
399*9b92b1d3SBarry Smith  automatically become MPI compiler wrappers.
400*9b92b1d3SBarry Smith
401*9b92b1d3SBarry Smith  ```console
402*9b92b1d3SBarry Smith  $ ./configure --with-cc=cc --with-cxx=CC --with-fc=ftn
403*9b92b1d3SBarry Smith  ```
404*9b92b1d3SBarry Smith
405*9b92b1d3SBarry 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,
406*9b92b1d3SBarry Smith  (without additionally specifying `--with-cc` etc.) using
407*9b92b1d3SBarry Smith
408*9b92b1d3SBarry Smith  ```console
409*9b92b1d3SBarry Smith  $  ./configure --with-mpi-dir=/absolute/path/to/mpi/install/directory
410*9b92b1d3SBarry Smith  ```
411*9b92b1d3SBarry Smith
412*9b92b1d3SBarry Smith- To control the compilers selected by `mpicc`, `mpicxx`, and `mpif90` one may use environmental
413*9b92b1d3SBarry Smith  variables appropriate for the MPI libraries. For Intel MPI, MPICH, and Open MPI they are
414*9b92b1d3SBarry Smith
415*9b92b1d3SBarry Smith  ```console
416*9b92b1d3SBarry Smith  $ export I_MPI_CC=c_compiler && export I_MPI_CXX=c++_compiler && export I_MPI_F90=fortran_compiler
417*9b92b1d3SBarry Smith  $ export MPICH_CC=c_compiler && export MPICH_CXX=c++_compiler && export MPICH_FC=fortran_compiler
418*9b92b1d3SBarry Smith  $ export OMPI_CC=c_compiler && export OMPI_CXX=c++_compiler && export OMPI_FC=fortran_compiler
419*9b92b1d3SBarry Smith  ```
420*9b92b1d3SBarry Smith
421*9b92b1d3SBarry Smith  Then, use
422*9b92b1d3SBarry Smith
423*9b92b1d3SBarry Smith  ```console
424*9b92b1d3SBarry Smith  $ ./configure --with-cc=mpicc --with-fc=mpif90 --with-cxx=mpicxx
425*9b92b1d3SBarry Smith  ```
426*9b92b1d3SBarry Smith
427*9b92b1d3SBarry Smith  We recommend avoiding these environmental variables unless absolutely necessary.
428*9b92b1d3SBarry Smith  They are easy to forget or they may be set and then forgotten, thus resulting in unexpected behavior.
429*9b92b1d3SBarry Smith
430*9b92b1d3SBarry Smith  And avoid using the syntax `--with-cc="mpicc -cc=icx"` - this can break some builds (for example: external packages that use CMake)
431*9b92b1d3SBarry Smith
432*9b92b1d3SBarry Smith  :::{note}
433*9b92b1d3SBarry Smith  The Intel environmental variables `I_MPI_CC`, `I_MPI_CXX`, and `I_MPI_F90` also changing the
434*9b92b1d3SBarry Smith  behavior of the compiler-specific MPI compiler wrappers ``` mpigcc, ``mpigxx ```, `mpif90`, `mpiicx`,
435*9b92b1d3SBarry Smith  `mpiicpx`, `mpiifx`, `mpiicc`, `mpiicpc`, and `mpiifort`. These variables may be automatically
436*9b92b1d3SBarry Smith  set by certain modules. So one must be careful to ensure they are using the desired compilers.
437*9b92b1d3SBarry Smith  :::
438*9b92b1d3SBarry Smith
439*9b92b1d3SBarry Smith### Installing With Open MPI With Shared MPI Libraries
440*9b92b1d3SBarry Smith
441*9b92b1d3SBarry Smith[Open MPI] defaults to building shared libraries for MPI. However, the binaries generated
442*9b92b1d3SBarry Smithby MPI compiler wrappers `mpicc`/`mpif90` etc. require `$LD_LIBRARY_PATH` to be set to the
443*9b92b1d3SBarry Smithlocation of these libraries.
444*9b92b1d3SBarry Smith
445*9b92b1d3SBarry 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:
446*9b92b1d3SBarry Smith
447*9b92b1d3SBarry Smith```text
448*9b92b1d3SBarry SmithUNABLE to EXECUTE BINARIES for config/configure.py
449*9b92b1d3SBarry Smith-------------------------------------------------------------------------------
450*9b92b1d3SBarry SmithCannot run executables created with C. If this machine uses a batch system
451*9b92b1d3SBarry Smithto submit jobs you will need to configure using/configure.py with the additional option --with-batch.
452*9b92b1d3SBarry SmithOtherwise there is problem with the compilers. Can you compile and run code with your C/C++ (and maybe Fortran) compilers?
453*9b92b1d3SBarry Smith```
454*9b92b1d3SBarry Smith
455*9b92b1d3SBarry Smithor when running a code compiled with [Open MPI]:
456*9b92b1d3SBarry Smith
457*9b92b1d3SBarry Smith```text
458*9b92b1d3SBarry Smitherror while loading shared libraries: libmpi.so.0: cannot open shared object file: No such file or directory
459*9b92b1d3SBarry Smith```
460*9b92b1d3SBarry Smith
461*9b92b1d3SBarry Smith(doc_macos_install)=
462*9b92b1d3SBarry Smith
463*9b92b1d3SBarry Smith## Installing On macOS
464*9b92b1d3SBarry Smith
465*9b92b1d3SBarry 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
466*9b92b1d3SBarry Smith
467*9b92b1d3SBarry Smith```console
468*9b92b1d3SBarry Smith$ xcode-select --install
469*9b92b1d3SBarry Smith```
470*9b92b1d3SBarry Smith
471*9b92b1d3SBarry 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.
472*9b92b1d3SBarry Smith
473*9b92b1d3SBarry SmithWe also recommend installing the package manager [homebrew](https://brew.sh/). To install `gfortran` one can use
474*9b92b1d3SBarry Smith
475*9b92b1d3SBarry Smith```console
476*9b92b1d3SBarry Smith$ brew update
477*9b92b1d3SBarry Smith$ brew list            # Show all packages installed through brew
478*9b92b1d3SBarry Smith$ brew upgrade         # Update packages already installed through brew
479*9b92b1d3SBarry Smith$ brew install gcc
480*9b92b1d3SBarry Smith```
481*9b92b1d3SBarry Smith
482*9b92b1d3SBarry SmithThis installs gfortran, gcc, and g++ with the compiler names
483*9b92b1d3SBarry Smith`gfortran-version` (also available as `gfortran`), `gcc-version` and `g++-version`, for example `gfortran-12`, `gcc-12`, and `g++-12`.
484*9b92b1d3SBarry Smith
485*9b92b1d3SBarry SmithAfter upgrading macOS, you generally need to update the Xcode GUI development system (using the standard Apple software update system),
486*9b92b1d3SBarry Smithand the Xcode Command Line tools (run `xcode-select --install` again).
487*9b92b1d3SBarry Smith
488*9b92b1d3SBarry 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
489*9b92b1d3SBarry Smithit is best to reinstall all `brew` packages using, for example,
490*9b92b1d3SBarry Smith
491*9b92b1d3SBarry Smith```console
492*9b92b1d3SBarry Smith$ brew leaves > list.txt         # save list of formulae to re-install
493*9b92b1d3SBarry Smith$ brew list --casks >> list.txt  # save list of casks to re-install
494*9b92b1d3SBarry Smith$ emacs list.txt                 # edit list.txt to remove any unneeded formulae or casks
495*9b92b1d3SBarry Smith$ brew uninstall `brew list`     # delete all installed formulae and casks
496*9b92b1d3SBarry Smith$ brew cleanup
497*9b92b1d3SBarry Smith$ brew update
498*9b92b1d3SBarry Smith$ brew install `cat list.txt`    # install needed formulae and casks
499*9b92b1d3SBarry Smith```
500*9b92b1d3SBarry Smith
501*9b92b1d3SBarry Smith(doc_config_install)=
502*9b92b1d3SBarry Smith
503*9b92b1d3SBarry Smith## Installation Location: In-place or Out-of-place
504*9b92b1d3SBarry Smith
505*9b92b1d3SBarry SmithBy default, PETSc does an in-place installation, meaning the libraries are kept in the
506*9b92b1d3SBarry Smithsame directories used to compile PETSc. This is particularly useful for those application
507*9b92b1d3SBarry Smithdevelopers who follow the PETSc git repository main or release branches since rebuilds
508*9b92b1d3SBarry Smithfor updates are very quick and painless.
509*9b92b1d3SBarry Smith
510*9b92b1d3SBarry Smith:::{note}
511*9b92b1d3SBarry SmithThe libraries and include files are located in `$PETSC_DIR/$PETSC_ARCH/lib` and
512*9b92b1d3SBarry Smith`$PETSC_DIR/$PETSC_ARCH/include`
513*9b92b1d3SBarry Smith:::
514*9b92b1d3SBarry Smith
515*9b92b1d3SBarry Smith### Out-of-place Installation With `--prefix`
516*9b92b1d3SBarry Smith
517*9b92b1d3SBarry SmithTo install the libraries and include files in another location use the `--prefix` option
518*9b92b1d3SBarry Smith
519*9b92b1d3SBarry Smith```console
520*9b92b1d3SBarry Smith$ ./configure --prefix=/home/userid/my-petsc-install --some-other-options
521*9b92b1d3SBarry Smith```
522*9b92b1d3SBarry Smith
523*9b92b1d3SBarry SmithThe libraries and include files will be located in `/home/userid/my-petsc-install/lib`
524*9b92b1d3SBarry Smithand `/home/userid/my-petsc-install/include`.
525*9b92b1d3SBarry Smith
526*9b92b1d3SBarry Smith### Installation in Root Location, **Not Recommended** (Uncommon)
527*9b92b1d3SBarry Smith
528*9b92b1d3SBarry Smith:::{warning}
529*9b92b1d3SBarry SmithOne should never run `configure` or make on any package using root access. **Do so at
530*9b92b1d3SBarry Smithyour own risk**.
531*9b92b1d3SBarry Smith:::
532*9b92b1d3SBarry Smith
533*9b92b1d3SBarry SmithIf one wants to install PETSc in a common system location like `/usr/local` or `/opt`
534*9b92b1d3SBarry Smiththat requires root access we suggest creating a directory for PETSc with user privileges,
535*9b92b1d3SBarry Smithand then do the PETSc install as a **regular/non-root** user:
536*9b92b1d3SBarry Smith
537*9b92b1d3SBarry Smith```console
538*9b92b1d3SBarry Smith$ sudo mkdir /opt/petsc
539*9b92b1d3SBarry Smith$ sudo chown user:group /opt/petsc
540*9b92b1d3SBarry Smith$ cd /home/userid/petsc
541*9b92b1d3SBarry Smith$ ./configure --prefix=/opt/petsc/my-root-petsc-install --some-other-options
542*9b92b1d3SBarry Smith$ make
543*9b92b1d3SBarry Smith$ make install
544*9b92b1d3SBarry Smith```
545*9b92b1d3SBarry Smith
546*9b92b1d3SBarry Smith### Installs For Package Managers: Using `DESTDIR` (Very uncommon)
547*9b92b1d3SBarry Smith
548*9b92b1d3SBarry Smith```console
549*9b92b1d3SBarry Smith$ ./configure --prefix=/opt/petsc/my-root-petsc-install
550*9b92b1d3SBarry Smith$ make
551*9b92b1d3SBarry Smith$ make install DESTDIR=/tmp/petsc-pkg
552*9b92b1d3SBarry Smith```
553*9b92b1d3SBarry Smith
554*9b92b1d3SBarry SmithPackage up `/tmp/petsc-pkg`. The package should then be installed at
555*9b92b1d3SBarry Smith`/opt/petsc/my-root-petsc-install`
556*9b92b1d3SBarry Smith
557*9b92b1d3SBarry Smith### Multiple Installs Using `--prefix` (See `DESTDIR`)
558*9b92b1d3SBarry Smith
559*9b92b1d3SBarry SmithSpecify a different `--prefix` location for each configure of different options - at
560*9b92b1d3SBarry Smithconfigure time. For example:
561*9b92b1d3SBarry Smith
562*9b92b1d3SBarry Smith```console
563*9b92b1d3SBarry Smith$ ./configure --prefix=/opt/petsc/petsc-3.22.0-mpich --with-mpi-dir=/opt/mpich
564*9b92b1d3SBarry Smith$ make
565*9b92b1d3SBarry Smith$ make install [DESTDIR=/tmp/petsc-pkg]
566*9b92b1d3SBarry Smith$ ./configure --prefix=/opt/petsc/petsc-3.22.0-openmpi --with-mpi-dir=/opt/openmpi
567*9b92b1d3SBarry Smith$ make
568*9b92b1d3SBarry Smith$ make install [DESTDIR=/tmp/petsc-pkg]
569*9b92b1d3SBarry Smith```
570*9b92b1d3SBarry Smith
571*9b92b1d3SBarry Smith### In-place Installation
572*9b92b1d3SBarry Smith
573*9b92b1d3SBarry SmithThe PETSc libraries and generated included files are placed in the sub-directory off the
574*9b92b1d3SBarry Smithcurrent directory `$PETSC_ARCH` which is either provided by the user with, for example:
575*9b92b1d3SBarry Smith
576*9b92b1d3SBarry Smith```console
577*9b92b1d3SBarry Smith$ export PETSC_ARCH=arch-debug
578*9b92b1d3SBarry Smith$ ./configure
579*9b92b1d3SBarry Smith$ make
580*9b92b1d3SBarry Smith$ export PETSC_ARCH=arch-opt
581*9b92b1d3SBarry Smith$ ./configure --some-optimization-options
582*9b92b1d3SBarry Smith$ make
583*9b92b1d3SBarry Smith```
584*9b92b1d3SBarry Smith
585*9b92b1d3SBarry Smithor
586*9b92b1d3SBarry Smith
587*9b92b1d3SBarry Smith```console
588*9b92b1d3SBarry Smith$ ./configure PETSC_ARCH=arch-debug
589*9b92b1d3SBarry Smith$ make
590*9b92b1d3SBarry Smith$ ./configure --some-optimization-options PETSC_ARCH=arch-opt
591*9b92b1d3SBarry Smith$ make
592*9b92b1d3SBarry Smith```
593*9b92b1d3SBarry Smith
594*9b92b1d3SBarry SmithIf not provided `configure` will generate a unique value automatically (for in-place non
595*9b92b1d3SBarry Smith`--prefix` configurations only).
596*9b92b1d3SBarry Smith
597*9b92b1d3SBarry Smith```console
598*9b92b1d3SBarry Smith$ ./configure
599*9b92b1d3SBarry Smith$ make
600*9b92b1d3SBarry Smith$ ./configure --with-debugging=0
601*9b92b1d3SBarry Smith$ make
602*9b92b1d3SBarry Smith```
603*9b92b1d3SBarry Smith
604*9b92b1d3SBarry SmithProduces the directories (on an Apple macOS machine) `$PETSC_DIR/arch-darwin-c-debug` and
605*9b92b1d3SBarry Smith`$PETSC_DIR/arch-darwin-c-opt`.
606*9b92b1d3SBarry Smith
607*9b92b1d3SBarry Smith## Installing On Machine Requiring Cross Compiler Or A Job Scheduler
608*9b92b1d3SBarry Smith
609*9b92b1d3SBarry SmithOn systems where you need to use a job scheduler or batch submission to run jobs use the
610*9b92b1d3SBarry Smith`configure` option `--with-batch`. **On such systems the make check option will not
611*9b92b1d3SBarry Smithwork**.
612*9b92b1d3SBarry Smith
613*9b92b1d3SBarry Smith- You must first ensure you have loaded appropriate modules for the compilers etc that you
614*9b92b1d3SBarry Smith  wish to use. Often the compilers are provided automatically for you and you do not need
615*9b92b1d3SBarry Smith  to provide `--with-cc=XXX` etc. Consult with the documentation and local support for
616*9b92b1d3SBarry Smith  such systems for information on these topics.
617*9b92b1d3SBarry Smith- On such systems you generally should not use `--with-blaslapack-dir` or
618*9b92b1d3SBarry Smith  `--download-fblaslapack` since the systems provide those automatically (sometimes
619*9b92b1d3SBarry Smith  appropriate modules must be loaded first).
620*9b92b1d3SBarry Smith- Some package's `--download-package` options do not work on these systems, for example
621*9b92b1d3SBarry Smith  [HDF5]. Thus you must use modules to load those packages and `--with-package` to
622*9b92b1d3SBarry Smith  configure with the package.
623*9b92b1d3SBarry Smith- Since building {ref}`external packages <doc_externalsoftware>` on these systems is often
624*9b92b1d3SBarry Smith  troublesome and slow we recommend only installing PETSc with those configuration
625*9b92b1d3SBarry Smith  packages that you need for your work, not extras.
626*9b92b1d3SBarry Smith
627*9b92b1d3SBarry Smith(doc_config_tau)=
628*9b92b1d3SBarry Smith
629*9b92b1d3SBarry Smith## Installing With TAU Instrumentation Package
630*9b92b1d3SBarry Smith
631*9b92b1d3SBarry 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:
632*9b92b1d3SBarry Smith
633*9b92b1d3SBarry Smith```console
634*9b92b1d3SBarry Smith$ export TAU_MAKEFILE=/home/balay/soft/linux64/tau-2.20.3/x86_64/lib/Makefile.tau-mpi-pdt
635*9b92b1d3SBarry Smith$ ./configure CC=/home/balay/soft/linux64/tau-2.20.3/x86_64/bin/tau_cc.sh --with-fc=0 PETSC_ARCH=arch-tau
636*9b92b1d3SBarry Smith```
637*9b92b1d3SBarry Smith
638*9b92b1d3SBarry Smith(doc_config_accel)=
639*9b92b1d3SBarry Smith
640*9b92b1d3SBarry Smith## Installing PETSc To Use GPUs And Accelerators
641*9b92b1d3SBarry Smith
642*9b92b1d3SBarry SmithPETSc is able to take advantage of GPU's and certain accelerator libraries, however some require additional `configure` options.
643*9b92b1d3SBarry Smith
644*9b92b1d3SBarry Smith(doc_config_accel_cuda)=
645*9b92b1d3SBarry Smith
646*9b92b1d3SBarry Smith### `OpenMP`
647*9b92b1d3SBarry Smith
648*9b92b1d3SBarry SmithUse `--with-openmp` to allow PETSc to be used within an OpenMP application; this also turns on OpenMP for all the packages that
649*9b92b1d3SBarry SmithPETSc builds using `--download-xxx`. If your application calls PETSc from within OpenMP threads then also use `--with-threadsafety`.
650*9b92b1d3SBarry Smith
651*9b92b1d3SBarry SmithUse `--with-openmp-kernels` to have some PETSc numerical routines use OpenMP to speed up their computations. This requires `--with-openmp`.
652*9b92b1d3SBarry Smith
653*9b92b1d3SBarry SmithNote that using OpenMP within MPI code must be done carefully to prevent too many OpenMP threads that overload the number of cores.
654*9b92b1d3SBarry Smith
655*9b92b1d3SBarry Smith### [CUDA]
656*9b92b1d3SBarry Smith
657*9b92b1d3SBarry Smith:::{important}
658*9b92b1d3SBarry SmithAn NVIDIA GPU is **required** to use [CUDA]-accelerated code. Check that your machine
659*9b92b1d3SBarry Smithhas a [CUDA] enabled GPU by consulting <https://developer.nvidia.com/cuda-gpus>.
660*9b92b1d3SBarry Smith:::
661*9b92b1d3SBarry Smith
662*9b92b1d3SBarry SmithOn Linux - verify [^id12] that CUDA compatible [NVIDIA driver](https://www.nvidia.com/en-us/drivers) is installed.
663*9b92b1d3SBarry Smith
664*9b92b1d3SBarry SmithOn Microsoft Windows - Use either [Cygwin] or [WSL] the latter of which is entirely untested right
665*9b92b1d3SBarry Smithnow. If you have experience with [WSL] and/or have successfully built PETSc on Microsoft Windows
666*9b92b1d3SBarry Smithfor use with [CUDA] we welcome your input at <mailto:petsc-maint@mcs.anl.gov>. See the
667*9b92b1d3SBarry Smithbug-reporting {ref}`documentation <doc_creepycrawly>` for more details.
668*9b92b1d3SBarry Smith
669*9b92b1d3SBarry SmithIn most cases you need only pass the configure option `--with-cuda`; check
670*9b92b1d3SBarry Smith`config/examples/arch-ci-linux-cuda-double.py` for example usage.
671*9b92b1d3SBarry Smith
672*9b92b1d3SBarry SmithCUDA build of PETSc currently works on Mac OS X, Linux, Microsoft Windows with [Cygwin].
673*9b92b1d3SBarry Smith
674*9b92b1d3SBarry SmithExamples that use CUDA have the suffix .cu; see `$PETSC_DIR/src/snes/tutorials/ex47cu.cu`
675*9b92b1d3SBarry Smith
676*9b92b1d3SBarry Smith(doc_config_accel_kokkos)=
677*9b92b1d3SBarry Smith
678*9b92b1d3SBarry Smith### [Kokkos]
679*9b92b1d3SBarry Smith
680*9b92b1d3SBarry SmithIn most cases you need only pass the configure option `--download-kokkos` `--download-kokkos-kernels`
681*9b92b1d3SBarry Smithand one of `--with-cuda`, `--with-openmp`, or `--with-pthread` (or nothing to use sequential
682*9b92b1d3SBarry Smith[Kokkos]). See the {ref}`CUDA installation documentation <doc_config_accel_cuda>`,
683*9b92b1d3SBarry Smith{ref}`Open MPI installation documentation <doc_config_mpi>` for further reference on their
684*9b92b1d3SBarry Smithrespective requirements.
685*9b92b1d3SBarry Smith
686*9b92b1d3SBarry SmithExamples that use [Kokkos] at user-level have the suffix .kokkos.cxx; see
687*9b92b1d3SBarry Smith`src/snes/tutorials/ex3k.kokkos.cxx`. More examples use [Kokkos] through options database;
688*9b92b1d3SBarry Smithsearch them with `grep -r -l "requires:.*kokkos_kernels" src/`.
689*9b92b1d3SBarry Smith
690*9b92b1d3SBarry Smith(doc_config_accel_opencl)=
691*9b92b1d3SBarry Smith
692*9b92b1d3SBarry Smith### [OpenCL]/[ViennaCL]
693*9b92b1d3SBarry Smith
694*9b92b1d3SBarry SmithRequires the [OpenCL] shared library, which is shipped in the vendor graphics driver and
695*9b92b1d3SBarry Smiththe [OpenCL] headers; if needed you can download them from the Khronos Group
696*9b92b1d3SBarry Smithdirectly. Package managers on Linux provide these headers through a package named
697*9b92b1d3SBarry Smith'opencl-headers' or similar. On Apple systems the [OpenCL] drivers and headers are always
698*9b92b1d3SBarry Smithavailable and do not need to be downloaded.
699*9b92b1d3SBarry Smith
700*9b92b1d3SBarry SmithAlways make sure you have the latest GPU driver installed. There are several known issues
701*9b92b1d3SBarry Smithwith older driver versions.
702*9b92b1d3SBarry Smith
703*9b92b1d3SBarry SmithRun `configure` with `--download-viennacl`; check
704*9b92b1d3SBarry Smith`config/examples/arch-ci-linux-viennacl.py` for example usage.
705*9b92b1d3SBarry Smith
706*9b92b1d3SBarry Smith[OpenCL]/[ViennaCL] builds of PETSc currently work on Mac OS X, Linux, and Microsoft Windows.
707*9b92b1d3SBarry Smith
708*9b92b1d3SBarry Smith(doc_emcc)=
709*9b92b1d3SBarry Smith
710*9b92b1d3SBarry Smith## Installing To Run in Browser with Emscripten
711*9b92b1d3SBarry Smith
712*9b92b1d3SBarry SmithPETSc can be used to run applications in the browser using <https://emscripten.org>, see <https://emscripten.org/docs/getting_started/downloads.html>,
713*9b92b1d3SBarry Smithfor instructions on installing Emscripten. Run
714*9b92b1d3SBarry Smith
715*9b92b1d3SBarry Smith```console
716*9b92b1d3SBarry 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
717*9b92b1d3SBarry Smith```
718*9b92b1d3SBarry Smith
719*9b92b1d3SBarry SmithApplications may be compiled with, for example,
720*9b92b1d3SBarry Smith
721*9b92b1d3SBarry Smith```console
722*9b92b1d3SBarry Smith$  make ex19.html
723*9b92b1d3SBarry Smith```
724*9b92b1d3SBarry Smith
725*9b92b1d3SBarry SmithThe rule for linking may be found in <a href="PETSC_DOC_OUT_ROOT_PLACEHOLDER/lib/petsc/conf/rules">lib/petsc/conf/rules></a>
726*9b92b1d3SBarry Smith
727*9b92b1d3SBarry Smith(doc_config_hpc)=
728*9b92b1d3SBarry Smith
729*9b92b1d3SBarry Smith## Installing On Large Scale DOE Systems
730*9b92b1d3SBarry Smith
731*9b92b1d3SBarry SmithThere are some notes on our [GitLab Wiki](https://gitlab.com/petsc/petsc/-/wikis/Installing-and-Running-on-Large-Scale-Systems)
732*9b92b1d3SBarry Smithwhich may be helpful in installing and running PETSc on large scale
733*9b92b1d3SBarry Smithsystems. Also note the configuration examples in `config/examples`.
734*9b92b1d3SBarry Smith
735*9b92b1d3SBarry Smith```{rubric} Footnotes
736*9b92b1d3SBarry Smith```
737*9b92b1d3SBarry Smith
738*9b92b1d3SBarry 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".
739*9b92b1d3SBarry Smith
740*9b92b1d3SBarry Smith[^id10]: The two packages provide slightly different (though largely overlapping) functionality which can only be fully used if both packages are installed.
741*9b92b1d3SBarry Smith
742*9b92b1d3SBarry Smith[^id11]: Apple provides customized `clang` and `clang++` for its system. To use the unmodified LLVM project `clang` and `clang++`
743*9b92b1d3SBarry Smith    install them with brew.
744*9b92b1d3SBarry Smith
745*9b92b1d3SBarry 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.
746*9b92b1d3SBarry Smith
747*9b92b1d3SBarry Smith[blas/lapack]: https://www.netlib.org/lapack/lug/node11.html
748*9b92b1d3SBarry Smith[cuda]: https://developer.nvidia.com/cuda-toolkit
749*9b92b1d3SBarry Smith[cygwin]: https://www.cygwin.com/
750*9b92b1d3SBarry Smith[essl]: https://www.ibm.com/support/knowledgecenter/en/SSFHY8/essl_welcome.html
751*9b92b1d3SBarry Smith[hdf5]: https://www.hdfgroup.org/solutions/hdf5/
752*9b92b1d3SBarry Smith[hypre]: https://computing.llnl.gov/projects/hypre-scalable-linear-solvers-multigrid-methods
753*9b92b1d3SBarry Smith[installation instructions]: https://www.open-mpi.org/faq/?category=building
754*9b92b1d3SBarry Smith[kokkos]: https://github.com/kokkos/kokkos
755*9b92b1d3SBarry Smith[metis]: http://glaros.dtc.umn.edu/gkhome/metis/metis/overview
756*9b92b1d3SBarry Smith[mkl]: https://software.intel.com/content/www/us/en/develop/tools/oneapi/components/onemkl.html
757*9b92b1d3SBarry Smith[mkl link line advisor]: https://software.intel.com/content/www/us/en/develop/articles/intel-mkl-link-line-advisor.html
758*9b92b1d3SBarry Smith[modules]: https://www.alcf.anl.gov/support-center/theta/compiling-and-linking-overview-theta-thetagpu
759*9b92b1d3SBarry Smith[mpich]: https://www.mpich.org/
760*9b92b1d3SBarry Smith[mumps]: https://mumps-solver.org/
761*9b92b1d3SBarry Smith[open mpi]: https://www.open-mpi.org/
762*9b92b1d3SBarry Smith[opencl]: https://www.khronos.org/opencl/
763*9b92b1d3SBarry Smith[parmetis]: http://glaros.dtc.umn.edu/gkhome/metis/parmetis/overview
764*9b92b1d3SBarry Smith[pdt]: https://www.cs.uoregon.edu/research/pdt/home.php
765*9b92b1d3SBarry Smith[superlu]: https://portal.nersc.gov/project/sparse/superlu/
766*9b92b1d3SBarry Smith[superlu_dist]: https://github.com/xiaoyeli/superlu_dist
767*9b92b1d3SBarry Smith[tau]: https://www.cs.uoregon.edu/research/tau/home.php
768*9b92b1d3SBarry Smith[viennacl]: http://viennacl.sourceforge.net/
769*9b92b1d3SBarry Smith[wsl]: https://docs.microsoft.com/en-us/windows/wsl/install-win10
770