Reference documentation for deal.II version Git fff2869c79 2020-01-20 12:00:24 -0500
\(\newcommand{\vcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\vcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
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  create_request(const int other_rank, std::vector<T1> &send_buffer);
997 
1006  virtual void
1007  prepare_buffer_for_answer(const int other_rank,
1008  std::vector<T2> &recv_buffer);
1009 
1022  virtual void
1023  answer_request(const unsigned int other_rank,
1024  const std::vector<T1> &buffer_recv,
1025  std::vector<T2> & request_buffer);
1026 
1034  virtual void
1035  read_answer(const int other_rank, const std::vector<T2> &recv_buffer);
1036  };
1037 
1068  template <typename T1, typename T2>
1070  {
1071  public:
1073  const MPI_Comm & comm);
1074 
1078  virtual ~ConsensusAlgorithm() = default;
1079 
1083  virtual void
1084  run() = 0;
1085 
1086  protected:
1091 
1095  const MPI_Comm &comm;
1096 
1100  const unsigned int my_rank;
1101 
1105  const unsigned int n_procs;
1106  };
1107 
1108 
1127  template <typename T1, typename T2>
1129  {
1130  public:
1138  const MPI_Comm & comm);
1139 
1143  virtual ~ConsensusAlgorithm_NBX() = default;
1144 
1148  virtual void
1149  run() override;
1150 
1151  private:
1152 #ifdef DEAL_II_WITH_MPI
1153 
1156  std::vector<unsigned int> targets;
1157 
1161  std::vector<std::vector<T1>> send_buffers;
1162 
1166  std::vector<MPI_Request> send_requests;
1167 
1171  std::vector<std::vector<T2>> recv_buffers;
1172 
1173 
1177  std::vector<MPI_Request> recv_requests;
1178 
1182  std::vector<std::unique_ptr<std::vector<T2>>> request_buffers;
1183 
1187  std::vector<std::unique_ptr<MPI_Request>> request_requests;
1188 
1189  // request for barrier
1190  MPI_Request barrier_request;
1191 #endif
1192 
1193 #ifdef DEBUG
1194 
1197  std::set<unsigned int> requesting_processes;
1198 #endif
1199 
1203  bool
1204  check_own_state();
1205 
1210  void
1211  signal_finish();
1212 
1217  bool
1218  check_global_state();
1219 
1224  void
1225  answer_requests();
1226 
1231  void
1232  start_communication();
1233 
1238  void
1239  clean_up_and_end_communication();
1240  };
1241 
1267  template <typename T1, typename T2>
1269  {
1270  public:
1278  const MPI_Comm & comm);
1279 
1283  virtual ~ConsensusAlgorithm_PEX() = default;
1284 
1288  virtual void
1289  run() override;
1290 
1291  private:
1292 #ifdef DEAL_II_WITH_MPI
1293 
1296  std::vector<unsigned int> targets;
1297 
1301  std::vector<unsigned int> sources;
1302 
1303  // data structures to send and receive requests
1304 
1308  std::vector<std::vector<T1>> send_buffers;
1309 
1313  std::vector<std::vector<T2>> recv_buffers;
1314 
1318  std::vector<MPI_Request> send_and_recv_buffers;
1319 
1323  std::vector<std::vector<T2>> requests_buffers;
1324 
1328  std::vector<MPI_Request> requests_answers;
1329 #endif
1330 
1335  void
1336  answer_requests(int index);
1337 
1342  unsigned int
1343  start_communication();
1344 
1349  void
1350  clean_up_and_end_communication();
1351  };
1352 
1366  template <typename T1, typename T2>
1368  {
1369  public:
1377  const MPI_Comm & comm);
1378 
1382  virtual ~ConsensusAlgorithmSelector() = default;
1383 
1389  virtual void
1390  run() override;
1391 
1392  private:
1393  // Pointer to the actual ConsensusAlgorithm implementation.
1394  std::shared_ptr<ConsensusAlgorithm<T1, T2>> consensus_algo;
1395  };
1396 
1441  std::vector<unsigned int>
1442  compute_index_owner(const IndexSet &owned_indices,
1443  const IndexSet &indices_to_look_up,
1444  const MPI_Comm &comm);
1445 
1446 #ifndef DOXYGEN
1447  // declaration for an internal function that lives in mpi.templates.h
1448  namespace internal
1449  {
1450  template <typename T>
1451  void
1452  all_reduce(const MPI_Op & mpi_op,
1453  const ArrayView<const T> &values,
1454  const MPI_Comm & mpi_communicator,
1455  const ArrayView<T> & output);
1456  }
1457 
1458  // Since these depend on N they must live in the header file
1459  template <typename T, unsigned int N>
1460  void
1461  sum(const T (&values)[N], const MPI_Comm &mpi_communicator, T (&sums)[N])
1462  {
1463  internal::all_reduce(MPI_SUM,
1464  ArrayView<const T>(values, N),
1465  mpi_communicator,
1466  ArrayView<T>(sums, N));
1467  }
1468 
1469  template <typename T, unsigned int N>
1470  void
1471  max(const T (&values)[N], const MPI_Comm &mpi_communicator, T (&maxima)[N])
1472  {
1473  internal::all_reduce(MPI_MAX,
1474  ArrayView<const T>(values, N),
1475  mpi_communicator,
1476  ArrayView<T>(maxima, N));
1477  }
1478 
1479  template <typename T, unsigned int N>
1480  void
1481  min(const T (&values)[N], const MPI_Comm &mpi_communicator, T (&minima)[N])
1482  {
1483  internal::all_reduce(MPI_MIN,
1484  ArrayView<const T>(values, N),
1485  mpi_communicator,
1486  ArrayView<T>(minima, N));
1487  }
1488 
1489  template <typename T>
1490  std::map<unsigned int, T>
1491  some_to_some(const MPI_Comm & comm,
1492  const std::map<unsigned int, T> &objects_to_send)
1493  {
1494 # ifndef DEAL_II_WITH_MPI
1495  (void)comm;
1496  Assert(objects_to_send.size() < 2,
1497  ExcMessage("Cannot send to more than one processor."));
1498  Assert(objects_to_send.find(0) != objects_to_send.end() ||
1499  objects_to_send.size() == 0,
1500  ExcMessage("Can only send to myself or to nobody."));
1501  return objects_to_send;
1502 # else
1503  const auto my_proc = this_mpi_process(comm);
1504 
1505  std::map<unsigned int, T> received_objects;
1506 
1507  std::vector<unsigned int> send_to;
1508  send_to.reserve(objects_to_send.size());
1509  for (const auto &m : objects_to_send)
1510  if (m.first == my_proc)
1511  received_objects[my_proc] = m.second;
1512  else
1513  send_to.emplace_back(m.first);
1514 
1515  const unsigned int n_point_point_communications =
1517 
1518  // Protect the following communication:
1519  static CollectiveMutex mutex;
1520  CollectiveMutex::ScopedLock lock(mutex, comm);
1521 
1522  // If we have something to send, or we expect something from other
1523  // processors, we need to visit one of the two scopes below. Otherwise,
1524  // no other action is required by this mpi process, and we can safely
1525  // return.
1526  if (send_to.size() == 0 && n_point_point_communications == 0)
1527  return received_objects;
1528 
1529  const int mpi_tag =
1531 
1532  // Sending buffers
1533  std::vector<std::vector<char>> buffers_to_send(send_to.size());
1534  std::vector<MPI_Request> buffer_send_requests(send_to.size());
1535  {
1536  unsigned int i = 0;
1537  for (const auto &rank_obj : objects_to_send)
1538  if (rank_obj.first != my_proc)
1539  {
1540  const auto &rank = rank_obj.first;
1541  buffers_to_send[i] = Utilities::pack(rank_obj.second);
1542  const int ierr = MPI_Isend(buffers_to_send[i].data(),
1543  buffers_to_send[i].size(),
1544  MPI_CHAR,
1545  rank,
1546  mpi_tag,
1547  comm,
1548  &buffer_send_requests[i]);
1549  AssertThrowMPI(ierr);
1550  ++i;
1551  }
1552  }
1553 
1554  // Fill the output map
1555  {
1556  std::vector<char> buffer;
1557  // We do this on a first come/first served basis
1558  for (unsigned int i = 0; i < n_point_point_communications; ++i)
1559  {
1560  // Probe what's going on. Take data from the first available sender
1561  MPI_Status status;
1562  int ierr = MPI_Probe(MPI_ANY_SOURCE, mpi_tag, comm, &status);
1563  AssertThrowMPI(ierr);
1564 
1565  // Length of the message
1566  int len;
1567  ierr = MPI_Get_count(&status, MPI_CHAR, &len);
1568  AssertThrowMPI(ierr);
1569  buffer.resize(len);
1570 
1571  // Source rank
1572  const unsigned int rank = status.MPI_SOURCE;
1573 
1574  // Actually receive the message
1575  ierr = MPI_Recv(buffer.data(),
1576  len,
1577  MPI_CHAR,
1578  status.MPI_SOURCE,
1579  status.MPI_TAG,
1580  comm,
1581  MPI_STATUS_IGNORE);
1582  AssertThrowMPI(ierr);
1583  Assert(received_objects.find(rank) == received_objects.end(),
1585  "I should not receive again from this rank"));
1586  received_objects[rank] = Utilities::unpack<T>(buffer);
1587  }
1588  }
1589 
1590  // Wait to have sent all objects.
1591  const int ierr = MPI_Waitall(send_to.size(),
1592  buffer_send_requests.data(),
1593  MPI_STATUSES_IGNORE);
1594  AssertThrowMPI(ierr);
1595 
1596  return received_objects;
1597 # endif // deal.II with MPI
1598  }
1599 
1600  template <typename T>
1601  std::vector<T>
1602  all_gather(const MPI_Comm &comm, const T &object)
1603  {
1604 # ifndef DEAL_II_WITH_MPI
1605  (void)comm;
1606  std::vector<T> v(1, object);
1607  return v;
1608 # else
1609  const auto n_procs = ::Utilities::MPI::n_mpi_processes(comm);
1610 
1611  std::vector<char> buffer = Utilities::pack(object);
1612 
1613  int n_local_data = buffer.size();
1614 
1615  // Vector to store the size of loc_data_array for every process
1616  std::vector<int> size_all_data(n_procs, 0);
1617 
1618  // Exchanging the size of each buffer
1619  MPI_Allgather(
1620  &n_local_data, 1, MPI_INT, size_all_data.data(), 1, MPI_INT, comm);
1621 
1622  // Now computing the displacement, relative to recvbuf,
1623  // at which to store the incoming buffer
1624  std::vector<int> rdispls(n_procs);
1625  rdispls[0] = 0;
1626  for (unsigned int i = 1; i < n_procs; ++i)
1627  rdispls[i] = rdispls[i - 1] + size_all_data[i - 1];
1628 
1629  // Step 3: exchange the buffer:
1630  std::vector<char> received_unrolled_buffer(rdispls.back() +
1631  size_all_data.back());
1632 
1633  MPI_Allgatherv(buffer.data(),
1634  n_local_data,
1635  MPI_CHAR,
1636  received_unrolled_buffer.data(),
1637  size_all_data.data(),
1638  rdispls.data(),
1639  MPI_CHAR,
1640  comm);
1641 
1642  std::vector<T> received_objects(n_procs);
1643  for (unsigned int i = 0; i < n_procs; ++i)
1644  {
1645  std::vector<char> local_buffer(received_unrolled_buffer.begin() +
1646  rdispls[i],
1647  received_unrolled_buffer.begin() +
1648  rdispls[i] + size_all_data[i]);
1649  received_objects[i] = Utilities::unpack<T>(local_buffer);
1650  }
1651 
1652  return received_objects;
1653 # endif
1654  }
1655 
1656  template <typename T>
1657  std::vector<T>
1658  gather(const MPI_Comm & comm,
1659  const T & object_to_send,
1660  const unsigned int root_process)
1661  {
1662 # ifndef DEAL_II_WITH_MPI
1663  (void)comm;
1664  (void)root_process;
1665  std::vector<T> v(1, object_to_send);
1666  return v;
1667 # else
1668  const auto n_procs = ::Utilities::MPI::n_mpi_processes(comm);
1669  const auto my_rank = ::Utilities::MPI::this_mpi_process(comm);
1670 
1671  AssertIndexRange(root_process, n_procs);
1672 
1673  std::vector<char> buffer = Utilities::pack(object_to_send);
1674  int n_local_data = buffer.size();
1675 
1676  // Vector to store the size of loc_data_array for every process
1677  // only the root process needs to allocate memory for that purpose
1678  std::vector<int> size_all_data;
1679  if (my_rank == root_process)
1680  size_all_data.resize(n_procs, 0);
1681 
1682  // Exchanging the size of each buffer
1683  int ierr = MPI_Gather(&n_local_data,
1684  1,
1685  MPI_INT,
1686  size_all_data.data(),
1687  1,
1688  MPI_INT,
1689  root_process,
1690  comm);
1691  AssertThrowMPI(ierr);
1692 
1693  // Now computing the displacement, relative to recvbuf,
1694  // at which to store the incoming buffer; only for root
1695  std::vector<int> rdispls;
1696  if (my_rank == root_process)
1697  {
1698  rdispls.resize(n_procs, 0);
1699  for (unsigned int i = 1; i < n_procs; ++i)
1700  rdispls[i] = rdispls[i - 1] + size_all_data[i - 1];
1701  }
1702  // exchange the buffer:
1703  std::vector<char> received_unrolled_buffer;
1704  if (my_rank == root_process)
1705  received_unrolled_buffer.resize(rdispls.back() + size_all_data.back());
1706 
1707  ierr = MPI_Gatherv(buffer.data(),
1708  n_local_data,
1709  MPI_CHAR,
1710  received_unrolled_buffer.data(),
1711  size_all_data.data(),
1712  rdispls.data(),
1713  MPI_CHAR,
1714  root_process,
1715  comm);
1716  AssertThrowMPI(ierr);
1717 
1718  std::vector<T> received_objects;
1719 
1720  if (my_rank == root_process)
1721  {
1722  received_objects.resize(n_procs);
1723 
1724  for (unsigned int i = 0; i < n_procs; ++i)
1725  {
1726  const std::vector<char> local_buffer(
1727  received_unrolled_buffer.begin() + rdispls[i],
1728  received_unrolled_buffer.begin() + rdispls[i] +
1729  size_all_data[i]);
1730  received_objects[i] = Utilities::unpack<T>(local_buffer);
1731  }
1732  }
1733  return received_objects;
1734 # endif
1735  }
1736 
1737 
1738 # ifdef DEAL_II_WITH_MPI
1739  template <class Iterator, typename Number>
1740  std::pair<Number, typename numbers::NumberTraits<Number>::real_type>
1741  mean_and_standard_deviation(const Iterator begin,
1742  const Iterator end,
1743  const MPI_Comm &comm)
1744  {
1745  // below we do simple and straight-forward implementation. More elaborate
1746  // options are:
1747  // http://dx.doi.org/10.1145/2807591.2807644 section 3.1.2
1748  // https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_online_algorithm
1749  // https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Online
1750  using Std = typename numbers::NumberTraits<Number>::real_type;
1751  const Number sum = std::accumulate(begin, end, Number(0.));
1752 
1753  const auto size = Utilities::MPI::sum(std::distance(begin, end), comm);
1754  Assert(size > 0, ExcDivideByZero());
1755  const Number mean =
1756  Utilities::MPI::sum(sum, comm) / static_cast<Std>(size);
1757  Std sq_sum = 0.;
1758  std::for_each(begin, end, [&mean, &sq_sum](const Number &v) {
1759  sq_sum += numbers::NumberTraits<Number>::abs_square(v - mean);
1760  });
1761  sq_sum = Utilities::MPI::sum(sq_sum, comm);
1762  return std::make_pair(mean,
1763  std::sqrt(sq_sum / static_cast<Std>(size - 1)));
1764  }
1765 # endif
1766 
1767 #endif
1768  } // end of namespace MPI
1769 } // end of namespace Utilities
1770 
1771 
1772 DEAL_II_NAMESPACE_CLOSE
1773 
1774 #endif
std::vector< unsigned int > sources
Definition: mpi.h:1301
static const unsigned int invalid_unsigned_int
Definition: types.h:187
std::vector< std::unique_ptr< std::vector< T2 > > > request_buffers
Definition: mpi.h:1182
std::vector< std::unique_ptr< MPI_Request > > request_requests
Definition: mpi.h:1187
std::vector< unsigned int > targets
Definition: mpi.h:1296
const unsigned int my_rank
Definition: mpi.h:1100
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
#define AssertIndexRange(index, range)
Definition: exceptions.h:1641
std::vector< std::vector< T2 > > recv_buffers
Definition: mpi.h:1313
std::set< unsigned int > requesting_processes
Definition: mpi.h:1197
types::global_dof_index size_type
Definition: index_set.h:85
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:1161
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:1177
std::vector< std::vector< T2 > > recv_buffers
Definition: mpi.h:1171
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:1105
std::vector< MPI_Request > send_requests
Definition: mpi.h:1166
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:1308
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:1323
std::vector< unsigned int > compute_index_owner(const IndexSet &owned_indices, const IndexSet &indices_to_look_up, const MPI_Comm &comm)
Definition: mpi.cc:1513
size_t pack(const T &object, std::vector< char > &dest_buffer, const bool allow_compression=true)
Definition: utilities.h:1221
std::vector< MPI_Request > requests_answers
Definition: mpi.h:1328
unsigned int n_mpi_processes(const MPI_Comm &mpi_communicator)
Definition: mpi.cc:75
void lock(MPI_Comm comm)
Definition: mpi.cc:1575
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:1090
T min(const T &t, const MPI_Comm &mpi_communicator)
std::vector< MPI_Request > send_and_recv_buffers
Definition: mpi.h:1318
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:1156
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