Driver: remove the unecessary Box
ing of RenderedStimulus
no obvious perf diff one way or the other, yet
This commit is contained in:
@@ -282,7 +282,7 @@ where
|
|||||||
|
|
||||||
trace!("step begin");
|
trace!("step begin");
|
||||||
self.diag.instrument_step(steps_this_time as u64, || {
|
self.diag.instrument_step(steps_this_time as u64, || {
|
||||||
self.state.step_multiple(steps_this_time, &*stim);
|
self.state.step_multiple(steps_this_time, &stim);
|
||||||
});
|
});
|
||||||
trace!("step end");
|
trace!("step end");
|
||||||
|
|
||||||
@@ -456,7 +456,7 @@ struct StimAccess<R, T> {
|
|||||||
/// queue)?
|
/// queue)?
|
||||||
/// A.K.A. "can i safely do a blocking recv on response_channel".
|
/// A.K.A. "can i safely do a blocking recv on response_channel".
|
||||||
outstanding: Cell<bool>,
|
outstanding: Cell<bool>,
|
||||||
worker: JobPool<(SimMeta<f32>, u64), (SimMeta<f32>, u64, Box<RenderedStimulus<R>>)>,
|
worker: JobPool<(SimMeta<f32>, u64), (SimMeta<f32>, u64, RenderedStimulus<R>)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<R, T> StimAccess<R, T> {
|
impl<R, T> StimAccess<R, T> {
|
||||||
@@ -483,7 +483,7 @@ impl<R, T> StimAccess<R, T> {
|
|||||||
/// waits for an outstanding job (if any).
|
/// waits for an outstanding job (if any).
|
||||||
/// if the response matches the request, return the response,
|
/// if the response matches the request, return the response,
|
||||||
/// else discard the response.
|
/// else discard the response.
|
||||||
fn maybe_wait_for_job(&self, meta: SimMeta<f32>, step: u64) -> Option<Box<RenderedStimulus<R>>> {
|
fn maybe_wait_for_job(&self, meta: SimMeta<f32>, step: u64) -> Option<RenderedStimulus<R>> {
|
||||||
if !self.outstanding.get() {
|
if !self.outstanding.get() {
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
@@ -501,7 +501,7 @@ impl<R, T> StimAccess<R, T> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<R: Real, T: DriverStimulus<R> + Send + 'static> StimAccess<R, T> {
|
impl<R: Real, T: DriverStimulus<R> + Send + 'static> StimAccess<R, T> {
|
||||||
fn get_for(&mut self, meta: SimMeta<f32>, step: u64) -> Box<RenderedStimulus<R>> {
|
fn get_for(&mut self, meta: SimMeta<f32>, step: u64) -> RenderedStimulus<R> {
|
||||||
// either claim the outstanding job (if it exists and matches)...
|
// either claim the outstanding job (if it exists and matches)...
|
||||||
self.maybe_wait_for_job(meta, step).unwrap_or_else(|| {
|
self.maybe_wait_for_job(meta, step).unwrap_or_else(|| {
|
||||||
// or start a job and wait for it to complete inline
|
// or start a job and wait for it to complete inline
|
||||||
@@ -529,14 +529,13 @@ impl<R: Real, T: DriverStimulus<R> + Send + 'static> StimAccess<R, T> {
|
|||||||
let stim = diag.instrument_stimuli(|| {
|
let stim = diag.instrument_stimuli(|| {
|
||||||
let stim = stim.lock().unwrap();
|
let stim = stim.lock().unwrap();
|
||||||
let opt = stim.optimized_for(meta, step);
|
let opt = stim.optimized_for(meta, step);
|
||||||
// TODO: remove this box. RenderedStimulus is already heap allocated, so no perf diff?
|
opt.as_ref().rendered(
|
||||||
Box::new(opt.as_ref().rendered(
|
|
||||||
meta.time_step().cast(),
|
meta.time_step().cast(),
|
||||||
// TODO: convert this to an integer
|
// TODO: convert this to an integer
|
||||||
meta.time_step().cast::<R>() * R::from_primitive(step),
|
meta.time_step().cast::<R>() * R::from_primitive(step),
|
||||||
meta.feature_size().cast(),
|
meta.feature_size().cast(),
|
||||||
meta.dim()
|
meta.dim()
|
||||||
).into_owned())
|
).into_owned()
|
||||||
//^ this 'into_owned' ought to be a no-op.
|
//^ this 'into_owned' ought to be a no-op.
|
||||||
//^ it would only ever be borrowed if we accidentally called `rendered` twice.
|
//^ it would only ever be borrowed if we accidentally called `rendered` twice.
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user