instrument the stimulus evaluation in our sim

... stimulus evaluation accounts for like 80% of the execution time 🤦
This commit is contained in:
2022-08-11 22:57:43 -07:00
parent 09bc7492ed
commit ae1eb861be
4 changed files with 14 additions and 3 deletions

View File

@@ -50,7 +50,7 @@ impl Diagnostics {
render_time,
block_time,
render_prep_time,
overall_time - step_time - stim_time - block_time - render_prep_time,
overall_time - step_time /*- stim_time*/ - block_time - render_prep_time,
)
}
}

View File

@@ -31,7 +31,9 @@ pub struct Driver<S> {
}
impl<S: AbstractSim> Driver<S> {
pub fn new(state: S) -> Self {
pub fn new(mut state: S) -> Self {
let diag = SyncDiagnostics::new();
state.use_diagnostics(diag.clone());
Self {
state,
renderer: Arc::new(MultiRenderer::new()),
@@ -45,7 +47,7 @@ impl<S: AbstractSim> Driver<S> {
],
stimuli: StimuliAdapter::new(),
sim_end_time: None,
diag: SyncDiagnostics::new(),
diag,
last_diag_time: Instant::now(),
}
}
@@ -125,6 +127,7 @@ impl<S: AbstractSim + Send + Sync + Serialize + for<'a> Deserialize<'a> + 'stati
let ser = render::SerializerRenderer::new(state_file);
let loaded = ser.try_load().map(|s| {
self.state = s.state;
self.state.use_diagnostics(self.diag.clone());
}).is_some();
self.add_renderer(ser, state_file, snapshot_frequency, None);
loaded

View File

@@ -1,3 +1,4 @@
use crate::diagnostics::SyncDiagnostics;
use crate::geom::{Coord, Cube, Index, InvertedRegion, Region};
use crate::cross::mat::{FullyGenericMaterial, Material, Vacuum};
use crate::cross::real::Real;
@@ -209,6 +210,9 @@ pub trait AbstractSim: Sync {
/// Take a "snapshot" of the simulation, dropping all material-specific information.
fn to_static(&self) -> StaticSim;
fn to_generic(&self) -> GenericSim<Self::Real>;
fn use_diagnostics(&mut self, _diag: SyncDiagnostics) {
// optional
}
//--- HELPER METHODS below (derived) ---//

View File

@@ -152,6 +152,10 @@ where
diag: self.diag.clone(),
}
}
fn use_diagnostics(&mut self, diag: SyncDiagnostics) {
self.diag = diag;
}
}
impl<R: Real, M: Default, B> SpirvSim<R, M, B>