interplane.Get Omega
Read in your language

aienux

Aienux, the AienOS kernel: boot, scheduling, IPC and capability boundaries. Pre-alpha; host, emulator and physical evidence are labelled separately.

Brought by drakestapleton

branch main Branches Tags History

aienux / scripts / pi5-8 / gen_measure_header.sh

26 lines · 1513 bytes Raw Blame History
1#!/usr/bin/env bash
2# PI5-8: turn host_golden.sh output (llama.cpp ids and greedy tokens) into the pi5_measure.h the measurement
3# kernel build includes. Requests: the short prompt three times (variance), then the two long prompts.
4# gen_measure_header.sh GOLDEN_DIR EOS_ID > pi5_measure.h
5set -euo pipefail
6d="${1:?golden dir}"; eos="${2:?eos id}"
7echo "/* generated by scripts/pi5-8/gen_measure_header.sh from $d (llama.cpp reference) */"
8echo "#define MEAS_EOS ${eos}u"
9for p in short long1 long2; do
10 ids=$(head -1 "$d/$p.ref" | cut -d' ' -f2- | tr ' ' ',')
11 exp=$(awk '$1=="step"{printf "%s%su", (n++?",":""), $3}' "$d/$p.ref")
12 echo "static const uint32_t meas_${p}_ids[] = {${ids}};"
13 echo "static const uint32_t meas_${p}_exp[] = {${exp}};"
14done
15cat <<'EOT'
16struct meas_req { const char *name; unsigned nids; const uint32_t *ids; unsigned nexp; const uint32_t *exp; };
17#define MEAS_N(a) ((unsigned)(sizeof(a) / sizeof((a)[0])))
18static const struct meas_req meas_reqs[] = {
19 {"short", MEAS_N(meas_short_ids), meas_short_ids, MEAS_N(meas_short_exp), meas_short_exp},
20 {"short", MEAS_N(meas_short_ids), meas_short_ids, MEAS_N(meas_short_exp), meas_short_exp},
21 {"short", MEAS_N(meas_short_ids), meas_short_ids, MEAS_N(meas_short_exp), meas_short_exp},
22 {"long1", MEAS_N(meas_long1_ids), meas_long1_ids, MEAS_N(meas_long1_exp), meas_long1_exp},
23 {"long2", MEAS_N(meas_long2_ids), meas_long2_ids, MEAS_N(meas_long2_exp), meas_long2_exp},
24};
25#define MEAS_NREQ MEAS_N(meas_reqs)
26EOT