This patch tracks all created HYPRE objects (`HYPREMatrix`,
`HYPREVector`, and `HYPRESolver`s) in a global `WeakKeyDict` to make
sure they are all finalized **before** MPI and/or HYPRE is finalized.
These libraries are typically finalized in Julia atexit hooks, but at
that point the object finalizers might yet not have been run. This patch
make sure to explicitly call `finalize` on any remaining HYPRE objects
before finalizing the library.
This patch fixes the buffer length in to_hypre_data(::MatrixAssembler).
Previously the buffer was always too long, which was not problematic for
correctness, but it is unnecessary. This patch also adds some assertions
to check the internal consistency of the buffer lengths.
This patch adds an assembler interface such that it is possible to
directly assemble HYPRE(Vector|Matrix) without going through a sparse
matrix datastructure in Julia. This is done as follows:
1. Create a new (empty) matrix/vector using the constructor.
2. Create an assembler and initialize the assembly using
HYPRE.start_assemble!.
3. Assemble all contributions using HYPRE.assemble!.
4. Finalize the assembly using HYPRE.finish_assemble!.
HYPRE.start_assemble!
The assembler caches some buffers that are (re)used by every call to
HYPRE.assemble! so this should be efficient. All MPI communication
should happen in the finalization step.
This patch updates the MPI.jl compat to allow 0.20. In addition, the Clang.jl generator is
updated to filter out all unnecessary bindings (e.g. MPI related) and instead bring in constants
from MPI.jl. This should make sure that those are synced, since everything now uses MPIPreferences.
Co-authored-by: Dennis Ogiermann <termi-official@users.noreply.github.com>
Co-authored-by: Fredrik Ekre <ekrefredrik@gmail.com>
This patch wraps the HYPRE_Destroy functions for the HYPRESolvers in a
functtion that checks if the pointer is NULL before calling the Destroy
function. While this makes sense on it self, it also makes it possible
to override a finalizer by adding a second one that sets the pointer to
NULL. This is utilized in the set_precond(::Hybrid, p) function, since
the Hybrid solver currently frees the provied preconditioner too.
This patch stores the MPI communicator in the solvers structs. The
default communicator is changed from COMM_WORLD to COMM_NULL, for
BiCGSTAB, GMRES, and PCG, since their respective HYPRE_Create functions
simply ignore this argument.
This patch adds HYPREError <: Exception which is thrown when a HYPRE_
function returns an error code. HYPRE_ClearAllErrors() are called just
before throwing.
Some solvers have option from the specific ParCSR solver + options for
the general solver. This updates the option generator to handle this
such that the specific method is preferred over the generic one. This
patch also include the result of the generator applied to PCG, which has
some specific options for ParCSRPCG.
This patch adds the function `HYPRE.Init()` which i) calls `MPI.Init`
(unless MPI is already initialized), ii) calls `HYPRE_Init`, and iii)
adds a Julia exit hook which calls `HYPRE_Finalize` (if the keyword
argument `finalize_atexit` is `true`).
This patch adds defaults for ilower and iupper in constructors when i)
using SparseMatrixCS(C|R) and Vector and ii) when no communicator is
passed. In this case we simply assume the users wants a single-processor
solve, and default to passing 1 and size(A, 1) as the default values.
In the future this could possibly use the HYPRE sequential compiler
flag to completely avoid MPI.
This patch changes the argument order from:
HYPREMatrix(::SparseMatrixCS(C|R), ::Integer, ::Integer, ::MPI.Comm)
HYPREVector(::Vector, ::Integer, ::Integer, ::MPI.Comm)
to:
HYPREMatrix(::MPI.Comm, ::SparseMatrixCS(C|R), ::Integer, ::Integer)
HYPREVector(::MPI.Comm, ::Vector, ::Integer, ::Integer)
to match the basic constructor. This also makes it easier to default
owned rows to the full matrix/vector for single process solves. The
methods without the communicator (added in this patch) will in the
future have this default.