Browse Source

runic -i .

pull/32/head
Fredrik Ekre 11 months ago
parent
commit
85af5be132
No known key found for this signature in database
GPG Key ID: DE82E6D5E364C0A2
  1. 33
      examples/ex5.jl
  2. 12
      ext/HYPREPartitionedArrays.jl
  3. 4
      ext/HYPRESparseArrays.jl
  4. 2
      ext/HYPRESparseMatricesCSR.jl
  5. 15
      gen/generator.jl
  6. 6
      gen/prologue.jl
  7. 3
      gen/solver_options.jl
  8. 1752
      lib/LibHYPRE.jl
  9. 15
      src/HYPRE.jl
  10. 3
      src/LibHYPRE.jl
  11. 8
      src/solver_options.jl
  12. 19
      src/solvers.jl
  13. 119
      test/runtests.jl
  14. 10
      test/test_assembler.jl

33
examples/ex5.jl

@ -85,7 +85,9 @@ function main(argc, argv)
end end
# Preliminaries: want at least one processor per row # Preliminaries: want at least one processor per row
if n * n < num_procs; n = trunc(Int, sqrt(n)) + 1; end if n * n < num_procs
n = trunc(Int, sqrt(n)) + 1
end
N = n * n # global number of rows N = n * n # global number of rows
h = 1.0 / (n + 1) # mesh size h = 1.0 / (n + 1) # mesh size
h2 = h * h h2 = h * h
@ -257,8 +259,7 @@ function main(argc, argv)
num_iterations = Ref{Cint}() num_iterations = Ref{Cint}()
final_res_norm = Ref{Cdouble}() final_res_norm = Ref{Cdouble}()
# AMG if solver_id == 0 # AMG
if solver_id == 0
# Create solver # Create solver
HYPRE_BoomerAMGCreate(solver_ref) HYPRE_BoomerAMGCreate(solver_ref)
solver = solver_ref[] solver = solver_ref[]
@ -270,7 +271,7 @@ function main(argc, argv)
HYPRE_BoomerAMGSetRelaxOrder(solver, 1) # uses C/F relaxation HYPRE_BoomerAMGSetRelaxOrder(solver, 1) # uses C/F relaxation
HYPRE_BoomerAMGSetNumSweeps(solver, 1) # Sweeeps on each level HYPRE_BoomerAMGSetNumSweeps(solver, 1) # Sweeeps on each level
HYPRE_BoomerAMGSetMaxLevels(solver, 20) # maximum number of levels HYPRE_BoomerAMGSetMaxLevels(solver, 20) # maximum number of levels
HYPRE_BoomerAMGSetTol(solver, 1e-7) # conv. tolerance HYPRE_BoomerAMGSetTol(solver, 1.0e-7) # conv. tolerance
# Now setup and solve! # Now setup and solve!
HYPRE_BoomerAMGSetup(solver, parcsr_A, par_b, par_x) HYPRE_BoomerAMGSetup(solver, parcsr_A, par_b, par_x)
@ -289,15 +290,14 @@ function main(argc, argv)
# Destroy solver # Destroy solver
HYPRE_BoomerAMGDestroy(solver) HYPRE_BoomerAMGDestroy(solver)
# PCG elseif solver_id == 50 # PCG
elseif solver_id == 50
# Create solver # Create solver
HYPRE_ParCSRPCGCreate(MPI_COMM_WORLD, solver_ref) HYPRE_ParCSRPCGCreate(MPI_COMM_WORLD, solver_ref)
solver = solver_ref[] solver = solver_ref[]
# Set some parameters (See Reference Manual for more parameters) # Set some parameters (See Reference Manual for more parameters)
HYPRE_PCGSetMaxIter(solver, 1000) # max iterations HYPRE_PCGSetMaxIter(solver, 1000) # max iterations
HYPRE_PCGSetTol(solver, 1e-7) # conv. tolerance HYPRE_PCGSetTol(solver, 1.0e-7) # conv. tolerance
HYPRE_PCGSetTwoNorm(solver, 1) # use the two norm as the stopping criteria HYPRE_PCGSetTwoNorm(solver, 1) # use the two norm as the stopping criteria
HYPRE_PCGSetPrintLevel(solver, 2) # prints out the iteration info HYPRE_PCGSetPrintLevel(solver, 2) # prints out the iteration info
HYPRE_PCGSetLogging(solver, 1) # needed to get run info later HYPRE_PCGSetLogging(solver, 1) # needed to get run info later
@ -319,15 +319,14 @@ function main(argc, argv)
# Destroy solver # Destroy solver
HYPRE_ParCSRPCGDestroy(solver) HYPRE_ParCSRPCGDestroy(solver)
# PCG with AMG preconditioner elseif solver_id == 1 # PCG with AMG preconditioner
elseif solver_id == 1
# Create solver # Create solver
HYPRE_ParCSRPCGCreate(MPI_COMM_WORLD, solver_ref) HYPRE_ParCSRPCGCreate(MPI_COMM_WORLD, solver_ref)
solver = solver_ref[] solver = solver_ref[]
# Set some parameters (See Reference Manual for more parameters) # Set some parameters (See Reference Manual for more parameters)
HYPRE_PCGSetMaxIter(solver, 1000) # max iterations HYPRE_PCGSetMaxIter(solver, 1000) # max iterations
HYPRE_PCGSetTol(solver, 1e-7) # conv. tolerance HYPRE_PCGSetTol(solver, 1.0e-7) # conv. tolerance
HYPRE_PCGSetTwoNorm(solver, 1) # use the two norm as the stopping criteria HYPRE_PCGSetTwoNorm(solver, 1) # use the two norm as the stopping criteria
HYPRE_PCGSetPrintLevel(solver, 2) # print solve info HYPRE_PCGSetPrintLevel(solver, 2) # print solve info
HYPRE_PCGSetLogging(solver, 1) # needed to get run info later HYPRE_PCGSetLogging(solver, 1) # needed to get run info later
@ -364,15 +363,14 @@ function main(argc, argv)
HYPRE_ParCSRPCGDestroy(solver) HYPRE_ParCSRPCGDestroy(solver)
HYPRE_BoomerAMGDestroy(precond) HYPRE_BoomerAMGDestroy(precond)
# PCG with Parasails Preconditioner elseif solver_id == 8 # PCG with Parasails Preconditioner
elseif solver_id == 8
# Create solver # Create solver
HYPRE_ParCSRPCGCreate(MPI_COMM_WORLD, solver_ref) HYPRE_ParCSRPCGCreate(MPI_COMM_WORLD, solver_ref)
solver = solver_ref[] solver = solver_ref[]
# Set some parameters (See Reference Manual for more parameters) # Set some parameters (See Reference Manual for more parameters)
HYPRE_PCGSetMaxIter(solver, 1000) # max iterations HYPRE_PCGSetMaxIter(solver, 1000) # max iterations
HYPRE_PCGSetTol(solver, 1e-7) # conv. tolerance HYPRE_PCGSetTol(solver, 1.0e-7) # conv. tolerance
HYPRE_PCGSetTwoNorm(solver, 1) # use the two norm as the stopping criteria HYPRE_PCGSetTwoNorm(solver, 1) # use the two norm as the stopping criteria
HYPRE_PCGSetPrintLevel(solver, 2) # print solve info HYPRE_PCGSetPrintLevel(solver, 2) # print solve info
HYPRE_PCGSetLogging(solver, 1) # needed to get run info later HYPRE_PCGSetLogging(solver, 1) # needed to get run info later
@ -412,8 +410,7 @@ function main(argc, argv)
HYPRE_ParCSRPCGDestroy(solver) HYPRE_ParCSRPCGDestroy(solver)
HYPRE_ParaSailsDestroy(precond) HYPRE_ParaSailsDestroy(precond)
# Flexible GMRES with AMG Preconditioner elseif solver_id == 61 # Flexible GMRES with AMG Preconditioner
elseif solver_id == 61
# Create solver # Create solver
HYPRE_ParCSRFlexGMRESCreate(MPI_COMM_WORLD, solver_ref) HYPRE_ParCSRFlexGMRESCreate(MPI_COMM_WORLD, solver_ref)
@ -422,7 +419,7 @@ function main(argc, argv)
# Set some parameters (See Reference Manual for more parameters) # Set some parameters (See Reference Manual for more parameters)
HYPRE_FlexGMRESSetKDim(solver, 30) # restart HYPRE_FlexGMRESSetKDim(solver, 30) # restart
HYPRE_FlexGMRESSetMaxIter(solver, 1000) # max iterations HYPRE_FlexGMRESSetMaxIter(solver, 1000) # max iterations
HYPRE_FlexGMRESSetTol(solver, 1e-7) # conv. tolerance HYPRE_FlexGMRESSetTol(solver, 1.0e-7) # conv. tolerance
HYPRE_FlexGMRESSetPrintLevel(solver, 2) # print solve info HYPRE_FlexGMRESSetPrintLevel(solver, 2) # print solve info
HYPRE_FlexGMRESSetLogging(solver, 1) # needed to get run info later HYPRE_FlexGMRESSetLogging(solver, 1) # needed to get run info later
@ -459,7 +456,9 @@ function main(argc, argv)
HYPRE_BoomerAMGDestroy(precond) HYPRE_BoomerAMGDestroy(precond)
else else
if myid == 0; println("Invalid solver id specified."); end if myid == 0
println("Invalid solver id specified.")
end
end end
# Clean up # Clean up

