52int main(
int argc,
char** argv) {
53 Kokkos::initialize(argc, argv);
55 const int reps = argc > 1 ? std::atoi(argv[1]) : 20;
56 const std::string cname = argc > 2 ? argv[2] :
"walls-y";
57 const char* dump = (argc > 3 && std::strcmp(argv[3],
"-") != 0) ? argv[3] :
nullptr;
59 for (
int a = 4; a < argc; ++a)
60 Ts.push_back(std::atoi(argv[a]));
62 Ts = {1, 2, 4, 8, 16, 24};
63 int bc[6] = {0, 0, 1, 1, 0, 0};
64 if (cname ==
"periodic")
66 const int nx = 32, ny = 24, nz = 16;
69 mg.
init(nx, ny, nz, 2);
71 const C3 e{nx + 2, ny + 2, nz + 2};
72 const std::size_t n = (std::size_t)e.x * e.y * e.z;
73 std::vector<double> hx(n), hy(n), hz(n);
74 const double lr = std::log(50.0), k = 2.0 * M_PI;
75 for (
int z = 0; z < e.z; ++z)
76 for (
int y = 0; y < e.y; ++y)
77 for (
int x = 0; x < e.x; ++x) {
78 const std::size_t i = x + (std::size_t)y * e.x + (std::size_t)z * e.x * e.y;
79 const double s = 0.5 + 0.5 * std::sin(k * x / nx) * std::cos(k * (y + 0.5 * z) / ny);
80 const double t = 0.5 + 0.5 * std::cos(k * (x + z) / nz);
81 hx[i] = std::exp(lr * s) / 50.0;
82 hy[i] = std::exp(lr * t) / 50.0;
83 hz[i] = std::exp(lr * (1.0 - s)) / 50.0;
85 auto dev = [](
const std::vector<double>& v,
const char* name) {
87 auto h = Kokkos::create_mirror_view(f);
88 for (std::size_t i = 0; i < v.size(); ++i)
90 Kokkos::deep_copy(f, h);
93 CCField ox = dev(hx,
"ox"), oy = dev(hy,
"oy"), oz = dev(hz,
"oz");
97 printf(
"bench_bottom_factor %s: P = %d, b = %d, border %d, %d reps, concurrency %d\n",
98 cname.c_str(), pl.
P, pl.
b, pl.
border, reps, (
int)
CCExec().concurrency());
99 std::vector<char> ref;
100 const bool host = std::is_same_v<CCMem, Kokkos::HostSpace>;
101 for (
int alg = 0; alg < (host ? 2 : 1); ++alg)
103 const bool team = alg == 1;
106 if (T != 0 && Tu != T) {
107 printf(
" T %3d: not available (ran %d), skipped\n", T, Tu);
110 for (
int w = 0; w < 3; ++w)
113#ifdef PECLET_FLOW_BOTTOM_PROBE
114 Kokkos::deep_copy(mg.bottomProbe_, 0LL);
116 std::vector<double> ms;
117 for (
int r = 0; r < reps; ++r) {
121 ms.push_back(tm.seconds() * 1e3);
123 std::sort(ms.begin(), ms.end());
124 const std::vector<char> st = storage(D);
125 const char*
same =
"reference";
129 FILE* f = std::fopen(dump,
"wb");
130 std::fwrite(ref.data(), 1, ref.size(), f);
134 same = (st == ref) ?
"bitwise identical" :
"DIFFERS";
136 printf(
" %s T %3d: factor min %8.3f ms median %8.3f ms max %8.3f ms (%s)\n",
137 host ? (team ?
"team" :
"host") :
"team", Tu, ms.front(), ms[ms.size() / 2],
139#ifdef PECLET_FLOW_BOTTOM_PROBE
141 auto h = Kokkos::create_mirror_view_and_copy(Kokkos::HostSpace(), mg.bottomProbe_);
143 for (
int c = 0; c < 8; ++c)
145 const char* nm[8] = {
"scale+cpl",
"assemble",
"diag",
"panel",
146 "trailing",
"W",
"Q",
"border"};
147 printf(
" phase split (ms of the median):");
148 for (
int c = 0; c < 8; ++c)
150 printf(
" %s %.3f", nm[c], tot > 0 ? ms[ms.size() / 2] * (
double)h(c) / tot : 0.0);
157 std::vector<double> hb(bt.n);
158 std::mt19937 rng(11);
159 std::uniform_real_distribution<double>
U(-1.0, 1.0);
162 CCField r = dev(hb,
"r"), z(
"z", bt.n);
164 Kokkos::deep_copy(bt.rhs, r);
166 std::vector<double> mM, mS;
167 for (
int rr = 0; rr < reps + 3; ++rr) {
170 const double a = tm.seconds() * 1e3;
171 Kokkos::deep_copy(bt.rhs, r);
175 const double b = ts.seconds() * 1e3;
181 std::sort(mM.begin(), mM.end());
182 std::sort(mS.begin(), mS.end());
184 " solve: M alone min %.4f median %.4f ms; FCG solve min %.4f median %.4f ms (%d inner "
186 mM.front(), mM[mM.size() / 2], mS.front(), mS[mS.size() / 2], it);