Stan Math Library  2.20.0
reverse mode automatic differentiation
mpi_distributed_apply.hpp
Go to the documentation of this file.
1 #ifdef STAN_MPI
2 
3 #ifndef STAN_MATH_PRIM_ARR_FUNCTOR_MPI_DISTRIBUTED_APPLY_HPP
4 #define STAN_MATH_PRIM_ARR_FUNCTOR_MPI_DISTRIBUTED_APPLY_HPP
5 
7 
8 #include <boost/serialization/nvp.hpp>
9 #include <boost/serialization/serialization.hpp>
10 #include <boost/serialization/access.hpp>
11 #include <boost/serialization/base_object.hpp>
12 
13 namespace stan {
14 namespace math {
15 
26 template <typename F>
27 struct mpi_distributed_apply : public mpi_command {
28  // declarations needed for boost.serialization (see
29  // https://www.boost.org/doc/libs/1_66_0/libs/serialization/doc/index.html)
30  friend class boost::serialization::access;
31  template <class Archive>
32  void serialize(Archive& ar, const unsigned int version) {
33  ar& BOOST_SERIALIZATION_BASE_OBJECT_NVP(mpi_command);
34  }
35 
40  void run() const { F::distributed_apply(); }
41 };
42 
43 } // namespace math
44 } // namespace stan
45 
46 #define STAN_REGISTER_MPI_DISTRIBUTED_APPLY(APPLY_FUNCTOR) \
47  STAN_REGISTER_MPI_COMMAND(stan::math::mpi_distributed_apply<APPLY_FUNCTOR>)
48 
49 #endif
50 
51 #endif

     [ Stan Home Page ] © 2011–2018, Stan Development Team.