Driver: fix a bug where we might step more than the user wanted
This commit is contained in:
@@ -296,14 +296,8 @@ where
|
|||||||
}
|
}
|
||||||
steps_this_time
|
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) {
|
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
|
/// Returns the number of timesteps needed to reach the end time
|
||||||
@@ -318,7 +312,9 @@ where
|
|||||||
self.sim_end_time = Some(sim_end_time);
|
self.sim_end_time = Some(sim_end_time);
|
||||||
let mut stepped = false;
|
let mut stepped = false;
|
||||||
while self.state.step_no() < *sim_end_time {
|
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;
|
stepped = true;
|
||||||
}
|
}
|
||||||
if stepped {
|
if stepped {
|
||||||
@@ -519,9 +515,11 @@ impl<R: Real, T: DriverStimulus<R> + Send + 'static> StimAccess<R, T> {
|
|||||||
assert!(!self.outstanding.get());
|
assert!(!self.outstanding.get());
|
||||||
self.outstanding.set(true);
|
self.outstanding.set(true);
|
||||||
|
|
||||||
|
// these are cheap Arc clones
|
||||||
let diag = self.diag.clone();
|
let diag = self.diag.clone();
|
||||||
let stim = self.stim.clone();
|
let stim = self.stim.clone();
|
||||||
let response_handle = self.response_channel.0.clone();
|
let response_handle = self.response_channel.0.clone();
|
||||||
|
|
||||||
self.worker.execute(move || {
|
self.worker.execute(move || {
|
||||||
trace!("eval_stimulus begin");
|
trace!("eval_stimulus begin");
|
||||||
let rendered = diag.instrument_stimuli(|| {
|
let rendered = diag.instrument_stimuli(|| {
|
||||||
|
Reference in New Issue
Block a user