]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/boost/graph/parallel/algorithm.hpp
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / boost / boost / graph / parallel / algorithm.hpp
1 // Copyright 2004 The Trustees of Indiana University.
2
3 // Use, modification and distribution is subject to the Boost Software
4 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
5 // http://www.boost.org/LICENSE_1_0.txt)
6
7 // Authors: Douglas Gregor
8 // Andrew Lumsdaine
9 #ifndef BOOST_PARALLEL_ALGORITHM_HPP
10 #define BOOST_PARALLEL_ALGORITHM_HPP
11
12 #ifndef BOOST_GRAPH_USE_MPI
13 #error "Parallel BGL files should not be included unless <boost/graph/use_mpi.hpp> has been included"
14 #endif
15
16 #include <boost/optional.hpp>
17 #include <boost/config.hpp> // for BOOST_STATIC_CONSTANT
18 #include <vector>
19
20 namespace boost { namespace parallel {
21 template<typename BinaryOp>
22 struct is_commutative
23 {
24 BOOST_STATIC_CONSTANT(bool, value = false);
25 };
26
27 template<typename T>
28 struct minimum
29 {
30 typedef T first_argument_type;
31 typedef T second_argument_type;
32 typedef T result_type;
33 const T& operator()(const T& x, const T& y) const { return x < y? x : y; }
34 };
35
36 template<typename T>
37 struct maximum
38 {
39 typedef T first_argument_type;
40 typedef T second_argument_type;
41 typedef T result_type;
42 const T& operator()(const T& x, const T& y) const { return x < y? y : x; }
43 };
44
45 template<typename T>
46 struct sum
47 {
48 typedef T first_argument_type;
49 typedef T second_argument_type;
50 typedef T result_type;
51 const T operator()(const T& x, const T& y) const { return x + y; }
52 };
53
54 template<typename ProcessGroup, typename InputIterator,
55 typename OutputIterator, typename BinaryOperation>
56 OutputIterator
57 reduce(ProcessGroup pg, typename ProcessGroup::process_id_type root,
58 InputIterator first, InputIterator last, OutputIterator out,
59 BinaryOperation bin_op);
60
61 template<typename ProcessGroup, typename T, typename BinaryOperation>
62 inline T
63 all_reduce(ProcessGroup pg, const T& value, BinaryOperation bin_op)
64 {
65 T result;
66 all_reduce(pg,
67 const_cast<T*>(&value), const_cast<T*>(&value+1),
68 &result, bin_op);
69 return result;
70 }
71
72 template<typename ProcessGroup, typename T, typename BinaryOperation>
73 inline T
74 scan(ProcessGroup pg, const T& value, BinaryOperation bin_op)
75 {
76 T result;
77 scan(pg,
78 const_cast<T*>(&value), const_cast<T*>(&value+1),
79 &result, bin_op);
80 return result;
81 }
82
83
84 template<typename ProcessGroup, typename InputIterator, typename T>
85 void
86 all_gather(ProcessGroup pg, InputIterator first, InputIterator last,
87 std::vector<T>& out);
88 } } // end namespace boost::parallel
89
90 #include <boost/graph/parallel/detail/inplace_all_to_all.hpp>
91
92 #endif // BOOST_PARALLEL_ALGORITHM_HPP