interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / tools / argus / r8_perthread.sh

48 lines · 2709 bytes Raw Blame History
1#!/bin/bash
2# SPDX-License-Identifier: Apache-2.0
3# Copyright 2026 Drake Stapleton (AIEN / aien-dev)
4#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# Per-thread perf counters for R8, interleaved RX_ARGUS=0 / 2 discard / 2 ingest.
18# Counters are counted, not sampled (period 1e12), plus one 2 ms cpu-clock sampler so
19# perf report has samples. Per-thread totals via `perf record -s` + `perf report -T`,
20# classified by r8_perthread.awk. pmu1 = X925 PMU, pmu0 = A725 PMU on the GB10.
21# CFGS (env): configs, default "0 2d 2i"; 2in = ingest with the consumer unpinned.
22# Usage: r8_perthread.sh BUILD_DIR CPUS ROUNDS WORKDIR > out.jsonl (under the bench flock)
23set -u
24D=$(realpath "${1:-build}"); CPUS=${2:-5-9,15-19}; ROUNDS=${3:-20}; W=${4:-.}
25AWK=$(realpath "$(dirname "$0")/r8_perthread.awk")
26cd "$W" || exit 1
27EV="cycles,instructions,task-clock,context-switches,cpu-migrations,cpu-clock/period=2000000/"
28for r in $(seq 1 "$ROUNDS"); do
29 for cfg in ${CFGS:-0 2d 2i}; do
30 case $cfg in
31 0) b=$D/argus0/rx_r8_aegis_test; env=();;
32 2d) b=$D/argus2/rx_r8_aegis_test; env=(RX_ARGUS_CONSUMER=discard);;
33 2i) b=$D/argus2/rx_r8_aegis_test; env=(RX_ARGUS_CONSUMER=ingest);;
34 2in) b=$D/argus2/rx_r8_aegis_test; env=(RX_ARGUS_CONSUMER=ingest RX_ARGUS_CONSUMER_CPU=none);;
35 esac
36 t0=$(date +%s%N)
37 env "${env[@]}" perf record -q -s -c 1000000000000 -e "$EV" -o pt.data -- taskset -c "$CPUS" "$b" >pt.log 2>&1
38 t1=$(date +%s%N)
39 pass=$(grep -q "failures 0" pt.log && echo true || echo false)
40 # main thread only: --no-inherit counts the exec'd leader, not its threads or children
41 env "${env[@]}" perf stat --no-inherit -x, -e cycles,instructions,task-clock,context-switches,cpu-migrations \
42 -o st.txt -- taskset -c "$CPUS" "$b" >/dev/null 2>&1
43 mainj=$(awk -F, '$1 ~ /^[0-9.]+$/ { k = $3; gsub(/armv8_pmuv3_/, "pmu", k); gsub(/\//, "_", k); sub(/_$/, "", k)
44 if (k in s) k = k "_b"; s[k] = 1; o = o sprintf(",\"%s\":%s", k, $1) } END { print "{\"n\":1" o "}" }' st.txt)
45 perf report -i pt.data -T --stdio 2>/dev/null | awk -v cfg="$cfg" -v r="$r" -v wall=$(( (t1-t0)/1000 )) -v pass="$pass" -v mainj="$mainj" -f "$AWK"
46 done
47done
48rm -f pt.data pt.log st.txt