WaSH Docs
kernels.hpp
1 #pragma once
2 
3 #include <functional>
4 
5 #include "particle.hpp"
6 
7 namespace wash {
8  using ForceFuncT = std::function<void(Particle&, const std::vector<Particle>::const_iterator&,
9  const std::vector<Particle>::const_iterator&)>;
10  using UpdateFuncT = std::function<void(Particle&)>;
11  using MapFuncT = std::function<double(const Particle&)>;
12  using VoidFuncT = std::function<void()>;
13  using NeighborsFuncT = std::function<void(Particle&)>;
14 
18  enum class ReduceOp { max, min, sum, prod };
19 
27  class Kernel {
28  public:
29  virtual ~Kernel() = default;
30  virtual void exec() const = 0;
31  };
32 
39  class ForceKernel : public Kernel {
40  private:
41  ForceFuncT func;
42 
43  public:
44  ForceKernel(const ForceFuncT func) : func(func) {}
45 
46  virtual void exec() const override;
47  };
48 
55  class UpdateKernel : public Kernel {
56  private:
57  UpdateFuncT func;
58 
59  public:
60  UpdateKernel(const UpdateFuncT func) : func(func) {}
61 
62  virtual void exec() const override;
63  };
64 
72  class ReductionKernel : public Kernel {
73  private:
74  MapFuncT map_func;
75  ReduceOp reduce_op;
76  double* variable;
77 
78  public:
79  ReductionKernel(const MapFuncT map_func, const ReduceOp reduce_op, double* variable)
80  : map_func(map_func), reduce_op(reduce_op), variable(variable) {}
81 
82  virtual void exec() const override;
83  };
84 
88  class VoidKernel : public Kernel {
89  private:
90  VoidFuncT func;
91 
92  public:
93  VoidKernel(const VoidFuncT func) : func(func) {}
94 
95  virtual void exec() const override;
96  };
97 }
Force Kernel Class.
Definition: kernels.hpp:39
Parent Kernel Class.
Definition: kernels.hpp:27
ReduceOp
Type of reduction operation to perform in a reduce kernel.
Definition: kernels.hpp:18
Reduction Kernel implements a reduction operation over the particles to a specifed variable...
Definition: kernels.hpp:72
Update Kernel Class.
Definition: kernels.hpp:55
TODO: Consider having this as a private header in WISB/WS2ST/etc implementations. ...
Definition: ascii.hpp:5
Void Kernel has no arguments/return.
Definition: kernels.hpp:88