File size: 1,351 Bytes
5b65ff7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh
# Build the image for one platform and benchmark native kernels against OpenBLAS.
# usage: scripts/docker_bench.sh <linux/arm64|linux/amd64> <wav> [contexts...]
set -eu
cd "$(dirname "$0")/.."
[ $# -ge 2 ] || { echo "usage: $0 <linux/arm64|linux/amd64> <wav> [contexts...]" >&2; exit 2; }
platform="$1"
wav="$2"
shift 2
contexts="${*:-640 320 160}"
model="${MODEL:-build/gigaam-v4-rnnt.gigaam}"
tag="gigaam-bench:$(echo "$platform" | tr / -)"
python="${PYTHON:-.venv/bin/python}"

docker buildx build --platform "$platform" -t "$tag" --load . >/dev/null
mkdir -p out
run() {
    docker run --rm --platform "$platform" -v "$PWD":/work -e OPENBLAS_NUM_THREADS="${2:-1}" \
        --entrypoint "$1" "$tag" "$model" "$wav" --context-ms "$3" --out "$4" --dump "$4" \
        2>&1 >/dev/null | sed "s/^/    /"
}
for ctx in $contexts; do
    echo "== $platform, context ${ctx} ms =="
    echo "  native (hand-rolled, 1 thread)"
    run gigaam_bench 1 "$ctx" "out/docker_native_$ctx"
    echo "  openblas (1 thread)"
    run gigaam_bench-openblas 1 "$ctx" "out/docker_openblas_$ctx"
    echo "  openblas (4 threads)"
    run gigaam_bench-openblas 4 "$ctx" "out/docker_openblas4_$ctx"
    echo "  native vs openblas:"
    "$python" scripts/compare_dumps.py "out/docker_openblas_$ctx" "out/docker_native_$ctx" \
        | sed "s/^/    /" || true
done