32 #ifndef VSMC_SMP_BACKEND_BASE_HPP 33 #define VSMC_SMP_BACKEND_BASE_HPP 37 #if VSMC_NO_RUNTIME_ASSERT 38 #define VSMC_BACKEND_BASE_DESTRUCTOR_PREFIX 40 #define VSMC_BACKEND_BASE_DESTRUCTOR_PREFIX virtual 43 #define VSMC_DEFINE_SMP_BACKEND_BASE_SPECIAL(Name) \ 44 Name##Base() = default; \ 45 Name##Base(const Name##Base<T, Derived> &) = default; \ 46 Name##Base<T, Derived> &operator=(const Name##Base<T, Derived> &) = \ 48 Name##Base(Name##Base<T, Derived> &&) = default; \ 49 Name##Base<T, Derived> &operator=(Name##Base<T, Derived> &&) = default; \ 50 VSMC_BACKEND_BASE_DESTRUCTOR_PREFIX ~Name##Base() {} 52 #define VSMC_DEFINE_SMP_BACKEND_BASE_SPECIAL_VIRTUAL(Name) \ 53 Name##Base() = default; \ 54 Name##Base(const Name##Base<T, Virtual> &) = default; \ 55 Name##Base<T, Virtual> &operator=(const Name##Base<T, Virtual> &) = \ 57 Name##Base(Name##Base<T, Virtual> &&) = default; \ 58 Name##Base<T, Virtual> &operator=(Name##Base<T, Virtual> &&) = default; \ 59 virtual ~Name##Base() {} 61 #define VSMC_DEFINE_SMP_BACKEND_SPECIAL(SMP, Name) \ 62 Name##SMP() = default; \ 63 Name##SMP(const Name##SMP<T, Derived> &) = default; \ 64 Name##SMP<T, Derived> &operator=(Name##SMP<T, Derived> &) = default; \ 65 Name##SMP(Name##SMP<T, Derived> &&) = default; \ 66 Name##SMP<T, Derived> &operator=(Name##SMP<T, Derived> &&) = default; \ 69 #define VSMC_DEFINE_SMP_BACKEND_FORWARD(Name) \ 70 template <typename T, typename = Virtual> \ 71 class Initialize##Name; \ 72 template <typename T, typename = Virtual> \ 74 template <typename T, typename = Virtual> \ 75 class MonitorEval##Name; \ 76 template <typename T, typename = Virtual> \ 79 #define VSMC_RUNTIME_ASSERT_SMP_BACKEND_BASE_DERIVED(basename) \ 80 VSMC_RUNTIME_ASSERT((dynamic_cast<Derived *>(this) != nullptr), \ 81 "DERIVED FROM " #basename \ 82 " WITH INCORRECT **Derived** TEMPLATE PARAMTER"); 94 template <
typename T,
typename Derived>
100 return eval_sp_dispatch(sp, &Derived::eval_sp);
105 eval_param_dispatch(particle, param, &Derived::eval_param);
110 eval_pre_dispatch(particle, &Derived::eval_pre);
115 eval_post_dispatch(particle, &Derived::eval_post);
124 template <typename D>
125 std::
size_t eval_sp_dispatch(
128 return static_cast<Derived *
>(
this)->
eval_sp(sp);
131 template <
typename D>
132 void eval_param_dispatch(
135 static_cast<Derived *
>(
this)->
eval_param(particle, param);
138 template <
typename D>
141 static_cast<Derived *
>(
this)->
eval_pre(particle);
144 template <
typename D>
147 static_cast<Derived *
>(
this)->
eval_post(particle);
152 template <
typename D>
153 std::size_t eval_sp_dispatch(
156 return static_cast<Derived *
>(
this)->
eval_sp(sp);
159 template <
typename D>
160 void eval_param_dispatch(
Particle<T> &particle,
void *param,
163 static_cast<Derived *
>(
this)->
eval_param(particle, param);
166 template <
typename D>
167 void eval_pre_dispatch(
170 static_cast<Derived *
>(
this)->
eval_pre(particle);
173 template <
typename D>
174 void eval_post_dispatch(
177 static_cast<Derived *
>(
this)->
eval_post(particle);
182 std::size_t eval_sp_dispatch(
185 return Derived::eval_sp(sp);
188 void eval_param_dispatch(
191 Derived::eval_param(particle, param);
196 Derived::eval_pre(particle);
201 Derived::eval_post(particle);
206 std::size_t eval_sp_dispatch(
212 void eval_param_dispatch(
217 void eval_pre_dispatch(
222 void eval_post_dispatch(
230 template <
typename T>
245 template <
typename T,
typename Derived>
251 return eval_sp_dispatch(iter, sp, &Derived::eval_sp);
256 eval_pre_dispatch(iter, particle, &Derived::eval_pre);
261 eval_post_dispatch(iter, particle, &Derived::eval_post);
270 template <typename D>
274 return static_cast<Derived *
>(
this)->
eval_sp(iter, sp);
277 template <
typename D>
278 void eval_pre_dispatch(std::size_t iter,
Particle<T> &particle,
281 static_cast<Derived *
>(
this)->
eval_pre(iter, particle);
284 template <
typename D>
285 void eval_post_dispatch(std::size_t iter,
Particle<T> &particle,
288 static_cast<Derived *
>(
this)->
eval_post(iter, particle);
293 template <
typename D>
297 return static_cast<Derived *
>(
this)->
eval_sp(iter, sp);
300 template <
typename D>
301 void eval_pre_dispatch(std::size_t iter,
Particle<T> &particle,
304 static_cast<Derived *
>(
this)->
eval_pre(iter, particle);
307 template <
typename D>
308 void eval_post_dispatch(std::size_t iter,
Particle<T> &particle,
311 static_cast<Derived *
>(
this)->
eval_post(iter, particle);
319 return Derived::eval_sp(iter, sp);
322 void eval_pre_dispatch(std::size_t iter,
Particle<T> &particle,
325 Derived::eval_pre(iter, particle);
328 void eval_post_dispatch(std::size_t iter,
Particle<T> &particle,
331 Derived::eval_post(iter, particle);
347 void eval_post_dispatch(std::size_t,
Particle<T> &,
355 template <
typename T>
369 template <
typename T,
typename Derived>
376 eval_sp_dispatch(iter, dim, sp, r, &Derived::eval_sp);
381 eval_pre_dispatch(iter, particle, &Derived::eval_pre);
386 eval_post_dispatch(iter, particle, &Derived::eval_post);
395 template <typename D>
396 void eval_sp_dispatch(
std::
size_t iter,
std::
size_t dim,
400 static_cast<Derived *
>(
this)->
eval_sp(iter, dim, sp, r);
403 template <
typename D>
404 void eval_pre_dispatch(std::size_t iter,
Particle<T> &particle,
407 static_cast<Derived *
>(
this)->
eval_pre(iter, particle);
410 template <
typename D>
411 void eval_post_dispatch(std::size_t iter,
Particle<T> &particle,
414 static_cast<Derived *
>(
this)->
eval_post(iter, particle);
419 template <
typename D>
420 void eval_sp_dispatch(std::size_t iter, std::size_t dim,
425 static_cast<Derived *
>(
this)->
eval_sp(iter, dim, sp, r);
428 template <
typename D>
429 void eval_pre_dispatch(std::size_t iter,
Particle<T> &particle,
432 static_cast<Derived *
>(
this)->
eval_pre(iter, particle);
435 template <
typename D>
436 void eval_post_dispatch(std::size_t iter,
Particle<T> &particle,
439 static_cast<Derived *
>(
this)->
eval_post(iter, particle);
444 void eval_sp_dispatch(std::size_t iter, std::size_t dim,
448 Derived::eval_sp(iter, dim, sp, r);
451 void eval_pre_dispatch(std::size_t iter,
Particle<T> &particle,
454 Derived::eval_pre(iter, particle);
457 void eval_post_dispatch(std::size_t iter,
Particle<T> &particle,
460 Derived::eval_post(iter, particle);
476 void eval_post_dispatch(std::size_t,
Particle<T> &,
484 template <
typename T>
500 template <
typename T,
typename Derived>
506 return eval_sp_dispatch(iter, sp, &Derived::eval_sp);
511 return eval_grid_dispatch(iter, particle, &Derived::eval_grid);
516 eval_pre_dispatch(iter, particle, &Derived::eval_pre);
521 eval_post_dispatch(iter, particle, &Derived::eval_post);
530 template <typename D>
534 return static_cast<Derived *
>(
this)->
eval_sp(iter, sp);
537 template <
typename D>
538 double eval_grid_dispatch(std::size_t iter,
Particle<T> &particle,
541 return static_cast<Derived *
>(
this)->eval_grid(iter, particle);
544 template <
typename D>
545 void eval_pre_dispatch(std::size_t iter,
Particle<T> &particle,
548 static_cast<Derived *
>(
this)->
eval_pre(iter, particle);
551 template <
typename D>
552 void eval_post_dispatch(std::size_t iter,
Particle<T> &particle,
555 static_cast<Derived *
>(
this)->
eval_post(iter, particle);
560 template <
typename D>
564 return static_cast<Derived *
>(
this)->
eval_sp(iter, sp);
567 template <
typename D>
568 double eval_grid_dispatch(std::size_t iter,
Particle<T> &particle,
571 return static_cast<Derived *
>(
this)->eval_grid(iter, particle);
574 template <
typename D>
575 void eval_pre_dispatch(std::size_t iter,
Particle<T> &particle,
578 static_cast<Derived *
>(
this)->
eval_pre(iter, particle);
581 template <
typename D>
582 void eval_post_dispatch(std::size_t iter,
Particle<T> &particle,
585 static_cast<Derived *
>(
this)->
eval_post(iter, particle);
593 return Derived::eval_sp(iter, sp);
596 double eval_grid_dispatch(std::size_t iter,
Particle<T> &particle,
599 return Derived::eval_grid(iter, particle);
602 void eval_pre_dispatch(std::size_t iter,
Particle<T> &particle,
605 Derived::eval_pre(iter, particle);
608 void eval_post_dispatch(std::size_t iter,
Particle<T> &particle,
611 Derived::eval_post(iter, particle);
622 double eval_grid_dispatch(std::size_t,
Particle<T> &,
633 void eval_post_dispatch(std::size_t,
Particle<T> &,
641 template <
typename T>
656 #endif // VSMC_SMP_BACKEND_BASE_HPP
Particle class representing the whole particle set.
virtual void eval_post(std::size_t, Particle< T > &)
void eval_param(Particle< T > &particle, void *param)
virtual void eval_pre(std::size_t, Particle< T > &)
#define VSMC_DEFINE_SMP_BACKEND_BASE_SPECIAL(Name)
virtual void eval_param(Particle< T > &, void *)
std::size_t eval_sp(SingleParticle< T > sp)
virtual std::size_t eval_sp(std::size_t, SingleParticle< T >)
double eval_grid(std::size_t iter, Particle< T > &particle)
Monitor evalution base dispatch class.
void eval_pre(std::size_t iter, Particle< T > &particle)
void eval_sp(std::size_t iter, std::size_t dim, SingleParticle< T > sp, double *r)
virtual double eval_sp(std::size_t, SingleParticle< T >)
virtual void eval_pre(Particle< T > &)
void eval_pre(Particle< T > &particle)
virtual double eval_grid(std::size_t, Particle< T > &)
virtual std::size_t eval_sp(SingleParticle< T >)
void eval_post(std::size_t iter, Particle< T > &particle)
virtual void eval_pre(std::size_t, Particle< T > &)
void eval_post(std::size_t iter, Particle< T > &particle)
void eval_post(std::size_t iter, Particle< T > &particle)
void eval_pre(std::size_t iter, Particle< T > &particle)
Move base dispatch class.
double eval_sp(std::size_t iter, SingleParticle< T > sp)
virtual void eval_post(Particle< T > &)
#define VSMC_DEFINE_SMP_BACKEND_BASE_SPECIAL_VIRTUAL(Name)
virtual void eval_post(std::size_t, Particle< T > &)
Path evalution base dispatch class.
virtual void eval_pre(std::size_t, Particle< T > &)
void eval_post(Particle< T > &particle)
std::size_t eval_sp(std::size_t iter, SingleParticle< T > sp)
virtual void eval_post(std::size_t, Particle< T > &)
A thin wrapper over a complete Particle.
virtual void eval_sp(std::size_t, std::size_t, SingleParticle< T >, double *)
void eval_pre(std::size_t iter, Particle< T > &particle)
Initialize base dispatch class.