47 Kokkos::initialize(
argc, argv);
49 const int reps =
argc > 1 ? std::atoi(argv[1]) : 20;
50 const std::string
cname =
argc > 2 ? argv[2] :
"walls-y";
51 const char* dump = (
argc > 3 && std::strcmp(argv[3],
"-") != 0) ? argv[3] :
nullptr;
53 for (
int a = 4; a <
argc; ++a)
54 Ts.push_back(std::atoi(argv[a]));
56 Ts = {1, 2, 4, 8, 16, 24};
57 int bc[6] = {0, 0, 1, 1, 0, 0};
58 if (
cname ==
"periodic")
60 const int nx = 32, ny = 24, nz = 16;
63 mg.
init(nx, ny, nz, 2);
65 const C3 e{nx + 2, ny + 2, nz + 2};
66 const std::size_t n = (std::size_t)e.x * e.y * e.z;
67 std::vector<double>
hx(n),
hy(n),
hz(n);
68 const double lr = std::log(50.0), k = 2.0 *
M_PI;
69 for (
int z = 0; z < e.z; ++z)
70 for (
int y = 0; y < e.y; ++y)
71 for (
int x = 0; x < e.x; ++x) {
72 const std::size_t i = x + (std::size_t)y * e.x + (std::size_t)z * e.x * e.y;
73 const double s = 0.5 + 0.5 * std::sin(k * x / nx) * std::cos(k * (y + 0.5 * z) / ny);
74 const double t = 0.5 + 0.5 * std::cos(k * (x + z) / nz);
75 hx[i] = std::exp(lr * s) / 50.0;
76 hy[i] = std::exp(lr * t) / 50.0;
77 hz[i] = std::exp(lr * (1.0 - s)) / 50.0;
79 auto dev = [](
const std::vector<double>& v,
const char* name) {
81 auto h = Kokkos::create_mirror_view(f);
82 for (std::size_t i = 0; i < v.size(); ++i)
84 Kokkos::deep_copy(f, h);
87 CCField ox = dev(
hx,
"ox"), oy = dev(
hy,
"oy"), oz = dev(
hz,
"oz");
91 printf(
"bench_bottom_factor %s: P = %d, b = %d, border %d, %d reps, concurrency %d\n",
93 std::vector<char> ref;
94 const bool host = std::is_same_v<CCMem, Kokkos::HostSpace>;
100 if (T != 0 &&
Tu != T) {
101 printf(
" T %3d: not available (ran %d), skipped\n", T,
Tu);
104 for (
int w = 0; w < 3; ++w)
107 std::vector<double> ms;
108 for (
int r = 0; r <
reps; ++r) {
112 ms.push_back(tm.seconds() * 1
e3);
114 std::sort(ms.begin(), ms.end());
115 const std::vector<char> st =
storage(D);
116 const char*
same =
"reference";
120 FILE* f = std::fopen(dump,
"wb");
121 std::fwrite(ref.data(), 1, ref.size(), f);
125 same = (st == ref) ?
"bitwise identical" :
"DIFFERS";
127 printf(
" %s T %3d: factor min %8.3f ms median %8.3f ms max %8.3f ms (%s)\n",
128 host ? (
team ?
"team" :
"host") :
"team",
Tu, ms.front(), ms[ms.size() / 2],