17 Kokkos::initialize(
argc, argv);
21 Ext3 inner{20, 16, 12};
22 Ext3 ext{inner.x + 2 * ghost, inner.y + 2 * ghost, inner.z + 2 * ghost};
23 const std::size_t n =
static_cast<std::size_t
>(ext.x) * ext.y * ext.z;
26 std::uniform_real_distribution<float>
uf(-1.f, 1.f);
27 std::vector<double> ha(n), hb(n);
28 for (std::size_t i = 0; i < n; ++i) {
33 DField a(
"a", n), b(
"b", n);
35 auto h = Kokkos::create_mirror_view(a);
36 for (std::size_t i = 0; i < n; ++i)
38 Kokkos::deep_copy(a, h);
41 auto h = Kokkos::create_mirror_view(b);
42 for (std::size_t i = 0; i < n; ++i)
44 Kokkos::deep_copy(b, h);
49 double dot =
localDot(a, b, ext, ghost, inner);
54 for (
int iz = 0;
iz < inner.z; ++
iz)
55 for (
int iy = 0;
iy < inner.y; ++
iy)
56 for (
int ix = 0;
ix < inner.x; ++
ix) {
57 std::size_t
idx = (std::size_t)(
ix + ghost) + (std::size_t)(
iy + ghost) * ext.x +
58 (std::size_t)(
iz + ghost) * (std::size_t)ext.x * ext.y;
65 auto close = [](
double x,
double y) {
return std::fabs(x - y) <= 1e-9 * (1.0 + std::fabs(y)); };
67 std::fprintf(
stderr,
"FAIL: sum %.10g/%.10g max %.10g/%.10g dot %.10g/%.10g\n",
sm.sum,
73 const double mean =
rsum /
static_cast<double>(count);
78 std::fprintf(
stderr,
"FAIL: post-subtract inner sum %.10g != %.10g\n",
sm2.sum,
expect2);
84 "[mac_reductions] PASS: sum/max/dot + mean-subtract match host (%ld inner cells, exec: "
double localDot(DConst a, DConst b, Ext3 ext, int ghost, Ext3 inner)
Local inner product <a,b> over the inner cells.