28#include <boost/signals2.hpp>
52#ifdef DEAL_II_WITH_MPI
53# define DEAL_II_MPI_CONST_CAST(expr) (expr)
63template <
int rank,
int dim,
typename Number>
65template <
int rank,
int dim,
typename Number>
67template <
typename Number>
109 template <
typename T>
127 std::complex<double>,
128 std::complex<long double>,
157 const std::vector<unsigned int>
182 std::vector<unsigned int>
459 template <
typename T>
467 template <
typename W,
typename G>
574#ifdef DEAL_II_WITH_MPI
590 std::vector<IndexSet>
607#ifdef DEAL_II_WITH_MPI
623 template <
class Iterator,
typename Number =
long double>
624 std::pair<Number, typename numbers::NumberTraits<Number>::real_type>
700 template <
typename T>
713 template <
typename T,
typename U>
726 template <
typename T>
737 template <
int rank,
int dim,
typename Number>
747 template <
int rank,
int dim,
typename Number>
760 template <
typename Number>
785 template <
typename T>
798 template <
typename T,
typename U>
811 template <
typename T>
836 template <
typename T>
849 template <
typename T,
typename U>
862 template <
typename T>
891 template <
typename T>
909 template <
typename T,
typename U>
922 template <
typename T>
1017 std::vector<MinMaxAvg>
1169 register_request(MPI_Request &request);
1175 unregister_request(MPI_Request &request);
1209#ifdef DEAL_II_WITH_PETSC
1245 template <
typename T>
1246 std::map<unsigned int, T>
1263 template <
typename T>
1282 template <
typename T>
1302 template <
typename T>
1343 template <
typename T>
1344 std::enable_if_t<is_mpi_type<T> ==
false, T>
1371 template <
typename T>
1372 std::enable_if_t<is_mpi_type<T> ==
true, T>
1393 template <
typename T>
1397 const unsigned int root,
1412 template <
typename T>
1416 const std::function<T(
const T &,
const T &)> &
combiner,
1428 template <
typename T>
1432 const std::function<T(
const T &,
const T &)> &
combiner);
1455 template <
typename T>
1460 const unsigned int mpi_tag = 0);
1479 template <
typename T>
1483 const unsigned int mpi_tag = 0);
1528 std::vector<unsigned int>
1530 const IndexSet &indices_to_look_up,
1540 template <
typename T>
1547 template <
typename T>
1562 namespace MPIDataTypes
1564#ifdef DEAL_II_WITH_MPI
1712#ifdef DEAL_II_WITH_MPI
1730 template <
typename T>
1733 static_cast<std::remove_cv_t<std::remove_reference_t<T>
> *>(
nullptr));
1740 template <
typename T>
1749 template <
typename T>
1750 template <
typename W,
typename G>
1760 template <
typename T>
1761 Future<T>::~Future()
1771 if ((get_was_called ==
false) && get_and_cleanup_function)
1777 template <
typename T>
1781 if (is_done ==
false)
1790 template <
typename T>
1794 Assert(get_was_called ==
false,
1796 "You can't call get() more than once on a Future object."));
1797 get_was_called =
true;
1800 return get_and_cleanup_function();
1805 template <
typename T,
unsigned int N>
1807 sum(
const T (&values)[N],
const MPI_Comm mpi_communicator, T (&
sums)[N])
1817 template <
typename T,
unsigned int N>
1829 template <
typename T,
unsigned int N>
1841 template <
typename T,
unsigned int N>
1847 static_assert(std::is_integral<T>::value,
1848 "The MPI_LOR operation only allows integral data types.");
1858 template <
typename T>
1859 std::map<unsigned int, T>
1863# ifndef DEAL_II_WITH_MPI
1866 ExcMessage(
"Cannot send to more than one processor."));
1869 ExcMessage(
"Can only send to myself or to nobody."));
1876 std::vector<unsigned int>
send_to;
1882 send_to.emplace_back(m.first);
1888 static CollectiveMutex mutex;
1889 CollectiveMutex::ScopedLock lock(mutex,
comm);
1899 internal::Tags::compute_point_to_point_communication_pattern;
1926 std::vector<char>
buffer;
1942 const unsigned int rank = status.MPI_SOURCE;
1955 "I should not receive again from this rank"));
1957 Utilities::unpack<T>(
buffer,
1974 template <
typename T>
1981# ifndef DEAL_II_WITH_MPI
1983 std::vector<T> v(1,
object);
2002 std::vector<int>
rdispls(n_procs);
2004 for (
unsigned int i = 1; i < n_procs; ++i)
2022 for (
unsigned int i = 0; i < n_procs; ++i)
2037 template <
typename T>
2043# ifndef DEAL_II_WITH_MPI
2080 for (
unsigned int i = 1; i < n_procs; ++i)
2105 for (
unsigned int i = 0; i < n_procs; ++i)
2120 template <
typename T>
2126# ifndef DEAL_II_WITH_MPI
2142 "The number of objects to be scattered must correspond to the number processes."));
2153 for (
unsigned int i = 0; i < n_procs; ++i)
2162 for (
unsigned int i = 0; i < n_procs; ++i)
2195 template <
typename T>
2199 const unsigned int root,
2202# ifndef DEAL_II_WITH_MPI
2213 const size_t max_send_count = std::numeric_limits<signed int>::max();
2223 mpi_type_id_for_type<
decltype(*
buffer)>,
2234 template <
typename T>
2235 std::enable_if_t<is_mpi_type<T> ==
false, T>
2240# ifndef DEAL_II_WITH_MPI
2249 std::vector<char>
buffer;
2278 return Utilities::unpack<T>(
buffer,
false);
2284 template <
typename T>
2285 std::enable_if_t<is_mpi_type<T> ==
true, T>
2290# ifndef DEAL_II_WITH_MPI
2306 template <
typename T>
2308 isend(
const T &
object,
2313# ifndef DEAL_II_WITH_MPI
2339 MPI_Request request;
2363 auto wait = [request]()
mutable {
2376 template <
typename T>
2382# ifndef DEAL_II_WITH_MPI
2403 std::shared_ptr<MPI_Message>
message = std::make_shared<MPI_Message>();
2404 std::shared_ptr<MPI_Status> status = std::make_shared<MPI_Status>();
2414 auto get = [status,
message]() {
2441# ifdef DEAL_II_WITH_MPI
2442 template <
class Iterator,
typename Number>
2443 std::pair<Number, typename numbers::NumberTraits<Number>::real_type>
2454 const Number
sum = std::accumulate(begin, end, Number(0.));
2461 std::for_each(begin, end, [&mean, &
sq_sum](
const Number &v) {
2465 return std::make_pair(mean,
value_type * data() const noexcept
void sum(const SparseMatrix< Number > &local, const MPI_Comm mpi_communicator, SparseMatrix< Number > &global)
SymmetricTensor< rank, dim, Number > sum(const SymmetricTensor< rank, dim, Number > &local, const MPI_Comm mpi_communicator)
Tensor< rank, dim, Number > sum(const Tensor< rank, dim, Number > &local, const MPI_Comm mpi_communicator)
ScopedLock(CollectiveMutex &mutex, const MPI_Comm comm)
void lock(const MPI_Comm comm)
void unlock(const MPI_Comm comm)
DuplicatedCommunicator(const DuplicatedCommunicator &)=delete
~DuplicatedCommunicator()
MPI_Comm operator*() const
DuplicatedCommunicator & operator=(const DuplicatedCommunicator &)=delete
DuplicatedCommunicator(const MPI_Comm communicator)
Future(const Future &)=delete
Future(Future &&) noexcept=default
std::function< void()> wait_function
std::function< T()> get_and_cleanup_function
Future(W &&wait_operation, G &&get_and_cleanup_operation)
static std::set< MPI_Request * > requests
#define DEAL_II_DEPRECATED
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcNeedsMPI()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
#define AssertThrowMPI(error_code)
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcDivideByZero()
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
MPI_Datatype mpi_type_id(const bool *)
std::vector< IndexSet > create_ascending_partitioning(const MPI_Comm comm, const types::global_dof_index locally_owned_size)
std::enable_if_t< is_mpi_type< T >==false, T > broadcast(const MPI_Comm comm, const T &object_to_send, const unsigned int root_process=0)
T sum(const T &t, const MPI_Comm mpi_communicator)
T logical_or(const T &t, const MPI_Comm mpi_communicator)
std::unique_ptr< MPI_Datatype, void(*)(MPI_Datatype *)> create_mpi_data_type_n_bytes(const std::size_t n_bytes)
Future< T > irecv(MPI_Comm communicator, const unsigned int source_rank, const unsigned int mpi_tag=0)
std::map< unsigned int, T > some_to_some(const MPI_Comm comm, const std::map< unsigned int, T > &objects_to_send)
std::pair< Number, typename numbers::NumberTraits< Number >::real_type > mean_and_standard_deviation(const Iterator begin, const Iterator end, const MPI_Comm comm)
unsigned int n_mpi_processes(const MPI_Comm mpi_communicator)
std::vector< T > all_gather(const MPI_Comm comm, const T &object_to_send)
std::vector< unsigned int > compute_index_owner(const IndexSet &owned_indices, const IndexSet &indices_to_look_up, const MPI_Comm comm)
std::vector< T > compute_set_union(const std::vector< T > &vec, const MPI_Comm comm)
unsigned int this_mpi_process(const MPI_Comm mpi_communicator)
T all_reduce(const T &local_value, const MPI_Comm comm, const std::function< T(const T &, const T &)> &combiner)
IndexSet create_evenly_distributed_partitioning(const MPI_Comm comm, const types::global_dof_index total_size)
std::vector< unsigned int > compute_point_to_point_communication_pattern(const MPI_Comm mpi_comm, const std::vector< unsigned int > &destinations)
int create_group(const MPI_Comm comm, const MPI_Group &group, const int tag, MPI_Comm *new_comm)
MPI_Comm duplicate_communicator(const MPI_Comm mpi_communicator)
const std::vector< unsigned int > mpi_processes_within_communicator(const MPI_Comm comm_large, const MPI_Comm comm_small)
T reduce(const T &local_value, const MPI_Comm comm, const std::function< T(const T &, const T &)> &combiner, const unsigned int root_process=0)
const MPI_Datatype mpi_type_id_for_type
void free_communicator(MPI_Comm mpi_communicator)
unsigned int compute_n_point_to_point_communications(const MPI_Comm mpi_comm, const std::vector< unsigned int > &destinations)
std::vector< T > gather(const MPI_Comm comm, const T &object_to_send, const unsigned int root_process=0)
MinMaxAvg min_max_avg(const double my_value, const MPI_Comm mpi_communicator)
constexpr bool is_mpi_type
T scatter(const MPI_Comm comm, const std::vector< T > &objects_to_send, const unsigned int root_process=0)
Future< void > isend(const T &object, MPI_Comm communicator, const unsigned int target_rank, const unsigned int mpi_tag=0)
size_t pack(const T &object, std::vector< char > &dest_buffer, const bool allow_compression=true)
IndexSet create_evenly_distributed_partitioning(const unsigned int my_partition_id, const unsigned int n_partitions, const types::global_dof_index total_size)
static const unsigned int invalid_unsigned_int
const types::global_dof_index invalid_size_type
::VectorizedArray< Number, width > min(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &)
boost::signals2::signal< void()> at_mpi_init
boost::signals2::signal< void()> at_mpi_finalize
static constexpr real_type abs_square(const number &x)
void gather(VectorizedArray< Number, width > &out, const std::array< Number *, width > &ptrs, const unsigned int offset)