Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gridap/GridapDistributed.jl into …
Browse files Browse the repository at this point in the history
…p4est-migration
  • Loading branch information
JordiManyer committed Jan 17, 2023
2 parents ae1cc6f + aa345f3 commit 506c8b8
Show file tree
Hide file tree
Showing 20 changed files with 33 additions and 31 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- Added `DistributedCellDof`, a distributed wrapper for `Gridap.CellDof`. This new wrapper acts on `DistributedCellField` in the same way `Gridap.CellDof` acts on `CellField`. Added `get_fe_dof_basis` function, which extracts a `DistributedCellDof` from a `DistributedFESpace`. Since PR [#97](https://github.com/gridap/GridapDistributed.jl/pull/97).
- Added `gather_free_and_dirichlet_values!` and `gather_free_values!` wrapper functions. Since PR [#97](https://github.com/gridap/GridapDistributed.jl/pull/97).
- Added compatibility with MPI v0.20 and PartitionedArrays v0.2.13

## [0.2.6] - 2022-06-07

Expand Down
7 changes: 4 additions & 3 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "GridapDistributed"
uuid = "f9701e48-63b3-45aa-9a63-9bc6c271f355"
authors = ["S. Badia <santiago.badia@monash.edu>", "A. F. Martin <alberto.martin@monash.edu>", "F. Verdugo <fverdugo@cimne.upc.edu>"]
authors = ["S. Badia <santiago.badia@monash.edu>", "A. F. Martin <alberto.f.martin@anu.edu.au>", "F. Verdugo <fverdugo@cimne.upc.edu>"]
version = "0.2.6"

[deps]
Expand All @@ -15,8 +15,9 @@ WriteVTK = "64499a7a-5c06-52f2-abe2-ccb03c286192"

[compat]
FillArrays = "0.8.4, 0.9, 0.10, 0.11, 0.12"
MPI = "0.16, 0.17, 0.18, 0.19"
PartitionedArrays = "0.2.10"
Gridap = "0.17.11"
MPI = "0.16, 0.17, 0.18, 0.19, 0.20"
PartitionedArrays = "0.2.13"
SparseMatricesCSR = "0.6.6"
WriteVTK = "1.12.0"
julia = "1.3"
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ with the appropriate number of MPI tasks, `-n 4` in this particular example.

## Simple example (MPI-parallel execution mode)

The following Julia code snippet solves a 2D Poisson problem in parallel on the unit square. The example follows the MPI-parallel execution mode (note the `mpi` argument to the `prun` function call) and thus it must be executed on 4 MPI tasks (note the mesh is partitioned into 4 parts) using the instructions [below](https://github.com/gridap/GridapDistributed.jl#mpi-parallel-julia-script-execution-instructions). If a user wants to use the sequential execution mode, one just replaces `mpi` by `sequential` in the call to `prun`. `GridapDistributed.jl` sequential execution mode scripts are executed as any other julia sequential script.
The following Julia code snippet solves a 2D Poisson problem in parallel on the unit square. The example follows the MPI-parallel execution mode (note the `MPIBackend()` argument to the `with_backend` function call) and thus it must be executed on 4 MPI tasks (note the mesh is partitioned into 4 parts) using the instructions [below](https://github.com/gridap/GridapDistributed.jl#mpi-parallel-julia-script-execution-instructions). If a user wants to use the sequential execution mode, one just replaces `MPIBackend()` by `SequentialBackend()` in the call to `with_backend`. `GridapDistributed.jl` sequential execution mode scripts are executed as any other julia sequential script.

```julia
using Gridap
using GridapDistributed
using PartitionedArrays
partition = (2,2)
prun(mpi,partition) do parts
with_backend(MPIBackend(),partition) do parts
domain = (0,1,0,1)
mesh_partition = (4,4)
model = CartesianDiscreteModel(parts,domain,mesh_partition)
Expand All @@ -64,7 +64,7 @@ prun(mpi,partition) do parts
writevtk(Ω,"results",cellfields=["uh"=>uh,"grad_uh"=>(uh)])
end
```
The domain is discretized using the parallel Cartesian-like mesh generator built-in in `GridapDistributed`. The only minimal difference with respect to the sequential `Gridap` script is a call to the `prun` function of [`PartitionedArrays.jl`](https://github.com/fverdugo/PartitionedArrays.jl) right at the beginning of the program. With this function, the programer sets up the `PartitionedArrays.jl` communication backend (i.e., MPI in the example), specifies the number of parts and their layout (i.e., 2x2 partition in the example), and provides a function (using Julia do-block syntax for function arguments in the example) to be run on each part. The function body is equivalent to a sequential `Gridap` script, except for the `CartesianDiscreteModel` call, which in `GridapDistributed` also requires the `parts` argument passed back by the `prun` function.
The domain is discretized using the parallel Cartesian-like mesh generator built-in in `GridapDistributed`. The only minimal difference with respect to the sequential `Gridap` script is a call to the `with_backend` function of [`PartitionedArrays.jl`](https://github.com/fverdugo/PartitionedArrays.jl) right at the beginning of the program. With this function, the programer sets up the `PartitionedArrays.jl` communication backend (i.e., MPI in the example), specifies the number of parts and their layout (i.e., 2x2 partition in the example), and provides a function (using Julia do-block syntax for function arguments in the example) to be run on each part. The function body is equivalent to a sequential `Gridap` script, except for the `CartesianDiscreteModel` call, which in `GridapDistributed` also requires the `parts` argument passed back by the `with_backend` function.

## Using parallel solvers

Expand All @@ -89,7 +89,7 @@ using GridapPETSc
using GridapDistributed
using PartitionedArrays
n = 6
prun(mpi,n) do parts
with_backend(MPIBackend(),n) do parts
options = "-ksp_type cg -pc_type gamg -ksp_monitor"
GridapPETSc.with(args=split(options)) do
model = GmshDiscreteModel(parts,"demo.msh")
Expand Down
2 changes: 1 addition & 1 deletion test/StokesOpenBoundaryTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ function main(parts)
g(t) = x -> (∇u(t))(x)
h(t) = x -> (u(t))(x)VectorValue(0.0,1.0) - p(t)(x)*VectorValue(0.0,1.0)

parts = get_part_ids(sequential,(2,2))
parts = get_part_ids(SequentialBackend(),(2,2))
domain = (0,1,0,1)
partition = (4,4)
model = CartesianDiscreteModel(parts,domain,partition)
Expand Down
2 changes: 1 addition & 1 deletion test/SurfaceCouplingTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ g(x) = tr(∇u(x))
function main(parts)

# Mesh
parts = get_part_ids(sequential,(2,2))
parts = get_part_ids(SequentialBackend(),(2,2))
cells = (10,10)
domain = (0,1,0,1)
model = CartesianDiscreteModel(parts,domain,cells)
Expand Down
2 changes: 1 addition & 1 deletion test/TestApp/compile/compile.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ module sysimagegenerator
include("../../mpi/runtests_np4_body.jl")
prun(all_tests,mpi,(1,1))
with_backend(all_tests,MPIBackend(),(1,1))
MPI.Finalize()
Expand Down
4 changes: 2 additions & 2 deletions test/mpi/runtests_np4.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ end
include("runtests_np4_body.jl")

if MPI.Comm_size(MPI.COMM_WORLD) == 4
prun(all_tests,mpi,(2,2))
with_backend(all_tests,MPIBackend(),(2,2))
elseif MPI.Comm_size(MPI.COMM_WORLD) == 1
prun(all_tests,mpi,(1,1))
with_backend(all_tests,MPIBackend(),(1,1))
else
MPI.Abort(MPI.COMM_WORLD,0)
end
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/CellDataTests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module CellDataTestsSeq
using PartitionedArrays
include("../CellDataTests.jl")
prun(CellDataTests.main,sequential,(2,2))
with_backend(CellDataTests.main,SequentialBackend(),(2,2))
end # module
2 changes: 1 addition & 1 deletion test/sequential/DivConformingTests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module DivConformingTestsSeq
using PartitionedArrays
include("../DivConformingTests.jl")
prun(DivConformingTests.main,sequential,2)
with_backend(DivConformingTests.main,SequentialBackend(),2)
end # module
2 changes: 1 addition & 1 deletion test/sequential/FESpacesTests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module FESpacesTestsSeq
using PartitionedArrays
include("../FESpacesTests.jl")
prun(FESpacesTests.main,sequential,(2,2))
with_backend(FESpacesTests.main,SequentialBackend(),(2,2))
end # module
4 changes: 2 additions & 2 deletions test/sequential/GeometryTests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module GeometryTestsSeq
using PartitionedArrays
include("../GeometryTests.jl")
prun(GeometryTests.main,sequential,(2,2))
prun(GeometryTests.main,sequential,(2,2,2))
with_backend(GeometryTests.main,SequentialBackend(),(2,2))
with_backend(GeometryTests.main,SequentialBackend(),(2,2,2))
end
2 changes: 1 addition & 1 deletion test/sequential/HeatEquationTests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module HeatEquationTestsSeq
using PartitionedArrays
include("../HeatEquationTests.jl")
prun(HeatEquationTests.main,sequential,(2,2))
with_backend(HeatEquationTests.main,SequentialBackend(),(2,2))
end # module
2 changes: 1 addition & 1 deletion test/sequential/MultiFieldTests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module MultiFieldTestsSeq
using PartitionedArrays
include("../MultiFieldTests.jl")
prun(MultiFieldTests.main,sequential,(2,2))
with_backend(MultiFieldTests.main,SequentialBackend(),(2,2))
end # module
2 changes: 1 addition & 1 deletion test/sequential/PLaplacianTests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module PLaplacianTestsSeq
using PartitionedArrays
include("../PLaplacianTests.jl")
prun(PLaplacianTests.main,sequential,(2,2))
with_backend(PLaplacianTests.main,SequentialBackend(),(2,2))
end # module
12 changes: 6 additions & 6 deletions test/sequential/PeriodicBCsTests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,17 @@ reffe = ReferenceFE(lagrangian,Float64,1)
ndofss = [25,20,20,16]
for np in nps
for (ndofs, isperiodic) in zip(ndofss,isperiodics)
parts = get_part_ids(sequential,np)
parts = get_part_ids(SequentialBackend(),np)
model = CartesianDiscreteModel(parts,domain,cells;isperiodic=isperiodic)
V = FESpace(model,reffe)
@test ndofs == num_free_dofs(V)
end
end

include("../PeriodicBCsTests.jl")
prun(PeriodicBCsTests.main,sequential,(2,2))
prun(PeriodicBCsTests.main,sequential,(2,1))
prun(PeriodicBCsTests.main,sequential,(1,1))
prun(PeriodicBCsTests.main,sequential,(1,2))
prun(PeriodicBCsTests.main,sequential,(2,3))
with_backend(PeriodicBCsTests.main,SequentialBackend(),(2,2))
with_backend(PeriodicBCsTests.main,SequentialBackend(),(2,1))
with_backend(PeriodicBCsTests.main,SequentialBackend(),(1,1))
with_backend(PeriodicBCsTests.main,SequentialBackend(),(1,2))
with_backend(PeriodicBCsTests.main,SequentialBackend(),(2,3))
end # module
2 changes: 1 addition & 1 deletion test/sequential/PoissonTests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module PoissonTestsSeq
using PartitionedArrays
include("../PoissonTests.jl")
prun(PoissonTests.main,sequential,(2,2))
with_backend(PoissonTests.main,SequentialBackend(),(2,2))
end # module
2 changes: 1 addition & 1 deletion test/sequential/StokesOpenBoundaryTests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module StokesOpenBoundaryTestsSeq
using PartitionedArrays
include("../StokesOpenBoundaryTests.jl")
prun(StokesOpenBoundaryTests.main,sequential,(2,2))
with_backend(StokesOpenBoundaryTests.main,SequentialBackend(),(2,2))
end # module
2 changes: 1 addition & 1 deletion test/sequential/SurfaceCouplingTests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module SurfaceCouplingTestsSeq
using PartitionedArrays
include("../SurfaceCouplingTests.jl")
prun(SurfaceCouplingTests.main,sequential,(2,2))
with_backend(SurfaceCouplingTests.main,SequentialBackend(),(2,2))
end # module

2 changes: 1 addition & 1 deletion test/sequential/TransientDistributedCellFieldTests.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module TransientDistributedCellFieldTestsSeq
using PartitionedArrays
include("../TransientDistributedCellFieldTests.jl")
prun(TransientDistributedCellFieldTests.main,sequential,(2,2))
with_backend(TransientDistributedCellFieldTests.main,SequentialBackend(),(2,2))
end # module
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module TransientMultiFieldDistributedCellFieldTestsSeq
using PartitionedArrays
include("../TransientMultiFieldDistributedCellFieldTests.jl")
prun(TransientMultiFieldDistributedCellFieldTests.main,sequential,(2,2))
with_backend(TransientMultiFieldDistributedCellFieldTests.main,SequentialBackend(),(2,2))
end # module

0 comments on commit 506c8b8

Please sign in to comment.