forked from rarias/nixos-riscv
Add SPEC launcher
This commit is contained in:
65
pkgs/spec-cpu/launcher.sh
Normal file
65
pkgs/spec-cpu/launcher.sh
Normal file
@@ -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"
|
||||
21
pkgs/spec-cpu/speclaunch.nix
Normal file
21
pkgs/spec-cpu/speclaunch.nix
Normal file
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user