Skip to content

Commit

Permalink
set P4est preferences before MPIPreferences
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaLampert committed Oct 15, 2023
1 parent 30646a8 commit 69c3eeb
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 30 deletions.
38 changes: 19 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,18 +76,7 @@ To enable this, you first need to obtain a local binary installation of
implementation used to build your local installation of
[`p4est`](https://github.com/cburstedde/p4est), see
[the documentation of MPI.jl](https://juliaparallel.org/MPI.jl/stable/configuration/).
At the time of writing, this can be done via

```julia
julia> using MPIPreferences

julia> MPIPreferences.use_system_binary()
```

if you use the default system MPI binary installation to build
[`p4est`](https://github.com/cburstedde/p4est).

Next, you need to set up the
At the time of writing, this can be done by first setting up the
[Preferences.jl](https://github.com/JuliaPackaging/Preferences.jl)
setting containing the path to your local build of the shared library of
[`p4est`](https://github.com/cburstedde/p4est).
Expand Down Expand Up @@ -126,6 +115,17 @@ To delete the preferences again, you can call `P4est.set_library_p4est!()` and
`P4est.set_library_sc!()`, respectively.
Note that you should restart your Julia session after changing the preferences.
Next, you need to set up the preferences for MPI, which can be done by
```julia
julia> using MPIPreferences

julia> MPIPreferences.use_system_binary()
```
if you use the default system MPI binary installation to build
[`p4est`](https://github.com/cburstedde/p4est).
To sum up, follow these steps to use
[P4est.jl](https://github.com/trixi-framework/P4est.jl) with a custom
installation of the underlying C libraries.
Expand All @@ -137,13 +137,7 @@ installation of the underlying C libraries.
new one if there is none.
- Install the required packages.
```julia
julia> Pkg.add(["MPIPreferences", "MPI", "UUIDs", "Preferences", "P4est"])
```
- Set [MPI.jl](https://github.com/JuliaParallel/MPI.jl) preferences.
```julia
julia> using MPIPreferences

julia> MPIPreferences.use_system_binary()
julia> Pkg.add(["MPIPreferences", "MPI", "P4est"])
```
- Set [P4est.jl](https://github.com/trixi-framework/P4est.jl) preferences.
```julia
Expand All @@ -155,6 +149,12 @@ installation of the underlying C libraries.
julia> P4est.set_library_sc!("/path/to/your/libsc.so")
[ Info: Please restart Julia and reload P4est.jl for the library changes to take effect
```
- Set [MPI.jl](https://github.com/JuliaParallel/MPI.jl) preferences.
```julia
julia> using MPIPreferences

julia> MPIPreferences.use_system_binary()
```
- Restart the Julia REPL and load the packages.
```julia
julia> import Pkg; Pkg.activate(".")
Expand Down
18 changes: 7 additions & 11 deletions test/configure_packages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,17 @@ const JULIA_P4EST_TEST_LIBP4EST = get(ENV, "JULIA_P4EST_TEST_LIBP4EST", "")
const JULIA_P4EST_TEST_LIBSC = get(ENV, "JULIA_P4EST_TEST_LIBSC", "")
rm(joinpath(dirname(@__DIR__), "LocalPreferences.toml"), force = true)

# Next, we configure MPI.jl appropriately.
# Next, we configure P4est.jl as desired.
@static if JULIA_P4EST_TEST == "P4EST_CUSTOM_MPI_CUSTOM"
import MPIPreferences
MPIPreferences.use_system_binary()
import P4est
P4est.set_library_p4est!(JULIA_P4EST_TEST_LIBP4EST, force = true)
P4est.set_library_sc!(JULIA_P4EST_TEST_LIBSC, force = true)
end

# Finally, we configure P4est.jl as desired.
# Finally, we configure MPI.jl appropriately.
@static if JULIA_P4EST_TEST == "P4EST_CUSTOM_MPI_CUSTOM"
import UUIDs, Preferences
Preferences.set_preferences!(
UUIDs.UUID("7d669430-f675-4ae7-b43e-fab78ec5a902"), # UUID of P4est.jl
"libp4est" => JULIA_P4EST_TEST_LIBP4EST, force = true)
Preferences.set_preferences!(
UUIDs.UUID("7d669430-f675-4ae7-b43e-fab78ec5a902"), # UUID of P4est.jl
"libsc" => JULIA_P4EST_TEST_LIBSC, force = true)
import MPIPreferences
MPIPreferences.use_system_binary()
end

@info "P4est.jl tests configured" JULIA_P4EST_TEST JULIA_P4EST_TEST_LIBP4EST JULIA_P4EST_TEST_LIBSC

0 comments on commit 69c3eeb

Please sign in to comment.