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; 77 #define VSMC_RUNTIME_ASSERT_SMP_BACKEND_BASE_DERIVED(basename) \ 78 VSMC_RUNTIME_ASSERT((dynamic_cast<Derived *>(this) != nullptr), \ 79 "DERIVED FROM " #basename \ 80 " WITH INCORRECT **Derived** TEMPLATE PARAMTER"); 92 template <
typename T,
typename Derived>
98 return eval_sp_dispatch(sp, &Derived::eval_sp);
103 eval_param_dispatch(particle, param, &Derived::eval_param);
108 eval_pre_dispatch(particle, &Derived::eval_pre);
113 eval_post_dispatch(particle, &Derived::eval_post);
122 template <typename D>
123 std::
size_t eval_sp_dispatch(
126 return static_cast<Derived *
>(
this)->
eval_sp(sp);
129 template <
typename D>
130 void eval_param_dispatch(
133 static_cast<Derived *
>(
this)->
eval_param(particle, param);
136 template <
typename D>
139 static_cast<Derived *
>(
this)->
eval_pre(particle);
142 template <
typename D>
145 static_cast<Derived *
>(
this)->
eval_post(particle);
150 template <
typename D>
151 std::size_t eval_sp_dispatch(
154 return static_cast<Derived *
>(
this)->
eval_sp(sp);
157 template <
typename D>
158 void eval_param_dispatch(
Particle<T> &particle,
void *param,
161 static_cast<Derived *
>(
this)->
eval_param(particle, param);
164 template <
typename D>
165 void eval_pre_dispatch(
168 static_cast<Derived *
>(
this)->
eval_pre(particle);
171 template <
typename D>
172 void eval_post_dispatch(
175 static_cast<Derived *
>(
this)->
eval_post(particle);
180 std::size_t eval_sp_dispatch(
183 return Derived::eval_sp(sp);
186 void eval_param_dispatch(
189 Derived::eval_param(particle, param);
194 Derived::eval_pre(particle);
199 Derived::eval_post(particle);
204 std::size_t eval_sp_dispatch(
210 void eval_param_dispatch(
215 void eval_pre_dispatch(
220 void eval_post_dispatch(
228 template <
typename T>
243 template <
typename T,
typename Derived>
249 return eval_sp_dispatch(iter, sp, &Derived::eval_sp);
254 eval_pre_dispatch(iter, particle, &Derived::eval_pre);
259 eval_post_dispatch(iter, particle, &Derived::eval_post);
268 template <typename D>
272 return static_cast<Derived *
>(
this)->
eval_sp(iter, sp);
275 template <
typename D>
276 void eval_pre_dispatch(std::size_t iter,
Particle<T> &particle,
279 static_cast<Derived *
>(
this)->
eval_pre(iter, particle);
282 template <
typename D>
283 void eval_post_dispatch(std::size_t iter,
Particle<T> &particle,
286 static_cast<Derived *
>(
this)->
eval_post(iter, particle);
291 template <
typename D>
295 return static_cast<Derived *
>(
this)->
eval_sp(iter, sp);
298 template <
typename D>
299 void eval_pre_dispatch(std::size_t iter,
Particle<T> &particle,
302 static_cast<Derived *
>(
this)->
eval_pre(iter, particle);
305 template <
typename D>
306 void eval_post_dispatch(std::size_t iter,
Particle<T> &particle,
309 static_cast<Derived *
>(
this)->
eval_post(iter, particle);
317 return Derived::eval_sp(iter, sp);
320 void eval_pre_dispatch(std::size_t iter,
Particle<T> &particle,
323 Derived::eval_pre(iter, particle);
326 void eval_post_dispatch(std::size_t iter,
Particle<T> &particle,
329 Derived::eval_post(iter, particle);
345 void eval_post_dispatch(std::size_t,
Particle<T> &,
353 template <
typename T>
367 template <
typename T,
typename Derived>
374 eval_sp_dispatch(iter, dim, sp, r, &Derived::eval_sp);
379 eval_pre_dispatch(iter, particle, &Derived::eval_pre);
384 eval_post_dispatch(iter, particle, &Derived::eval_post);
393 template <typename D>
394 void eval_sp_dispatch(
std::
size_t iter,
std::
size_t dim,
398 static_cast<Derived *
>(
this)->
eval_sp(iter, dim, sp, r);
401 template <
typename D>
402 void eval_pre_dispatch(std::size_t iter,
Particle<T> &particle,
405 static_cast<Derived *
>(
this)->
eval_pre(iter, particle);
408 template <
typename D>
409 void eval_post_dispatch(std::size_t iter,
Particle<T> &particle,
412 static_cast<Derived *
>(
this)->
eval_post(iter, particle);
417 template <
typename D>
418 void eval_sp_dispatch(std::size_t iter, std::size_t dim,
423 static_cast<Derived *
>(
this)->
eval_sp(iter, dim, sp, r);
426 template <
typename D>
427 void eval_pre_dispatch(std::size_t iter,
Particle<T> &particle,
430 static_cast<Derived *
>(
this)->
eval_pre(iter, particle);
433 template <
typename D>
434 void eval_post_dispatch(std::size_t iter,
Particle<T> &particle,
437 static_cast<Derived *
>(
this)->
eval_post(iter, particle);
442 void eval_sp_dispatch(std::size_t iter, std::size_t dim,
446 Derived::eval_sp(iter, dim, sp, r);
449 void eval_pre_dispatch(std::size_t iter,
Particle<T> &particle,
452 Derived::eval_pre(iter, particle);
455 void eval_post_dispatch(std::size_t iter,
Particle<T> &particle,
458 Derived::eval_post(iter, particle);
474 void eval_post_dispatch(std::size_t,
Particle<T> &,
482 template <
typename T>
498 #endif // VSMC_SMP_BACKEND_BASE_HPP
Particle class representing the whole particle set.
void eval_param(Particle< T > &particle, void *param)
#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 >)
Monitor evalution base dispatch class.
void eval_sp(std::size_t iter, std::size_t dim, SingleParticle< T > sp, double *r)
virtual void eval_pre(Particle< T > &)
void eval_pre(Particle< T > &particle)
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_pre(std::size_t iter, Particle< T > &particle)
Move base dispatch class.
virtual void eval_post(Particle< T > &)
#define VSMC_DEFINE_SMP_BACKEND_BASE_SPECIAL_VIRTUAL(Name)
virtual void eval_post(std::size_t, Particle< T > &)
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.