Browse Source

Use COMM_SELF for single process solves.

pull/5/head
Fredrik Ekre 3 years ago
parent
commit
ae33518ca5
  1. 2
      docs/src/hypre-matrix-vector.md
  2. 6
      src/HYPRE.jl
  3. 6
      test/runtests.jl

2
docs/src/hypre-matrix-vector.md

@ -27,7 +27,7 @@ based it can be *slightly* more resource efficient to use `SparseMatrixCSR`. @@ -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**

6
src/HYPRE.jl

@ -243,7 +243,7 @@ function HYPREMatrix(comm::MPI.Comm, B::Union{SparseMatrixCSC,SparseMatrixCSR}, @@ -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) @@ -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 @@ -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

6
test/runtests.jl

@ -73,13 +73,13 @@ end @@ -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 @@ -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

Loading…
Cancel
Save