Loading...
Searching...
No Matches
CalculatorGroupUse.h
Go to the documentation of this file.
1/*
2** This file is part of eOn.
3**
4** SPDX-License-Identifier: BSD-3-Clause
5**
6** Copyright (c) 2010--present, eOn Development Team
7** All rights reserved.
8**
9** Repo:
10** https://github.com/TheochemUI/eOn
11*/
12#pragma once
13
14#include <algorithm>
15#include <cstddef>
16#include <format>
17#include <numeric>
18#include <string>
19#include <vector>
20
21namespace eonc {
22
29 std::vector<double> busy;
30 std::vector<double> systems;
31 double wall{0.0};
32 double singleWall{0.0};
33 long batches{0};
34 long singles{0};
35
36 [[nodiscard]] std::size_t groups() const noexcept { return busy.size(); }
37
38 [[nodiscard]] double meanBusy() const noexcept {
39 if (busy.empty()) {
40 return 0.0;
41 }
42 return std::accumulate(busy.begin(), busy.end(), 0.0) /
43 static_cast<double>(busy.size());
44 }
45
46 [[nodiscard]] double maxBusy() const noexcept {
47 return busy.empty() ? 0.0 : *std::max_element(busy.begin(), busy.end());
48 }
49
51 [[nodiscard]] double loadBalance() const noexcept {
52 const double m = maxBusy();
53 return m > 0.0 ? meanBusy() / m : 1.0;
54 }
55
59 [[nodiscard]] double communicationEfficiency() const noexcept {
60 return wall > 0.0 ? std::min(1.0, maxBusy() / wall) : 1.0;
61 }
62
63 [[nodiscard]] double parallelEfficiency() const noexcept {
65 }
66
68 [[nodiscard]] double idleFraction(std::size_t group) const noexcept {
69 if (group >= busy.size() || wall <= 0.0) {
70 return 0.0;
71 }
72 return std::clamp(1.0 - busy[group] / wall, 0.0, 1.0);
73 }
74
75 [[nodiscard]] std::string table() const {
76 std::string out = std::format(
77 "calculator groups: {} groups, {} batches and {} single requests, "
78 "{:.1f} s grouped wall ({:.1f} s single)\n",
80 out += std::format("{:>6} {:>8} {:>10} {:>6}\n", "group", "systems",
81 "busy_s", "idle");
82 for (std::size_t g = 0; g < busy.size(); ++g) {
83 const double n = g < systems.size() ? systems[g] : 0.0;
84 out += std::format("{:>6} {:>8.0f} {:>10.2f} {:>5.1f}%\n", g, n, busy[g],
85 100.0 * idleFraction(g));
86 }
87 out += std::format("load balance {:.3f}, communication efficiency {:.3f}, "
88 "parallel efficiency {:.3f}\n",
91 return out;
92 }
93};
94
95} // namespace eonc
RAII resource manager for the ARTn C library with global synchronization.
How a job used its calculator groups: the seconds each group spent inside engine calls,...
double idleFraction(std::size_t group) const noexcept
Fraction of the grouped wall time a group spent outside engine calls.
double singleWall
of which single-system requests
long singles
single-system requests (group 0 only)
double parallelEfficiency() const noexcept
std::vector< double > systems
systems evaluated, per group
long batches
grouped batch requests
double communicationEfficiency() const noexcept
Max busy over wall: the share of the driver's wait that the busiest group spent computing.
std::string table() const
std::size_t groups() const noexcept
std::vector< double > busy
seconds in engine calls, per group
double maxBusy() const noexcept
double loadBalance() const noexcept
Mean over max busy time: 1 when every group carried the same work.
double wall
driver seconds inside grouped requests
double meanBusy() const noexcept