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 ...@@ -21,7 +21,11 @@ namespace cbm::algo
fSS = std::stringstream(); 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(); } std::string Finalize() { return fSS.str(); }
...@@ -35,13 +39,20 @@ namespace cbm::algo ...@@ -35,13 +39,20 @@ namespace cbm::algo
Measurement("Memset", t.memset(), t.throughput_memset()); Measurement("Memset", t.memset(), t.throughput_memset());
NewLine(); 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()) { for (xpu::timings& st : t.children()) {
if (st.kernels().empty()) { subtimers[std::string(st.name())].merge(st);
Measurement(st.name(), st.wall(), st.throughput()); }
for (auto& [name, st] : subtimers) {
if (st.kernels().empty() && st.children().empty()) {
Measurement(name, st.wall(), st.throughput());
NewLine(); NewLine();
} }
else { else {
Title(st.name()); Title(name);
Fmt(st); Fmt(st);
NewLine(); NewLine();
} }
...@@ -52,8 +63,10 @@ namespace cbm::algo ...@@ -52,8 +63,10 @@ namespace cbm::algo
NewLine(); NewLine();
} }
Measurement("Kernel time", t.kernel_time(), t.throughput_kernels()); if (!t.kernels().empty()) {
NewLine(); Measurement("Kernel time", t.kernel_time(), t.throughput_kernels());
NewLine();
}
Measurement("Wall time", t.wall(), t.throughput()); Measurement("Wall time", t.wall(), t.throughput());
fIndent -= 2; fIndent -= 2;
} }
...@@ -88,7 +101,7 @@ namespace cbm::algo ...@@ -88,7 +101,7 @@ namespace cbm::algo
private: private:
void Measurement(std::string_view name, f64 time, f64 throughput) 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); fSS << std::setw(fAlign) << std::setfill(' ') << std::left << fmt::format("{}:", name);
Real(time, 10, 3, "ms"); Real(time, 10, 3, "ms");
if (std::isnormal(throughput)) { if (std::isnormal(throughput)) {
...@@ -113,6 +126,8 @@ namespace cbm::algo ...@@ -113,6 +126,8 @@ namespace cbm::algo
} }
} }
void Indent() { fSS << std::setw(fIndent) << std::setfill(' ') << std::left << ""; }
size_t fAlign = 0; size_t fAlign = 0;
size_t fIndent = 0; size_t fIndent = 0;
std::stringstream fSS; 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