]>
Commit | Line | Data |
---|---|---|
1 | /* | |
2 | [auto_generated] | |
3 | boost/numeric/odeint/external/mpi/mpi_nested_algebra.hpp | |
4 | ||
5 | [begin_description] | |
6 | Nested parallelized algebra for MPI. | |
7 | [end_description] | |
8 | ||
9 | Copyright 2013 Karsten Ahnert | |
10 | Copyright 2013 Mario Mulansky | |
11 | Copyright 2013 Pascal Germroth | |
12 | ||
13 | Distributed under the Boost Software License, Version 1.0. | |
14 | (See accompanying file LICENSE_1_0.txt or | |
15 | copy at http://www.boost.org/LICENSE_1_0.txt) | |
16 | */ | |
17 | ||
18 | ||
19 | #ifndef BOOST_NUMERIC_ODEINT_EXTERNAL_MPI_MPI_NESTED_ALGEBRA_HPP_INCLUDED | |
20 | #define BOOST_NUMERIC_ODEINT_EXTERNAL_MPI_MPI_NESTED_ALGEBRA_HPP_INCLUDED | |
21 | ||
22 | #include <boost/numeric/odeint/algebra/norm_result_type.hpp> | |
23 | #include <boost/numeric/odeint/util/n_ary_helper.hpp> | |
24 | ||
25 | namespace boost { | |
26 | namespace numeric { | |
27 | namespace odeint { | |
28 | ||
29 | /** \brief MPI-parallelized algebra, wrapping another algebra. | |
30 | */ | |
31 | template< class InnerAlgebra > | |
32 | struct mpi_nested_algebra | |
33 | { | |
34 | ||
35 | // execute the InnerAlgebra on each node's local data. | |
36 | #define BOOST_ODEINT_GEN_BODY(n) \ | |
37 | InnerAlgebra::for_each##n( \ | |
38 | BOOST_PP_ENUM_BINARY_PARAMS(n, s, () BOOST_PP_INTERCEPT) , \ | |
39 | op \ | |
40 | ); | |
41 | BOOST_ODEINT_GEN_FOR_EACH(BOOST_ODEINT_GEN_BODY) | |
42 | #undef BOOST_ODEINT_GEN_BODY | |
43 | ||
44 | ||
45 | template< class NestedState > | |
46 | static typename norm_result_type< typename NestedState::value_type >::type norm_inf( const NestedState &s ) | |
47 | { | |
48 | typedef typename norm_result_type< typename NestedState::value_type >::type result_type; | |
49 | // local maximum | |
50 | result_type value = InnerAlgebra::norm_inf( s() ); | |
51 | // global maximum | |
52 | return boost::mpi::all_reduce(s.world, value, boost::mpi::maximum<result_type>()); | |
53 | } | |
54 | ||
55 | }; | |
56 | ||
57 | ||
58 | } | |
59 | } | |
60 | } | |
61 | ||
62 | #endif |