12
ext/HYPREPartitionedArrays.jl

@ -66,7 +66,7 @@ function Internals.to_hypre_data(
# Keep track of the last index used for every row # Keep track of the last index used for every row
lastinds = zeros(Int, nrows) lastinds = zeros(Int, nrows)
cumsum!((@view lastinds[2:end]), (@view ncols[1:end-1])) cumsum!((@view lastinds[2:end]), (@view ncols[1:(end - 1)]))
# Second pass to populate the output. Here we need to map column # Second pass to populate the output. Here we need to map column
# indices from own/ghost to global # indices from own/ghost to global
@ -149,11 +149,11 @@ function Internals.to_hypre_data(
return nrows, ncols, rows, cols, values return nrows, ncols, rows, cols, values
end end
function Internals.get_comm(A::Union{PSparseMatrix{<:Any,<:M}, PVector{<:Any,<:M}}) where M <: MPIArray function Internals.get_comm(A::Union{PSparseMatrix{<:Any, <:M}, PVector{<:Any, <:M}}) where {M <: MPIArray}
return partition(A).comm return partition(A).comm
end end
Internals.get_comm(_::Union{PSparseMatrix,PVector}) = MPI.COMM_SELF Internals.get_comm(_::Union{PSparseMatrix, PVector}) = MPI.COMM_SELF
function Internals.get_proc_rows(A::Union{PSparseMatrix, PVector}) function Internals.get_proc_rows(A::Union{PSparseMatrix, PVector})
ilower::HYPRE_BigInt = typemax(HYPRE_BigInt) ilower::HYPRE_BigInt = typemax(HYPRE_BigInt)
@ -238,10 +238,10 @@ function copy_check(dst::HYPREVector, src::PVector)
il_src, iu_src = Internals.get_proc_rows(src) il_src, iu_src = Internals.get_proc_rows(src)
if il_dst != il_src && iu_dst != iu_src if il_dst != il_src && iu_dst != iu_src
# TODO: Why require this? # TODO: Why require this?
throw(ArgumentError( msg = "row owner mismatch between dst ($(il_dst:iu_dst)) and src ($(il_src:iu_src))"
"row owner mismatch between dst ($(il_dst:iu_dst)) and src ($(il_src:iu_src))" throw(ArgumentError(msg))
))
end end
return
end end
# TODO: Other eltypes could be support by using a intermediate buffer # TODO: Other eltypes could be support by using a intermediate buffer

4
ext/HYPRESparseArrays.jl

@ -33,7 +33,7 @@ function Internals.to_hypre_data(A::SparseMatrixCSC, ilower, iupper)
# Keep track of the last index used for every row # Keep track of the last index used for every row
lastinds = zeros(Int, nrows) lastinds = zeros(Int, nrows)
cumsum!((@view lastinds[2:end]), (@view ncols[1:end-1])) cumsum!((@view lastinds[2:end]), (@view ncols[1:(end - 1)]))
# Second pass to populate the output # Second pass to populate the output
@inbounds for j in 1:size(A, 2) @inbounds for j in 1:size(A, 2)
@ -59,7 +59,7 @@ function HYPRE.HYPREMatrix(comm::MPI.Comm, B::SparseMatrixCSC, ilower, iupper)
end end
# Note: keep in sync with the SparseMatrixCSC method # Note: keep in sync with the SparseMatrixCSC method
function HYPRE.HYPREMatrix(B::SparseMatrixCSC, ilower=1, iupper=size(B, 1)) function HYPRE.HYPREMatrix(B::SparseMatrixCSC, ilower = 1, iupper = size(B, 1))
return HYPREMatrix(MPI.COMM_SELF, B, ilower, iupper) return HYPREMatrix(MPI.COMM_SELF, B, ilower, iupper)
end end

2
ext/HYPRESparseMatricesCSR.jl

@ -53,7 +53,7 @@ function HYPRE.HYPREMatrix(comm::MPI.Comm, B::SparseMatrixCSR, ilower, iupper)
end end
# Note: keep in sync with the SparseMatrixCSC method # Note: keep in sync with the SparseMatrixCSC method
function HYPRE.HYPREMatrix(B::SparseMatrixCSR, ilower=1, iupper=size(B, 1)) function HYPRE.HYPREMatrix(B::SparseMatrixCSR, ilower = 1, iupper = size(B, 1))
return HYPREMatrix(MPI.COMM_SELF, B, ilower, iupper) return HYPREMatrix(MPI.COMM_SELF, B, ilower, iupper)
end end

15
gen/generator.jl

@ -21,12 +21,15 @@ push!(args, "-DHYPRE_ENABLE_CUDA_STREAMS=OFF")
push!(args, "-DHYPRE_ENABLE_CUSPARSE=OFF") push!(args, "-DHYPRE_ENABLE_CUSPARSE=OFF")
push!(args, "-DHYPRE_ENABLE_CURAND=OFF") push!(args, "-DHYPRE_ENABLE_CURAND=OFF")
headers = joinpath.(hypre_include_dir, [ headers = joinpath.(
"HYPRE.h", hypre_include_dir,
"HYPRE_IJ_mv.h", [
"HYPRE_parcsr_mv.h", "HYPRE.h",
"HYPRE_parcsr_ls.h", "HYPRE_IJ_mv.h",
]) "HYPRE_parcsr_mv.h",
"HYPRE_parcsr_ls.h",
]
)
ctx = create_context(headers, args, options) ctx = create_context(headers, args, options)

6
gen/prologue.jl

@ -1,6 +1,8 @@
using MPI: MPI, MPI_Comm using MPI: MPI, MPI_Comm
if isdefined(MPI, :API) # MPI >= 0.20.0 if isdefined(MPI, :API)
# MPI >= 0.20.0
using MPI.API: MPI_INT, MPI_DOUBLE using MPI.API: MPI_INT, MPI_DOUBLE
else # MPI < 0.20.0 else
# MPI < 0.20.0
using MPI: MPI_INT, MPI_DOUBLE using MPI: MPI_INT, MPI_DOUBLE
end end

3
gen/solver_options.jl

@ -5,7 +5,7 @@ function generate_options(io, structname, prefixes...)
println(io, "function Internals.set_options(solver::$(structname), kwargs)") println(io, "function Internals.set_options(solver::$(structname), kwargs)")
println(io, " for (k, v) in kwargs") println(io, " for (k, v) in kwargs")
ns = Tuple{Symbol,String}[] ns = Tuple{Symbol, String}[]
for prefix in prefixes, n in names(LibHYPRE) for prefix in prefixes, n in names(LibHYPRE)
r = Regex("^" * prefix * "([A-Z].*)\$") r = Regex("^" * prefix * "([A-Z].*)\$")
if (m = match(r, string(n)); m !== nothing) if (m = match(r, string(n)); m !== nothing)
@ -43,6 +43,7 @@ function generate_options(io, structname, prefixes...)
println(io, " end") println(io, " end")
println(io, " end") println(io, " end")
println(io, "end") println(io, "end")
return
end end
open(joinpath(@__DIR__, "..", "src", "solver_options.jl"), "w") do io open(joinpath(@__DIR__, "..", "src", "solver_options.jl"), "w") do io

1752
lib/LibHYPRE.jl

File diff suppressed because it is too large Load Diff

15
src/HYPRE.jl

@ -25,7 +25,7 @@ initialized.
**Note**: This function *must* be called before using HYPRE functions. **Note**: This function *must* be called before using HYPRE functions.
""" """
function Init(; finalize_atexit=true) function Init(; finalize_atexit = true)
if !(MPI.Initialized()) if !(MPI.Initialized())
MPI.Init() MPI.Init()
end end
@ -65,8 +65,11 @@ end
Base.unsafe_convert(::Type{HYPRE_IJMatrix}, A::HYPREMatrix) = A.ijmatrix Base.unsafe_convert(::Type{HYPRE_IJMatrix}, A::HYPREMatrix) = A.ijmatrix
Base.unsafe_convert(::Type{HYPRE_ParCSRMatrix}, A::HYPREMatrix) = A.parmatrix Base.unsafe_convert(::Type{HYPRE_ParCSRMatrix}, A::HYPREMatrix) = A.parmatrix
function HYPREMatrix(comm::MPI.Comm, ilower::Integer, iupper::Integer, function HYPREMatrix(
jlower::Integer=ilower, jupper::Integer=iupper) comm::MPI.Comm,
ilower::Integer, iupper::Integer,
jlower::Integer = ilower, jupper::Integer = iupper
)
# Create the IJ matrix # Create the IJ matrix
A = HYPREMatrix(comm, ilower, iupper, jlower, jupper, C_NULL, C_NULL) A = HYPREMatrix(comm, ilower, iupper, jlower, jupper, C_NULL, C_NULL)
ijmatrix_ref = Ref{HYPRE_IJMatrix}(C_NULL) ijmatrix_ref = Ref{HYPRE_IJMatrix}(C_NULL)
@ -191,6 +194,7 @@ function Internals.check_n_rows(A, ilower, iupper)
if size(A, 1) != (iupper - ilower + 1) if size(A, 1) != (iupper - ilower + 1)
throw(ArgumentError("number of rows in matrix does not match global start/end rows ilower and iupper")) throw(ArgumentError("number of rows in matrix does not match global start/end rows ilower and iupper"))
end end
return
end end
function Internals.to_hypre_data(x::Vector, ilower, iupper) function Internals.to_hypre_data(x::Vector, ilower, iupper)
@ -209,8 +213,9 @@ function HYPREVector(comm::MPI.Comm, x::Vector, ilower, iupper)
return b return b
end end
HYPREVector(x::Vector, ilower=1, iupper=length(x)) = function HYPREVector(x::Vector, ilower = 1, iupper = length(x))
HYPREVector(MPI.COMM_SELF, x, ilower, iupper) return HYPREVector(MPI.COMM_SELF, x, ilower, iupper)
end
# TODO: Other eltypes could be support by using a intermediate buffer # TODO: Other eltypes could be support by using a intermediate buffer
function Base.copy!(dst::Vector{HYPRE_Complex}, src::HYPREVector) function Base.copy!(dst::Vector{HYPRE_Complex}, src::HYPREVector)

3
src/LibHYPRE.jl

@ -80,7 +80,7 @@ macro check(arg)
end end
# Export everything with HYPRE_ prefix # Export everything with HYPRE_ prefix
for name in names(@__MODULE__; all=true) for name in names(@__MODULE__; all = true)
if startswith(string(name), "HYPRE_") if startswith(string(name), "HYPRE_")
@eval export $name @eval export $name
end end
@ -92,6 +92,7 @@ function __init__()
patch_ref = Ref{HYPRE_Int}(-1) patch_ref = Ref{HYPRE_Int}(-1)
@check HYPRE_VersionNumber(major_ref, minor_ref, patch_ref, C_NULL) @check HYPRE_VersionNumber(major_ref, minor_ref, patch_ref, C_NULL)
global VERSION = VersionNumber(major_ref[], minor_ref[], patch_ref[]) global VERSION = VersionNumber(major_ref[], minor_ref[], patch_ref[])
return
end end
end end

8
src/solver_options.jl

@ -29,6 +29,7 @@ function Internals.set_options(solver::BiCGSTAB, kwargs)
throw(ArgumentError("unknown option $k for HYPRE.BiCGSTAB")) throw(ArgumentError("unknown option $k for HYPRE.BiCGSTAB"))
end end
end end
return
end end
function Internals.set_options(solver::BoomerAMG, kwargs) function Internals.set_options(solver::BoomerAMG, kwargs)
@ -285,6 +286,7 @@ function Internals.set_options(solver::BoomerAMG, kwargs)
throw(ArgumentError("unknown option $k for HYPRE.BoomerAMG")) throw(ArgumentError("unknown option $k for HYPRE.BoomerAMG"))
end end
end end
return
end end
function Internals.set_options(solver::FlexGMRES, kwargs) function Internals.set_options(solver::FlexGMRES, kwargs)
@ -314,6 +316,7 @@ function Internals.set_options(solver::FlexGMRES, kwargs)
throw(ArgumentError("unknown option $k for HYPRE.FlexGMRES")) throw(ArgumentError("unknown option $k for HYPRE.FlexGMRES"))
end end
end end
return
end end
function Internals.set_options(solver::GMRES, kwargs) function Internals.set_options(solver::GMRES, kwargs)
@ -347,6 +350,7 @@ function Internals.set_options(solver::GMRES, kwargs)
throw(ArgumentError("unknown option $k for HYPRE.GMRES")) throw(ArgumentError("unknown option $k for HYPRE.GMRES"))
end end
end end
return
end end
function Internals.set_options(solver::Hybrid, kwargs) function Internals.set_options(solver::Hybrid, kwargs)
@ -456,6 +460,7 @@ function Internals.set_options(solver::Hybrid, kwargs)
throw(ArgumentError("unknown option $k for HYPRE.Hybrid")) throw(ArgumentError("unknown option $k for HYPRE.Hybrid"))
end end
end end
return
end end
function Internals.set_options(solver::ILU, kwargs) function Internals.set_options(solver::ILU, kwargs)
@ -490,6 +495,7 @@ function Internals.set_options(solver::ILU, kwargs)
throw(ArgumentError("unknown option $k for HYPRE.ILU")) throw(ArgumentError("unknown option $k for HYPRE.ILU"))
end end
end end
return
end end
function Internals.set_options(solver::ParaSails, kwargs) function Internals.set_options(solver::ParaSails, kwargs)
@ -510,6 +516,7 @@ function Internals.set_options(solver::ParaSails, kwargs)
throw(ArgumentError("unknown option $k for HYPRE.ParaSails")) throw(ArgumentError("unknown option $k for HYPRE.ParaSails"))
end end
end end
return
end end
function Internals.set_options(solver::PCG, kwargs) function Internals.set_options(solver::PCG, kwargs)
@ -547,4 +554,5 @@ function Internals.set_options(solver::PCG, kwargs)
throw(ArgumentError("unknown option $k for HYPRE.PCG")) throw(ArgumentError("unknown option $k for HYPRE.PCG"))
end end
end end
return
end end

19
src/solvers.jl

@ -17,6 +17,7 @@ function Internals.safe_finalizer(Destroy, solver)
s.solver = C_NULL s.solver = C_NULL
end end
end end
return
end end
# Defining unsafe_convert enables ccall to automatically convert solver::HYPRESolver to # Defining unsafe_convert enables ccall to automatically convert solver::HYPRESolver to
@ -71,8 +72,8 @@ Create a `BiCGSTAB` solver. See HYPRE API reference for details and supported se
mutable struct BiCGSTAB <: HYPRESolver mutable struct BiCGSTAB <: HYPRESolver
comm::MPI.Comm comm::MPI.Comm
solver::HYPRE_Solver solver::HYPRE_Solver
precond::Union{HYPRESolver,Nothing} precond::Union{HYPRESolver, Nothing}
function BiCGSTAB(comm::MPI.Comm=MPI.COMM_NULL; kwargs...) function BiCGSTAB(comm::MPI.Comm = MPI.COMM_NULL; kwargs...)
# comm defaults to COMM_NULL since it is unused in HYPRE_ParCSRBiCGSTABCreate # comm defaults to COMM_NULL since it is unused in HYPRE_ParCSRBiCGSTABCreate
solver = new(comm, C_NULL, nothing) solver = new(comm, C_NULL, nothing)
solver_ref = Ref{HYPRE_Solver}(C_NULL) solver_ref = Ref{HYPRE_Solver}(C_NULL)
@ -166,8 +167,8 @@ Create a `FlexGMRES` solver. See HYPRE API reference for details and supported s
mutable struct FlexGMRES <: HYPRESolver mutable struct FlexGMRES <: HYPRESolver
comm::MPI.Comm comm::MPI.Comm
solver::HYPRE_Solver solver::HYPRE_Solver
precond::Union{HYPRESolver,Nothing} precond::Union{HYPRESolver, Nothing}
function FlexGMRES(comm::MPI.Comm=MPI.COMM_NULL; kwargs...) function FlexGMRES(comm::MPI.Comm = MPI.COMM_NULL; kwargs...)
# comm defaults to COMM_NULL since it is unused in HYPRE_ParCSRFlexGMRESCreate # comm defaults to COMM_NULL since it is unused in HYPRE_ParCSRFlexGMRESCreate
solver = new(comm, C_NULL, nothing) solver = new(comm, C_NULL, nothing)
solver_ref = Ref{HYPRE_Solver}(C_NULL) solver_ref = Ref{HYPRE_Solver}(C_NULL)
@ -251,8 +252,8 @@ Create a `GMRES` solver. See HYPRE API reference for details and supported setti
mutable struct GMRES <: HYPRESolver mutable struct GMRES <: HYPRESolver
comm::MPI.Comm comm::MPI.Comm
solver::HYPRE_Solver solver::HYPRE_Solver
precond::Union{HYPRESolver,Nothing} precond::Union{HYPRESolver, Nothing}
function GMRES(comm::MPI.Comm=MPI.COMM_NULL; kwargs...) function GMRES(comm::MPI.Comm = MPI.COMM_NULL; kwargs...)
# comm defaults to COMM_NULL since it is unused in HYPRE_ParCSRGMRESCreate # comm defaults to COMM_NULL since it is unused in HYPRE_ParCSRGMRESCreate
solver = new(comm, C_NULL, nothing) solver = new(comm, C_NULL, nothing)
solver_ref = Ref{HYPRE_Solver}(C_NULL) solver_ref = Ref{HYPRE_Solver}(C_NULL)
@ -299,7 +300,7 @@ Create a `Hybrid` solver. See HYPRE API reference for details and supported sett
""" """
mutable struct Hybrid <: HYPRESolver mutable struct Hybrid <: HYPRESolver
solver::HYPRE_Solver solver::HYPRE_Solver
precond::Union{HYPRESolver,Nothing} precond::Union{HYPRESolver, Nothing}
function Hybrid(; kwargs...) function Hybrid(; kwargs...)
solver = new(C_NULL, nothing) solver = new(C_NULL, nothing)
solver_ref = Ref{HYPRE_Solver}(C_NULL) solver_ref = Ref{HYPRE_Solver}(C_NULL)
@ -396,7 +397,7 @@ settings.
mutable struct ParaSails <: HYPRESolver mutable struct ParaSails <: HYPRESolver
comm::MPI.Comm comm::MPI.Comm
solver::HYPRE_Solver solver::HYPRE_Solver
function ParaSails(comm::MPI.Comm=MPI.COMM_WORLD; kwargs...) function ParaSails(comm::MPI.Comm = MPI.COMM_WORLD; kwargs...)
# Note: comm is used in this solver so default to COMM_WORLD # Note: comm is used in this solver so default to COMM_WORLD
solver = new(comm, C_NULL) solver = new(comm, C_NULL)
solver_ref = Ref{HYPRE_Solver}(C_NULL) solver_ref = Ref{HYPRE_Solver}(C_NULL)
@ -432,7 +433,7 @@ mutable struct PCG <: HYPRESolver
comm::MPI.Comm comm::MPI.Comm
solver::HYPRE_Solver solver::HYPRE_Solver
precond::Union{HYPRESolver, Nothing} precond::Union{HYPRESolver, Nothing}
function PCG(comm::MPI.Comm=MPI.COMM_NULL; kwargs...) function PCG(comm::MPI.Comm = MPI.COMM_NULL; kwargs...)
# comm defaults to COMM_NULL since it is unused in HYPRE_ParCSRPCGCreate # comm defaults to COMM_NULL since it is unused in HYPRE_ParCSRPCGCreate
solver = new(comm, C_NULL, nothing) solver = new(comm, C_NULL, nothing)
solver_ref = Ref{HYPRE_Solver}(C_NULL) solver_ref = Ref{HYPRE_Solver}(C_NULL)

119
test/runtests.jl

@ -31,11 +31,10 @@ end
@testset "HYPREMatrix(::SparseMatrixCS(C|R))" begin @testset "HYPREMatrix(::SparseMatrixCS(C|R))" begin
ilower, iupper = 4, 6 ilower, iupper = 4, 6
CSC = convert(SparseMatrixCSC{HYPRE_Complex, HYPRE_Int}, sparse([ CSC = convert(
1 2 0 0 3 SparseMatrixCSC{HYPRE_Complex, HYPRE_Int},
0 4 0 5 0 sparse([1 2 0 0 3; 0 4 0 5 0; 0 6 7 0 8])
0 6 7 0 8 )
]))
CSR = sparsecsr(findnz(CSC)..., size(CSC)...) CSR = sparsecsr(findnz(CSC)..., size(CSC)...)
@test CSC == CSR @test CSC == CSR
csc = Internals.to_hypre_data(CSC, ilower, iupper) csc = Internals.to_hypre_data(CSC, ilower, iupper)
@ -52,8 +51,8 @@ end
@test csr[5] == CSR.nzval @test csr[5] == CSR.nzval
@test_broken csr[5]::Vector{HYPRE_Complex} === CSR.nzval @test_broken csr[5]::Vector{HYPRE_Complex} === CSR.nzval
@test_throws ArgumentError Internals.to_hypre_data(CSC, ilower, iupper-1) @test_throws ArgumentError Internals.to_hypre_data(CSC, ilower, iupper - 1)
@test_throws ArgumentError Internals.to_hypre_data(CSR, ilower, iupper+1) @test_throws ArgumentError Internals.to_hypre_data(CSR, ilower, iupper + 1)
ilower, iupper = 6, 10 ilower, iupper = 6, 10
CSC = sprand(5, 10, 0.3) CSC = sprand(5, 10, 0.3)
@ -70,7 +69,7 @@ end
H = HYPREMatrix(CSR, ilower, iupper) H = HYPREMatrix(CSR, ilower, iupper)
@test H.ijmatrix != HYPRE_IJMatrix(C_NULL) @test H.ijmatrix != HYPRE_IJMatrix(C_NULL)
@test H.parmatrix != HYPRE_ParCSRMatrix(C_NULL) @test H.parmatrix != HYPRE_ParCSRMatrix(C_NULL)
H = HYPREMatrix(MPI.COMM_WORLD, CSR, ilower, iupper) H = HYPREMatrix(MPI.COMM_WORLD, CSR, ilower, iupper)
@test H.ijmatrix != HYPRE_IJMatrix(C_NULL) @test H.ijmatrix != HYPRE_IJMatrix(C_NULL)
@test H.parmatrix != HYPRE_ParCSRMatrix(C_NULL) @test H.parmatrix != HYPRE_ParCSRMatrix(C_NULL)
@ -183,7 +182,6 @@ end
end end
@testset "HYPREVector" begin @testset "HYPREVector" begin
h = HYPREVector(MPI.COMM_WORLD, 1, 5) h = HYPREVector(MPI.COMM_WORLD, 1, 5)
@test h.ijvector != HYPRE_IJVector(C_NULL) @test h.ijvector != HYPRE_IJVector(C_NULL)
@ -283,7 +281,7 @@ end
@test H === H′ @test H === H′
pbc = similar(pb) pbc = similar(pb)
copy!(pbc, H) copy!(pbc, H)
@test pbc == 2*pb @test pbc == 2 * pb
end end
end end
@ -360,16 +358,16 @@ end
b_h = HYPREVector(b) b_h = HYPREVector(b)
x_h = HYPREVector(x) x_h = HYPREVector(x)
# Solve # Solve
tol = 1e-9 tol = 1.0e-9
bicg = HYPRE.BiCGSTAB(; Tol = tol) bicg = HYPRE.BiCGSTAB(; Tol = tol)
HYPRE.solve!(bicg, x_h, A_h, b_h) HYPRE.solve!(bicg, x_h, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
# Test result with direct solver # Test result with direct solver
@test x A \ b atol=tol @test x A \ b atol = tol
# Test without passing initial guess # Test without passing initial guess
x_h = HYPRE.solve(bicg, A_h, b_h) x_h = HYPRE.solve(bicg, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
@test x A \ b atol=tol @test x A \ b atol = tol
# Test solver queries # Test solver queries
@test HYPRE.GetFinalRelativeResidualNorm(bicg) < tol @test HYPRE.GetFinalRelativeResidualNorm(bicg) < tol
@test HYPRE.GetNumIterations(bicg) > 0 @test HYPRE.GetNumIterations(bicg) > 0
@ -381,11 +379,11 @@ end
HYPRE.solve!(bicg, x_h, A_h, b_h) HYPRE.solve!(bicg, x_h, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
# Test result with direct solver # Test result with direct solver
@test x A \ b atol=tol @test x A \ b atol = tol
# Test without passing initial guess # Test without passing initial guess
x_h = HYPRE.solve(bicg, A_h, b_h) x_h = HYPRE.solve(bicg, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
@test x A \ b atol=tol @test x A \ b atol = tol
# Tests Internals.set_precond_defaults for BoomerAMG # Tests Internals.set_precond_defaults for BoomerAMG
precond = HYPRE.BoomerAMG() precond = HYPRE.BoomerAMG()
bicg = HYPRE.BiCGSTAB(; Tol = tol, Precond = precond) bicg = HYPRE.BiCGSTAB(; Tol = tol, Precond = precond)
@ -393,7 +391,7 @@ end
HYPRE.solve!(bicg, x_h, A_h, b_h) HYPRE.solve!(bicg, x_h, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
# Test result with direct solver # Test result with direct solver
@test x A \ b atol=tol @test x A \ b atol = tol
end end
@testset "BoomerAMG" begin @testset "BoomerAMG" begin
@ -407,11 +405,11 @@ end
for i in 1:99 for i in 1:99
k = (1 + rand()) * [1.0 -1.0; -1.0 1.0] k = (1 + rand()) * [1.0 -1.0; -1.0 1.0]
append!(V, k) append!(V, k)
append!(I, [i, i+1, i, i+1]) # rows append!(I, [i, i + 1, i, i + 1]) # rows
append!(J, [i, i, i+1, i+1]) # cols append!(J, [i, i, i + 1, i + 1]) # cols
end end
A = sparse(I, J, V) A = sparse(I, J, V)
A[:, 1] .= 0; A[1, :] .= 0; A[:, end] .= 0; A[end, :] .= 0; A[:, 1] .= 0; A[1, :] .= 0; A[:, end] .= 0; A[end, :] .= 0
A[1, 1] = 2; A[end, end] = 2 A[1, 1] = 2; A[end, end] = 2
@test isposdef(A) @test isposdef(A)
b = rand(100) b = rand(100)
@ -421,7 +419,7 @@ end
b_h = HYPREVector(b, ilower, iupper) b_h = HYPREVector(b, ilower, iupper)
x_h = HYPREVector(b, ilower, iupper) x_h = HYPREVector(b, ilower, iupper)
# Solve # Solve
tol = 1e-9 tol = 1.0e-9
amg = HYPRE.BoomerAMG(; Tol = tol) amg = HYPRE.BoomerAMG(; Tol = tol)
HYPRE.solve!(amg, x_h, A_h, b_h) HYPRE.solve!(amg, x_h, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
@ -451,16 +449,16 @@ end
b_h = HYPREVector(b) b_h = HYPREVector(b)
x_h = HYPREVector(x) x_h = HYPREVector(x)
# Solve # Solve
tol = 1e-9 tol = 1.0e-9
gmres = HYPRE.FlexGMRES(; Tol = tol) gmres = HYPRE.FlexGMRES(; Tol = tol)
HYPRE.solve!(gmres, x_h, A_h, b_h) HYPRE.solve!(gmres, x_h, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
# Test result with direct solver # Test result with direct solver
@test x A \ b atol=tol @test x A \ b atol = tol
# Test without passing initial guess # Test without passing initial guess
x_h = HYPRE.solve(gmres, A_h, b_h) x_h = HYPRE.solve(gmres, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
@test x A \ b atol=tol @test x A \ b atol = tol
# Test solver queries # Test solver queries
@test HYPRE.GetFinalRelativeResidualNorm(gmres) < tol @test HYPRE.GetFinalRelativeResidualNorm(gmres) < tol
@test HYPRE.GetNumIterations(gmres) > 0 @test HYPRE.GetNumIterations(gmres) > 0
@ -472,11 +470,11 @@ end
HYPRE.solve!(gmres, x_h, A_h, b_h) HYPRE.solve!(gmres, x_h, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
# Test result with direct solver # Test result with direct solver
@test x A \ b atol=tol @test x A \ b atol = tol
# Test without passing initial guess # Test without passing initial guess
x_h = HYPRE.solve(gmres, A_h, b_h) x_h = HYPRE.solve(gmres, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
@test x A \ b atol=tol @test x A \ b atol = tol
end end
@ -494,16 +492,16 @@ end
b_h = HYPREVector(b) b_h = HYPREVector(b)
x_h = HYPREVector(x) x_h = HYPREVector(x)
# Solve # Solve
tol = 1e-9 tol = 1.0e-9
gmres = HYPRE.GMRES(; Tol = tol) gmres = HYPRE.GMRES(; Tol = tol)
HYPRE.solve!(gmres, x_h, A_h, b_h) HYPRE.solve!(gmres, x_h, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
# Test result with direct solver # Test result with direct solver
@test x A \ b atol=tol @test x A \ b atol = tol
# Test without passing initial guess # Test without passing initial guess
x_h = HYPRE.solve(gmres, A_h, b_h) x_h = HYPRE.solve(gmres, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
@test x A \ b atol=tol @test x A \ b atol = tol
# Test solver queries # Test solver queries
@test HYPRE.GetFinalRelativeResidualNorm(gmres) < tol @test HYPRE.GetFinalRelativeResidualNorm(gmres) < tol
@test HYPRE.GetNumIterations(gmres) > 0 @test HYPRE.GetNumIterations(gmres) > 0
@ -515,11 +513,11 @@ end
HYPRE.solve!(gmres, x_h, A_h, b_h) HYPRE.solve!(gmres, x_h, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
# Test result with direct solver # Test result with direct solver
@test x A \ b atol=tol @test x A \ b atol = tol
# Test without passing initial guess # Test without passing initial guess
x_h = HYPRE.solve(gmres, A_h, b_h) x_h = HYPRE.solve(gmres, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
@test x A \ b atol=tol @test x A \ b atol = tol
end end
@testset "Hybrid" begin @testset "Hybrid" begin
@ -536,16 +534,16 @@ end
b_h = HYPREVector(b) b_h = HYPREVector(b)
x_h = HYPREVector(x) x_h = HYPREVector(x)
# Solve # Solve
tol = 1e-9 tol = 1.0e-9
hybrid = HYPRE.Hybrid(; Tol = tol) hybrid = HYPRE.Hybrid(; Tol = tol)
HYPRE.solve!(hybrid, x_h, A_h, b_h) HYPRE.solve!(hybrid, x_h, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
# Test result with direct solver # Test result with direct solver
@test x A \ b atol=tol @test x A \ b atol = tol
# Test without passing initial guess # Test without passing initial guess
x_h = HYPRE.solve(hybrid, A_h, b_h) x_h = HYPRE.solve(hybrid, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
@test x A \ b atol=tol @test x A \ b atol = tol
# Test solver queries # Test solver queries
@test HYPRE.GetFinalRelativeResidualNorm(hybrid) < tol @test HYPRE.GetFinalRelativeResidualNorm(hybrid) < tol
@test HYPRE.GetNumIterations(hybrid) > 0 @test HYPRE.GetNumIterations(hybrid) > 0
@ -557,11 +555,11 @@ end
HYPRE.solve!(hybrid, x_h, A_h, b_h) HYPRE.solve!(hybrid, x_h, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
# Test result with direct solver # Test result with direct solver
@test x A \ b atol=tol @test x A \ b atol = tol
# Test without passing initial guess # Test without passing initial guess
x_h = HYPRE.solve(hybrid, A_h, b_h) x_h = HYPRE.solve(hybrid, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
@test x A \ b atol=tol @test x A \ b atol = tol
end end
@ -579,16 +577,16 @@ end
b_h = HYPREVector(b) b_h = HYPREVector(b)
x_h = HYPREVector(x) x_h = HYPREVector(x)
# Solve # Solve
tol = 1e-9 tol = 1.0e-9
ilu = HYPRE.ILU(; Tol = tol) ilu = HYPRE.ILU(; Tol = tol)
HYPRE.solve!(ilu, x_h, A_h, b_h) HYPRE.solve!(ilu, x_h, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
# Test result with direct solver # Test result with direct solver
@test x A \ b atol=tol @test x A \ b atol = tol
# Test without passing initial guess # Test without passing initial guess
x_h = HYPRE.solve(ilu, A_h, b_h) x_h = HYPRE.solve(ilu, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
@test x A \ b atol=tol @test x A \ b atol = tol
# Test solver queries # Test solver queries
@test HYPRE.GetFinalRelativeResidualNorm(ilu) < tol @test HYPRE.GetFinalRelativeResidualNorm(ilu) < tol
@test HYPRE.GetNumIterations(ilu) > 0 @test HYPRE.GetNumIterations(ilu) > 0
@ -600,11 +598,11 @@ end
HYPRE.solve!(pcg, x_h, A_h, b_h) HYPRE.solve!(pcg, x_h, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
# Test result with direct solver # Test result with direct solver
@test x A \ b atol=tol @test x A \ b atol = tol
# Test without passing initial guess # Test without passing initial guess
x_h = HYPRE.solve(pcg, A_h, b_h) x_h = HYPRE.solve(pcg, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
@test x A \ b atol=tol @test x A \ b atol = tol
end end
@ -623,13 +621,13 @@ end
b_h = HYPREVector(b, ilower, iupper) b_h = HYPREVector(b, ilower, iupper)
x_h = HYPREVector(b, ilower, iupper) x_h = HYPREVector(b, ilower, iupper)
# Solve with ParaSails as preconditioner # Solve with ParaSails as preconditioner
tol = 1e-9 tol = 1.0e-9
parasails = HYPRE.ParaSails() parasails = HYPRE.ParaSails()
pcg = HYPRE.PCG(; Tol = tol, Precond = parasails) pcg = HYPRE.PCG(; Tol = tol, Precond = parasails)
HYPRE.solve!(pcg, x_h, A_h, b_h) HYPRE.solve!(pcg, x_h, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
# Test result with direct solver # Test result with direct solver
@test x A \ b atol=tol @test x A \ b atol = tol
# Test solver queries (should error) # Test solver queries (should error)
@test_throws ArgumentError("cannot get residual norm for HYPRE.ParaSails") HYPRE.GetFinalRelativeResidualNorm(parasails) @test_throws ArgumentError("cannot get residual norm for HYPRE.ParaSails") HYPRE.GetFinalRelativeResidualNorm(parasails)
@test_throws ArgumentError("cannot get number of iterations for HYPRE.ParaSails") HYPRE.GetNumIterations(parasails) @test_throws ArgumentError("cannot get number of iterations for HYPRE.ParaSails") HYPRE.GetNumIterations(parasails)
@ -650,16 +648,16 @@ end
b_h = HYPREVector(b, ilower, iupper) b_h = HYPREVector(b, ilower, iupper)
x_h = HYPREVector(b, ilower, iupper) x_h = HYPREVector(b, ilower, iupper)
# Solve # Solve
tol = 1e-9 tol = 1.0e-9
pcg = HYPRE.PCG(; Tol = tol) pcg = HYPRE.PCG(; Tol = tol)
HYPRE.solve!(pcg, x_h, A_h, b_h) HYPRE.solve!(pcg, x_h, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
# Test result with direct solver # Test result with direct solver
@test x A \ b atol=tol @test x A \ b atol = tol
# Test without passing initial guess # Test without passing initial guess
x_h = HYPRE.solve(pcg, A_h, b_h) x_h = HYPRE.solve(pcg, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
@test x A \ b atol=tol @test x A \ b atol = tol
# Test solver queries # Test solver queries
@test HYPRE.GetFinalRelativeResidualNorm(pcg) < tol @test HYPRE.GetFinalRelativeResidualNorm(pcg) < tol
@test HYPRE.GetNumIterations(pcg) > 0 @test HYPRE.GetNumIterations(pcg) > 0
@ -671,11 +669,11 @@ end
HYPRE.solve!(pcg, x_h, A_h, b_h) HYPRE.solve!(pcg, x_h, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
# Test result with direct solver # Test result with direct solver
@test x A \ b atol=tol @test x A \ b atol = tol
# Test without passing initial guess # Test without passing initial guess
x_h = HYPRE.solve(pcg, A_h, b_h) x_h = HYPRE.solve(pcg, A_h, b_h)
copy!(x, x_h) copy!(x, x_h)
@test x A \ b atol=tol @test x A \ b atol = tol
end end
function topartitioned(x::Vector, A::SparseMatrixCSC, b::Vector, backend) function topartitioned(x::Vector, A::SparseMatrixCSC, b::Vector, backend)
@ -713,18 +711,18 @@ end
end end
# Solve # Solve
tol = 1e-9 tol = 1.0e-9
pcg = HYPRE.PCG(; Tol = tol) pcg = HYPRE.PCG(; Tol = tol)
## solve! ## solve!
HYPRE.solve!(pcg, x_p, A_p, b_p) HYPRE.solve!(pcg, x_p, A_p, b_p)
ref = A\b ref = A \ b
map(local_values(x_p)) do x map(local_values(x_p)) do x
@test x ref atol=tol @test x ref atol = tol
end end
## solve ## solve
x_p = HYPRE.solve(pcg, A_p, b_p) x_p = HYPRE.solve(pcg, A_p, b_p)
map(local_values(x_p)) do x map(local_values(x_p)) do x
@test x ref atol=tol @test x ref atol = tol
end end
end end
end end
@ -737,24 +735,27 @@ end
xcsc = zeros(100) xcsc = zeros(100)
xcsr = zeros(100) xcsr = zeros(100)
# Solve # Solve
tol = 1e-9 tol = 1.0e-9
pcg = HYPRE.PCG(; Tol = tol) pcg = HYPRE.PCG(; Tol = tol)
## solve! ## solve!
HYPRE.solve!(pcg, xcsc, CSC, b) HYPRE.solve!(pcg, xcsc, CSC, b)
@test xcsc CSC \ b atol=tol @test xcsc CSC \ b atol = tol
HYPRE.solve!(pcg, xcsr, CSR, b) HYPRE.solve!(pcg, xcsr, CSR, b)
@test xcsr CSC \ b atol=tol # TODO: CSR \ b fails @test xcsr CSC \ b atol = tol # TODO: CSR \ b fails
## solve ## solve
xcsc = HYPRE.solve(pcg, CSC, b) xcsc = HYPRE.solve(pcg, CSC, b)
@test xcsc CSC \ b atol=tol @test xcsc CSC \ b atol = tol
xcsr = HYPRE.solve(pcg, CSR, b) xcsr = HYPRE.solve(pcg, CSR, b)
@test xcsr CSC \ b atol=tol # TODO: CSR \ b fails @test xcsr CSC \ b atol = tol # TODO: CSR \ b fails
end end
@testset "MPI execution" begin @testset "MPI execution" begin
testfiles = joinpath.(@__DIR__, [ testfiles = joinpath.(
"test_assembler.jl", @__DIR__,
]) [
"test_assembler.jl",
]
)
for file in testfiles for file in testfiles
r = run(ignorestatus(`$(mpiexec()) -n 2 $(Base.julia_cmd()) $(file)`)) r = run(ignorestatus(`$(mpiexec()) -n 2 $(Base.julia_cmd()) $(file)`))
@test r.exitcode == 0 @test r.exitcode == 0

10
test/test_assembler.jl

@ -30,11 +30,13 @@ end
function values_and_indices(n) function values_and_indices(n)
idx = [n - 1, n, n + 1] idx = [n - 1, n, n + 1]
a = Float64[ a = Float64[
n -2n -n # runic: off
-2n n -2n n -2n -n
-n -2n n -2n n -2n
-n -2n n
# runic: on
] ]
b = Float64[n, n/2, n/3] b = Float64[n, n / 2, n / 3]
return idx, a, b return idx, a, b
end end

Loading…
Cancel
Save