Skip to content

Commit 7ce2622

Browse files
committed
Expose TimingManager OutputTextStrategy
VPUx references directly. This was hidden on the LLVM side with commit 362aa43
1 parent 9eaff2e commit 7ce2622

File tree

2 files changed

+48
-47
lines changed

2 files changed

+48
-47
lines changed

mlir/include/mlir/Support/Timing.h

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "llvm/ADT/STLExtras.h"
1818
#include "llvm/ADT/StringMapEntry.h"
1919
#include "llvm/Support/raw_ostream.h"
20+
#include "llvm/Support/Format.h"
2021
#include <optional>
2122

2223
namespace mlir {
@@ -367,6 +368,53 @@ class OutputStrategy {
367368
raw_ostream &os;
368369
};
369370

371+
constexpr llvm::StringLiteral kTimingDescription =
372+
"... Execution time report ...";
373+
374+
class OutputTextStrategy : public OutputStrategy {
375+
public:
376+
OutputTextStrategy(raw_ostream &os) : OutputStrategy(os) {}
377+
378+
void printHeader(const TimeRecord &total) override {
379+
// Figure out how many spaces to description name.
380+
unsigned padding = (80 - kTimingDescription.size()) / 2;
381+
os << "===" << std::string(73, '-') << "===\n";
382+
os.indent(padding) << kTimingDescription << '\n';
383+
os << "===" << std::string(73, '-') << "===\n";
384+
385+
// Print the total time followed by the section headers.
386+
os << llvm::format(" Total Execution Time: %.4f seconds\n\n", total.wall);
387+
if (total.user != total.wall)
388+
os << " ----User Time----";
389+
os << " ----Wall Time---- ----Name----\n";
390+
}
391+
392+
void printFooter() override { os.flush(); }
393+
394+
void printTime(const TimeRecord &time, const TimeRecord &total) override {
395+
if (total.user != total.wall) {
396+
os << llvm::format(" %8.4f (%5.1f%%)", time.user,
397+
100.0 * time.user / total.user);
398+
}
399+
os << llvm::format(" %8.4f (%5.1f%%) ", time.wall,
400+
100.0 * time.wall / total.wall);
401+
}
402+
403+
void printListEntry(StringRef name, const TimeRecord &time,
404+
const TimeRecord &total, bool lastEntry) override {
405+
printTime(time, total);
406+
os << name << "\n";
407+
}
408+
409+
void printTreeEntry(unsigned indent, StringRef name, const TimeRecord &time,
410+
const TimeRecord &total) override {
411+
printTime(time, total);
412+
os.indent(indent) << name << "\n";
413+
}
414+
415+
void printTreeEntryEnd(unsigned indent, bool lastEntry) override {}
416+
};
417+
370418
//===----------------------------------------------------------------------===//
371419
// DefaultTimingManager
372420
//===----------------------------------------------------------------------===//

mlir/lib/Support/Timing.cpp

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@ using namespace detail;
3434
using DisplayMode = DefaultTimingManager::DisplayMode;
3535
using OutputFormat = DefaultTimingManager::OutputFormat;
3636

37-
constexpr llvm::StringLiteral kTimingDescription =
38-
"... Execution time report ...";
39-
4037
//===----------------------------------------------------------------------===//
4138
// TimingManager
4239
//===----------------------------------------------------------------------===//
@@ -110,50 +107,6 @@ TimingIdentifier TimingIdentifier::get(StringRef str, TimingManager &tm) {
110107

111108
namespace {
112109

113-
class OutputTextStrategy : public OutputStrategy {
114-
public:
115-
OutputTextStrategy(raw_ostream &os) : OutputStrategy(os) {}
116-
117-
void printHeader(const TimeRecord &total) override {
118-
// Figure out how many spaces to description name.
119-
unsigned padding = (80 - kTimingDescription.size()) / 2;
120-
os << "===" << std::string(73, '-') << "===\n";
121-
os.indent(padding) << kTimingDescription << '\n';
122-
os << "===" << std::string(73, '-') << "===\n";
123-
124-
// Print the total time followed by the section headers.
125-
os << llvm::format(" Total Execution Time: %.4f seconds\n\n", total.wall);
126-
if (total.user != total.wall)
127-
os << " ----User Time----";
128-
os << " ----Wall Time---- ----Name----\n";
129-
}
130-
131-
void printFooter() override { os.flush(); }
132-
133-
void printTime(const TimeRecord &time, const TimeRecord &total) override {
134-
if (total.user != total.wall) {
135-
os << llvm::format(" %8.4f (%5.1f%%)", time.user,
136-
100.0 * time.user / total.user);
137-
}
138-
os << llvm::format(" %8.4f (%5.1f%%) ", time.wall,
139-
100.0 * time.wall / total.wall);
140-
}
141-
142-
void printListEntry(StringRef name, const TimeRecord &time,
143-
const TimeRecord &total, bool lastEntry) override {
144-
printTime(time, total);
145-
os << name << "\n";
146-
}
147-
148-
void printTreeEntry(unsigned indent, StringRef name, const TimeRecord &time,
149-
const TimeRecord &total) override {
150-
printTime(time, total);
151-
os.indent(indent) << name << "\n";
152-
}
153-
154-
void printTreeEntryEnd(unsigned indent, bool lastEntry) override {}
155-
};
156-
157110
class OutputJsonStrategy : public OutputStrategy {
158111
public:
159112
OutputJsonStrategy(raw_ostream &os) : OutputStrategy(os) {}

0 commit comments

Comments
 (0)