app: stacked-cores: short-circuit sims that have already completed
this takes the per-sim time down from about 30s to 1s for completed runs. allows much easier stopping + restarting of batched sims.
This commit is contained in:
@@ -3906,23 +3906,6 @@ fn run_sim<const C: usize, const R: usize>(
|
|||||||
// each col M denotes the drive current at core M.
|
// each col M denotes the drive current at core M.
|
||||||
let num_cycles = drive_map.len() as u32;
|
let num_cycles = drive_map.len() as u32;
|
||||||
let num_cores = drive_map[0].len() as u32;
|
let num_cores = drive_map[0].len() as u32;
|
||||||
let mut core_drivers = vec![Vec::default(); num_cores as usize];
|
|
||||||
for (cycle, cores) in drive_map.into_iter().enumerate() {
|
|
||||||
for (core, clock) in cores.into_iter().enumerate() {
|
|
||||||
core_drivers[core as usize].extend(clock.time_stimulus(¶ms, cycle as u32));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
let stim: Vec<_> = core_drivers.into_iter()
|
|
||||||
.enumerate()
|
|
||||||
.map(|(core, time_varying)| {
|
|
||||||
let region = params.ctl(core as u32);
|
|
||||||
let area = region.cross_section();
|
|
||||||
let amp = 1.0 / area;
|
|
||||||
let v_field = CurlVectorField::new(region.clone());
|
|
||||||
ModulatedVectorField::new(v_field, time_varying.scaled(amp.cast::<R>()))
|
|
||||||
})
|
|
||||||
.collect();
|
|
||||||
assert_eq!(stim.len(), num_cores as usize);
|
|
||||||
|
|
||||||
|
|
||||||
let ctl_mat = IsomorphicConductor::new(params.ctl_conductivity.cast::<R>());
|
let ctl_mat = IsomorphicConductor::new(params.ctl_conductivity.cast::<R>());
|
||||||
@@ -3934,6 +3917,25 @@ fn run_sim<const C: usize, const R: usize>(
|
|||||||
let mut driver = Driver::new(Sim::new(
|
let mut driver = Driver::new(Sim::new(
|
||||||
sim_bounds(num_cores).to_index(feat_size), feat_size,
|
sim_bounds(num_cores).to_index(feat_size), feat_size,
|
||||||
));
|
));
|
||||||
|
|
||||||
|
let duration = Seconds(params.clock_phase_duration * num_cycles as f32);
|
||||||
|
let snapshot_freq = 12800;
|
||||||
|
let duration_frames = duration.to_frame(driver.timestep()).round_up(snapshot_freq);
|
||||||
|
let prefix = format!("out/applications/stacked_cores/{}/", name);
|
||||||
|
let _ = std::fs::create_dir_all(&prefix);
|
||||||
|
driver.add_state_file(&*format!("{}state.bc", prefix), snapshot_freq);
|
||||||
|
|
||||||
|
if driver.steps_until(duration_frames) == 0 {
|
||||||
|
println!("sim already completed");
|
||||||
|
return; // all our work is done
|
||||||
|
}
|
||||||
|
|
||||||
|
driver.add_serializer_renderer(&*format!("{}frame-", prefix), 6400, Some(12800));
|
||||||
|
// driver.add_csv_renderer(&*format!("{}meas-detailed.csv", prefix), 100, None);
|
||||||
|
driver.add_csv_renderer(&*format!("{}meas.csv", prefix), 1600, None);
|
||||||
|
driver.add_csv_renderer(&*format!("{}meas-sparse.csv", prefix), 12800, None);
|
||||||
|
driver.set_steps_per_stimulus(200);
|
||||||
|
|
||||||
driver.add_classical_boundary(sim_padding);
|
driver.add_classical_boundary(sim_padding);
|
||||||
|
|
||||||
//////// create the wires and toroids
|
//////// create the wires and toroids
|
||||||
@@ -4005,26 +4007,30 @@ fn run_sim<const C: usize, const R: usize>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
let duration = Seconds(params.clock_phase_duration * num_cycles as f32);
|
//////// add the stimuli
|
||||||
|
let mut core_drivers = vec![Vec::default(); num_cores as usize];
|
||||||
|
for (cycle, cores) in drive_map.into_iter().enumerate() {
|
||||||
|
for (core, clock) in cores.into_iter().enumerate() {
|
||||||
|
core_drivers[core as usize].extend(clock.time_stimulus(¶ms, cycle as u32));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let stim: Vec<_> = core_drivers.into_iter()
|
||||||
|
.enumerate()
|
||||||
|
.map(|(core, time_varying)| {
|
||||||
|
let region = params.ctl(core as u32);
|
||||||
|
let area = region.cross_section();
|
||||||
|
let amp = 1.0 / area;
|
||||||
|
let v_field = CurlVectorField::new(region.clone());
|
||||||
|
ModulatedVectorField::new(v_field, time_varying.scaled(amp.cast::<R>()))
|
||||||
|
})
|
||||||
|
.collect();
|
||||||
|
assert_eq!(stim.len(), num_cores as usize);
|
||||||
|
|
||||||
// let stim = DynStimuli::from_vec(stim.map(MapIntoBoxStimulus).into_vec());
|
|
||||||
let mut driver = driver.with_modulated_stimulus();
|
let mut driver = driver.with_modulated_stimulus();
|
||||||
for s in stim {
|
for s in stim {
|
||||||
driver.add_stimulus(s);
|
driver.add_stimulus(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
let prefix = format!("out/applications/stacked_cores/{}/", name);
|
driver.step_until(duration_frames);
|
||||||
let _ = std::fs::create_dir_all(&prefix);
|
println!("sim complete");
|
||||||
driver.add_state_file(&*format!("{}state.bc", prefix), 12800);
|
|
||||||
driver.add_serializer_renderer(&*format!("{}frame-", prefix), 6400, Some(12800));
|
|
||||||
// driver.add_csv_renderer(&*format!("{}meas-detailed.csv", prefix), 100, None);
|
|
||||||
driver.add_csv_renderer(&*format!("{}meas.csv", prefix), 1600, None);
|
|
||||||
driver.add_csv_renderer(&*format!("{}meas-sparse.csv", prefix), 12800, None);
|
|
||||||
driver.set_steps_per_stimulus(200);
|
|
||||||
|
|
||||||
driver.step_until(
|
|
||||||
duration
|
|
||||||
.to_frame(driver.timestep())
|
|
||||||
.round_up(25600)
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user