@@ -216,6 +216,23 @@ namespace xt
216216 }
217217 }
218218
219+ inline auto stencil_twodirections (benchmark::State& state, size_t size)
220+ {
221+ for (auto _ : state)
222+ {
223+ const std::array<size_t , 3 > shape = {size, size, size};
224+ xt::xtensor<double , 3 > a (shape), b (shape);
225+ auto core = xt::range (1 , size - 1 );
226+ xt::noalias (xt::view (b, core, core, core)
227+ ) = 1.0 / 7.0
228+ * (xt::view (a, core, core, core) + xt::view (a, core, xt::range (2 , size), core)
229+ + xt::view (a, core, xt::range (0 , size - 2 ), core)
230+ + xt::view (a, xt::range (2 , size), core, core)
231+ + xt::view (a, xt::range (0 , size - 2 ), core, core));
232+ benchmark::DoNotOptimize (b);
233+ }
234+ }
235+
219236 inline auto stencil_onedirection (benchmark::State& state, size_t size)
220237 {
221238 for (auto _ : state)
@@ -236,6 +253,11 @@ namespace xt
236253 BENCHMARK_CAPTURE (stencil_threedirections, stencil_threedirections_200, 200 );
237254 BENCHMARK_CAPTURE (stencil_threedirections, stencil_threedirections_300, 300 );
238255 BENCHMARK_CAPTURE (stencil_threedirections, stencil_threedirections_500, 500 );
256+ BENCHMARK_CAPTURE (stencil_twodirections, stencil_twodirections_50, 50 );
257+ BENCHMARK_CAPTURE (stencil_twodirections, stencil_twodirections_100, 100 );
258+ BENCHMARK_CAPTURE (stencil_twodirections, stencil_twodirections_200, 200 );
259+ BENCHMARK_CAPTURE (stencil_twodirections, stencil_twodirections_300, 300 );
260+ BENCHMARK_CAPTURE (stencil_twodirections, stencil_twodirections_500, 500 );
239261 BENCHMARK_CAPTURE (stencil_onedirection, stencil_onedirections_50, 50 );
240262 BENCHMARK_CAPTURE (stencil_onedirection, stencil_onedirections_100, 100 );
241263 BENCHMARK_CAPTURE (stencil_onedirection, stencil_onedirections_200, 200 );
0 commit comments