32 #ifndef MCKL_SMP_BACKEND_TBB_HPP 33 #define MCKL_SMP_BACKEND_TBB_HPP 36 #include <tbb/blocked_range.h> 37 #include <tbb/parallel_for.h> 43 template <
typename IntType>
45 IntType N, std::size_t grainsize)
47 return grainsize == 0 ? ::tbb::blocked_range<IntType>(0, N) :
48 ::tbb::blocked_range<IntType>(0, N, grainsize);
56 template <
typename T,
typename Derived>
67 : wptr_(wptr), iter_(iter), pptr_(pptr)
71 void operator()(const ::tbb::blocked_range<size_type> &range)
const 73 wptr_->eval_range(iter_, pptr_->range(range.begin(), range.end()));
78 const std::size_t iter_;
93 run(iter, particle, 1);
96 template <
typename... Args>
100 this->eval_first(iter, particle);
103 work_type(
this, iter, &particle), std::forward<Args>(args)...);
104 this->eval_last(iter, particle);
111 template <
typename T,
typename Derived>
121 std::size_t iter, std::size_t dim,
Particle<T> *pptr,
double *r)
122 : wptr_(wptr), iter_(iter), dim_(dim), pptr_(pptr), r_(r)
126 void operator()(const ::tbb::blocked_range<size_type> &range)
const 128 wptr_->eval_range(iter_, dim_,
129 pptr_->range(range.begin(), range.end()),
130 r_ + static_cast<std::size_t>(range.begin()) * dim_);
135 const std::size_t iter_;
136 const std::size_t dim_;
143 std::size_t iter, std::size_t dim,
Particle<T> &particle,
double *r)
145 run(iter, dim, particle, r);
152 std::
size_t iter,
std::
size_t dim,
Particle<T> &particle,
double *r)
154 run(iter, dim, particle, r, 1);
157 template <
typename... Args>
159 double *r, std::size_t grainsize, Args &&... args)
161 this->eval_first(iter, particle);
164 work_type(
this, iter, dim, &particle, r),
165 std::forward<Args>(args)...);
166 this->eval_last(iter, particle);
173 template <
typename T,
typename Derived>
179 template <
typename T,
typename Derived>
184 #endif // MCKL_SMP_BACKEND_TBB_HPP void operator()(std::size_t iter, Particle< T > &particle)
SMCSampler evaluation base dispatch class.
void run(std::size_t iter, std::size_t dim, Particle< T > &particle, double *r, std::size_t grainsize, Args &&... args)
SMCSampler<T>::eval_type subtype using Intel Threading Building Blocks.
SMCSMCSampler<T>::eval_type.
SMCEstimator<T>::eval_type.
size_type size() const
The number of particles.
SMCEstimator evalution base dispatch class.
void run(std::size_t iter, Particle< T > &particle, std::size_t grainsize, Args &&... args)
void operator()(std::size_t iter, std::size_t dim, Particle< T > &particle, double *r)
inline ::tbb::blocked_range< IntType > backend_tbb_range(IntType N, std::size_t grainsize)
#define MCKL_DEFINE_SMP_BACKEND_SPECIAL(Impl, Name)
SMCEstimator<T>::eval_type subtype using Intel Threading Building Blocks.