Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:42:50

0001 /*
0002  [auto_generated]
0003  boost/numeric/odeint/external/mpi/mpi_nested_algebra.hpp
0004 
0005  [begin_description]
0006  Nested parallelized algebra for MPI.
0007  [end_description]
0008 
0009  Copyright 2013 Karsten Ahnert
0010  Copyright 2013 Mario Mulansky
0011  Copyright 2013 Pascal Germroth
0012 
0013  Distributed under the Boost Software License, Version 1.0.
0014  (See accompanying file LICENSE_1_0.txt or
0015  copy at http://www.boost.org/LICENSE_1_0.txt)
0016  */
0017 
0018 
0019 #ifndef BOOST_NUMERIC_ODEINT_EXTERNAL_MPI_MPI_NESTED_ALGEBRA_HPP_INCLUDED
0020 #define BOOST_NUMERIC_ODEINT_EXTERNAL_MPI_MPI_NESTED_ALGEBRA_HPP_INCLUDED
0021 
0022 #include <boost/numeric/odeint/algebra/norm_result_type.hpp>
0023 #include <boost/numeric/odeint/util/n_ary_helper.hpp>
0024 
0025 namespace boost {
0026 namespace numeric {
0027 namespace odeint {
0028 
0029 /** \brief MPI-parallelized algebra, wrapping another algebra.
0030  */
0031 template< class InnerAlgebra >
0032 struct mpi_nested_algebra
0033 {
0034 
0035 // execute the InnerAlgebra on each node's local data.
0036 #define BOOST_ODEINT_GEN_BODY(n) \
0037     InnerAlgebra::for_each##n( \
0038         BOOST_PP_ENUM_BINARY_PARAMS(n, s, () BOOST_PP_INTERCEPT) , \
0039         op \
0040     );
0041 BOOST_ODEINT_GEN_FOR_EACH(BOOST_ODEINT_GEN_BODY)
0042 #undef BOOST_ODEINT_GEN_BODY
0043 
0044 
0045     template< class NestedState >
0046     static typename norm_result_type< typename NestedState::value_type >::type norm_inf( const NestedState &s )
0047     {
0048         typedef typename norm_result_type< typename NestedState::value_type >::type result_type;
0049         // local maximum
0050         result_type value = InnerAlgebra::norm_inf( s() );
0051         // global maximum
0052         return boost::mpi::all_reduce(s.world, value, boost::mpi::maximum<result_type>());
0053     }
0054 
0055 };
0056 
0057 
0058 }
0059 }
0060 }
0061 
0062 #endif