ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
Loading...
Searching...
No Matches
script_interface/communication.hpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2022 The ESPResSo project
3
*
4
* This file is part of ESPResSo.
5
*
6
* ESPResSo is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* ESPResSo is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18
*/
19
#ifndef ESPRESSO_SRC_SCRIPT_INTERFACE_COMMUNICATION_HPP
20
#define ESPRESSO_SRC_SCRIPT_INTERFACE_COMMUNICATION_HPP
21
22
#include <boost/mpi/collectives/reduce.hpp>
23
#include <boost/mpi/communicator.hpp>
24
25
#include <cassert>
26
#include <functional>
27
28
namespace
ScriptInterface
{
29
30
/**
31
* @brief Reduce object by sum on the head node.
32
* Worker nodes get a default-constructed object.
33
*/
34
template
<
typename
T>
35
T
mpi_reduce_sum
(boost::mpi::communicator
const
&comm, T
const
&result) {
36
T out{};
37
boost::mpi::reduce(comm, result, out, std::plus<T>{}, 0);
38
return
out;
39
}
40
41
}
// namespace ScriptInterface
42
43
#endif
ScriptInterface
Definition
script_interface/accumulators/AccumulatorBase.hpp:33
ScriptInterface::mpi_reduce_sum
T mpi_reduce_sum(boost::mpi::communicator const &comm, T const &result)
Reduce object by sum on the head node.
Definition
script_interface/communication.hpp:35
src
script_interface
communication.hpp
Generated on Thu Dec 19 2024 02:13:16 for ESPResSo by
1.9.8