Utilities::MPI::compute_point_to_point_communication_pattern(comm,
send_to);
+ // Protect the following communication:
+ static CollectiveMutex mutex;
+ CollectiveMutex::ScopedLock lock(mutex, comm);
+
// Sending buffers
std::vector<std::vector<char>> buffers_to_send(send_to.size());
std::vector<MPI_Request> buffer_send_requests(send_to.size());
std::vector<MPI_Request> requests(cells_to_send.size());
std::vector<unsigned int> destinations;
+ // Protect the communcation below:
+ static Utilities::MPI::CollectiveMutex mutex;
+ Utilities::MPI::CollectiveMutex::ScopedLock lock(mutex, communicator);
+
// send data
unsigned int idx = 0;
for (typename std::vector<CellData>::const_iterator it =
}
}
+ // Protect the following communcation:
+ static Utilities::MPI::CollectiveMutex mutex;
+ Utilities::MPI::CollectiveMutex::ScopedLock lock(mutex,
+ tria->get_communicator());
// 2. send our messages
std::set<dealii::types::subdomain_id> ghost_owners = tria->ghost_owners();
needs_to_get_cells);
}
- // sending
+ // Send information
+
+ // We need to protect this communication below using a mutex:
+ static Utilities::MPI::CollectiveMutex mutex;
+ Utilities::MPI::CollectiveMutex::ScopedLock lock(
+ mutex, this->get_communicator());
+
std::vector<std::vector<char>> sendbuffers(needs_to_get_cells.size());
std::vector<std::vector<char>>::iterator buffer = sendbuffers.begin();
std::vector<MPI_Request> requests(needs_to_get_cells.size());
Assert(level_ghost_owners.size() == neighbor_cell_list.size(),
ExcInternalError());
+
+ // Before sending & receiving, make sure we protect this section with
+ // a mutex:
+ static Utilities::MPI::CollectiveMutex mutex;
+ Utilities::MPI::CollectiveMutex::ScopedLock lock(
+ mutex, tria.get_communicator());
+
//* send our requests:
std::vector<MPI_Request> requests(level_ghost_owners.size());
{
// send data
+
+ static Utilities::MPI::CollectiveMutex mutex;
+ Utilities::MPI::CollectiveMutex::ScopedLock lock(mutex, mpi_comm);
+
{
unsigned int idx = 0;
for (const auto &sparsity_line : send_data)
{
MPI_Status status;
int len;
- int ierr = MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, mpi_comm, &status);
+ int ierr = MPI_Probe(MPI_ANY_SOURCE, 124, mpi_comm, &status);
AssertThrowMPI(ierr);
- Assert(status.MPI_TAG == 124, ExcInternalError());
ierr = MPI_Get_count(&status, DEAL_II_DOF_INDEX_MPI_TYPE, &len);
AssertThrowMPI(ierr);
level_dof_indices[i]);
}
+
+ // Protect the send/recv logic with a mutex:
+ static Utilities::MPI::CollectiveMutex mutex;
+ Utilities::MPI::CollectiveMutex::ScopedLock lock(
+ mutex, tria->get_communicator());
+
// * send
std::vector<MPI_Request> requests;
{