From: Daniel Arndt Date: Mon, 4 Feb 2019 01:08:20 +0000 (+0100) Subject: Fix MPI support for older versions X-Git-Tag: v9.1.0-rc1~368^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c3223347d55c131c4daf797b3ba579007e56dca;p=dealii.git Fix MPI support for older versions --- diff --git a/include/deal.II/lac/scalapack.h b/include/deal.II/lac/scalapack.h index e44ef1ffe4..ebc212f622 100644 --- a/include/deal.II/lac/scalapack.h +++ b/include/deal.II/lac/scalapack.h @@ -203,6 +203,8 @@ public: * The user has to ensure that all processes call this with identical @p rank. * The @p rank refers to a process of the MPI communicator used to create the process grid * of the distributed matrix. + * + * @note This function requires MPI-3.0 support */ void copy_from(const LAPACKFullMatrix &matrix, @@ -213,6 +215,7 @@ public: * * @note This function should only be used for relatively small matrix * dimensions. It is primarily intended for debugging purposes. + * This function requires MPI-3.0 support */ void copy_to(FullMatrix &matrix) const; diff --git a/source/lac/scalapack.cc b/source/lac/scalapack.cc index 9a5f1bb157..8651557833 100644 --- a/source/lac/scalapack.cc +++ b/source/lac/scalapack.cc @@ -361,18 +361,19 @@ void ScaLAPACKMatrix::copy_from(const LAPACKFullMatrix &B, const unsigned int rank) { +# if DEAL_II_MPI_VERSION_GTE(3, 0) if (n_rows * n_columns == 0) return; const unsigned int this_mpi_process( Utilities::MPI::this_mpi_process(this->grid->mpi_communicator)); -# ifdef DEBUG +# ifdef DEBUG Assert(Utilities::MPI::max(rank, this->grid->mpi_communicator) == rank, ExcMessage("All processes have to call routine with identical rank")); Assert(Utilities::MPI::min(rank, this->grid->mpi_communicator) == rank, ExcMessage("All processes have to call routine with identical rank")); -# endif +# endif // root process has to be active in the grid of A if (this_mpi_process == rank) @@ -484,6 +485,11 @@ ScaLAPACKMatrix::copy_from(const LAPACKFullMatrix &B, MPI_Comm_free(&communicator_B); state = LAPACKSupport::matrix; +# else + (void)B; + (void)rank; + AssertThrow(false, ExcNotImplemented()); +# endif } @@ -528,18 +534,19 @@ void ScaLAPACKMatrix::copy_to(LAPACKFullMatrix &B, const unsigned int rank) const { +# if DEAL_II_MPI_VERSION_GTE(3, 0) if (n_rows * n_columns == 0) return; const unsigned int this_mpi_process( Utilities::MPI::this_mpi_process(this->grid->mpi_communicator)); -# ifdef DEBUG +# ifdef DEBUG Assert(Utilities::MPI::max(rank, this->grid->mpi_communicator) == rank, ExcMessage("All processes have to call routine with identical rank")); Assert(Utilities::MPI::min(rank, this->grid->mpi_communicator) == rank, ExcMessage("All processes have to call routine with identical rank")); -# endif +# endif if (this_mpi_process == rank) { @@ -650,6 +657,11 @@ ScaLAPACKMatrix::copy_to(LAPACKFullMatrix &B, MPI_Group_free(&group_B); if (MPI_COMM_NULL != communicator_B) MPI_Comm_free(&communicator_B); +# else + (void)B; + (void)rank; + AssertThrow(false, ExcNotImplemented()); +# endif } diff --git a/source/lac/sparsity_tools.cc b/source/lac/sparsity_tools.cc index e6698f28aa..e04c9e54f4 100644 --- a/source/lac/sparsity_tools.cc +++ b/source/lac/sparsity_tools.cc @@ -994,13 +994,14 @@ namespace SparsityTools unsigned int idx = 0; for (const auto &sparsity_line : send_data) { - const int ierr = MPI_Isend(sparsity_line.second.data(), - sparsity_line.second.size(), - DEAL_II_DOF_INDEX_MPI_TYPE, - sparsity_line.first, - 124, - mpi_comm, - &requests[idx++]); + const int ierr = + MPI_Isend(DEAL_II_MPI_CONST_CAST(sparsity_line.second.data()), + sparsity_line.second.size(), + DEAL_II_DOF_INDEX_MPI_TYPE, + sparsity_line.first, + 124, + mpi_comm, + &requests[idx++]); AssertThrowMPI(ierr); } } @@ -1138,13 +1139,14 @@ namespace SparsityTools unsigned int idx = 0; for (const auto &sparsity_line : send_data) { - const int ierr = MPI_Isend(sparsity_line.second.data(), - sparsity_line.second.size(), - DEAL_II_DOF_INDEX_MPI_TYPE, - sparsity_line.first, - 124, - mpi_comm, - &requests[idx++]); + const int ierr = + MPI_Isend(DEAL_II_MPI_CONST_CAST(sparsity_line.second.data()), + sparsity_line.second.size(), + DEAL_II_DOF_INDEX_MPI_TYPE, + sparsity_line.first, + 124, + mpi_comm, + &requests[idx++]); AssertThrowMPI(ierr); } }