Reference documentation for deal.II version Git 3e516b7449 2019-12-12 13:14:56 -0500
\(\newcommand{\dealcoloneq}{\mathrel{\vcenter{:}}=}\)
mpi.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2011 - 2019 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_mpi_h
17 #define dealii_mpi_h
18 
19 #include <deal.II/base/config.h>
20 
21 #include <deal.II/base/array_view.h>
22 #include <deal.II/base/mpi_tags.h>
23 #include <deal.II/base/numbers.h>
24 
25 #include <map>
26 #include <numeric>
27 #include <set>
28 #include <vector>
29 
30 #if !defined(DEAL_II_WITH_MPI) && !defined(DEAL_II_WITH_PETSC)
31 // without MPI, we would still like to use
32 // some constructs with MPI data
33 // types. Therefore, create some dummies
34 using MPI_Comm = int;
35 using MPI_Request = int;
36 using MPI_Datatype = int;
37 using MPI_Op = int;
38 # ifndef MPI_COMM_WORLD
39 # define MPI_COMM_WORLD 0
40 # endif
41 # ifndef MPI_COMM_SELF
42 # define MPI_COMM_SELF 0
43 # endif
44 # ifndef MPI_REQUEST_NULL
45 # define MPI_REQUEST_NULL 0
46 # endif
47 # ifndef MPI_MIN
48 # define MPI_MIN 0
49 # endif
50 # ifndef MPI_MAX
51 # define MPI_MAX 0
52 # endif
53 # ifndef MPI_SUM
54 # define MPI_SUM 0
55 # endif
56 #endif
57 
58 
59 
73 #ifdef DEAL_II_WITH_MPI
74 # if DEAL_II_MPI_VERSION_GTE(3, 0)
75 
76 # define DEAL_II_MPI_CONST_CAST(expr) (expr)
77 
78 # else
79 
80 # include <type_traits>
81 
82 # define DEAL_II_MPI_CONST_CAST(expr) \
83  const_cast<typename std::remove_const< \
84  typename std::remove_pointer<decltype(expr)>::type>::type *>(expr)
85 
86 # endif
87 #endif
88 
89 
90 
91 DEAL_II_NAMESPACE_OPEN
92 
93 
94 // Forward type declarations to allow MPI sums over tensorial types
95 #ifndef DOXYGEN
96 template <int rank, int dim, typename Number>
97 class Tensor;
98 template <int rank, int dim, typename Number>
99 class SymmetricTensor;
100 template <typename Number>
101 class SparseMatrix;
102 class IndexSet;
103 #endif
104 
105 namespace Utilities
106 {
114  namespace MPI
115  {
124  unsigned int
125  n_mpi_processes(const MPI_Comm &mpi_communicator);
126 
135  unsigned int
136  this_mpi_process(const MPI_Comm &mpi_communicator);
137 
159  std::vector<unsigned int>
161  const MPI_Comm & mpi_comm,
162  const std::vector<unsigned int> &destinations);
163 
183  unsigned int
185  const MPI_Comm & mpi_comm,
186  const std::vector<unsigned int> &destinations);
187 
204  MPI_Comm
205  duplicate_communicator(const MPI_Comm &mpi_communicator);
206 
216  void
217  free_communicator(MPI_Comm &mpi_communicator);
218 
232  {
233  public:
237  explicit DuplicatedCommunicator(const MPI_Comm &communicator)
238  : comm(duplicate_communicator(communicator))
239  {}
240 
245 
250  {
252  }
253 
257  const MPI_Comm &operator*() const
258  {
259  return comm;
260  }
261 
262 
267  operator=(const DuplicatedCommunicator &) = delete;
268 
269  private:
273  MPI_Comm comm;
274  };
275 
306  {
307  public:
314  {
315  public:
319  explicit ScopedLock(CollectiveMutex &mutex, const MPI_Comm &comm)
320  : mutex(mutex)
321  , comm(comm)
322  {
323  mutex.lock(comm);
324  }
325 
330  {
331  mutex.unlock(comm);
332  }
333 
334  private:
342  const MPI_Comm comm;
343  };
344 
348  explicit CollectiveMutex();
349 
353  ~CollectiveMutex();
354 
361  void
362  lock(MPI_Comm comm);
363 
370  void
371  unlock(MPI_Comm comm);
372 
373  private:
377  bool locked;
378 
382  MPI_Request request;
383  };
384 
385 
386 
414 #ifdef DEAL_II_WITH_MPI
415  int
416  create_group(const MPI_Comm & comm,
417  const MPI_Group &group,
418  const int tag,
419  MPI_Comm * new_comm);
420 #endif
421 
430  std::vector<IndexSet>
431  create_ascending_partitioning(const MPI_Comm & comm,
432  const IndexSet::size_type &local_size);
433 
434 #ifdef DEAL_II_WITH_MPI
435 
450  template <class Iterator, typename Number = long double>
451  std::pair<Number, typename numbers::NumberTraits<Number>::real_type>
452  mean_and_standard_deviation(const Iterator begin,
453  const Iterator end,
454  const MPI_Comm &comm);
455 #endif
456 
476  template <typename T>
477  T
478  sum(const T &t, const MPI_Comm &mpi_communicator);
479 
489  template <typename T, typename U>
490  void
491  sum(const T &values, const MPI_Comm &mpi_communicator, U &sums);
492 
502  template <typename T>
503  void
504  sum(const ArrayView<const T> &values,
505  const MPI_Comm & mpi_communicator,
506  const ArrayView<T> & sums);
507 
513  template <int rank, int dim, typename Number>
516  const MPI_Comm & mpi_communicator);
517 
523  template <int rank, int dim, typename Number>
525  sum(const Tensor<rank, dim, Number> &local,
526  const MPI_Comm & mpi_communicator);
527 
536  template <typename Number>
537  void
538  sum(const SparseMatrix<Number> &local,
539  const MPI_Comm & mpi_communicator,
540  SparseMatrix<Number> & global);
541 
561  template <typename T>
562  T
563  max(const T &t, const MPI_Comm &mpi_communicator);
564 
574  template <typename T, typename U>
575  void
576  max(const T &values, const MPI_Comm &mpi_communicator, U &maxima);
577 
587  template <typename T>
588  void
589  max(const ArrayView<const T> &values,
590  const MPI_Comm & mpi_communicator,
591  const ArrayView<T> & maxima);
592 
612  template <typename T>
613  T
614  min(const T &t, const MPI_Comm &mpi_communicator);
615 
625  template <typename T, typename U>
626  void
627  min(const T &values, const MPI_Comm &mpi_communicator, U &minima);
628 
638  template <typename T>
639  void
640  min(const ArrayView<const T> &values,
641  const MPI_Comm & mpi_communicator,
642  const ArrayView<T> & minima);
643 
658  struct MinMaxAvg
659  {
664  double sum;
665 
670  double min;
671 
676  double max;
677 
686  unsigned int min_index;
687 
696  unsigned int max_index;
697 
702  double avg;
703  };
704 
719  MinMaxAvg
720  min_max_avg(const double my_value, const MPI_Comm &mpi_communicator);
721 
766  {
767  public:
814  int & argc,
815  char **& argv,
816  const unsigned int max_num_threads = numbers::invalid_unsigned_int);
817 
822  ~MPI_InitFinalize();
823 
850  static void
851  register_request(MPI_Request &request);
852 
856  static void
857  unregister_request(MPI_Request &request);
858 
859  private:
863  static std::set<MPI_Request *> requests;
864  };
865 
877  bool
879 
899  template <typename T>
900  std::map<unsigned int, T>
901  some_to_some(const MPI_Comm & comm,
902  const std::map<unsigned int, T> &objects_to_send);
903 
919  template <typename T>
920  std::vector<T>
921  all_gather(const MPI_Comm &comm, const T &object_to_send);
922 
940  template <typename T>
941  std::vector<T>
942  gather(const MPI_Comm & comm,
943  const T & object_to_send,
944  const unsigned int root_process = 0);
945 
969  template <typename T1, typename T2>
971  {
972  public:
976  virtual ~ConsensusAlgorithmProcess() = default;
977 
984  virtual std::vector<unsigned int>
985  compute_targets() = 0;
986 
995  virtual void
996  pack_recv_buffer(const int other_rank, std::vector<T1> &send_buffer);
997 
1006  virtual void
1007  prepare_recv_buffer(const int other_rank, std::vector<T2> &recv_buffer);
1008 
1021  virtual void
1022  process_request(const unsigned int other_rank,
1023  const std::vector<T1> &buffer_recv,
1024  std::vector<T2> & request_buffer);
1025 
1033  virtual void
1034  unpack_recv_buffer(const int other_rank,
1035  const std::vector<T2> &recv_buffer);
1036  };
1037 
1063  template <typename T1, typename T2>
1065  {
1066  public:
1068  const MPI_Comm & comm);
1069 
1073  virtual ~ConsensusAlgorithm() = default;
1074 
1078  virtual void
1079  run() = 0;
1080 
1081  protected:
1086 
1090  const MPI_Comm &comm;
1091 
1095  const unsigned int my_rank;
1096 
1100  const unsigned int n_procs;
1101  };
1102 
1120  template <typename T1, typename T2>
1122  {
1123  public:
1131  const MPI_Comm & comm);
1132 
1136  virtual ~ConsensusAlgorithm_NBX() = default;
1137 
1141  virtual void
1142  run() override;
1143 
1144  private:
1145 #ifdef DEAL_II_WITH_MPI
1146 
1149  std::vector<unsigned int> targets;
1150 
1154  std::vector<std::vector<T1>> send_buffers;
1155 
1159  std::vector<MPI_Request> send_requests;
1160 
1164  std::vector<std::vector<T2>> recv_buffers;
1165 
1166 
1170  std::vector<MPI_Request> recv_requests;
1171 
1175  std::vector<std::unique_ptr<std::vector<T2>>> request_buffers;
1176 
1180  std::vector<std::unique_ptr<MPI_Request>> request_requests;
1181 
1182  // request for barrier
1183  MPI_Request barrier_request;
1184 #endif
1185 
1186 #ifdef DEBUG
1187 
1190  std::set<unsigned int> requesting_processes;
1191 #endif
1192 
1196  bool
1197  check_own_state();
1198 
1203  void
1204  signal_finish();
1205 
1210  bool
1211  check_global_state();
1212 
1217  void
1218  process_requests();
1219 
1224  void
1225  start_communication();
1226 
1231  void
1232  clean_up_and_end_communication();
1233  };
1234 
1258  template <typename T1, typename T2>
1260  {
1261  public:
1269  const MPI_Comm & comm);
1270 
1274  virtual ~ConsensusAlgorithm_PEX() = default;
1275 
1279  virtual void
1280  run() override;
1281 
1282  private:
1283 #ifdef DEAL_II_WITH_MPI
1284 
1287  std::vector<unsigned int> targets;
1288 
1292  std::vector<unsigned int> sources;
1293 
1294  // data structures to send and receive requests
1295 
1299  std::vector<std::vector<T1>> send_buffers;
1300 
1304  std::vector<std::vector<T2>> recv_buffers;
1305 
1309  std::vector<MPI_Request> send_and_recv_buffers;
1310 
1314  std::vector<std::vector<T2>> requests_buffers;
1315 
1319  std::vector<MPI_Request> requests_answers;
1320 #endif
1321 
1326  void
1327  process_requests(int index);
1328 
1333  unsigned int
1334  start_communication();
1335 
1340  void
1341  clean_up_and_end_communication();
1342  };
1343 
1357  template <typename T1, typename T2>
1359  {
1360  public:
1368  const MPI_Comm & comm);
1369 
1373  virtual ~ConsensusAlgorithmSelector() = default;
1374 
1380  virtual void
1381  run() override;
1382 
1383  private:
1384  // Pointer to the actual ConsensusAlgorithm implementation.
1385  std::shared_ptr<ConsensusAlgorithm<T1, T2>> consensus_algo;
1386  };
1387 
1432  std::vector<unsigned int>
1433  compute_index_owner(const IndexSet &owned_indices,
1434  const IndexSet &indices_to_look_up,
1435  const MPI_Comm &comm);
1436 
1437 #ifndef DOXYGEN
1438  // declaration for an internal function that lives in mpi.templates.h
1439  namespace internal
1440  {
1441  template <typename T>
1442  void
1443  all_reduce(const MPI_Op & mpi_op,
1444  const ArrayView<const T> &values,
1445  const MPI_Comm & mpi_communicator,
1446  const ArrayView<T> & output);
1447  }
1448 
1449  // Since these depend on N they must live in the header file
1450  template <typename T, unsigned int N>
1451  void
1452  sum(const T (&values)[N], const MPI_Comm &mpi_communicator, T (&sums)[N])
1453  {
1454  internal::all_reduce(MPI_SUM,
1455  ArrayView<const T>(values, N),
1456  mpi_communicator,
1457  ArrayView<T>(sums, N));
1458  }
1459 
1460  template <typename T, unsigned int N>
1461  void
1462  max(const T (&values)[N], const MPI_Comm &mpi_communicator, T (&maxima)[N])
1463  {
1464  internal::all_reduce(MPI_MAX,
1465  ArrayView<const T>(values, N),
1466  mpi_communicator,
1467  ArrayView<T>(maxima, N));
1468  }
1469 
1470  template <typename T, unsigned int N>
1471  void
1472  min(const T (&values)[N], const MPI_Comm &mpi_communicator, T (&minima)[N])
1473  {
1474  internal::all_reduce(MPI_MIN,
1475  ArrayView<const T>(values, N),
1476  mpi_communicator,
1477  ArrayView<T>(minima, N));
1478  }
1479 
1480  template <typename T>
1481  std::map<unsigned int, T>
1482  some_to_some(const MPI_Comm & comm,
1483  const std::map<unsigned int, T> &objects_to_send)
1484  {
1485 # ifndef DEAL_II_WITH_MPI
1486  (void)comm;
1487  Assert(objects_to_send.size() < 2,
1488  ExcMessage("Cannot send to more than one processor."));
1489  Assert(objects_to_send.find(0) != objects_to_send.end() ||
1490  objects_to_send.size() == 0,
1491  ExcMessage("Can only send to myself or to nobody."));
1492  return objects_to_send;
1493 # else
1494  const auto my_proc = this_mpi_process(comm);
1495 
1496  std::map<unsigned int, T> received_objects;
1497 
1498  std::vector<unsigned int> send_to;
1499  send_to.reserve(objects_to_send.size());
1500  for (const auto &m : objects_to_send)
1501  if (m.first == my_proc)
1502  received_objects[my_proc] = m.second;
1503  else
1504  send_to.emplace_back(m.first);
1505 
1506  const unsigned int n_point_point_communications =
1508 
1509  // Protect the following communication:
1510  static CollectiveMutex mutex;
1511  CollectiveMutex::ScopedLock lock(mutex, comm);
1512 
1513  // If we have something to send, or we expect something from other
1514  // processors, we need to visit one of the two scopes below. Otherwise,
1515  // no other action is required by this mpi process, and we can safely
1516  // return.
1517  if (send_to.size() == 0 && n_point_point_communications == 0)
1518  return received_objects;
1519 
1520  const int mpi_tag =
1522 
1523  // Sending buffers
1524  std::vector<std::vector<char>> buffers_to_send(send_to.size());
1525  std::vector<MPI_Request> buffer_send_requests(send_to.size());
1526  {
1527  unsigned int i = 0;
1528  for (const auto &rank_obj : objects_to_send)
1529  if (rank_obj.first != my_proc)
1530  {
1531  const auto &rank = rank_obj.first;
1532  buffers_to_send[i] = Utilities::pack(rank_obj.second);
1533  const int ierr = MPI_Isend(buffers_to_send[i].data(),
1534  buffers_to_send[i].size(),
1535  MPI_CHAR,
1536  rank,
1537  mpi_tag,
1538  comm,
1539  &buffer_send_requests[i]);
1540  AssertThrowMPI(ierr);
1541  ++i;
1542  }
1543  }
1544 
1545  // Fill the output map
1546  {
1547  std::vector<char> buffer;
1548  // We do this on a first come/first served basis
1549  for (unsigned int i = 0; i < n_point_point_communications; ++i)
1550  {
1551  // Probe what's going on. Take data from the first available sender
1552  MPI_Status status;
1553  int ierr = MPI_Probe(MPI_ANY_SOURCE, mpi_tag, comm, &status);
1554  AssertThrowMPI(ierr);
1555 
1556  // Length of the message
1557  int len;
1558  ierr = MPI_Get_count(&status, MPI_CHAR, &len);
1559  AssertThrowMPI(ierr);
1560  buffer.resize(len);
1561 
1562  // Source rank
1563  const unsigned int rank = status.MPI_SOURCE;
1564 
1565  // Actually receive the message
1566  ierr = MPI_Recv(buffer.data(),
1567  len,
1568  MPI_CHAR,
1569  status.MPI_SOURCE,
1570  status.MPI_TAG,
1571  comm,
1572  MPI_STATUS_IGNORE);
1573  AssertThrowMPI(ierr);
1574  Assert(received_objects.find(rank) == received_objects.end(),
1576  "I should not receive again from this rank"));
1577  received_objects[rank] = Utilities::unpack<T>(buffer);
1578  }
1579  }
1580 
1581  // Wait to have sent all objects.
1582  MPI_Waitall(send_to.size(),
1583  buffer_send_requests.data(),
1584  MPI_STATUSES_IGNORE);
1585 
1586  return received_objects;
1587 # endif // deal.II with MPI
1588  }
1589 
1590  template <typename T>
1591  std::vector<T>
1592  all_gather(const MPI_Comm &comm, const T &object)
1593  {
1594 # ifndef DEAL_II_WITH_MPI
1595  (void)comm;
1596  std::vector<T> v(1, object);
1597  return v;
1598 # else
1599  const auto n_procs = ::Utilities::MPI::n_mpi_processes(comm);
1600 
1601  std::vector<char> buffer = Utilities::pack(object);
1602 
1603  int n_local_data = buffer.size();
1604 
1605  // Vector to store the size of loc_data_array for every process
1606  std::vector<int> size_all_data(n_procs, 0);
1607 
1608  // Exchanging the size of each buffer
1609  MPI_Allgather(
1610  &n_local_data, 1, MPI_INT, size_all_data.data(), 1, MPI_INT, comm);
1611 
1612  // Now computing the displacement, relative to recvbuf,
1613  // at which to store the incoming buffer
1614  std::vector<int> rdispls(n_procs);
1615  rdispls[0] = 0;
1616  for (unsigned int i = 1; i < n_procs; ++i)
1617  rdispls[i] = rdispls[i - 1] + size_all_data[i - 1];
1618 
1619  // Step 3: exchange the buffer:
1620  std::vector<char> received_unrolled_buffer(rdispls.back() +
1621  size_all_data.back());
1622 
1623  MPI_Allgatherv(buffer.data(),
1624  n_local_data,
1625  MPI_CHAR,
1626  received_unrolled_buffer.data(),
1627  size_all_data.data(),
1628  rdispls.data(),
1629  MPI_CHAR,
1630  comm);
1631 
1632  std::vector<T> received_objects(n_procs);
1633  for (unsigned int i = 0; i < n_procs; ++i)
1634  {
1635  std::vector<char> local_buffer(received_unrolled_buffer.begin() +
1636  rdispls[i],
1637  received_unrolled_buffer.begin() +
1638  rdispls[i] + size_all_data[i]);
1639  received_objects[i] = Utilities::unpack<T>(local_buffer);
1640  }
1641 
1642  return received_objects;
1643 # endif
1644  }
1645 
1646  template <typename T>
1647  std::vector<T>
1648  gather(const MPI_Comm & comm,
1649  const T & object_to_send,
1650  const unsigned int root_process)
1651  {
1652 # ifndef DEAL_II_WITH_MPI
1653  (void)comm;
1654  (void)root_process;
1655  std::vector<T> v(1, object_to_send);
1656  return v;
1657 # else
1658  const auto n_procs = ::Utilities::MPI::n_mpi_processes(comm);
1659  const auto my_rank = ::Utilities::MPI::this_mpi_process(comm);
1660 
1661  Assert(root_process < n_procs, ExcIndexRange(root_process, 0, n_procs));
1662 
1663  std::vector<char> buffer = Utilities::pack(object_to_send);
1664  int n_local_data = buffer.size();
1665 
1666  // Vector to store the size of loc_data_array for every process
1667  // only the root process needs to allocate memory for that purpose
1668  std::vector<int> size_all_data;
1669  if (my_rank == root_process)
1670  size_all_data.resize(n_procs, 0);
1671 
1672  // Exchanging the size of each buffer
1673  int ierr = MPI_Gather(&n_local_data,
1674  1,
1675  MPI_INT,
1676  size_all_data.data(),
1677  1,
1678  MPI_INT,
1679  root_process,
1680  comm);
1681  AssertThrowMPI(ierr);
1682 
1683  // Now computing the displacement, relative to recvbuf,
1684  // at which to store the incoming buffer; only for root
1685  std::vector<int> rdispls;
1686  if (my_rank == root_process)
1687  {
1688  rdispls.resize(n_procs, 0);
1689  for (unsigned int i = 1; i < n_procs; ++i)
1690  rdispls[i] = rdispls[i - 1] + size_all_data[i - 1];
1691  }
1692  // exchange the buffer:
1693  std::vector<char> received_unrolled_buffer;
1694  if (my_rank == root_process)
1695  received_unrolled_buffer.resize(rdispls.back() + size_all_data.back());
1696 
1697  ierr = MPI_Gatherv(buffer.data(),
1698  n_local_data,
1699  MPI_CHAR,
1700  received_unrolled_buffer.data(),
1701  size_all_data.data(),
1702  rdispls.data(),
1703  MPI_CHAR,
1704  root_process,
1705  comm);
1706  AssertThrowMPI(ierr);
1707 
1708  std::vector<T> received_objects;
1709 
1710  if (my_rank == root_process)
1711  {
1712  received_objects.resize(n_procs);
1713 
1714  for (unsigned int i = 0; i < n_procs; ++i)
1715  {
1716  const std::vector<char> local_buffer(
1717  received_unrolled_buffer.begin() + rdispls[i],
1718  received_unrolled_buffer.begin() + rdispls[i] +
1719  size_all_data[i]);
1720  received_objects[i] = Utilities::unpack<T>(local_buffer);
1721  }
1722  }
1723  return received_objects;
1724 # endif
1725  }
1726 
1727 
1728 # ifdef DEAL_II_WITH_MPI
1729  template <class Iterator, typename Number>
1730  std::pair<Number, typename numbers::NumberTraits<Number>::real_type>
1731  mean_and_standard_deviation(const Iterator begin,
1732  const Iterator end,
1733  const MPI_Comm &comm)
1734  {
1735  // below we do simple and straight-forward implementation. More elaborate
1736  // options are:
1737  // http://dx.doi.org/10.1145/2807591.2807644 section 3.1.2
1738  // https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm
1739  // https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Online
1740  using Std = typename numbers::NumberTraits<Number>::real_type;
1741  const Number sum = std::accumulate(begin, end, Number(0.));
1742 
1743  const auto size = Utilities::MPI::sum(std::distance(begin, end), comm);
1744  Assert(size > 0, ExcDivideByZero());
1745  const Number mean =
1746  Utilities::MPI::sum(sum, comm) / static_cast<Std>(size);
1747  Std sq_sum = 0.;
1748  std::for_each(begin, end, [&mean, &sq_sum](const Number &v) {
1749  sq_sum += numbers::NumberTraits<Number>::abs_square(v - mean);
1750  });
1751  sq_sum = Utilities::MPI::sum(sq_sum, comm);
1752  return std::make_pair(mean,
1753  std::sqrt(sq_sum / static_cast<Std>(size - 1)));
1754  }
1755 # endif
1756 
1757 #endif
1758  } // end of namespace MPI
1759 } // end of namespace Utilities
1760 
1761 
1762 DEAL_II_NAMESPACE_CLOSE
1763 
1764 #endif
std::vector< unsigned int > sources
Definition: mpi.h:1292
static const unsigned int invalid_unsigned_int
Definition: types.h:187
std::vector< std::unique_ptr< std::vector< T2 > > > request_buffers
Definition: mpi.h:1175
std::vector< std::unique_ptr< MPI_Request > > request_requests
Definition: mpi.h:1180
std::vector< unsigned int > targets
Definition: mpi.h:1287
const unsigned int my_rank
Definition: mpi.h:1095
unsigned int compute_n_point_to_point_communications(const MPI_Comm &mpi_comm, const std::vector< unsigned int > &destinations)
Definition: mpi.cc:425
static constexpr std::enable_if< std::is_same< Dummy, number >::value &&is_cuda_compatible< Dummy >::value, real_type >::type abs_square(const number &x)
Definition: numbers.h:605
std::vector< std::vector< T2 > > recv_buffers
Definition: mpi.h:1304
std::set< unsigned int > requesting_processes
Definition: mpi.h:1190
types::global_dof_index size_type
Definition: index_set.h:85
static ::ExceptionBase & ExcIndexRange(int arg1, int arg2, int arg3)
static ::ExceptionBase & ExcDivideByZero()
std::pair< Number, typename numbers::NumberTraits< Number >::real_type > mean_and_standard_deviation(const Iterator begin, const Iterator end, const MPI_Comm &comm)
std::vector< std::vector< T1 > > send_buffers
Definition: mpi.h:1154
ScopedLock(CollectiveMutex &mutex, const MPI_Comm &comm)
Definition: mpi.h:319
void free_communicator(MPI_Comm &mpi_communicator)
Definition: mpi.cc:108
static ::ExceptionBase & ExcMessage(std::string arg1)
std::vector< MPI_Request > recv_requests
Definition: mpi.h:1170
std::vector< std::vector< T2 > > recv_buffers
Definition: mpi.h:1164
T sum(const T &t, const MPI_Comm &mpi_communicator)
#define Assert(cond, exc)
Definition: exceptions.h:1411
const unsigned int n_procs
Definition: mpi.h:1100
std::vector< MPI_Request > send_requests
Definition: mpi.h:1159
std::vector< T > gather(const MPI_Comm &comm, const T &object_to_send, const unsigned int root_process=0)
std::vector< std::vector< T1 > > send_buffers
Definition: mpi.h:1299
int create_group(const MPI_Comm &comm, const MPI_Group &group, const int tag, MPI_Comm *new_comm)
Definition: mpi.cc:118
const MPI_Comm & operator*() const
Definition: mpi.h:257
std::vector< std::vector< T2 > > requests_buffers
Definition: mpi.h:1314
std::vector< unsigned int > compute_index_owner(const IndexSet &owned_indices, const IndexSet &indices_to_look_up, const MPI_Comm &comm)
Definition: mpi.cc:1515
size_t pack(const T &object, std::vector< char > &dest_buffer, const bool allow_compression=true)
Definition: utilities.h:1186
std::vector< MPI_Request > requests_answers
Definition: mpi.h:1319
unsigned int n_mpi_processes(const MPI_Comm &mpi_communicator)
Definition: mpi.cc:75
void lock(MPI_Comm comm)
Definition: mpi.cc:1577
Definition: cuda.h:31
#define AssertThrowMPI(error_code)
Definition: exceptions.h:1699
Utilities::MPI::compute_point_to_point_communication_pattern()
Definition: mpi_tags.h:57
MPI_Comm duplicate_communicator(const MPI_Comm &mpi_communicator)
Definition: mpi.cc:97
Definition: tensor.h:422
ConsensusAlgorithmProcess< T1, T2 > & process
Definition: mpi.h:1085
T min(const T &t, const MPI_Comm &mpi_communicator)
std::vector< MPI_Request > send_and_recv_buffers
Definition: mpi.h:1309
static std::set< MPI_Request * > requests
Definition: mpi.h:863
unsigned int this_mpi_process(const MPI_Comm &mpi_communicator)
Definition: mpi.cc:86
std::vector< unsigned int > targets
Definition: mpi.h:1149
std::vector< T > all_gather(const MPI_Comm &comm, const T &object_to_send)
std::vector< IndexSet > create_ascending_partitioning(const MPI_Comm &comm, const IndexSet::size_type &local_size)
Definition: mpi.cc:200
DuplicatedCommunicator(const MPI_Comm &communicator)
Definition: mpi.h:237
MinMaxAvg min_max_avg(const double my_value, const MPI_Comm &mpi_communicator)
Definition: mpi.cc:530
std::vector< unsigned int > compute_point_to_point_communication_pattern(const MPI_Comm &mpi_comm, const std::vector< unsigned int > &destinations)
Definition: mpi.cc:284
bool job_supports_mpi()
Definition: mpi.cc:949
std::map< unsigned int, T > some_to_some(const MPI_Comm &comm, const std::map< unsigned int, T > &objects_to_send)
unsigned int min_index
Definition: mpi.h:686
T max(const T &t, const MPI_Comm &mpi_communicator)
unsigned int max_index
Definition: mpi.h:696
static ::ExceptionBase & ExcInternalError()
DuplicatedCommunicator & operator=(const DuplicatedCommunicator &)=delete