115 lines
4.1 KiB
Rust
115 lines
4.1 KiB
Rust
//! The `batch-NNNN.json` file of the alternation runner: what a batch ran and on which host (it computes no
|
|
//! statistics).
|
|
|
|
#[allow(unused_imports)]
|
|
use super::*;
|
|
|
|
/// The batch file, written once after the first round (the CPU model comes from that round's processes).
|
|
pub(super) fn batch_json(
|
|
run: &AltRun,
|
|
cpu_model: &str,
|
|
equality: &BTreeMap<&'static str, Outcome>,
|
|
) -> Result<String, String> {
|
|
let kab_sha = file_sha(&run.paths.kab)?;
|
|
let exe_sha = file_sha(&run.paths.own_exe)?;
|
|
let mut j = batch_json_run(run);
|
|
j += &batch_json_host(run, cpu_model);
|
|
j += &batch_json_files(run, &kab_sha, &exe_sha);
|
|
j += &batch_json_tail(run, equality);
|
|
Ok(j)
|
|
}
|
|
|
|
/// The batch file from its opening brace through the input hash.
|
|
fn batch_json_run(run: &AltRun) -> String {
|
|
let (a, first_round) = (run.a, run.first_round);
|
|
format!(
|
|
"{{\n \"format\": \"KAB1-alt\",\n \"version\": 1,\n \"batch\": {},\n \"rounds\": {},\n \
|
|
\"first_round\": {first_round},\n \"run_started_utc\": {},\n \"case\": {},\n \"run_dir\": {},\n \
|
|
\"manifest_sha256\": {},\n \"input_sha256\": {},\n",
|
|
a.batch,
|
|
a.rounds,
|
|
jstr(&run.started),
|
|
jstr(&a.case),
|
|
jstr(&a.dir.display().to_string()),
|
|
jstr(&run.verified.manifest_sha256),
|
|
jstr(&run.case.in_sha256)
|
|
)
|
|
}
|
|
|
|
/// The pin, the pool and the machine, and the seed.
|
|
fn batch_json_host(run: &AltRun, cpu_model: &str) -> String {
|
|
let sibling_at_start = run.host.sibling_at_start;
|
|
format!(
|
|
" \"pin\": {{\"logical_cpu\": {}, \"sibling_idle_at_start\": {sibling_at_start}}},\n \
|
|
\"pool\": {{\"workers\": 1}},\n \"machine\": {{\"machine_role\": {}, \"cpu_model\": {}, \"os\": {}}},\n \
|
|
\"seed\": {},\n",
|
|
run.a.pin,
|
|
jstr(&run.host.machine_role),
|
|
jstr(cpu_model),
|
|
jstr(&host_os()),
|
|
run.a.seed
|
|
)
|
|
}
|
|
|
|
/// The schedule file, the C++ driver and this example with their hashes, and the slice settings.
|
|
fn batch_json_files(run: &AltRun, kab_sha: &str, exe_sha: &str) -> String {
|
|
let a = run.a;
|
|
format!(
|
|
" \"schedule\": {{\"file\": {}, \"sha256\": {}}},\n \"kab\": {{\"path\": {}, \"sha256\": {}}},\n \
|
|
\"rust_example\": {{\"path\": {}, \"sha256\": {}}},\n \"slices_per_regime\": {},\n \"slice_ms\": {},\n",
|
|
jstr(&a.schedule.display().to_string()),
|
|
jstr(&sha_hex(run.schedule_text.as_bytes())),
|
|
jstr(&run.paths.kab.display().to_string()),
|
|
jstr(kab_sha),
|
|
jstr(&run.paths.own_exe.display().to_string()),
|
|
jstr(exe_sha),
|
|
a.slices,
|
|
a.slice_ms.map_or("null".to_owned(), |m| jnum(m, 1))
|
|
)
|
|
}
|
|
|
|
/// The equality verdicts, the cells and the closing note.
|
|
fn batch_json_tail(run: &AltRun, equality: &BTreeMap<&'static str, Outcome>) -> String {
|
|
format!(
|
|
" \"equality\": [{}],\n \"cells\": [{}],\n \"no_statistics\": \"this file computes no class, no interval \
|
|
and \
|
|
no A/A verdict (S0.10b, STRA-313)\"\n}}\n",
|
|
equality_json(run.case, equality),
|
|
cells_json(&run.procs)
|
|
)
|
|
}
|
|
|
|
fn equality_json(case: &CaseEntry, equality: &BTreeMap<&'static str, Outcome>) -> String {
|
|
equality
|
|
.iter()
|
|
.map(|(t, o)| {
|
|
format!(
|
|
"{{\"tree\": {}, \"verdict\": \"{}\", \"mode\": \"{}\", \"compared_values\": {}, \"mismatches\": {}}}",
|
|
jstr(t),
|
|
if o.equal() { "EQUAL" } else { "NOT_EQUAL" },
|
|
if case.tolerance.is_some() { "tolerance" } else { "bitwise" },
|
|
o.compared,
|
|
o.mismatches
|
|
)
|
|
})
|
|
.collect::<Vec<_>>()
|
|
.join(", ")
|
|
}
|
|
|
|
fn cells_json(procs: &[Proc]) -> String {
|
|
procs
|
|
.iter()
|
|
.map(|p| {
|
|
format!(
|
|
"{{\"process\": {}, \"impl\": {}, \"tree\": {}, \"env_set\": {}, \
|
|
\"env_scrubbed\": \"every STRATA_* and LELEKA_* variable of the parent\"}}",
|
|
jstr(&p.name()),
|
|
jstr(p.imp.name()),
|
|
jstr(p.tree),
|
|
json_env(&cell_env(p).into_iter().collect())
|
|
)
|
|
})
|
|
.collect::<Vec<_>>()
|
|
.join(", ")
|
|
}
|