32 #ifndef VSMC_SMP_BACKEND_PPL_HPP
33 #define VSMC_SMP_BACKEND_PPL_HPP
51 explicit StatePPL (size_type N) : BaseState(N) {}
53 template <
typename IntType>
54 void copy (size_type N,
const IntType *copy_from)
59 copy_work_<IntType>(
this, copy_from));
64 template <
typename IntType>
68 state_(state), copy_from_(copy_from) {}
70 void operator() (size_type to)
const
71 {state_->copy_particle(copy_from_[to], to);}
75 StatePPL<BaseState> *
const state_;
76 const IntType *
const copy_from_;
82 template <
typename T,
typename Derived>
83 class InitializePPL :
public InitializeBase<T, Derived>
90 const size_type N =
static_cast<size_type
>(particle.
size());
93 ::concurrency::combinable<std::size_t> accept(accept_init_);
95 work_(
this, &particle, &accept));
98 return accept.combine(accept_accu_);
113 ::concurrency::combinable<std::size_t> *accept) :
114 init_(init), particle_(particle), accept_(accept) {}
118 accept_->local() += init_->initialize_state(
126 ::concurrency::combinable<std::size_t> *
const accept_;
129 static std::size_t accept_init_ () {
return 0;}
130 static std::size_t accept_accu_ (std::size_t a, std::size_t b)
136 template <
typename T,
typename Derived>
137 class MovePPL :
public MoveBase<T, Derived>
144 const size_type N =
static_cast<size_type
>(particle.
size());
146 ::concurrency::combinable<std::size_t> accept(accept_init_);
148 work_(
this, iter, &particle, &accept));
151 return accept.combine(accept_accu_);
166 ::concurrency::combinable<std::size_t> *accept):
167 move_(move), particle_(particle), accept_(accept), iter_(iter) {}
171 accept_->local() += move_->move_state(iter_,
179 ::concurrency::combinable<std::size_t> *
const accept_;
180 const std::size_t iter_;
183 static std::size_t accept_init_ () {
return 0;}
184 static std::size_t accept_accu_ (std::size_t a, std::size_t b)
190 template <
typename T,
typename Derived>
191 class MonitorEvalPPL :
public MonitorEvalBase<T, Derived>
199 const size_type N =
static_cast<size_type
>(particle.
size());
202 work_(
this, iter, dim, &particle, res));
217 std::size_t iter, std::size_t dim,
219 monitor_(monitor), particle_(particle), res_(res),
220 iter_(iter), dim_(dim) {}
224 monitor_->monitor_state(iter_, dim_,
233 const std::size_t iter_;
234 const std::size_t dim_;
240 template <
typename T,
typename Derived>
241 class PathEvalPPL :
public PathEvalBase<T, Derived>
249 const size_type N =
static_cast<size_type
>(particle.
size());
252 work_(
this, iter, &particle, res));
270 path_(path), particle_(particle), res_(res), iter_(iter) {}
274 res_[i] = path_->path_state(iter_,
283 const std::size_t iter_;
289 #endif // VSMC_SMP_BACKEND_PPL_HPP
Sampler::init_type subtype using Parallel Pattern Library.
Particle class representing the whole particle set.
void initialize_param(Particle< T > &particle, void *param)
traits::SizeTypeTrait< BaseState >::type size_type
#define VSMC_RUNTIME_ASSERT_SMP_BACKEND_BASE_COPY_SIZE_MISMATCH(name)
Path::eval_type subtype using Parallel Pattern Library.
void pre_processor(Particle< T > &particle)
void post_processor(std::size_t iter, const Particle< T > &particle)
double path_grid(std::size_t iter, const Particle< T > &particle)
void post_processor(std::size_t iter, Particle< T > &particle)
void operator()(std::size_t iter, std::size_t dim, const Particle< T > &particle, double *res)
void pre_processor(std::size_t iter, Particle< T > &particle)
void post_processor(std::size_t iter, const Particle< T > &particle)
void copy(size_type N, const IntType *copy_from)
Monitor::eval_type subtype using Parallel Pattern Library.
remove_reference< T >::type && move(T &&t) noexcept
void pre_processor(std::size_t iter, const Particle< T > &particle)
Sampler::move_type subtype using Parallel Pattern Library.
traits::SizeTypeTrait< T >::type size_type
internal::SizeTypeDispatch< T, value >::type type
void post_processor(Particle< T > &particle)
Particle::value_type subtype using Parallel Pattern Library.
size_type size() const
Number of particles.
std::size_t operator()(Particle< T > &particle, void *param)
A thin wrapper over a complete Particle.
void pre_processor(std::size_t iter, const Particle< T > &particle)
std::size_t operator()(std::size_t iter, Particle< T > &particle)
#define VSMC_DEFINE_SMP_FORWARD(Name)
A const variant to SingleParticle.
#define VSMC_DEFINE_SMP_IMPL_COPY(Impl, Name)
double operator()(std::size_t iter, const Particle< T > &particle, double *res)
void parallel_for(const Range &range, WorkType &&work)
Parallel for using std::thread.