32 #ifndef VSMC_SMP_BACKEND_TBB_HPP 33 #define VSMC_SMP_BACKEND_TBB_HPP 38 #define VSMC_DEFINE_SMP_BACKEND_TBB_PARALLEL_RUN_INITIALIZE(args) \ 39 this->eval_param(particle, param); \ 40 this->eval_pre(particle); \ 41 work_type work(this, &particle); \ 42 ::tbb::parallel_reduce args; \ 43 this->eval_post(particle); \ 46 #define VSMC_DEFINE_SMP_BACKEND_TBB_PARALLEL_RUN_MOVE(args) \ 47 this->eval_pre(iter, particle); \ 48 work_type work(this, iter, &particle); \ 49 ::tbb::parallel_reduce args; \ 50 this->eval_post(iter, particle); \ 53 #define VSMC_DEFINE_SMP_BACKEND_TBB_PARALLEL_RUN_MONITOR_EVAL(args) \ 54 this->eval_pre(iter, particle); \ 55 work_type work(this, iter, dim, &particle, r); \ 56 ::tbb::parallel_for args; \ 57 this->eval_post(iter, particle); 74 template <
typename IntType>
77 parallel_copy_run(index, ::tbb::blocked_range<size_type>(0, N));
81 template <
typename IntType>
86 : state_(state), index_(index)
90 void operator()(const ::tbb::blocked_range<size_type> &range)
const 92 for (
size_type i = range.begin(); i != range.end(); ++i) {
93 state_->copy_particle(static_cast<size_type>(index_[i]), i);
99 const IntType *
const index_;
102 template <
typename IntType>
104 const IntType *index, const ::tbb::blocked_range<size_type> &range)
109 template <
typename IntType>
111 const ::tbb::blocked_range<size_type> &range,
112 const ::tbb::auto_partitioner &partitioner)
118 template <
typename IntType>
120 const ::tbb::blocked_range<size_type> &range,
121 const ::tbb::simple_partitioner &partitioner)
127 template <
typename IntType>
129 const ::tbb::blocked_range<size_type> &range,
130 ::tbb::affinity_partitioner &partitioner)
136 #if __TBB_TASK_GROUP_CONTEXT 137 template <
typename IntType>
139 const ::tbb::blocked_range<size_type> &range,
140 const ::tbb::auto_partitioner &partitioner,
141 ::tbb::task_group_context &context)
147 template <
typename IntType>
149 const ::tbb::blocked_range<size_type> &range,
150 const ::tbb::simple_partitioner &partitioner,
151 ::tbb::task_group_context &context)
157 template <
typename IntType>
159 const ::tbb::blocked_range<size_type> &range,
160 ::tbb::affinity_partitioner &partitioner,
161 ::tbb::task_group_context &context)
166 #endif // __TBB_TASK_GROUP_CONTEXT 171 template <
typename T,
typename Derived>
177 return parallel_run(particle, param,
179 0, particle.
size()));
191 : wptr_(wptr), pptr_(pptr), accept_(0)
196 : wptr_(other.wptr_), pptr_(other.pptr_), accept_(0)
200 void operator()(const ::tbb::blocked_range<size_type> &range)
202 for (
size_type i = range.begin(); i != range.end(); ++i)
203 accept_ += wptr_->eval_sp(pptr_->sp(i));
206 void join(
const work_type &other) { accept_ += other.accept_; }
208 std::size_t
accept()
const {
return accept_; }
224 const ::tbb::auto_partitioner &partitioner)
227 (range, work, partitioner));
232 const ::tbb::simple_partitioner &partitioner)
235 (range, work, partitioner));
240 ::tbb::affinity_partitioner &partitioner)
243 (range, work, partitioner));
246 #if __TBB_TASK_GROUP_CONTEXT 249 const ::tbb::auto_partitioner &partitioner,
250 ::tbb::task_group_context &context)
253 (range, work, partitioner, context));
258 const ::tbb::simple_partitioner &partitioner,
259 ::tbb::task_group_context &context)
262 (range, work, partitioner, context));
267 ::tbb::affinity_partitioner &partitioner,
268 ::tbb::task_group_context &context)
271 (range, work, partitioner, context));
273 #endif // __TBB_TASK_GROUP_CONTEXT 278 template <
typename T,
typename Derived>
284 return parallel_run(iter, particle,
286 0, particle.
size()));
299 : wptr_(wptr), iter_(iter), pptr_(pptr), accept_(0)
311 void operator()(const ::tbb::blocked_range<size_type> &range)
313 for (
size_type i = range.begin(); i != range.end(); ++i)
314 accept_ += wptr_->eval_sp(iter_, pptr_->sp(i));
317 void join(
const work_type &other) { accept_ += other.accept_; }
319 std::size_t
accept()
const {
return accept_; }
323 const std::size_t iter_;
336 const ::tbb::auto_partitioner &partitioner)
339 (range, work, partitioner));
344 const ::tbb::simple_partitioner &partitioner)
347 (range, work, partitioner));
352 ::tbb::affinity_partitioner &partitioner)
355 (range, work, partitioner));
358 #if __TBB_TASK_GROUP_CONTEXT 361 const ::tbb::auto_partitioner &partitioner,
362 ::tbb::task_group_context &context)
365 (range, work, partitioner, context));
370 const ::tbb::simple_partitioner &partitioner,
371 ::tbb::task_group_context &context)
374 (range, work, partitioner, context));
379 ::tbb::affinity_partitioner &partitioner,
380 ::tbb::task_group_context &context)
383 (range, work, partitioner, context));
385 #endif // __TBB_TASK_GROUP_CONTEXT 390 template <
typename T,
typename Derived>
395 std::size_t iter, std::size_t dim,
Particle<T> &particle,
double *r)
397 parallel_run(iter, dim, particle, r,
399 0, particle.
size()));
412 : wptr_(wptr), iter_(iter), dim_(dim), pptr_(pptr), r_(r)
416 void operator()(const ::tbb::blocked_range<size_type> &range)
const 418 for (
size_type i = range.begin(); i != range.end(); ++i) {
419 wptr_->eval_sp(iter_, dim_, pptr_->sp(i),
420 r_ +
static_cast<std::size_t
>(i) * dim_);
426 const std::size_t iter_;
427 const std::size_t dim_;
442 const ::tbb::auto_partitioner &partitioner)
445 (range, work, partitioner));
451 const ::tbb::simple_partitioner &partitioner)
454 (range, work, partitioner));
460 ::tbb::affinity_partitioner &partitioner)
463 (range, work, partitioner));
466 #if __TBB_TASK_GROUP_CONTEXT 470 const ::tbb::auto_partitioner &partitioner,
471 ::tbb::task_group_context &context)
474 (range, work, partitioner, context));
480 const ::tbb::simple_partitioner &partitioner,
481 ::tbb::task_group_context &context)
484 (range, work, partitioner, context));
490 ::tbb::affinity_partitioner &partitioner,
491 ::tbb::task_group_context &context)
494 (range, work, partitioner, context));
496 #endif // __TBB_TASK_GROUP_CONTEXT 501 #endif // VSMC_SMP_BACKEND_TBB_HPP
Particle class representing the whole particle set.
void parallel_copy_run(const IntType *index, const ::tbb::blocked_range< size_type > &range, const ::tbb::auto_partitioner &partitioner)
std::size_t accept() const
Sampler<T>::init_type subtype using Intel Threading Building Blocks.
void join(const work_type &other)
std::size_t parallel_run(Particle< T > &particle, void *param, const ::tbb::blocked_range< typename Particle< T >::size_type > &range, const ::tbb::auto_partitioner &partitioner,::tbb::task_group_context &context)
void operator()(const ::tbb::blocked_range< size_type > &range)
void operator()(const ::tbb::blocked_range< size_type > &range) const
void parallel_run(std::size_t iter, std::size_t dim, Particle< T > &particle, double *r, const ::tbb::blocked_range< typename Particle< T >::size_type > &range, const ::tbb::simple_partitioner &partitioner)
std::size_t parallel_run(Particle< T > &particle, void *param, const ::tbb::blocked_range< typename Particle< T >::size_type > &range,::tbb::affinity_partitioner &partitioner,::tbb::task_group_context &context)
Monitor evalution base dispatch class.
void parallel_copy_run(const IntType *index, const ::tbb::blocked_range< size_type > &range, const ::tbb::simple_partitioner &partitioner,::tbb::task_group_context &context)
work_type(MonitorEvalTBB< T, Derived > *wptr, std::size_t iter, std::size_t dim, Particle< T > *pptr, double *r)
std::size_t parallel_run(std::size_t iter, Particle< T > &particle, const ::tbb::blocked_range< typename Particle< T >::size_type > &range,::tbb::affinity_partitioner &partitioner)
void parallel_run(std::size_t iter, std::size_t dim, Particle< T > &particle, double *r, const ::tbb::blocked_range< typename Particle< T >::size_type > &range,::tbb::affinity_partitioner &partitioner)
void operator()(std::size_t iter, std::size_t dim, Particle< T > &particle, double *r)
void parallel_run(std::size_t iter, std::size_t dim, Particle< T > &particle, double *r, const ::tbb::blocked_range< typename Particle< T >::size_type > &range, const ::tbb::simple_partitioner &partitioner,::tbb::task_group_context &context)
void parallel_run(std::size_t iter, std::size_t dim, Particle< T > &particle, double *r, const ::tbb::blocked_range< typename Particle< T >::size_type > &range)
#define VSMC_DEFINE_SMP_BACKEND_FORWARD(Name)
void operator()(const ::tbb::blocked_range< size_type > &range) const
#define VSMC_DEFINE_SMP_BACKEND_TBB_PARALLEL_RUN_INITIALIZE(args)
std::size_t parallel_run(std::size_t iter, Particle< T > &particle, const ::tbb::blocked_range< typename Particle< T >::size_type > &range, const ::tbb::simple_partitioner &partitioner,::tbb::task_group_context &context)
void copy(size_type N, const IntType *index)
void parallel_copy_run(const IntType *index, const ::tbb::blocked_range< size_type > &range)
typename Particle< T >::size_type size_type
#define VSMC_DEFINE_SMP_BACKEND_TBB_PARALLEL_RUN_MOVE(args)
Monitor<T>::eval_type subtype using Intel Threading Building Blocks.
std::size_t operator()(std::size_t iter, Particle< T > &particle)
std::size_t parallel_run(Particle< T > &particle, void *param, const ::tbb::blocked_range< typename Particle< T >::size_type > &range, const ::tbb::simple_partitioner &partitioner,::tbb::task_group_context &context)
std::size_t parallel_run(std::size_t iter, Particle< T > &particle, const ::tbb::blocked_range< typename Particle< T >::size_type > &range, const ::tbb::simple_partitioner &partitioner)
work_type(InitializeTBB< T, Derived > *wptr, Particle< T > *pptr)
void parallel_run(std::size_t iter, std::size_t dim, Particle< T > &particle, double *r, const ::tbb::blocked_range< typename Particle< T >::size_type > &range,::tbb::affinity_partitioner &partitioner,::tbb::task_group_context &context)
Sampler<T>::move_type subtype using Intel Threading Building Blocks.
void operator()(const ::tbb::blocked_range< size_type > &range)
#define VSMC_DEFINE_SMP_BACKEND_TBB_PARALLEL_RUN_MONITOR_EVAL(args)
std::size_t accept() const
std::size_t parallel_run(Particle< T > &particle, void *param, const ::tbb::blocked_range< typename Particle< T >::size_type > &range)
std::size_t parallel_run(std::size_t iter, Particle< T > &particle, const ::tbb::blocked_range< typename Particle< T >::size_type > &range, const ::tbb::auto_partitioner &partitioner)
work_type(MoveTBB< T, Derived > *wptr, std::size_t iter, Particle< T > *pptr)
work_type(const work_type &other,::tbb::split)
std::size_t parallel_run(std::size_t iter, Particle< T > &particle, const ::tbb::blocked_range< typename Particle< T >::size_type > &range,::tbb::affinity_partitioner &partitioner,::tbb::task_group_context &context)
work_type(const work_type &other,::tbb::split)
void parallel_run(std::size_t iter, std::size_t dim, Particle< T > &particle, double *r, const ::tbb::blocked_range< typename Particle< T >::size_type > &range, const ::tbb::auto_partitioner &partitioner,::tbb::task_group_context &context)
SizeType< StateBase > size_type
void parallel_copy_run(const IntType *index, const ::tbb::blocked_range< size_type > &range, const ::tbb::auto_partitioner &partitioner,::tbb::task_group_context &context)
Move base dispatch class.
std::size_t parallel_run(Particle< T > &particle, void *param, const ::tbb::blocked_range< typename Particle< T >::size_type > &range,::tbb::affinity_partitioner &partitioner)
std::size_t parallel_run(Particle< T > &particle, void *param, const ::tbb::blocked_range< typename Particle< T >::size_type > &range, const ::tbb::simple_partitioner &partitioner)
void parallel_copy_run(const IntType *index, const ::tbb::blocked_range< size_type > &range, const ::tbb::simple_partitioner &partitioner)
typename Particle< T >::size_type size_type
Particle::value_type subtype using Intel Threading Building Blocks.
typename SizeTypeTrait< T >::type SizeType
std::size_t parallel_run(Particle< T > &particle, void *param, const ::tbb::blocked_range< typename Particle< T >::size_type > &range, const ::tbb::auto_partitioner &partitioner)
void parallel_copy_run(const IntType *index, const ::tbb::blocked_range< size_type > &range,::tbb::affinity_partitioner &partitioner)
void join(const work_type &other)
size_type size() const
Number of particles.
work_type(StateTBB< StateBase > *state, const IntType *index)
std::size_t parallel_run(std::size_t iter, Particle< T > &particle, const ::tbb::blocked_range< typename Particle< T >::size_type > &range, const ::tbb::auto_partitioner &partitioner,::tbb::task_group_context &context)
#define VSMC_DEFINE_SMP_BACKEND_SPECIAL(SMP, Name)
std::size_t parallel_run(std::size_t iter, Particle< T > &particle, const ::tbb::blocked_range< typename Particle< T >::size_type > &range)
std::size_t operator()(Particle< T > &particle, void *param)
void parallel_copy_run(const IntType *index, const ::tbb::blocked_range< size_type > &range,::tbb::affinity_partitioner &partitioner,::tbb::task_group_context &context)
typename Particle< T >::size_type size_type
Initialize base dispatch class.
void parallel_run(std::size_t iter, std::size_t dim, Particle< T > &particle, double *r, const ::tbb::blocked_range< typename Particle< T >::size_type > &range, const ::tbb::auto_partitioner &partitioner)