Skip to content

Commit

Permalink
[alien,ArcaneInterface,external_packages] Fix mpi communicator access…
Browse files Browse the repository at this point in the history
… in Hypre matrix, vector and solver.
  • Loading branch information
stdcm committed Oct 2, 2024
1 parent da444ee commit fdb4983
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <alien/core/impl/MultiMatrixImpl.h>
#include <alien/data/ISpace.h>

#include <arccore/message_passing/Communicator.h>
#include <arccore/message_passing_mpi/MpiMessagePassingMng.h>

/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -58,15 +59,15 @@ HypreMatrix::initMatrix(const int ilower, const int iupper, const int jlower,
delete m_internal;
auto memory_type = HypreInternalLinearSolver::m_library_plugin->getMemoryType() ;
auto exec_space = HypreInternalLinearSolver::m_library_plugin->getExecSpace() ;
auto* pm = dynamic_cast<Arccore::MessagePassing::Mpi::MpiMessagePassingMng*>(m_pm);
if (*static_cast<const MPI_Comm*>(pm->getMPIComm()) != MPI_COMM_NULL)
m_internal = new MatrixInternal(*static_cast<const MPI_Comm*>(pm->getMPIComm()),
memory_type,
exec_space);
else
m_internal = new MatrixInternal(MPI_COMM_WORLD,
memory_type,
exec_space);
auto pm = m_pm->communicator();
if (pm.isValid()) {
m_internal = new MatrixInternal(static_cast<MPI_Comm>(pm), memory_type, exec_space);
}
else {
alien_fatal([&] {
cout() << "Mpi is not initialized. Should be the case even in sequential";
});

Check warning on line 69 in alien/ArcaneInterface/modules/external_packages/src/alien/kernels/hypre/data_structure/HypreMatrix.cc

View check run for this annotation

Codecov / codecov/patch

alien/ArcaneInterface/modules/external_packages/src/alien/kernels/hypre/data_structure/HypreMatrix.cc#L67-L69

Added lines #L67 - L69 were not covered by tests
}
return m_internal->init(ilower, iupper, jlower, jupper, lineSizes);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include <alien/kernels/hypre/data_structure/HypreInternal.h>

#include <arccore/message_passing_mpi/MpiMessagePassingMng.h>
#include <arccore/message_passing/Communicator.h>

/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -73,16 +74,16 @@ HypreVector::allocate()
auto memory_type = HypreInternalLinearSolver::m_library_plugin->getMemoryType() ;
auto exec_space = HypreInternalLinearSolver::m_library_plugin->getExecSpace() ;
const VectorDistribution& dist = this->distribution();
auto* pm = dynamic_cast<Arccore::MessagePassing::Mpi::MpiMessagePassingMng*>(
dist.parallelMng());
if (*static_cast<const MPI_Comm*>(pm->getMPIComm()) != MPI_COMM_NULL)
m_internal = new VectorInternal(*static_cast<const MPI_Comm*>(pm->getMPIComm()),
memory_type,
exec_space);
else
m_internal = new VectorInternal(MPI_COMM_WORLD,
memory_type,
exec_space);
auto pm = dist.parallelMng()->communicator();
if (pm.isValid()) {
m_internal =
new VectorInternal(static_cast<const MPI_Comm>(pm), memory_type, exec_space);
}
else {
alien_fatal([&] {
cout() << "Mpi is not initialized. Should be the case even in sequential";
});

Check warning on line 85 in alien/ArcaneInterface/modules/external_packages/src/alien/kernels/hypre/data_structure/HypreVector.cc

View check run for this annotation

Codecov / codecov/patch

alien/ArcaneInterface/modules/external_packages/src/alien/kernels/hypre/data_structure/HypreVector.cc#L83-L85

Added lines #L83 - L85 were not covered by tests
}
int ilower = dist.offset() * m_block_size;
int iupper = ilower + dist.localSize() * m_block_size - 1;
m_internal->init(ilower, iupper);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -236,12 +236,11 @@ HypreInternalLinearSolver::solve(
HYPRE_PtrToParSolverFcn precond_setup_function = NULL;
int (*precond_destroy_function)(HYPRE_Solver) = NULL;

auto* pm = dynamic_cast<Arccore::MessagePassing::Mpi::MpiMessagePassingMng*>(
A.getParallelMng());
MPI_Comm comm = (*static_cast<const MPI_Comm*>(pm->getMPIComm()) == MPI_COMM_NULL)
? MPI_COMM_WORLD
: *static_cast<const MPI_Comm*>(pm->getMPIComm());

auto pm = A.getParallelMng()->communicator();
if (!pm.isValid()) alien_fatal([&] {
cout() << "Mpi is not initialized. Should be the case even in sequential";
});

Check warning on line 242 in alien/ArcaneInterface/modules/external_packages/src/alien/kernels/hypre/linear_solver/HypreInternalLinearSolver.cc

View check run for this annotation

Codecov / codecov/patch

alien/ArcaneInterface/modules/external_packages/src/alien/kernels/hypre/linear_solver/HypreInternalLinearSolver.cc#L241-L242

Added lines #L241 - L242 were not covered by tests
MPI_Comm comm = static_cast<const MPI_Comm>(pm);
std::string precond_name = "undefined";
switch (m_options->preconditioner()) {
case HypreOptionTypes::NoPC:
Expand Down

0 comments on commit fdb4983

Please sign in to comment.