Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Commit 0819d46

Browse files
Wenzhe Xuediyessi
authored andcommitted
add rank id to trace file name (#3525)
1 parent 70c6579 commit 0819d46

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/ngraph/event_tracing.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <sstream>
1919
#include <string>
2020

21+
#include "distributed.hpp"
2122
#include "event_tracing.hpp"
2223
#include "nlohmann/json.hpp"
2324

@@ -42,7 +43,15 @@ void ngraph::Event::write_trace(const ngraph::Event& event)
4243
if (!so_initialized)
4344
{
4445
// Open the file
45-
s_event_log.open("ngraph_event_trace.json", ios_base::trunc);
46+
std::string file_name = "ngraph_event_trace.json";
47+
if (get_distributed_interface()->get_size() > 1)
48+
{
49+
auto rank = std::to_string(get_distributed_interface()->get_rank());
50+
int num_zero = 3;
51+
std::string prefix = std::string(num_zero - rank.length(), '0') + rank + "_";
52+
file_name.insert(0, prefix);
53+
}
54+
s_event_log.open(file_name, ios_base::trunc);
4655
s_event_log << "[\n";
4756
so_initialized = true;
4857
}

0 commit comments

Comments
 (0)