Skip to content

Commit

Permalink
[onert] Modify ChromeTracingWriter to generate traceEvents only once (#…
Browse files Browse the repository at this point in the history
…14633)

This commit ensures that `traceEvents` is generated only once and prevents the error of generating multiple `traceEvents` when using multiple nnfw sessions.

ONE-DCO-1.0-Signed-off-by: youngsik kim <ys44.kim@samsung.com>
  • Loading branch information
ys44kim authored Feb 11, 2025
1 parent 537457d commit 6527e1c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
16 changes: 11 additions & 5 deletions runtime/onert/core/src/util/ChromeTracingEventWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,25 @@ std::string getTid(const DurationEvent &evt)

} // namespace

void ChromeTracingWriter::flush(const std::vector<std::unique_ptr<EventRecorder>> &recorders)
ChromeTracingWriter::ChromeTracingWriter(const std::string &filepath) : EventFormatWriter(filepath)
{
_os << "{\n";
_os << " " << quote("traceEvents") << ": [\n";
}

ChromeTracingWriter::~ChromeTracingWriter()
{
_os << " { }\n";
_os << " ]\n";
_os << "}\n";
}

void ChromeTracingWriter::flush(const std::vector<std::unique_ptr<EventRecorder>> &recorders)
{
for (const auto &recorder : recorders)
{
flushOneRecord(*recorder);
}

_os << " { }\n";
_os << " ]\n";
_os << "}\n";
}

void ChromeTracingWriter::flushOneRecord(const EventRecorder &recorder)
Expand Down
2 changes: 2 additions & 0 deletions runtime/onert/core/src/util/EventWriter.cc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ void EventWriter::readyToFlush(std::unique_ptr<EventRecorder> &&recorder)
flush(WriteFormat::SNPE_BENCHMARK);
flush(WriteFormat::CHROME_TRACING);
flush(WriteFormat::MD_TABLE);

_recorders.clear();
}

void EventWriter::flush(WriteFormat write_format)
Expand Down
6 changes: 2 additions & 4 deletions runtime/onert/core/src/util/EventWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,8 @@ class SNPEWriter : public EventFormatWriter
class ChromeTracingWriter : public EventFormatWriter
{
public:
ChromeTracingWriter(const std::string &filepath) : EventFormatWriter(filepath)
{ /* empty */
}
~ChromeTracingWriter() {}
ChromeTracingWriter(const std::string &filepath);
~ChromeTracingWriter();

void flush(const std::vector<std::unique_ptr<EventRecorder>> &) override;

Expand Down

0 comments on commit 6527e1c

Please sign in to comment.