app: multi_core_inverter: perf: move the stimulus Gating to outside the CurlStimulus
the region.contains() logic is much more expensive than the time bounds check. this gets an easy 50% perf boost to the ENTIRE simulation
This commit is contained in:
@@ -137,30 +137,30 @@ struct Params {
|
||||
clock_decay: f32, // exp decay half-life
|
||||
}
|
||||
|
||||
type HoldStim = CurlStimulus<Torus, Gated<f32>>;
|
||||
type ReleaseStim = CurlStimulus<Torus, Shifted<Gated<Exp<f32>>>>;
|
||||
type HoldStim = Gated<CurlStimulus<Torus, f32>>;
|
||||
type ReleaseStim = Shifted<Gated<Exp<CurlStimulus<Torus, f32>>>>;
|
||||
fn control_signal_hold(params: Params, region: Torus, cycle: u32, ty: DriveType) -> HoldStim {
|
||||
let area = region.cross_section();
|
||||
let amp = ty.direction() as f32 * params.input_magnitude / area;
|
||||
let start = params.clock_phase_duration * cycle as f32;
|
||||
// simple square wave:
|
||||
let wave = Gated::new(amp, start, start + params.clock_phase_duration);
|
||||
CurlStimulus::new(
|
||||
let base_stim = CurlStimulus::new(
|
||||
region.clone(),
|
||||
wave.clone(),
|
||||
)
|
||||
amp,
|
||||
);
|
||||
// simple square wave:
|
||||
let start = params.clock_phase_duration * cycle as f32;
|
||||
Gated::new(base_stim, start, start + params.clock_phase_duration)
|
||||
}
|
||||
|
||||
fn control_signal_release(params: Params, region: Torus, cycle: u32, ty: DriveType) -> ReleaseStim {
|
||||
let area = region.cross_section();
|
||||
let amp = ty.direction() as f32 * params.input_magnitude / area;
|
||||
let start = params.clock_phase_duration * cycle as f32;
|
||||
// decaying exponential wave:
|
||||
let wave = Exp::new_at(amp, start, params.clock_decay);
|
||||
CurlStimulus::new(
|
||||
let base_stim = CurlStimulus::new(
|
||||
region.clone(),
|
||||
wave.clone(),
|
||||
)
|
||||
amp,
|
||||
);
|
||||
// decaying exponential wave:
|
||||
let start = params.clock_phase_duration * cycle as f32;
|
||||
Exp::new_at(base_stim, start, params.clock_decay)
|
||||
}
|
||||
|
||||
|
||||
@@ -393,7 +393,7 @@ fn main() {
|
||||
assert_eq!(num_cores, 5);
|
||||
let mut driver = driver.with_stimulus(stim);
|
||||
|
||||
let prefix = "out/applications/multi_core_inverter/13/";
|
||||
let prefix = "out/applications/multi_core_inverter/14/";
|
||||
let _ = std::fs::create_dir_all(&prefix);
|
||||
driver.add_state_file(&*format!("{}state.bc", prefix), 6400);
|
||||
driver.add_serializer_renderer(&*format!("{}frame-", prefix), 3200, None);
|
||||
|
Reference in New Issue
Block a user