vSMC
vSMC: Scalable Monte Carlo
backend_tbb.hpp
Go to the documentation of this file.
1 //============================================================================
2 // vSMC/include/vsmc/smp/backend_tbb.hpp
3 //----------------------------------------------------------------------------
4 // vSMC: Scalable Monte Carlo
5 //----------------------------------------------------------------------------
6 // Copyright (c) 2013-2015, Yan Zhou
7 // All rights reserved.
8 //
9 // Redistribution and use in source and binary forms, with or without
10 // modification, are permitted provided that the following conditions are met:
11 //
12 // Redistributions of source code must retain the above copyright notice,
13 // this list of conditions and the following disclaimer.
14 //
15 // Redistributions in binary form must reproduce the above copyright notice,
16 // this list of conditions and the following disclaimer in the documentation
17 // and/or other materials provided with the distribution.
18 //
19 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
20 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 // POSSIBILITY OF SUCH DAMAGE.
30 //============================================================================
31 
32 #ifndef VSMC_SMP_BACKEND_TBB_HPP
33 #define VSMC_SMP_BACKEND_TBB_HPP
34 
36 #include <tbb/tbb.h>
37 
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); \
44  return work.accept();
45 
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); \
51  return work.accept();
52 
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);
58 
59 #define VSMC_DEFINE_SMP_BACKEND_TBB_PARALLEL_RUN_PATH_EVAL(args) \
60  this->eval_pre(iter, particle); \
61  work_type work(this, iter, &particle, r); \
62  ::tbb::parallel_for args; \
63  this->eval_post(iter, particle); \
64  return this->eval_grid(iter, particle);
65 
66 namespace vsmc
67 {
68 
70 
71 template <typename StateBase>
74 class StateTBB : public StateBase
75 {
76  public:
78 
79  explicit StateTBB(size_type N) : StateBase(N) {}
80 
81  template <typename IntType>
82  void copy(size_type N, const IntType *src_idx)
83  {
84  parallel_copy_run(src_idx, ::tbb::blocked_range<size_type>(0, N));
85  }
86 
87  protected:
88  template <typename IntType>
89  class work_type
90  {
91  public:
92  work_type(StateTBB<StateBase> *state, const IntType *src_idx)
93  : state_(state), src_idx_(src_idx)
94  {
95  }
96 
97  void operator()(const ::tbb::blocked_range<size_type> &range) const
98  {
99  for (size_type i = range.begin(); i != range.end(); ++i) {
100  state_->copy_particle(static_cast<size_type>(src_idx_[i]), i);
101  }
102  }
103 
104  private:
105  StateTBB<StateBase> *const state_;
106  const IntType *const src_idx_;
107  }; // class work_type
108 
109  template <typename IntType>
111  const IntType *src_idx, const ::tbb::blocked_range<size_type> &range)
112  {
113  ::tbb::parallel_for(range, work_type<IntType>(this, src_idx));
114  }
115 
116  template <typename IntType>
117  void parallel_copy_run(const IntType *src_idx,
118  const ::tbb::blocked_range<size_type> &range,
119  const ::tbb::auto_partitioner &partitioner)
120  {
121  ::tbb::parallel_for(
122  range, work_type<IntType>(this, src_idx), partitioner);
123  }
124 
125  template <typename IntType>
126  void parallel_copy_run(const IntType *src_idx,
127  const ::tbb::blocked_range<size_type> &range,
128  const ::tbb::simple_partitioner &partitioner)
129  {
130  ::tbb::parallel_for(
131  range, work_type<IntType>(this, src_idx), partitioner);
132  }
133 
134  template <typename IntType>
135  void parallel_copy_run(const IntType *src_idx,
136  const ::tbb::blocked_range<size_type> &range,
137  ::tbb::affinity_partitioner &partitioner)
138  {
139  ::tbb::parallel_for(
140  range, work_type<IntType>(this, src_idx), partitioner);
141  }
142 
143 #if __TBB_TASK_GROUP_CONTEXT
144  template <typename IntType>
145  void parallel_copy_run(const IntType *src_idx,
146  const ::tbb::blocked_range<size_type> &range,
147  const ::tbb::auto_partitioner &partitioner,
148  ::tbb::task_group_context &context)
149  {
150  ::tbb::parallel_for(
151  range, work_type<IntType>(this, src_idx), partitioner, context);
152  }
153 
154  template <typename IntType>
155  void parallel_copy_run(const IntType *src_idx,
156  const ::tbb::blocked_range<size_type> &range,
157  const ::tbb::simple_partitioner &partitioner,
158  ::tbb::task_group_context &context)
159  {
160  ::tbb::parallel_for(
161  range, work_type<IntType>(this, src_idx), partitioner, context);
162  }
163 
164  template <typename IntType>
165  void parallel_copy_run(const IntType *src_idx,
166  const ::tbb::blocked_range<size_type> &range,
167  ::tbb::affinity_partitioner &partitioner,
168  ::tbb::task_group_context &context)
169  {
170  ::tbb::parallel_for(
171  range, work_type<IntType>(this, src_idx), partitioner, context);
172  }
173 #endif // __TBB_TASK_GROUP_CONTEXT
174 }; // class StateTBB
175 
178 template <typename T, typename Derived>
179 class InitializeTBB : public InitializeBase<T, Derived>
180 {
181  public:
182  std::size_t operator()(Particle<T> &particle, void *param)
183  {
184  return parallel_run(particle, param,
185  ::tbb::blocked_range<typename Particle<T>::size_type>(
186  0, particle.size()));
187  }
188 
189  protected:
191 
192  class work_type
193  {
194  public:
196 
198  : wptr_(wptr), pptr_(pptr), accept_(0)
199  {
200  }
201 
202  work_type(const work_type &other, ::tbb::split)
203  : wptr_(other.wptr_), pptr_(other.pptr_), accept_(0)
204  {
205  }
206 
207  void operator()(const ::tbb::blocked_range<size_type> &range)
208  {
209  for (size_type i = range.begin(); i != range.end(); ++i)
210  accept_ += wptr_->eval_sp(SingleParticle<T>(i, pptr_));
211  }
212 
213  void join(const work_type &other) { accept_ += other.accept_; }
214 
215  std::size_t accept() const { return accept_; }
216 
217  private:
218  InitializeTBB<T, Derived> *const wptr_;
219  Particle<T> *const pptr_;
220  std::size_t accept_;
221  }; // class work_type
222 
223  std::size_t parallel_run(Particle<T> &particle, void *param,
224  const ::tbb::blocked_range<typename Particle<T>::size_type> &range)
225  {
227  }
228 
229  std::size_t parallel_run(Particle<T> &particle, void *param,
230  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
231  const ::tbb::auto_partitioner &partitioner)
232  {
234  (range, work, partitioner));
235  }
236 
237  std::size_t parallel_run(Particle<T> &particle, void *param,
238  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
239  const ::tbb::simple_partitioner &partitioner)
240  {
242  (range, work, partitioner));
243  }
244 
245  std::size_t parallel_run(Particle<T> &particle, void *param,
246  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
247  ::tbb::affinity_partitioner &partitioner)
248  {
250  (range, work, partitioner));
251  }
252 
253 #if __TBB_TASK_GROUP_CONTEXT
254  std::size_t parallel_run(Particle<T> &particle, void *param,
255  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
256  const ::tbb::auto_partitioner &partitioner,
257  ::tbb::task_group_context &context)
258  {
260  (range, work, partitioner, context));
261  }
262 
263  std::size_t parallel_run(Particle<T> &particle, void *param,
264  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
265  const ::tbb::simple_partitioner &partitioner,
266  ::tbb::task_group_context &context)
267  {
269  (range, work, partitioner, context));
270  }
271 
272  std::size_t parallel_run(Particle<T> &particle, void *param,
273  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
274  ::tbb::affinity_partitioner &partitioner,
275  ::tbb::task_group_context &context)
276  {
278  (range, work, partitioner, context));
279  }
280 #endif // __TBB_TASK_GROUP_CONTEXT
281 }; // class InitializeTBB
282 
285 template <typename T, typename Derived>
286 class MoveTBB : public MoveBase<T, Derived>
287 {
288  public:
289  std::size_t operator()(std::size_t iter, Particle<T> &particle)
290  {
291  return parallel_run(iter, particle,
292  ::tbb::blocked_range<typename Particle<T>::size_type>(
293  0, particle.size()));
294  }
295 
296  protected:
298 
299  class work_type
300  {
301  public:
303 
305  MoveTBB<T, Derived> *wptr, std::size_t iter, Particle<T> *pptr)
306  : wptr_(wptr), iter_(iter), pptr_(pptr), accept_(0)
307  {
308  }
309 
310  work_type(const work_type &other, ::tbb::split)
311  : wptr_(other.wptr_)
312  , iter_(other.iter_)
313  , pptr_(other.pptr_)
314  , accept_(0)
315  {
316  }
317 
318  void operator()(const ::tbb::blocked_range<size_type> &range)
319  {
320  for (size_type i = range.begin(); i != range.end(); ++i)
321  accept_ += wptr_->eval_sp(iter_, SingleParticle<T>(i, pptr_));
322  }
323 
324  void join(const work_type &other) { accept_ += other.accept_; }
325 
326  std::size_t accept() const { return accept_; }
327 
328  private:
329  MoveTBB<T, Derived> *const wptr_;
330  const std::size_t iter_;
331  Particle<T> *const pptr_;
332  std::size_t accept_;
333  }; // class work_type
334 
335  std::size_t parallel_run(std::size_t iter, Particle<T> &particle,
336  const ::tbb::blocked_range<typename Particle<T>::size_type> &range)
337  {
339  }
340 
341  std::size_t parallel_run(std::size_t iter, Particle<T> &particle,
342  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
343  const ::tbb::auto_partitioner &partitioner)
344  {
346  (range, work, partitioner));
347  }
348 
349  std::size_t parallel_run(std::size_t iter, Particle<T> &particle,
350  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
351  const ::tbb::simple_partitioner &partitioner)
352  {
354  (range, work, partitioner));
355  }
356 
357  std::size_t parallel_run(std::size_t iter, Particle<T> &particle,
358  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
359  ::tbb::affinity_partitioner &partitioner)
360  {
362  (range, work, partitioner));
363  }
364 
365 #if __TBB_TASK_GROUP_CONTEXT
366  std::size_t parallel_run(std::size_t iter, Particle<T> &particle,
367  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
368  const ::tbb::auto_partitioner &partitioner,
369  ::tbb::task_group_context &context)
370  {
372  (range, work, partitioner, context));
373  }
374 
375  std::size_t parallel_run(std::size_t iter, Particle<T> &particle,
376  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
377  const ::tbb::simple_partitioner &partitioner,
378  ::tbb::task_group_context &context)
379  {
381  (range, work, partitioner, context));
382  }
383 
384  std::size_t parallel_run(std::size_t iter, Particle<T> &particle,
385  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
386  ::tbb::affinity_partitioner &partitioner,
387  ::tbb::task_group_context &context)
388  {
390  (range, work, partitioner, context));
391  }
392 #endif // __TBB_TASK_GROUP_CONTEXT
393 }; // class MoveTBB
394 
397 template <typename T, typename Derived>
398 class MonitorEvalTBB : public MonitorEvalBase<T, Derived>
399 {
400  public:
402  std::size_t iter, std::size_t dim, Particle<T> &particle, double *r)
403  {
404  parallel_run(iter, dim, particle, r,
405  ::tbb::blocked_range<typename Particle<T>::size_type>(
406  0, particle.size()));
407  }
408 
409  protected:
411 
412  class work_type
413  {
414  public:
416 
417  work_type(MonitorEvalTBB<T, Derived> *wptr, std::size_t iter,
418  std::size_t dim, Particle<T> *pptr, double *r)
419  : wptr_(wptr), iter_(iter), dim_(dim), pptr_(pptr), r_(r)
420  {
421  }
422 
423  void operator()(const ::tbb::blocked_range<size_type> &range) const
424  {
425  for (size_type i = range.begin(); i != range.end(); ++i) {
426  wptr_->eval_sp(iter_, dim_, SingleParticle<T>(i, pptr_),
427  r_ + static_cast<std::size_t>(i) * dim_);
428  }
429  }
430 
431  private:
432  MonitorEvalTBB<T, Derived> *const wptr_;
433  const std::size_t iter_;
434  const std::size_t dim_;
435  Particle<T> *const pptr_;
436  double *const r_;
437  }; // class work_type
438 
439  void parallel_run(std::size_t iter, std::size_t dim, Particle<T> &particle,
440  double *r,
441  const ::tbb::blocked_range<typename Particle<T>::size_type> &range)
442  {
444  }
445 
446  void parallel_run(std::size_t iter, std::size_t dim, Particle<T> &particle,
447  double *r,
448  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
449  const ::tbb::auto_partitioner &partitioner)
450  {
452  (range, work, partitioner));
453  }
454 
455  void parallel_run(std::size_t iter, std::size_t dim, Particle<T> &particle,
456  double *r,
457  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
458  const ::tbb::simple_partitioner &partitioner)
459  {
461  (range, work, partitioner));
462  }
463 
464  void parallel_run(std::size_t iter, std::size_t dim, Particle<T> &particle,
465  double *r,
466  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
467  ::tbb::affinity_partitioner &partitioner)
468  {
470  (range, work, partitioner));
471  }
472 
473 #if __TBB_TASK_GROUP_CONTEXT
474  void parallel_run(std::size_t iter, std::size_t dim, Particle<T> &particle,
475  double *r,
476  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
477  const ::tbb::auto_partitioner &partitioner,
478  ::tbb::task_group_context &context)
479  {
481  (range, work, partitioner, context));
482  }
483 
484  void parallel_run(std::size_t iter, std::size_t dim, Particle<T> &particle,
485  double *r,
486  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
487  const ::tbb::simple_partitioner &partitioner,
488  ::tbb::task_group_context &context)
489  {
491  (range, work, partitioner, context));
492  }
493 
494  void parallel_run(std::size_t iter, std::size_t dim, Particle<T> &particle,
495  double *r,
496  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
497  ::tbb::affinity_partitioner &partitioner,
498  ::tbb::task_group_context &context)
499  {
501  (range, work, partitioner, context));
502  }
503 #endif // __TBB_TASK_GROUP_CONTEXT
504 }; // class MonitorEvalTBB
505 
508 template <typename T, typename Derived>
509 class PathEvalTBB : public PathEvalBase<T, Derived>
510 {
511  public:
512  double operator()(std::size_t iter, Particle<T> &particle, double *r)
513  {
514  return parallel_run(iter, particle, r,
515  ::tbb::blocked_range<typename Particle<T>::size_type>(
516  0, particle.size()));
517  }
518 
519  protected:
521 
522  class work_type
523  {
524  public:
526 
527  work_type(PathEvalTBB<T, Derived> *wptr, std::size_t iter,
528  Particle<T> *pptr, double *r)
529  : wptr_(wptr), iter_(iter), pptr_(pptr), r_(r)
530  {
531  }
532 
533  void operator()(const ::tbb::blocked_range<size_type> &range) const
534  {
535  for (size_type i = range.begin(); i != range.end(); ++i)
536  r_[i] = wptr_->eval_sp(iter_, SingleParticle<T>(i, pptr_));
537  }
538 
539  private:
540  PathEvalTBB<T, Derived> *const wptr_;
541  const std::size_t iter_;
542  Particle<T> *const pptr_;
543  double *const r_;
544  }; // class ParallelPathState
545 
546  double parallel_run(std::size_t iter, Particle<T> &particle, double *r,
547  const ::tbb::blocked_range<typename Particle<T>::size_type> &range)
548  {
550  }
551 
552  double parallel_run(std::size_t iter, Particle<T> &particle, double *r,
553  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
554  const ::tbb::auto_partitioner &partitioner)
555  {
557  (range, work, partitioner));
558  }
559 
560  double parallel_run(std::size_t iter, Particle<T> &particle, double *r,
561  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
562  const ::tbb::simple_partitioner &partitioner)
563  {
565  (range, work, partitioner));
566  }
567 
568  double parallel_run(std::size_t iter, Particle<T> &particle, double *r,
569  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
570  ::tbb::affinity_partitioner &partitioner)
571  {
573  (range, work, partitioner));
574  }
575 
576 #if __TBB_TASK_GROUP_CONTEXT
577  double parallel_run(std::size_t iter, Particle<T> &particle, double *r,
578  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
579  const ::tbb::auto_partitioner &partitioner,
580  ::tbb::task_group_context &context)
581  {
583  (range, work, partitioner, context));
584  }
585 
586  double parallel_run(std::size_t iter, Particle<T> &particle, double *r,
587  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
588  const ::tbb::simple_partitioner &partitioner,
589  ::tbb::task_group_context &context)
590  {
592  (range, work, partitioner, context));
593  }
594 
595  double parallel_run(std::size_t iter, Particle<T> &particle, double *r,
596  const ::tbb::blocked_range<typename Particle<T>::size_type> &range,
597  ::tbb::affinity_partitioner &partitioner,
598  ::tbb::task_group_context &context)
599  {
601  (range, work, partitioner, context));
602  }
603 #endif // __TBB_TASK_GROUP_CONTEXT
604 }; // PathEvalTBB
605 
606 } // namespace vsmc
607 
608 #endif // VSMC_SMP_BACKEND_TBB_HPP
Definition: monitor.hpp:49
SizeType< T > size_type
Definition: particle.hpp:51
Particle class representing the whole particle set.
Definition: particle.hpp:48
double parallel_run(std::size_t iter, 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)
double parallel_run(std::size_t iter, Particle< T > &particle, double *r, const ::tbb::blocked_range< typename Particle< T >::size_type > &range,::tbb::affinity_partitioner &partitioner,::tbb::task_group_context &context)
std::size_t accept() const
Sampler<T>::init_type subtype using Intel Threading Building Blocks.
Definition: backend_tbb.hpp:69
void parallel_copy_run(const IntType *src_idx, const ::tbb::blocked_range< size_type > &range, const ::tbb::simple_partitioner &partitioner,::tbb::task_group_context &context)
double operator()(std::size_t iter, Particle< T > &particle, double *r)
void parallel_copy_run(const IntType *src_idx, const ::tbb::blocked_range< size_type > &range,::tbb::affinity_partitioner &partitioner,::tbb::task_group_context &context)
void join(const work_type &other)
double parallel_run(std::size_t iter, Particle< T > &particle, double *r, 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::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
work_type(StateTBB< StateBase > *state, const IntType *src_idx)
Definition: backend_tbb.hpp:92
StateTBB(size_type N)
Definition: backend_tbb.hpp:79
double parallel_run(std::size_t iter, Particle< T > &particle, double *r, const ::tbb::blocked_range< typename Particle< T >::size_type > &range, const ::tbb::auto_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, 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)
double parallel_run(std::size_t iter, 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)
Monitor evalution base dispatch class.
work_type(MonitorEvalTBB< T, Derived > *wptr, std::size_t iter, std::size_t dim, Particle< T > *pptr, double *r)
void operator()(const ::tbb::blocked_range< size_type > &range) const
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 parallel_copy_run(const IntType *src_idx, const ::tbb::blocked_range< size_type > &range, const ::tbb::simple_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
Definition: backend_tbb.hpp:97
#define VSMC_DEFINE_SMP_BACKEND_TBB_PARALLEL_RUN_INITIALIZE(args)
Definition: backend_tbb.hpp:38
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 *src_idx)
Definition: backend_tbb.hpp:82
typename Particle< T >::size_type size_type
#define VSMC_DEFINE_SMP_BACKEND_TBB_PARALLEL_RUN_MOVE(args)
Definition: backend_tbb.hpp:46
Monitor<T>::eval_type subtype using Intel Threading Building Blocks.
Definition: backend_tbb.hpp:69
typename Particle< T >::size_type size_type
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.
Definition: backend_tbb.hpp:69
void operator()(const ::tbb::blocked_range< size_type > &range)
#define VSMC_DEFINE_SMP_BACKEND_TBB_PARALLEL_RUN_MONITOR_EVAL(args)
Definition: backend_tbb.hpp:53
std::size_t accept() const
#define VSMC_DEFINE_SMP_BACKEND_TBB_PARALLEL_RUN_PATH_EVAL(args)
Definition: backend_tbb.hpp:59
double parallel_run(std::size_t iter, 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)
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)
double parallel_run(std::size_t iter, Particle< T > &particle, double *r, const ::tbb::blocked_range< typename Particle< T >::size_type > &range)
void parallel_copy_run(const IntType *src_idx, const ::tbb::blocked_range< size_type > &range,::tbb::affinity_partitioner &partitioner)
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
Definition: backend_tbb.hpp:77
work_type(PathEvalTBB< T, Derived > *wptr, std::size_t iter, Particle< T > *pptr, double *r)
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)
typename Particle< T >::size_type size_type
Particle::value_type subtype using Intel Threading Building Blocks.
Definition: backend_tbb.hpp:74
Path<T>::eval_type subtype using Intel Threading Building Blocks.
Definition: backend_tbb.hpp:69
typename SizeTypeTrait< T >::type SizeType
Definition: traits.hpp:212
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)
Path evalution base dispatch class.
void join(const work_type &other)
size_type size() const
Number of particles.
Definition: particle.hpp:122
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)
void parallel_copy_run(const IntType *src_idx, const ::tbb::blocked_range< size_type > &range, const ::tbb::auto_partitioner &partitioner)
#define VSMC_DEFINE_SMP_BACKEND_SPECIAL(SMP, Name)
A thin wrapper over a complete Particle.
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 *src_idx, const ::tbb::blocked_range< size_type > &range)
typename Particle< T >::size_type size_type
void parallel_copy_run(const IntType *src_idx, const ::tbb::blocked_range< size_type > &range, const ::tbb::auto_partitioner &partitioner,::tbb::task_group_context &context)
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)