SPH
Kernel.cpp
Go to the documentation of this file.
1 #include "sph/kernel/Kernel.h"
2 #include "bench/Session.h"
3 #include "math/rng/Rng.h"
4 
5 using namespace Sph;
6 
7 BENCHMARK("LutKernel sequential", "[kernel]", Benchmark::Context& context) {
9  while (context.running()) {
10  for (Float r = 0.f; r < kernel.radius(); r += 1.e-4_f) {
11  Benchmark::doNotOptimize(kernel.value(Vector(r, 0.f, 0.f), 1.f));
12  Benchmark::doNotOptimize(kernel.grad(Vector(0.f, r, 0.f), 1.f));
14  }
15  }
16 }
17 
18 BENCHMARK("LutKernel random", "[kernel]", Benchmark::Context& context) {
19  LutKernel<3> kernel(CubicSpline<3>{});
20  UniformRng rng;
21  while (context.running()) {
22  for (Size i = 0; i < 1e4; ++i) {
23  Benchmark::doNotOptimize(kernel.value(Vector(3._f * rng(), 0.f, 0.f), 1.f));
24  Benchmark::doNotOptimize(kernel.grad(Vector(0.f, 3._f * rng(), 0.f), 1.f));
26  }
27  }
28 }
uint32_t Size
Integral type used to index arrays (by default).
Definition: Globals.h:16
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
Definition: Globals.h:13
BENCHMARK("LutKernel sequential", "[kernel]", Benchmark::Context &context)
Definition: Kernel.cpp:7
SPH kernels.
Random number generators.
Benchmark.
INLINE T && doNotOptimize(T &&value)
Definition: Session.h:180
INLINE void clobberMemory()
Definition: Session.h:190
Cubic spline (M4) kernel.
Definition: Kernel.h:150
Random number generator with uniform distribution.
Definition: Rng.h:16
Definition: MemoryPool.h:5