37#ifdef DEAL_II_WITH_MPI
57#ifdef DEAL_II_WITH_MPI
58# define DEAL_II_MPI_CONST_CAST(expr) (expr)
68template <
int rank,
int dim,
typename Number>
70template <
int rank,
int dim,
typename Number>
72template <
typename Number>
114 template <
typename T>
132 std::complex<double>,
133 std::complex<long double>,
162 std::vector<unsigned int>
187 std::vector<unsigned int>
464 template <
typename T>
472 template <
typename W,
typename G>
573#ifdef DEAL_II_WITH_MPI
589 template <
class Iterator,
typename Number =
long double>
590 std::pair<Number, typename numbers::NumberTraits<Number>::real_type>
666 template <
typename T>
679 template <
typename T,
typename U>
692 template <
typename T>
703 template <
int rank,
int dim,
typename Number>
713 template <
int rank,
int dim,
typename Number>
726 template <
typename Number>
751 template <
typename T>
764 template <
typename T,
typename U>
777 template <
typename T>
802 template <
typename T>
815 template <
typename T,
typename U>
828 template <
typename T>
857 template <
typename T>
875 template <
typename T,
typename U>
888 template <
typename T>
983 std::vector<MinMaxAvg>
1140 template <
typename T>
1141 std::map<unsigned int, T>
1158 template <
typename T>
1177 template <
typename T>
1197 template <
typename T>
1241 template <
typename T>
1263 template <
typename T>
1266 const std::size_t
count,
1267 const unsigned int root,
1282 template <
typename T>
1286 const std::function<T(
const T &,
const T &)> &
combiner,
1301 template <
typename T,
typename = std::enable_if_t<is_mpi_type<T> == true>>
1315 template <
typename T>
1319 const std::function<T(
const T &,
const T &)> &
combiner);
1342 template <
typename T>
1347 const unsigned int mpi_tag = 0);
1366 template <
typename T>
1370 const unsigned int mpi_tag = 0);
1416 std::vector<unsigned int>
1431 std::pair<std::vector<unsigned int>, std::map<unsigned int, IndexSet>>
1443 template <
typename T>
1450 template <
typename T>
1465 namespace MPIDataTypes
1467#ifdef DEAL_II_WITH_MPI
1615#ifdef DEAL_II_WITH_MPI
1633 template <
typename T>
1636 static_cast<std::remove_cv_t<std::remove_reference_t<T>
> *>(
nullptr));
1643 template <
typename T>
1652 template <
typename T>
1653 template <
typename W,
typename G>
1663 template <
typename T>
1664 Future<T>::~Future()
1674 if ((get_was_called ==
false) && get_and_cleanup_function)
1680 template <
typename T>
1684 if (is_done ==
false)
1693 template <
typename T>
1697 Assert(get_was_called ==
false,
1699 "You can't call get() more than once on a Future object."));
1700 get_was_called =
true;
1703 return get_and_cleanup_function();
1708 template <
typename T,
unsigned int N>
1710 sum(
const T (&values)[N],
const MPI_Comm mpi_communicator, T (&
sums)[N])
1720 template <
typename T,
unsigned int N>
1732 template <
typename T,
unsigned int N>
1744 template <
typename T,
unsigned int N>
1750 static_assert(std::is_integral_v<T>,
1751 "The MPI_LOR operation only allows integral data types.");
1761 template <
typename T>
1762 std::map<unsigned int, T>
1766# ifndef DEAL_II_WITH_MPI
1769 ExcMessage(
"Cannot send to more than one processor."));
1772 ExcMessage(
"Can only send to myself or to nobody."));
1779 std::vector<unsigned int>
send_to;
1785 send_to.emplace_back(m.first);
1791 static CollectiveMutex mutex;
1792 CollectiveMutex::ScopedLock lock(mutex,
comm);
1802 internal::Tags::compute_point_to_point_communication_pattern;
1829 std::vector<char>
buffer;
1845 const unsigned int rank = status.MPI_SOURCE;
1858 "I should not receive again from this rank"));
1860 Utilities::unpack<T>(
buffer,
1877 template <
typename T,
typename>
1881# ifndef DEAL_II_WITH_MPI
1915 template <
typename T>
1922# ifndef DEAL_II_WITH_MPI
1924 std::vector<T> v(1,
object);
1945 for (
unsigned int i = 1; i <
n_procs; ++i)
1963 for (
unsigned int i = 0; i <
n_procs; ++i)
1978 template <
typename T>
1984# ifndef DEAL_II_WITH_MPI
2021 for (
unsigned int i = 1; i <
n_procs; ++i)
2046 for (
unsigned int i = 0; i <
n_procs; ++i)
2061 template <
typename T>
2067# ifndef DEAL_II_WITH_MPI
2083 "The number of objects to be scattered must correspond to the number processes."));
2094 for (
unsigned int i = 0; i <
n_procs; ++i)
2103 for (
unsigned int i = 0; i <
n_procs; ++i)
2136 template <
typename T>
2139 const std::size_t
count,
2140 const unsigned int root,
2143# ifndef DEAL_II_WITH_MPI
2154 const size_t max_send_count = std::numeric_limits<signed int>::max();
2164 mpi_type_id_for_type<
decltype(*
buffer)>,
2175 template <
typename T>
2181# ifndef DEAL_II_WITH_MPI
2201 std::vector<char>
buffer;
2230 return Utilities::unpack<T>(
buffer,
false);
2237 template <
typename T>
2239 isend(
const T &
object,
2244# ifndef DEAL_II_WITH_MPI
2270 MPI_Request request;
2274 mpi_type_id_for_type<
decltype(*
send_buffer->data())>,
2294 auto wait = [request]()
mutable {
2307 template <
typename T>
2313# ifndef DEAL_II_WITH_MPI
2334 std::shared_ptr<MPI_Message>
message = std::make_shared<MPI_Message>();
2335 std::shared_ptr<MPI_Status> status = std::make_shared<MPI_Status>();
2345 auto get = [status,
message]() {
2372# ifdef DEAL_II_WITH_MPI
2373 template <
class Iterator,
typename Number>
2374 std::pair<Number, typename numbers::NumberTraits<Number>::real_type>
2385 const Number
sum = std::accumulate(begin, end, Number(0.));
2392 std::for_each(begin, end, [&mean, &
sq_sum](
const Number &v) {
2396 return std::make_pair(mean,
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)
~MPI_InitFinalize()=default
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
#define DEAL_II_NAMESPACE_CLOSE
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
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)
const unsigned int my_rank
const IndexSet & indices_to_look_up
std::vector< index_type > data
const IndexSet & owned_indices
types::global_dof_index locally_owned_size
const unsigned int n_procs
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::pair< std::vector< unsigned int >, std::map< unsigned int, IndexSet > > compute_index_owner_and_requesters(const IndexSet &owned_indices, const IndexSet &indices_to_look_up, const MPI_Comm &comm)
std::pair< T, T > partial_and_total_sum(const T &value, const MPI_Comm comm)
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)
T max(const T &t, const MPI_Comm mpi_communicator)
T min(const T &t, 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)
MPI_Comm duplicate_communicator(const MPI_Comm mpi_communicator)
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)
std::vector< unsigned int > mpi_processes_within_communicator(const MPI_Comm comm_large, const MPI_Comm comm_small)
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)
T broadcast(const MPI_Comm comm, const T &object_to_send, const unsigned int root_process=0)
std::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)
constexpr types::global_dof_index invalid_size_type
constexpr unsigned int invalid_unsigned_int
::VectorizedArray< Number, width > min(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &)
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)