From ae33518ca5bca7d18ea6d0c21eb83647acca649c Mon Sep 17 00:00:00 2001 From: Fredrik Ekre Date: Wed, 27 Jul 2022 18:42:41 +0200 Subject: [PATCH] Use COMM_SELF for single process solves. --- docs/src/hypre-matrix-vector.md | 2 +- src/HYPRE.jl | 6 +++--- test/runtests.jl | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/src/hypre-matrix-vector.md b/docs/src/hypre-matrix-vector.md index 0bc30a1..ea3b813 100644 --- a/docs/src/hypre-matrix-vector.md +++ b/docs/src/hypre-matrix-vector.md @@ -27,7 +27,7 @@ based it can be *slightly* more resource efficient to use `SparseMatrixCSR`. The constructors also support both PartitionedArrays.jl backends: When using the `MPI` backend the communicator of the `PSparseMatrix`/`PVector` is used also for the `HYPREMatrix`/`HYPREVector`, and when using the `Sequential` backend it is assumed to be a -single-process setup, and the global communicator `MPI.COMM_WORLD` is used. +single-process setup, and the `MPI.COMM_SELF` communicator is used. **Example pseudocode** diff --git a/src/HYPRE.jl b/src/HYPRE.jl index 9af147f..f8da68c 100644 --- a/src/HYPRE.jl +++ b/src/HYPRE.jl @@ -243,7 +243,7 @@ function HYPREMatrix(comm::MPI.Comm, B::Union{SparseMatrixCSC,SparseMatrixCSR}, end HYPREMatrix(B::Union{SparseMatrixCSC,SparseMatrixCSR}, ilower=1, iupper=size(B, 1)) = - HYPREMatrix(MPI.COMM_WORLD, B, ilower, iupper) + HYPREMatrix(MPI.COMM_SELF, B, ilower, iupper) ######################### # Vector -> HYPREVector # @@ -266,7 +266,7 @@ function HYPREVector(comm::MPI.Comm, x::Vector, ilower, iupper) end HYPREVector(x::Vector, ilower=1, iupper=length(x)) = - HYPREVector(MPI.COMM_WORLD, x, ilower, iupper) + HYPREVector(MPI.COMM_SELF, x, ilower, iupper) # TODO: Other eltypes could be support by using a intermediate buffer function Base.copy!(x::Vector{HYPRE_Complex}, h::HYPREVector) @@ -376,7 +376,7 @@ end function Internals.get_comm(A::Union{PSparseMatrix{<:Any,<:M}, PVector{<:Any,<:M}}) where M <: MPIData return A.rows.partition.comm end -Internals.get_comm(_::Union{PSparseMatrix,PVector}) = MPI.COMM_WORLD +Internals.get_comm(_::Union{PSparseMatrix,PVector}) = MPI.COMM_SELF function Internals.get_proc_rows(A::Union{PSparseMatrix{<:Any,<:M}, PVector{<:Any,<:M}}) where M <: MPIData r = A.rows.partition.part diff --git a/test/runtests.jl b/test/runtests.jl index f07d05a..c3a9d23 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -73,13 +73,13 @@ end H = HYPREMatrix(CSC) @test H.ijmatrix != HYPRE_IJMatrix(C_NULL) @test H.parmatrix != HYPRE_ParCSRMatrix(C_NULL) - @test H.comm == MPI.COMM_WORLD + @test H.comm == MPI.COMM_SELF @test H.ilower == H.jlower == 1 @test H.iupper == H.jupper == 10 H = HYPREMatrix(CSR) @test H.ijmatrix != HYPRE_IJMatrix(C_NULL) @test H.parmatrix != HYPRE_ParCSRMatrix(C_NULL) - @test H.comm == MPI.COMM_WORLD + @test H.comm == MPI.COMM_SELF @test H.ilower == H.jlower == 1 @test H.iupper == H.jupper == 10 end @@ -214,7 +214,7 @@ end h = HYPREVector(b) @test h.ijvector != HYPRE_IJVector(C_NULL) @test h.parvector != HYPRE_ParVector(C_NULL) - @test h.comm == MPI.COMM_WORLD + @test h.comm == MPI.COMM_SELF @test h.ilower == 1 @test h.iupper == 10