Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:37:20

0001 // Copyright 2004 The Trustees of Indiana University.
0002 
0003 // Use, modification and distribution is subject to the Boost Software
0004 // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
0005 // http://www.boost.org/LICENSE_1_0.txt)
0006 
0007 //  Authors: Douglas Gregor
0008 //           Andrew Lumsdaine
0009 #ifndef BOOST_PARALLEL_ALGORITHM_HPP
0010 #define BOOST_PARALLEL_ALGORITHM_HPP
0011 
0012 #ifndef BOOST_GRAPH_USE_MPI
0013 #error "Parallel BGL files should not be included unless <boost/graph/use_mpi.hpp> has been included"
0014 #endif
0015 
0016 #include <boost/optional.hpp>
0017 #include <boost/config.hpp> // for BOOST_STATIC_CONSTANT
0018 #include <vector>
0019 
0020 namespace boost { namespace parallel {
0021   template<typename BinaryOp>
0022   struct is_commutative
0023   {
0024     BOOST_STATIC_CONSTANT(bool, value = false);
0025   };
0026 
0027   template<typename T>
0028   struct minimum
0029   {
0030     typedef T first_argument_type;
0031     typedef T second_argument_type;
0032     typedef T result_type;
0033     const T& operator()(const T& x, const T& y) const { return x < y? x : y; }
0034   };
0035 
0036   template<typename T>
0037   struct maximum
0038   {
0039     typedef T first_argument_type;
0040     typedef T second_argument_type;
0041     typedef T result_type;
0042     const T& operator()(const T& x, const T& y) const { return x < y? y : x; }
0043   };
0044 
0045   template<typename T>
0046   struct sum
0047   {
0048     typedef T first_argument_type;
0049     typedef T second_argument_type;
0050     typedef T result_type;
0051     const T operator()(const T& x, const T& y) const { return x + y; }
0052   };
0053 
0054   template<typename ProcessGroup, typename InputIterator,
0055            typename OutputIterator, typename BinaryOperation>
0056   OutputIterator
0057   reduce(ProcessGroup pg, typename ProcessGroup::process_id_type root,
0058          InputIterator first, InputIterator last, OutputIterator out,
0059          BinaryOperation bin_op);
0060 
0061   template<typename ProcessGroup, typename T, typename BinaryOperation>
0062   inline T
0063   all_reduce(ProcessGroup pg, const T& value, BinaryOperation bin_op)
0064   {
0065     T result;
0066     all_reduce(pg,
0067                const_cast<T*>(&value), const_cast<T*>(&value+1),
0068                &result, bin_op);
0069     return result;
0070   }
0071 
0072   template<typename ProcessGroup, typename T, typename BinaryOperation>
0073   inline T
0074   scan(ProcessGroup pg, const T& value, BinaryOperation bin_op)
0075   {
0076     T result;
0077     scan(pg,
0078          const_cast<T*>(&value), const_cast<T*>(&value+1),
0079          &result, bin_op);
0080     return result;
0081   }
0082 
0083 
0084   template<typename ProcessGroup, typename InputIterator, typename T>
0085   void
0086   all_gather(ProcessGroup pg, InputIterator first, InputIterator last,
0087              std::vector<T>& out);
0088 } } // end namespace boost::parallel
0089 
0090 #include <boost/graph/parallel/detail/inplace_all_to_all.hpp>
0091 
0092 #endif // BOOST_PARALLEL_ALGORITHM_HPP