From 3bcc4255dbdeb7054c1d91ef66b5c02a32acf7c0 Mon Sep 17 00:00:00 2001 From: Rodrigo Arias Mallo Date: Wed, 9 Oct 2024 15:52:46 +0200 Subject: [PATCH] Add SPEC launcher --- JOURNAL.md | 24 +++++++++++++ overlay.nix | 1 + pkgs/spec-cpu/launcher.sh | 65 ++++++++++++++++++++++++++++++++++++ pkgs/spec-cpu/speclaunch.nix | 21 ++++++++++++ 4 files changed, 111 insertions(+) create mode 100644 pkgs/spec-cpu/launcher.sh create mode 100644 pkgs/spec-cpu/speclaunch.nix diff --git a/JOURNAL.md b/JOURNAL.md index 265cc2e..136d903 100644 --- a/JOURNAL.md +++ b/JOURNAL.md @@ -5149,3 +5149,27 @@ and "integer" variants and removing a couple of large benchmarks. Still, the closure is gigantic, as they are collecting the environment during the build phase and that makes the result depend on the build packages. + +## 2024-10-09 + +One of the problems with the `speccmds.cmd` file is that is assumes that it can +write the output of the benchmarks in the same place that the binaries are +located. + + hut% cat benchspec/CPU/602.gcc_s/run/run_base_test_nix-m64.0000/speccmds.cmd + -r + -N C + -C /build/out/benchspec/CPU/602.gcc_s/run/run_base_test_nix-m64.0000 + -o t1.opts-O3_-finline-limit_50000.out -e t1.opts-O3_-finline-limit_50000.err ../run_base_test_nix-m64.0000/sgcc_base.nix-m64 t1.c -O3 -finline-limit=50000 -o t1.opts-O3_-finline-limit_50000.s > t1.opts-O3_-finline-limit_50000.out 2>> t1.opts-O3_-finline-limit_50000.err + +We can address this problem by modifying the `-C ...` command and just use `-C +602.gcc_s` (not sure if it creates it directly). Then we need to modify the +../run... part to use the full path of the binary. + + hut% cat speccmds.cmd | sed '/^-C/d' + -r + -N C + -o t1.opts-O3_-finline-limit_50000.out -e t1.opts-O3_-finline-limit_50000.err ../run_base_test_nix-m64.0000/sgcc_base.nix-m64 t1.c -O3 -finline-limit=50000 -o t1.opts-O3_-finline-limit_50000.s > t1.opts-O3_-finline-limit_50000.out 2>> t1.opts-O3_-finline-limit_50000.err + +I can create a symlink to the benchmark directory, so it finds it at +`../run_base_test_nix-m64.0000`. diff --git a/overlay.nix b/overlay.nix index 2eeee5c..190d510 100644 --- a/overlay.nix +++ b/overlay.nix @@ -15,6 +15,7 @@ final: prev: spec-cpu = final.callPackage ./pkgs/spec-cpu/default.nix { }; spec-cpu-mini = final.callPackage ./pkgs/spec-cpu/mini.nix { }; specinvoke = final.callPackage ./pkgs/spec-cpu/specinvoke.nix { }; + speclaunch = final.callPackage ./pkgs/spec-cpu/speclaunch.nix { }; spec-cpu-clang = final.callPackage ./pkgs/spec-cpu/default.nix { stdenv = final.stdenvClangEpi; }; blis = ((prev.blis.override { diff --git a/pkgs/spec-cpu/launcher.sh b/pkgs/spec-cpu/launcher.sh new file mode 100644 index 0000000..4aa641d --- /dev/null +++ b/pkgs/spec-cpu/launcher.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +set -e + +if [ -z "$SPEC" ]; then + SPEC=$(spec-cpu-mini) +fi + +if [ -z "$SPEC" ]; then + echo "cannot find spec, set SPEC variable" + exit 1 +fi + +where=$TMPDIR +if [ -z "$where" ]; then + if [ -d /tmp ]; then + where=/tmp + else + where=$PWD + fi +fi + +cwd=$(readlink -f $where) +# Place the outcome here +wd="$cwd/spec" +mkdir -p "$wd" + +benchniter=1 +benchsize=test +benchtune=base + +echo "--- Placing output in $wd ---" + +printf 'benchmark\tsize\ttune\titer\ttime_s\n' > "$wd/time.csv" + +for srcbench in $SPEC/benchspec/CPU/*; do + name=$(basename $srcbench) + bench="$wd/$name" + rm -rf "$bench" + cp -r "$srcbench" "$bench" + chmod +w -R "$bench" + + rundir="$bench/run/run_${benchtune}_${benchsize}_nix-m64.0000" + sed -i '/^-C/d' "$rundir/speccmds.cmd" + echo "--- Running $name for $benchniter iterations ---" + ( + #set -x + cd $rundir + specinvoke -i $benchniter -E speccmds.cmd > /dev/null + #set +x + ) + # Print time + awk '/^run [0-9]* elapsed time/{printf \ + "%s\t%s\t%s\t%s\t%s\n", \ + "'$name'","'$benchsize'","'$benchtune'",$2,$7}' \ + "$rundir/speccmds.out" > "$rundir/time.csv" + + cat "$rundir/time.csv" + + # Accumulate in main CSV + cat "$rundir/time.csv" >> "$wd/time.csv" +done + +echo "--- RESULTS in $wd/time.csv ---" +cat "$wd/time.csv" diff --git a/pkgs/spec-cpu/speclaunch.nix b/pkgs/spec-cpu/speclaunch.nix new file mode 100644 index 0000000..cbbb95b --- /dev/null +++ b/pkgs/spec-cpu/speclaunch.nix @@ -0,0 +1,21 @@ +{ + stdenv +, bash +}: + +stdenv.mkDerivation { + name = "speclaunch"; + src = ./launcher.sh; + dontUnpack = true; + dontConfigure = true; + dontBuild = true; + installPhase = '' + mkdir -p $out/bin + cp $src $out/bin/speclaunch + chmod +x $out/bin/speclaunch + ''; + buildInputs = [ bash ]; + enableParallelBuilding = false; + hardeningDisable = [ "all" ]; + dontStrip = true; +}