32 #ifndef VSMC_SMP_INTERNAL_PARALLEL_WORK_HPP
33 #define VSMC_SMP_INTERNAL_PARALLEL_WORK_HPP
50 template <
typename T,
typename IntType>
56 state_(state), copy_from_(copy_from) {}
58 template <
typename SizeType>
64 state_->copy_particle(
65 static_cast<size_type>(copy_from_[
id]),
66 static_cast<size_type>(
id));
69 template <
typename RangeType>
76 const const_iterator begin =
77 static_cast<const_iterator
>(range.begin());
78 const const_iterator end =
79 static_cast<const_iterator
>(range.end());
80 for (const_iterator
id = begin;
id != end; ++id)
87 const IntType *
const copy_from_;
90 template <
typename T,
typename InitType>
96 init_(init), particle_(particle), accept_(0) {}
98 template <
typename SplitType>
101 init_(other.init_), particle_(other.particle_), accept_(0) {}
103 template <
typename SizeType>
110 static_cast<size_type>(
id), particle_));
113 template <
typename RangeType>
120 const const_iterator begin =
121 static_cast<const_iterator
>(range.begin());
122 const const_iterator end =
123 static_cast<const_iterator
>(range.end());
124 for (const_iterator
id = begin;
id != end; ++id)
129 {accept_ += other.accept_;}
131 std::size_t
accept ()
const {
return accept_;}
135 InitType *
const init_;
140 template <
typename T,
typename MoveType>
149 move_(move), iter_(iter), particle_(particle), accept_(0) {}
151 template <
typename SplitType>
154 move_(other.move_), iter_(other.iter_), particle_(other.particle_),
157 template <
typename SizeType>
164 static_cast<size_type>(
id), particle_));
167 template <
typename RangeType>
174 const const_iterator begin =
175 static_cast<const_iterator
>(range.begin());
176 const const_iterator end =
177 static_cast<const_iterator
>(range.end());
178 for (const_iterator
id = begin;
id != end; ++id)
183 {accept_ += other.accept_;}
185 std::size_t
accept ()
const {
return accept_;}
189 MoveType *
const move_;
190 const std::size_t iter_;
195 template <
typename T,
typename MonitorEvalType>
201 std::size_t iter, std::size_t dim,
203 monitor_(monitor), iter_(iter), dim_(dim),
204 particle_(particle), res_(res) {}
206 template <
typename SizeType>
212 monitor_->monitor_state(iter_, dim_,
217 template <
typename RangeType>
224 const const_iterator begin =
225 static_cast<const_iterator
>(range.begin());
226 const const_iterator end =
227 static_cast<const_iterator
>(range.end());
228 for (const_iterator
id = begin;
id != end; ++id)
234 MonitorEvalType *
const monitor_;
235 const std::size_t iter_;
236 const std::size_t dim_;
241 template <
typename T,
typename PathEvalType>
248 path_(path), iter_(iter), particle_(particle), res_(res) {}
250 template <
typename SizeType>
256 res_[id] = path_->path_state(iter_,
260 template <
typename RangeType>
267 const const_iterator begin =
268 static_cast<const_iterator
>(range.begin());
269 const const_iterator end =
270 static_cast<const_iterator
>(range.end());
271 for (const_iterator
id = begin;
id != end; ++id)
277 PathEvalType *
const path_;
278 const std::size_t iter_;
287 #endif // VSMC_SMP_INTERNAL_PARALLEL_WORK_HPP
traits::SizeTypeTrait< T >::type size_type
void join(const ParallelInitializeState< T, InitType > &other)
Particle class representing the whole particle set.
void join(const ParallelMoveState< T, MoveType > &other)
std::size_t accept() const
cxx11::enable_if< cxx11::is_integral< SizeType >::value >::type operator()(SizeType id)
internal::RangeTypeConstIteratorDispatch< T, value >::type type
cxx11::enable_if< cxx11::is_integral< SizeType >::value >::type operator()(SizeType id) const
ParallelInitializeState(const ParallelInitializeState< T, InitType > &other, SplitType)
#define VSMC_DEFINE_TYPE_DISPATCH_TRAIT(Outer, Inner, Default)
cxx11::enable_if< cxx11::is_integral< SizeType >::value >::type operator()(SizeType id) const
remove_reference< T >::type && move(T &&t) noexcept
cxx11::enable_if< cxx11::is_integral< SizeType >::value >::type operator()(SizeType id)
ParallelCopyParticle(T *state, const IntType *copy_from)
internal::SizeTypeDispatch< T, value >::type type
ParallelMoveState(MoveType *move, std::size_t iter, Particle< T > *particle)
ParallelPathState(PathEvalType *path, std::size_t iter, const Particle< T > *particle, double *res)
ParallelInitializeState(InitType *init, Particle< T > *particle)
std::size_t accept() const
A thin wrapper over a complete Particle.
ParallelMonitorState(MonitorEvalType *monitor, std::size_t iter, std::size_t dim, const Particle< T > *particle, double *res)
ParallelMoveState(const ParallelMoveState< T, MoveType > &other, SplitType)
A const variant to SingleParticle.
cxx11::enable_if< cxx11::is_integral< SizeType >::value >::type operator()(SizeType id) const