From 4838cbbd3227ce6a377abf30de10ee092cb5cea6 Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Tue, 19 Oct 2021 16:52:18 +0200 Subject: [PATCH 1/4] Adding mpi tests --- Manifest.toml | 4 ++-- Project.toml | 1 + test/mpi/CellDataTests.jl | 13 +++++++++++++ test/mpi/FESpacesTests.jl | 14 ++++++++++++++ test/mpi/GeometryTests.jl | 19 +++++++++++++++++++ test/mpi/MultiFieldTests.jl | 14 ++++++++++++++ test/mpi/PLaplacianTests.jl | 13 +++++++++++++ test/mpi/PoissonTests.jl | 15 +++++++++++++++ test/mpi/runtests.jl | 21 +++++++++++++++++++++ 9 files changed, 112 insertions(+), 2 deletions(-) create mode 100644 test/mpi/CellDataTests.jl create mode 100644 test/mpi/FESpacesTests.jl create mode 100644 test/mpi/GeometryTests.jl create mode 100644 test/mpi/MultiFieldTests.jl create mode 100644 test/mpi/PLaplacianTests.jl create mode 100644 test/mpi/PoissonTests.jl diff --git a/Manifest.toml b/Manifest.toml index 12672e0e..b40d3fd7 100644 --- a/Manifest.toml +++ b/Manifest.toml @@ -244,9 +244,9 @@ uuid = "56ddb016-857b-54e1-b83d-db4d58db5568" [[MPI]] deps = ["Distributed", "DocStringExtensions", "Libdl", "MPICH_jll", "MicrosoftMPI_jll", "OpenMPI_jll", "Pkg", "Random", "Requires", "Serialization", "Sockets"] -git-tree-sha1 = "e4549a5ced642a73bd8ba2dd1d3b1d30b3530d94" +git-tree-sha1 = "340d8dc89e1c85a846d3f38ee294bfdd1684055a" uuid = "da04e1cc-30fd-572f-bb4f-1f8673147195" -version = "0.19.0" +version = "0.19.1" [[MPICH_jll]] deps = ["Artifacts", "CompilerSupportLibraries_jll", "JLLWrappers", "Libdl", "Pkg"] diff --git a/Project.toml b/Project.toml index 96b551a0..f4981849 100644 --- a/Project.toml +++ b/Project.toml @@ -7,6 +7,7 @@ version = "0.2.0" FillArrays = "1a297f60-69ca-5386-bcde-b61e274b549b" Gridap = "56d4f2e9-7ea1-5844-9cf6-b9c51ca7ce8e" LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e" +MPI = "da04e1cc-30fd-572f-bb4f-1f8673147195" PartitionedArrays = "5a9dfac6-5c52-46f7-8278-5e2210713be9" SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf" diff --git a/test/mpi/CellDataTests.jl b/test/mpi/CellDataTests.jl new file mode 100644 index 00000000..3a45948f --- /dev/null +++ b/test/mpi/CellDataTests.jl @@ -0,0 +1,13 @@ +module CellDataTestsSeq + +using PartitionedArrays +using MPI +MPI.Init() + +include("../CellDataTests.jl") + +parts = get_part_ids(mpi,(2,2)) +display(parts) +CellDataTests.main(parts) + +end # module diff --git a/test/mpi/FESpacesTests.jl b/test/mpi/FESpacesTests.jl new file mode 100644 index 00000000..9267d946 --- /dev/null +++ b/test/mpi/FESpacesTests.jl @@ -0,0 +1,14 @@ +module FESpacesTestsSeq + +using PartitionedArrays +using MPI +MPI.Init() + +include("../FESpacesTests.jl") + +parts = get_part_ids(mpi,(2,2)) +display(parts) +FESpacesTests.main(parts) + +end # module + diff --git a/test/mpi/GeometryTests.jl b/test/mpi/GeometryTests.jl new file mode 100644 index 00000000..6438506c --- /dev/null +++ b/test/mpi/GeometryTests.jl @@ -0,0 +1,19 @@ +module GeometryTestsSeq +using MPI +using PartitionedArrays + +include("../GeometryTests.jl") + +MPI.Init() + +if MPI.Comm_size(MPI.COMM_WORLD) == 4 + parts = get_part_ids(mpi,(2,2)) +elseif MPI.Comm_size(MPI.COMM_WORLD) == 8 + parts = get_part_ids(mpi,(2,2,2)) +else + error() +end +display(parts) +GeometryTests.main(parts) + +end diff --git a/test/mpi/MultiFieldTests.jl b/test/mpi/MultiFieldTests.jl new file mode 100644 index 00000000..65082d00 --- /dev/null +++ b/test/mpi/MultiFieldTests.jl @@ -0,0 +1,14 @@ +module MultiFieldTestsSeq + +using PartitionedArrays +using MPI +MPI.Init() + +include("../MultiFieldTests.jl") + +parts = get_part_ids(mpi,(2,2)) +display(parts) +MultiFieldTests.main(parts) + +end # module + diff --git a/test/mpi/PLaplacianTests.jl b/test/mpi/PLaplacianTests.jl new file mode 100644 index 00000000..e7cbd307 --- /dev/null +++ b/test/mpi/PLaplacianTests.jl @@ -0,0 +1,13 @@ +module PLaplacianTestsSeq + +using PartitionedArrays +using MPI +MPI.Init() + +include("../PLaplacianTests.jl") + +parts = get_part_ids(mpi,(2,2)) +display(parts) +PLaplacianTests.main(parts) + +end # module diff --git a/test/mpi/PoissonTests.jl b/test/mpi/PoissonTests.jl new file mode 100644 index 00000000..849ed49c --- /dev/null +++ b/test/mpi/PoissonTests.jl @@ -0,0 +1,15 @@ +module PoissonTestsSeq + +using PartitionedArrays +using MPI +MPI.Init() + +include("../PoissonTests.jl") + +parts = get_part_ids(mpi,(2,2)) +display(parts) +PoissonTests.main(parts) + +end # module + + diff --git a/test/mpi/runtests.jl b/test/mpi/runtests.jl index bf399f1e..c754eca6 100644 --- a/test/mpi/runtests.jl +++ b/test/mpi/runtests.jl @@ -1,3 +1,24 @@ module MPITests +using MPI +using Test + +mpidir = @__DIR__ +testdir = joinpath(mpidir,"..") +repodir = joinpath(testdir,"..") + +function run_driver(procs,file) + mpiexec() do cmd + run(`$cmd -n $procs $(Base.julia_cmd()) --project=$repodir $(joinpath(mpidir,file))`) + @test true + end +end + +@time @testset "Geometry" begin run_driver(4,"GeometryTests.jl") end +@time @testset "CellData" begin run_driver(4,"CellDataTests.jl") end +@time @testset "FESpaces" begin run_driver(4,"FESpacesTests.jl") end +@time @testset "MultiField" begin run_driver(4,"MultiField") end +@time @testset "Poisson" begin run_driver(4,"Poisson") end +@time @testset "PLaplacian" begin run_driver(4,"PLaplacian") end + end # module From 1cabbf531d3057c271785a197a3ff33e136f885e Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Tue, 19 Oct 2021 17:29:48 +0200 Subject: [PATCH 2/4] Minor --- test/mpi/runtests.jl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/mpi/runtests.jl b/test/mpi/runtests.jl index c754eca6..9dcba6a0 100644 --- a/test/mpi/runtests.jl +++ b/test/mpi/runtests.jl @@ -17,8 +17,8 @@ end @time @testset "Geometry" begin run_driver(4,"GeometryTests.jl") end @time @testset "CellData" begin run_driver(4,"CellDataTests.jl") end @time @testset "FESpaces" begin run_driver(4,"FESpacesTests.jl") end -@time @testset "MultiField" begin run_driver(4,"MultiField") end -@time @testset "Poisson" begin run_driver(4,"Poisson") end -@time @testset "PLaplacian" begin run_driver(4,"PLaplacian") end +@time @testset "MultiField" begin run_driver(4,"MultiField.jl") end +@time @testset "Poisson" begin run_driver(4,"Poisson.jl") end +@time @testset "PLaplacian" begin run_driver(4,"PLaplacian.jl") end end # module From 136dc180346d7ebac687079f48698a2ca76dc6bc Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Wed, 20 Oct 2021 07:43:16 +0200 Subject: [PATCH 3/4] Refactored mpi tests --- test/mpi/CellDataTests.jl | 13 ---------- test/mpi/FESpacesTests.jl | 14 ---------- test/mpi/GeometryTests.jl | 19 -------------- test/mpi/MultiFieldTests.jl | 14 ---------- test/mpi/PLaplacianTests.jl | 13 ---------- test/mpi/PoissonTests.jl | 15 ----------- test/mpi/runtests.jl | 9 +++---- test/mpi/runtests_np4.jl | 52 +++++++++++++++++++++++++++++++++++++ 8 files changed, 55 insertions(+), 94 deletions(-) delete mode 100644 test/mpi/CellDataTests.jl delete mode 100644 test/mpi/FESpacesTests.jl delete mode 100644 test/mpi/GeometryTests.jl delete mode 100644 test/mpi/MultiFieldTests.jl delete mode 100644 test/mpi/PLaplacianTests.jl delete mode 100644 test/mpi/PoissonTests.jl create mode 100644 test/mpi/runtests_np4.jl diff --git a/test/mpi/CellDataTests.jl b/test/mpi/CellDataTests.jl deleted file mode 100644 index 3a45948f..00000000 --- a/test/mpi/CellDataTests.jl +++ /dev/null @@ -1,13 +0,0 @@ -module CellDataTestsSeq - -using PartitionedArrays -using MPI -MPI.Init() - -include("../CellDataTests.jl") - -parts = get_part_ids(mpi,(2,2)) -display(parts) -CellDataTests.main(parts) - -end # module diff --git a/test/mpi/FESpacesTests.jl b/test/mpi/FESpacesTests.jl deleted file mode 100644 index 9267d946..00000000 --- a/test/mpi/FESpacesTests.jl +++ /dev/null @@ -1,14 +0,0 @@ -module FESpacesTestsSeq - -using PartitionedArrays -using MPI -MPI.Init() - -include("../FESpacesTests.jl") - -parts = get_part_ids(mpi,(2,2)) -display(parts) -FESpacesTests.main(parts) - -end # module - diff --git a/test/mpi/GeometryTests.jl b/test/mpi/GeometryTests.jl deleted file mode 100644 index 6438506c..00000000 --- a/test/mpi/GeometryTests.jl +++ /dev/null @@ -1,19 +0,0 @@ -module GeometryTestsSeq -using MPI -using PartitionedArrays - -include("../GeometryTests.jl") - -MPI.Init() - -if MPI.Comm_size(MPI.COMM_WORLD) == 4 - parts = get_part_ids(mpi,(2,2)) -elseif MPI.Comm_size(MPI.COMM_WORLD) == 8 - parts = get_part_ids(mpi,(2,2,2)) -else - error() -end -display(parts) -GeometryTests.main(parts) - -end diff --git a/test/mpi/MultiFieldTests.jl b/test/mpi/MultiFieldTests.jl deleted file mode 100644 index 65082d00..00000000 --- a/test/mpi/MultiFieldTests.jl +++ /dev/null @@ -1,14 +0,0 @@ -module MultiFieldTestsSeq - -using PartitionedArrays -using MPI -MPI.Init() - -include("../MultiFieldTests.jl") - -parts = get_part_ids(mpi,(2,2)) -display(parts) -MultiFieldTests.main(parts) - -end # module - diff --git a/test/mpi/PLaplacianTests.jl b/test/mpi/PLaplacianTests.jl deleted file mode 100644 index e7cbd307..00000000 --- a/test/mpi/PLaplacianTests.jl +++ /dev/null @@ -1,13 +0,0 @@ -module PLaplacianTestsSeq - -using PartitionedArrays -using MPI -MPI.Init() - -include("../PLaplacianTests.jl") - -parts = get_part_ids(mpi,(2,2)) -display(parts) -PLaplacianTests.main(parts) - -end # module diff --git a/test/mpi/PoissonTests.jl b/test/mpi/PoissonTests.jl deleted file mode 100644 index 849ed49c..00000000 --- a/test/mpi/PoissonTests.jl +++ /dev/null @@ -1,15 +0,0 @@ -module PoissonTestsSeq - -using PartitionedArrays -using MPI -MPI.Init() - -include("../PoissonTests.jl") - -parts = get_part_ids(mpi,(2,2)) -display(parts) -PoissonTests.main(parts) - -end # module - - diff --git a/test/mpi/runtests.jl b/test/mpi/runtests.jl index 9dcba6a0..7f4a65d2 100644 --- a/test/mpi/runtests.jl +++ b/test/mpi/runtests.jl @@ -14,11 +14,8 @@ function run_driver(procs,file) end end -@time @testset "Geometry" begin run_driver(4,"GeometryTests.jl") end -@time @testset "CellData" begin run_driver(4,"CellDataTests.jl") end -@time @testset "FESpaces" begin run_driver(4,"FESpacesTests.jl") end -@time @testset "MultiField" begin run_driver(4,"MultiField.jl") end -@time @testset "Poisson" begin run_driver(4,"Poisson.jl") end -@time @testset "PLaplacian" begin run_driver(4,"PLaplacian.jl") end +run_driver(1,"runtests_np4.jl") # Check that the degenerated case works +run_driver(4,"runtests_np4.jl") + end # module diff --git a/test/mpi/runtests_np4.jl b/test/mpi/runtests_np4.jl new file mode 100644 index 00000000..f14ad468 --- /dev/null +++ b/test/mpi/runtests_np4.jl @@ -0,0 +1,52 @@ +module NP4 +# All test running on 4 procs here + +using PartitionedArrays +const PArrays = PartitionedArrays +using MPI + +if ! MPI.Initialized() + MPI.Init() +end + +include("../GeometryTests.jl") +include("../CellDataTests.jl") +include("../FESpacesTests.jl") +include("../MultiFieldTests.jl") +include("../PoissonTests.jl") +include("../PLaplacianTests.jl") + +if MPI.Comm_size(MPI.COMM_WORLD) == 4 + parts = get_part_ids(mpi,(2,2)) +elseif MPI.Comm_size(MPI.COMM_WORLD) == 1 + parts = get_part_ids(mpi,(1,1)) +else + error() +end + +display(parts) + +t = PArrays.PTimer(parts,verbose=true) +PArrays.tic!(t) + +GeometryTests.main(parts) +PArrays.toc!(t,"Geometry") + +CellDataTests.main(parts) +PArrays.toc!(t,"CellData") + +FESpacesTests.main(parts) +PArrays.toc!(t,"FESpaces") + +MultiFieldTests.main(parts) +PArrays.toc!(t,"MultiField") + +PoissonTests.main(parts) +PArrays.toc!(t,"Poisson") + +PLaplacianTests.main(parts) +PArrays.toc!(t,"PLaplacian") + +display(t) + +end #module From 47bed30da56c1cf0d32773afa4492a3e172dd585 Mon Sep 17 00:00:00 2001 From: Francesc Verdugo Date: Wed, 20 Oct 2021 08:52:27 +0200 Subject: [PATCH 4/4] Trying to fix dead lock. --- test/PLaplacianTests.jl | 5 ++++- test/mpi/runtests.jl | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/test/PLaplacianTests.jl b/test/PLaplacianTests.jl index b53d3094..911cc50c 100644 --- a/test/PLaplacianTests.jl +++ b/test/PLaplacianTests.jl @@ -46,7 +46,10 @@ function main(parts,strategy) fill!(x,1) @test (norm(A*x-_A*x)+1) ≈ 1 - nls = NLSolver(show_trace=i_am_main(parts), method=:newton) + # This leads to a dead lock since the printing of the trace seems to lead to collective operations + # show_trace = i_am_main(parts) + show_trace = true # The output in MPI will be ugly, but fixing this would require to edit NLSolvers package. + nls = NLSolver(show_trace=show_trace, method=:newton) solver = FESolver(nls) uh = solve(solver,op) diff --git a/test/mpi/runtests.jl b/test/mpi/runtests.jl index 7f4a65d2..8e150ba0 100644 --- a/test/mpi/runtests.jl +++ b/test/mpi/runtests.jl @@ -14,8 +14,8 @@ function run_driver(procs,file) end end -run_driver(1,"runtests_np4.jl") # Check that the degenerated case works run_driver(4,"runtests_np4.jl") +run_driver(1,"runtests_np4.jl") # Check that the degenerated case works end # module