123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- #ifndef BOOST_NUMERIC_ODEINT_EXTERNAL_MPI_MPI_STATE_HPP_INCLUDED
- #define BOOST_NUMERIC_ODEINT_EXTERNAL_MPI_MPI_STATE_HPP_INCLUDED
- #include <vector>
- #include <algorithm>
- #include <boost/mpi.hpp>
- #include <boost/numeric/odeint/util/copy.hpp>
- #include <boost/numeric/odeint/util/split.hpp>
- #include <boost/numeric/odeint/util/resize.hpp>
- #include <boost/numeric/odeint/util/same_size.hpp>
- #include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
- #include <boost/numeric/odeint/external/mpi/mpi_nested_algebra.hpp>
- namespace boost {
- namespace numeric {
- namespace odeint {
- template< class InnerState >
- struct mpi_state
- {
- typedef InnerState value_type;
-
- InnerState m_data;
- boost::mpi::communicator world;
- mpi_state() {}
- mpi_state(boost::mpi::communicator comm) : world(comm) {}
- inline InnerState &operator()() { return m_data; }
- inline const InnerState &operator()() const { return m_data; }
- };
- template< class InnerState >
- struct is_resizeable< mpi_state< InnerState > >
- : is_resizeable< InnerState > { };
- template< class InnerState1 , class InnerState2 >
- struct same_size_impl< mpi_state< InnerState1 > , mpi_state< InnerState2 > >
- {
- static bool same_size( const mpi_state< InnerState1 > &x , const mpi_state< InnerState2 > &y )
- {
- const bool local = boost::numeric::odeint::same_size(x(), y());
- return boost::mpi::all_reduce(x.world, local, mpi::bitwise_and<bool>());
- }
- };
- template< class InnerState1 , class InnerState2 >
- struct resize_impl< mpi_state< InnerState1 > , mpi_state< InnerState2 > >
- {
- static void resize( mpi_state< InnerState1 > &x , const mpi_state< InnerState2 > &y )
- {
-
- boost::numeric::odeint::resize(x(), y());
- }
- };
- template< class InnerState1 , class InnerState2 >
- struct copy_impl< mpi_state< InnerState1 > , mpi_state< InnerState2 > >
- {
- static void copy( const mpi_state< InnerState1 > &from , mpi_state< InnerState2 > &to )
- {
-
- boost::numeric::odeint::copy(from(), to());
- }
- };
- template< class InnerState >
- struct algebra_dispatcher< mpi_state< InnerState > >
- {
- typedef mpi_nested_algebra<
- typename algebra_dispatcher< InnerState >::algebra_type
- > algebra_type;
- };
- }
- }
- }
- #endif
|