app: stacked_cores: more experiments around multi-core setups with bias

This commit is contained in:
2022-09-18 17:39:47 -07:00
parent e8fc3c355f
commit 5641dc12f1
3 changed files with 248 additions and 3 deletions

View File

@@ -6,6 +6,7 @@
//! $ cargo run --release --bin stacked_cores //! $ cargo run --release --bin stacked_cores
//! $ pushd crates/coremem; cargo run --release --bin viewer ../../out/applications/stacked_cores/0/ ; popd //! $ pushd crates/coremem; cargo run --release --bin viewer ../../out/applications/stacked_cores/0/ ; popd
//! ``` //! ```
#![feature(generic_const_exprs)]
use coremem::geom::{Coord as _, Meters}; use coremem::geom::{Coord as _, Meters};
use coremem::geom::region::{ use coremem::geom::region::{
@@ -959,6 +960,43 @@ fn drive_map_5stack_with_init5(amp0: f32, amp1: f32, amp2: f32, amp3: f32, amp4:
] ]
} }
#[allow(unused)]
fn drive_map_7stack_half_pos_half_inv(amp_pos: f32, amp_inv: f32, amp_recv: f32) -> [[ClockState; 7]; 3] {
use ClockState as C;
[
// charge all
[C::hold(amp_pos), C::hold(amp_pos), C::hold(amp_pos), C::hold(amp_recv), C::hold(-amp_inv), C::hold(-amp_inv), C::hold(-amp_inv), ],
// let the cores settle
[C::release(amp_pos), C::release(amp_pos), C::release(amp_pos), C::release(amp_recv), C::release(-amp_inv), C::release(-amp_inv), C::release(-amp_inv), ],
// write S* -> S3
[C::hold_low(), C::hold_low(), C::hold_low(), C::float(), C::hold_high(), C::hold_high(), C::hold_high(), ],
]
}
#[allow(unused)]
fn drive_map_nstack_pos_minv<const N: usize, const M: usize>(amp_pos: f32, amp_inv: f32) -> [[ClockState; N+M+1]; 3] {
use ClockState as C;
let mut clocks = [[C::float(); N+M+1]; 3];
for c in 0..N+M+1 {
clocks[0][c] = match c { // charge to base state
0 => C::hold_low(), // prepare to receive
x if x <= N => C::hold(amp_pos), // pos tx
_ => C::hold(-amp_inv), // inv tx
};
clocks[1][c] = match c { // let settle
0 => C::release_low(), // prepare to receive
x if x <= N => C::release(amp_pos), // pos tx
_ => C::release(-amp_inv), // inv tx
};
clocks[2][c] = match c { // write
0 => C::float(), // receive
x if x <= N => C::hold_low(), // write positive
_ => C::hold_high(), // write inverse
};
}
clocks
}
#[allow(unused)] #[allow(unused)]
fn drive_map_3stack_with_init3_m2_inv(amp0: f32, amp1: f32, amp2: f32) -> [[ClockState; 3]; 3] { fn drive_map_3stack_with_init3_m2_inv(amp0: f32, amp1: f32, amp2: f32) -> [[ClockState; 3]; 3] {
use ClockState as C; use ClockState as C;
@@ -3378,7 +3416,7 @@ fn main() {
} }
} }
if true { if false {
let p36xx = params let p36xx = params
.with_clock_phase_duration(ps(1000)) .with_clock_phase_duration(ps(1000))
.with_clock_decay(ps(50)) .with_clock_decay(ps(50))
@@ -3389,7 +3427,7 @@ fn main() {
.with_coupling_loops(8) .with_coupling_loops(8)
.with_coupling(0, 4, 0, 1, CouplingMethod::Direct) .with_coupling(0, 4, 0, 1, CouplingMethod::Direct)
; ;
for (scur, cur) in [("15e9", 15e9), ("1e10", 1e9), ("2e10", 2e10), ] { for (scur, cur) in [("1e10", 1e10), ("15e9", 15e9), ("2e10", 2e10), ] {
for (srx, rx) in [("n100", -1.00), ] { for (srx, rx) in [("n100", -1.00), ] {
for (sshunt, fshunt) in [("p100", 1.00), /*("p050", 0.50),*/] { for (sshunt, fshunt) in [("p100", 1.00), /*("p050", 0.50),*/] {
for (sinit, finit) in [ for (sinit, finit) in [
@@ -3415,6 +3453,144 @@ fn main() {
} }
} }
} }
if false {
let p37xx = params
.with_clock_phase_duration(ps(1000))
.with_clock_decay(ps(50))
.with_input_magnitude(2e10)
.with_ctl_conductivity(5e2)
.with_coupling_conductivity(5e3)
.with_s_major(um(400))
.with_coupling_loops(8)
.with_coupling(0, 6, 0, 1, CouplingMethod::Direct)
;
for (scur, cur) in [("2e10", 2e10), ("15e9", 15e9), ("1e10", 1e10), ] {
for (srx, frx) in [("n100", -1.00), ] {
for (sshunt, fshunt) in [("p100", 1.00), ("p050", 0.50), ("p020", 0.20)] {
for (sinit, finit) in [
("n100", -1.00),
("n080", -0.80),
("n050", -0.50),
("n030", -0.30),
("n020", -0.20),
("000", 0.00),
("p020", 0.20),
("p050", 0.50),
("p080", 0.80),
("p100", 1.00),
] {
run_sim(
&format!("37-{}-8loop-{}rx-{}shunt-{}tx", scur, srx, sshunt, sinit),
drive_map_7stack_half_pos_half_inv(finit, fshunt, frx),
p37xx
.with_input_magnitude(cur)
)
}
}
}
}
}
if true {
let p38xx = params
.with_clock_phase_duration(ps(1000))
.with_clock_decay(ps(50))
.with_input_magnitude(2e10)
.with_ctl_conductivity(5e2)
.with_coupling_conductivity(5e3)
.with_s_major(um(400))
.with_coupling_loops(8)
;
for (scur, cur) in [("2e10", 2e10), ("15e9", 15e9), ("1e10", 1e10), ] {
for (sinit, finit) in [
("p100", 1.00),
("n100", -1.00),
("000", 0.00),
("p050", 0.50),
// ("n080", -0.80),
("n050", -0.50),
// ("n030", -0.30),
("p020", 0.20),
("n020", -0.20),
// ("p080", 0.80),
] {
let params = p38xx.with_input_magnitude(cur);
// run_sim(
// &format!("38-{}:{}tx_shunt_cores-{}-8loop-n100rx-p100shunt-{}tx", 3, 2, scur, sinit),
// drive_map_nstack_pos_minv::<3, 2>(finit, 1.00),
// params
// .with_coupling(0, 3+2, 0, 1, CouplingMethod::Direct)
// );
run_sim(
&format!("38-{}:{}tx_shunt_cores-{}-8loop-n100rx-p100shunt-{}tx", 4, 2, scur, sinit),
drive_map_nstack_pos_minv::<4, 2>(finit, 1.00),
params
.with_coupling(0, 4+2, 0, 1, CouplingMethod::Direct)
);
// run_sim(
// &format!("38-{}:{}tx_shunt_cores-{}-8loop-n100rx-p100shunt-{}tx", 4, 3, scur, sinit),
// drive_map_nstack_pos_minv::<4, 3>(finit, 1.00),
// params
// .with_coupling(0, 4+3, 0, 1, CouplingMethod::Direct)
// );
run_sim(
&format!("38-{}:{}tx_shunt_cores-{}-8loop-n100rx-p100shunt-{}tx", 5, 2, scur, sinit),
drive_map_nstack_pos_minv::<5, 2>(finit, 1.00),
params
.with_coupling(0, 5+2, 0, 1, CouplingMethod::Direct)
);
// run_sim(
// &format!("38-{}:{}tx_shunt_cores-{}-8loop-n100rx-p100shunt-{}tx", 5, 3, scur, sinit),
// drive_map_nstack_pos_minv::<5, 3>(finit, 1.00),
// params
// .with_coupling(0, 5+3, 0, 1, CouplingMethod::Direct)
// );
// run_sim(
// &format!("38-{}:{}tx_shunt_cores-{}-8loop-n100rx-p100shunt-{}tx", 5, 4, scur, sinit),
// drive_map_nstack_pos_minv::<5, 4>(finit, 1.00),
// params
// .with_coupling(0, 5+4, 0, 1, CouplingMethod::Direct)
// );
run_sim(
&format!("38-{}:{}tx_shunt_cores-{}-8loop-n100rx-p100shunt-{}tx", 6, 2, scur, sinit),
drive_map_nstack_pos_minv::<6, 2>(finit, 1.00),
params
.with_coupling(0, 6+2, 0, 1, CouplingMethod::Direct)
);
run_sim(
&format!("38-{}:{}tx_shunt_cores-{}-8loop-n100rx-p100shunt-{}tx", 6, 3, scur, sinit),
drive_map_nstack_pos_minv::<6, 3>(finit, 1.00),
params
.with_coupling(0, 6+3, 0, 1, CouplingMethod::Direct)
);
// run_sim(
// &format!("38-{}:{}tx_shunt_cores-{}-8loop-n100rx-p100shunt-{}tx", 6, 4, scur, sinit),
// drive_map_nstack_pos_minv::<6, 4>(finit, 1.00),
// params
// .with_coupling(0, 6+4, 0, 1, CouplingMethod::Direct)
// );
// run_sim(
// &format!("38-{}:{}tx_shunt_cores-{}-8loop-n100rx-p100shunt-{}tx", 6, 5, scur, sinit),
// drive_map_nstack_pos_minv::<6, 5>(finit, 1.00),
// params
// .with_coupling(0, 6+5, 0, 1, CouplingMethod::Direct)
// );
run_sim(
&format!("38-{}:{}tx_shunt_cores-{}-8loop-n100rx-p100shunt-{}tx", 7, 2, scur, sinit),
drive_map_nstack_pos_minv::<7, 2>(finit, 1.00),
params
.with_coupling(0, 7+2, 0, 1, CouplingMethod::Direct)
);
run_sim(
&format!("38-{}:{}tx_shunt_cores-{}-8loop-n100rx-p100shunt-{}tx", 7, 3, scur, sinit),
drive_map_nstack_pos_minv::<7, 3>(finit, 1.00),
params
.with_coupling(0, 7+3, 0, 1, CouplingMethod::Direct)
);
}
}
}
} }
@@ -3545,7 +3721,7 @@ fn run_sim<const C: usize, const R: usize>(
let prefix = format!("out/applications/stacked_cores/{}/", name); let prefix = format!("out/applications/stacked_cores/{}/", name);
let _ = std::fs::create_dir_all(&prefix); let _ = std::fs::create_dir_all(&prefix);
driver.add_state_file(&*format!("{}state.bc", prefix), 25600); driver.add_state_file(&*format!("{}state.bc", prefix), 25600);
driver.add_serializer_renderer(&*format!("{}frame-", prefix), 6400, Some(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-detailed.csv", prefix), 100, None);
driver.add_csv_renderer(&*format!("{}meas.csv", prefix), 1600, None); driver.add_csv_renderer(&*format!("{}meas.csv", prefix), 1600, None);
driver.add_csv_renderer(&*format!("{}meas-sparse.csv", prefix), 12800, None); driver.add_csv_renderer(&*format!("{}meas-sparse.csv", prefix), 12800, None);

View File

@@ -0,0 +1,40 @@
#!/usr/bin/env python3
"""
invoke with the path to a meas.csv file for the stacked_core 37-xx demos
to extract higher-level info from them.
"""
import sys
from stacked_cores import load_csv, labeled_rows, last_row_before_t, extract_m
def extract_37xx(path: str):
header, raw_rows = load_csv(path)
rows = labeled_rows(header, raw_rows)
tx_init = last_row_before_t(rows, 2e-9)
tx_fini = last_row_before_t(rows, 3e-9)
m_init = extract_m(tx_init)
m_fini = extract_m(tx_fini)
m0 = -(m_fini[0] - m_init[0])
m1 = -(m_fini[1] - m_init[1])
m2 = -(m_fini[2] - m_init[2])
m3 = m_fini[3] - m_init[3]
m4 = m_fini[4] - m_init[4]
m5 = m_fini[5] - m_init[5]
m6 = m_fini[6] - m_init[6]
print(f'\t- madj: {m0 + m1 + m2 - m4 - m5 - m6}')
print(f'\t\t- m0: {m_init[0]} -> {m_fini[0]}')
print(f'\t\t- m1: {m_init[1]} -> {m_fini[1]}')
print(f'\t\t- m2: {m_init[2]} -> {m_fini[2]}')
print(f'\t\t- m4: {m_init[4]} -> {m_fini[4]}')
print(f'\t\t- m5: {m_init[5]} -> {m_fini[5]}')
print(f'\t\t- m6: {m_init[6]} -> {m_fini[6]}')
print(f'\t- m3: {m3}')
print(f'\t\t- {m_init[3]} -> {m_fini[3]}')
if __name__ == '__main__':
extract_37xx(sys.argv[1])

View File

@@ -0,0 +1,29 @@
#!/usr/bin/env python3
"""
invoke with the path to a meas.csv file for the stacked_core 38-xx demos
to extract higher-level info from them.
"""
import sys
from stacked_cores import load_csv, labeled_rows, last_row_before_t, extract_m
def extract_38xx(path: str):
header, raw_rows = load_csv(path)
rows = labeled_rows(header, raw_rows)
tx_init = last_row_before_t(rows, 2e-9)
tx_fini = last_row_before_t(rows, 3e-9)
m_init = extract_m(tx_init)
m_fini = extract_m(tx_fini)
m0 = -(m_fini[0] - m_init[0])
madj = sum(init - fini for (init, fini) in zip(m_init[1:], m_fini[1:]))
print(f'\t- madj: {madj}')
for i, (init, fini) in enumerate(zip(m_init[1:], m_fini[1:])):
print(f'\t\t- m{i+1}: {init} -> {fini}')
print(f'\t- m0: {m0}')
print(f'\t\t- {m_init[0]} -> {m_fini[0]}')
if __name__ == '__main__':
extract_38xx(sys.argv[1])