Skip to main content

Crate henad_cli

Crate henad_cli 

Source
Expand description

The command line of Henad, a headless benchmark and sweep runner, as a library.

run parses a command line, runs it over the models a CliOptions holds, and returns the exit code. The official henad-cli binary is three lines over it with the example models. A project with its own models builds the same command line over its own ModelSet.

use std::process::ExitCode;

use henad_cli::CliOptions;
use henad_compute::entry::ModelSet;

fn main() -> ExitCode {
    let models = ModelSet::new(henad_core::build_info!());
    let options = CliOptions::new(models, henad_core::build_info!()).command_name("my-models");
    ExitCode::from(henad_cli::run(options, std::env::args_os()))
}

A benchmark builds a model from the set and steps its SimState in a bare loop, with no rendering, no SimThread and no pacing, so a measurement times nothing but state.step().

Both CPU and GPU models run. For a set that holds a GPU model, run acquires a device through acquire_headless, sized to the set’s needs, and builds GPU models on the resulting GpuContext. Without a device --list leaves the GPU models out, and a GPU model id on the command line is rejected. The benchmark is henad_explore::benchmark::run_benchmark, and the two exports step a Simulation.

henad-cli --list
henad-cli ants --params
henad-cli game_of_life --steps 10000 --reps 5
henad-cli sir --set grid_width=512 --steps 2000 --export final.txt
henad-cli sir --steps 2000 --export-stats sir.csv --stats-every 10
henad-cli game_of_life --steps 1000 --act clear@500 --export final.txt
henad-cli gpu_game_of_life --set grid_width=4096 --set grid_height=4096 --steps 10000
henad-cli sir --vary infection_rate=0.1:0.5:0.1 --reps 5 --steps 500 --out sir-sweep
henad-cli --spec crates/henad-explore/specs/sir_sweep.toml --out sir-sweep
henad-cli --merge shard-0 shard-1 --out sir-sweep

--export writes the final state, the grid or point cloud at the end of the run. --export-stats writes the time series, one row per sampled tick. Both formats live in henad_core::export, and the app writes through the same module.

--out, --spec or --dry-run runs a sweep instead, many runs over a grid of parameter values written to a directory, and --merge joins a sweep’s shard directories.

Structs§

CliOptions
Options for the command line that a host runs: the models, the host’s build, the command name and the help text’s opening line.

Constants§

SOME_RUNS_NOT_OK
Exit code of a sweep that ran to its end with a run that is not ok, or of a merge that is missing a run or holds a run that is not ok.

Functions§

run
Parses arguments, the program name first, runs them over the options’ models, and returns the exit code.