Skip to content

Commit 12bb0c8

Browse files
author
janekdererste
committed
Make events writing configurable
1 parent 775ae7c commit 12bb0c8

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/simulation/config.rs

+11
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ impl Config {
4343
config.set_output(Output {
4444
output_dir: out_dir,
4545
profiling: config.output().profiling,
46+
write_events: Default::default(),
4647
});
4748
}
4849
config
@@ -90,6 +91,7 @@ impl Config {
9091
let default = Output {
9192
output_dir: "./".to_string(),
9293
profiling: Profiling::None,
94+
write_events: Default::default(),
9395
};
9496
self.modules
9597
.borrow_mut()
@@ -157,6 +159,8 @@ pub struct Output {
157159
pub output_dir: String,
158160
#[serde(default)]
159161
pub profiling: Profiling,
162+
#[serde(default)]
163+
pub write_events: WriteEvents,
160164
}
161165

162166
#[derive(Serialize, Deserialize, Clone)]
@@ -242,6 +246,13 @@ pub enum Profiling {
242246
CSV(ProfilingLevel),
243247
}
244248

249+
#[derive(PartialEq, Debug, Clone, Serialize, Deserialize, Default)]
250+
pub enum WriteEvents {
251+
#[default]
252+
None,
253+
Proto,
254+
}
255+
245256
#[derive(PartialEq, Debug, Clone, Serialize, Deserialize, Default)]
246257
pub struct ProfilingLevel {
247258
#[serde(default = "default_profiling_level")]

src/simulation/controller.rs

+8-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ use mpi::traits::{Communicator, CommunicatorCollectives};
99
use nohash_hasher::IntMap;
1010
use tracing::info;
1111

12-
use crate::simulation::config::{CommandLineArgs, Config, PartitionMethod, RoutingMode};
12+
use crate::simulation::config::{
13+
CommandLineArgs, Config, PartitionMethod, RoutingMode, WriteEvents,
14+
};
1315
use crate::simulation::io::proto_events::ProtoEventsWriter;
1416
use crate::simulation::messaging::communication::communicators::{
1517
ChannelSimCommunicator, MpiSimCommunicator, SimCommunicator,
@@ -126,12 +128,13 @@ fn execute_partition<C: SimCommunicator + 'static>(comm: C, args: &CommandLineAr
126128

127129
let mut events = EventsPublisher::new();
128130

129-
let events_file = format!("events.{rank}.binpb");
130-
let events_path = output_path.join(events_file);
131-
events.add_subscriber(Box::new(ProtoEventsWriter::new(&events_path)));
131+
if config.output().write_events == WriteEvents::Proto {
132+
let events_file = format!("events.{rank}.binpb");
133+
let events_path = output_path.join(events_file);
134+
events.add_subscriber(Box::new(ProtoEventsWriter::new(&events_path)));
135+
}
132136
let travel_time_collector = Box::new(TravelTimeCollector::new());
133137
events.add_subscriber(travel_time_collector);
134-
//events.add_subscriber(Box::new(EventsLogger {}));
135138

136139
let rc = Rc::new(comm);
137140

0 commit comments

Comments
 (0)