TRIQS/mpi 1.3.0
C++ interface to MPI
Loading...
Searching...
No Matches
pair.hpp
Go to the documentation of this file.
1// Copyright (c) 2021-2024 Simons Foundation
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0.txt
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14//
15// Authors: Thomas Hahn, Nils Wentzell
16
22#pragma once
23
24#include "./mpi.hpp"
25
26#include <mpi.h>
27
28#include <utility>
29
30namespace mpi {
31
48 template <typename T1, typename T2> void mpi_broadcast(std::pair<T1, T2> &p, communicator c = {}, int root = 0) {
49 broadcast(p.first, c, root);
50 broadcast(p.second, c, root);
51 }
52
67 template <typename T1, typename T2>
68 auto mpi_reduce(std::pair<T1, T2> const &p, communicator c = {}, int root = 0, bool all = false, MPI_Op op = MPI_SUM) {
69 return std::make_pair(reduce(p.first, c, root, all, op), reduce(p.second, c, root, all, op));
70 }
71
74} // namespace mpi
C++ wrapper around MPI_Comm providing various convenience functions.
auto mpi_reduce(std::array< T, N > const &arr, communicator c={}, int root=0, bool all=false, MPI_Op op=MPI_SUM)
Implementation of an MPI reduce for a std::array.
Definition array.hpp:86
decltype(auto) reduce(T &&x, communicator c={}, int root=0, bool all=false, MPI_Op op=MPI_SUM)
Generic MPI reduce.
void mpi_broadcast(std::array< T, N > &arr, communicator c={}, int root=0)
Implementation of an MPI broadcast for a std::arr.
Definition array.hpp:51
void broadcast(T &&x, communicator c={}, int root=0)
Generic MPI broadcast.
Includes all relevant mpi headers.