Automatic Differentiation
 
Loading...
Searching...
No Matches
mpi_distributed_apply.hpp
Go to the documentation of this file.
1#ifdef STAN_MPI
2
3#ifndef STAN_MATH_PRIM_FUNCTOR_MPI_DISTRIBUTED_APPLY_HPP
4#define STAN_MATH_PRIM_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
13namespace stan {
14namespace math {
15
26template <typename F>
28 // declarations needed for boost.serialization (see
29 // https://www.boost.org/doc/libs/1_66_0/libs/serialization/doc/index.html)
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
The lgamma implementation in stan-math is based on either the reentrant safe lgamma_r implementation ...
A MPI command object is used to execute code on worker nodes.
friend class boost::serialization::access
void run() const
Executes the static member distributed_apply of the given functor F.
void serialize(Archive &ar, const unsigned int version)
MPI command template which calls the static method distributed_apply of the given class F.