diff --git a/crates/coremem/src/driver.rs b/crates/coremem/src/driver.rs index d6b4e33..e0e72da 100644 --- a/crates/coremem/src/driver.rs +++ b/crates/coremem/src/driver.rs @@ -296,14 +296,8 @@ where } steps_this_time } - pub fn step_multiple(&mut self, num_steps: u32) { - let mut steps_remaining = num_steps; - while steps_remaining != 0 { - steps_remaining -= self.step_at_most(steps_remaining); - } - } pub fn step(&mut self) { - self.step_multiple(1); + self.step_at_most(1); } /// Returns the number of timesteps needed to reach the end time @@ -318,7 +312,9 @@ where self.sim_end_time = Some(sim_end_time); let mut stepped = false; while self.state.step_no() < *sim_end_time { - self.step_multiple(1000); + let steps_left = *sim_end_time - self.state.step_no(); + // sanity limit: don't try to step too much at once else we may lock up the GPU/etc. + self.step_at_most(steps_left.min(1000) as u32); stepped = true; } if stepped { @@ -519,9 +515,11 @@ impl + Send + 'static> StimAccess { assert!(!self.outstanding.get()); self.outstanding.set(true); + // these are cheap Arc clones let diag = self.diag.clone(); let stim = self.stim.clone(); let response_handle = self.response_channel.0.clone(); + self.worker.execute(move || { trace!("eval_stimulus begin"); let rendered = diag.instrument_stimuli(|| {