You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Use local dynamic libraries rather than jll binaries (#235)
* update initialisation to allow specfying a lobrary on HPC systems:
We now have 2 options:
# Option 1: point directly to your library (sets libs AND skips JLL)
export JULIA_PETSC_LIBRARY=/path/to/libpetsc.so
# Option 2: skip JLL, then use set_petsclib() in your script
export JULIA_PETSC_SKIP_JLL=1
With option 2, getlib() won't work (no libs registered), but set_petsclib("/path/to/libpetsc.so") gives you full control over scalar/int types.
* configure type of library through ENV variables:
export JULIA_PETSC_LIBRARY=/path/to/libpetsc.so
export JULIA_PETSC_SCALAR=Float64 # Float32 | ComplexFloat64 | ComplexFloat32
export JULIA_PETSC_INT=Int64 # Int32
* update docs
* update getting started page
* replace environmental variables by preferences
* oops
* load preferences
Copy file name to clipboardExpand all lines: README.md
+6-9Lines changed: 6 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,19 +29,16 @@ julia>]test PETSc
29
29
30
30
By default, the package uses a pre-built binary of PETSc (see [PETSc_jll](https://github.com/JuliaBinaryWrappers/PETSc_jll.jl)) along with a default installation of `MPI.jl`, so you don't have to install it on your machine.
31
31
32
-
If you want to use the package with custom builds of the PETSc library, this can be done by using the function `set_petsclib` which requires you to point to the correct dynamic library (which should be compatible with the MPI version used by `MPI.jl`)
32
+
If you want to use the package with a custom PETSc build, use `set_library!` to configure it once — the path is stored persistently in `LocalPreferences.toml` and no environment variables are needed:
Copy file name to clipboardExpand all lines: docs/src/man/FAQ.md
+20-2Lines changed: 20 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,9 +2,27 @@
2
2
3
3
4
4
## 1. Can I use my own PETSc library?
5
-
Yes, see the function `set_petsclib`. You do need to compile this library as a dynamic library, and `MPI.jl` must be configured to be compatible with the MPI library used to compile PETSc. If you run this on a HPC system, and you don't know exactly which options were used, you can compile one of the PETSc examples and run it with the `-log_view` command line option. At the end of the simulation, it will give you the configuration options used on that machine.
5
+
Yes. You do need to compile PETSc as a dynamic (shared) library, and `MPI.jl` must be configured to be compatible with the MPI used to compile PETSc. If you run this on an HPC system and don't know the configuration options, compile one of the PETSc examples and run it with `-log_view`; the output lists all configuration options used on that machine.
6
6
7
-
Please note that the version of PETSc should be compatible with the version used for the wrapper.
7
+
Please note that the version of PETSc should be compatible with the version used for the wrappers.
8
+
9
+
The recommended approach is `set_library!`, which stores the path persistently in `LocalPreferences.toml` — no environment variables needed:
Copy file name to clipboardExpand all lines: docs/src/man/getting_started.md
+21-7Lines changed: 21 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,7 +3,7 @@
3
3
4
4
-[Getting started](#getting-started)
5
5
-[1a. Installation using pre-built libraries](#1a-installation-using-pre-built-libraries)
6
-
-[1b. Installation using pre-built libraries](#1b-installation-using-pre-built-libraries)
6
+
-[1b. Installation using a custom PETSc build](#1b-installation-using-a-custom-petsc-build)
7
7
-[2. Solving a linear system of equations](#2-solving-a-linear-system-of-equations)
8
8
-[3. Nonlinear example](#3-nonlinear-example)
9
9
-[4. Next steps](#4-next-steps)
@@ -21,14 +21,28 @@ which will install a pre-built PETSc library (`PETSc_jll`) as well as `MPI.jl` o
21
21
22
22
**Windows users are therefore advised to install the [Windows Subsystem for Linux](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux) (WSL) and run PETSc.jl from within WSL.** This will provide full functionality with both serial and parallel (MPI) support.
23
23
24
-
### 1b. Installation using pre-built libraries
25
-
On many high-performance clusters, you will have to use the provided `MPI` installation for that cluster and the default download above will not be sufficient. Alternatively, you may be interested in a PETSc installation that comes with additional external packages. Ensure that this PETSc installation is compiled as a dynamic (and not a static) library, after which you need to specify the correct library with:
24
+
### 1b. Installation using a custom PETSc build
25
+
Sometimes, you may be interested in a PETSc installation that comes with additional external packages, or that you compiled yourself. Ensure the library is compiled as a **dynamic** (not static) library.
26
+
27
+
Use `set_library!` to configure the path once — it is stored in `LocalPreferences.toml` and no environment variables are needed afterwards:
28
+
29
+
```julia
30
+
using PETSc
31
+
PETSc.set_library!(
32
+
"/path/to/custom/libpetsc.so";
33
+
PetscScalar = Float64,
34
+
PetscInt = Int64,
35
+
)
36
+
# Restart Julia — PETSc_jll is not loaded and your library is used automatically.
37
+
```
38
+
39
+
To revert to the bundled binaries: `PETSc.unset_library!()`.
40
+
41
+
For a one-off session without changing persistent settings, use `set_petsclib` directly:
0 commit comments