76 "bench_triad", Kokkos::RangePolicy<>(0, n),
100int main(
int argc,
char** argv) {
101 Kokkos::initialize(argc, argv);
103 const int n = argc > 1 ? std::atoi(argv[1]) : 128;
104 const int reps = argc > 2 ? std::atoi(argv[2]) : 50;
105 Kokkos::Tools::Experimental::set_allocate_data_callback(onAlloc);
106 Kokkos::Tools::Experimental::set_deallocate_data_callback(onFree);
108 const double bwStream = streamTriad();
109 std::printf(
"G-perf backend %s, n = %d\n", Kokkos::DefaultExecutionSpace::name(), n);
110 std::printf(
" stream triad: %.1f GB/s\n", bwStream);
118 const double cells = (double)n * n * n;
120 const auto t0 = Clock::now();
121 (void)s.scalarCutGeometry();
123 const double tGeom = seconds(t0);
124 const std::uint64_t geomBytes = gBytes;
127 const auto t1 = Clock::now();
128 s.addScalar(
"c", 0.7, 1, 50,
true);
129 s.setScalarWall(
"c", 1, 1.0, 0.0, -1);
130 s.setScalarSource(
"c", -0.3);
131 s.solveScalarSteady(
"c");
133 const double tSolve = seconds(t1);
135 auto& sc = s.scalarField(
"c");
137 " memory: geometry record (per solver, shared) %.0f B/cell; one single-phase scalar "
138 "(steady, %d MG levels) live %.0f B/cell, peak %.0f B/cell (bound 300)\n",
139 (
double)geomBytes / cells, sc.cut->mgLevels, (
double)gBytes / cells, (
double)gPeak / cells);
140 std::printf(
" geometry record build: %.3f s\n", tGeom);
141 std::printf(
" first steady solve (assembly + MG build + %d iterations): %.3f s\n",
142 sc.cut->iterations, tSolve);
144 const std::size_t ne = sc.c.extent(0);
145 CCField x(
"bx", ne), y(
"by", ne);
146 Kokkos::deep_copy(x, sc.c);
147 s.scalarCutMatvec(sc, y, x);
149 double best = 1e30, sum = 0.0;
150 for (
int r = 0; r < reps; ++r) {
151 const auto t1 = Clock::now();
152 s.scalarCutMatvec(sc, y, x);
154 const double t = seconds(t1);
155 best = std::fmin(best, t);
158 const double bw = 9.0 * 8.0 * (double)ne / best / 1e9;
160 " matvec: best %.3f ms, mean %.3f ms; effective %.1f GB/s on 72 B per extended cell = "
161 "%.0f %% of the triad (red flag < 50 %%)\n",
162 1e3 * best, 1e3 * sum / reps, bw, 100.0 * bw / bwStream);