Skip to content
Snippets Groups Projects
Commit 4f3999d3 authored by Felix Weiglhofer's avatar Felix Weiglhofer Committed by Dominik Smith
Browse files

algo::TimingsFormat: Improve handling of subtimers.

parent cdc6c061
No related branches found
No related tags found
1 merge request!1219algo: Unpack TOF and STS in parallel.
......@@ -21,7 +21,11 @@ namespace cbm::algo
fSS = std::stringstream();
}
void Title(std::string_view title) { fSS << fmt::format("{:<{}}\n", title, fAlign); }
void Title(std::string_view title)
{
Indent();
fSS << fmt::format("{:<{}}\n", title, fAlign);
}
std::string Finalize() { return fSS.str(); }
......@@ -35,13 +39,20 @@ namespace cbm::algo
Measurement("Memset", t.memset(), t.throughput_memset());
NewLine();
// Merge subtimers with identical names
// Useful eg in unpacking, where unpacker might be called multiple times per TS
std::unordered_map<std::string, xpu::timings> subtimers;
for (xpu::timings& st : t.children()) {
if (st.kernels().empty()) {
Measurement(st.name(), st.wall(), st.throughput());
subtimers[std::string(st.name())].merge(st);
}
for (auto& [name, st] : subtimers) {
if (st.kernels().empty() && st.children().empty()) {
Measurement(name, st.wall(), st.throughput());
NewLine();
}
else {
Title(st.name());
Title(name);
Fmt(st);
NewLine();
}
......@@ -52,8 +63,10 @@ namespace cbm::algo
NewLine();
}
Measurement("Kernel time", t.kernel_time(), t.throughput_kernels());
NewLine();
if (!t.kernels().empty()) {
Measurement("Kernel time", t.kernel_time(), t.throughput_kernels());
NewLine();
}
Measurement("Wall time", t.wall(), t.throughput());
fIndent -= 2;
}
......@@ -88,7 +101,7 @@ namespace cbm::algo
private:
void Measurement(std::string_view name, f64 time, f64 throughput)
{
fSS << std::setw(fIndent) << std::setfill(' ') << std::right << "";
Indent();
fSS << std::setw(fAlign) << std::setfill(' ') << std::left << fmt::format("{}:", name);
Real(time, 10, 3, "ms");
if (std::isnormal(throughput)) {
......@@ -113,6 +126,8 @@ namespace cbm::algo
}
}
void Indent() { fSS << std::setw(fIndent) << std::setfill(' ') << std::left << ""; }
size_t fAlign = 0;
size_t fIndent = 0;
std::stringstream fSS;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment