From 3c0168526eb9895292a6f92b42f243fce4fd1a9d Mon Sep 17 00:00:00 2001 From: Prashanth Mundkur Date: Wed, 2 Jan 2019 16:03:49 -0800 Subject: Add support for performance measurements, and a script to estimate it over the unit-tests. --- test/get_perf.py | 42 ++++++++++++++++++++++++++++++++++++++++++ test/run_tests.sh | 2 +- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100755 test/get_perf.py (limited to 'test') diff --git a/test/get_perf.py b/test/get_perf.py new file mode 100755 index 0000000..c3e94cf --- /dev/null +++ b/test/get_perf.py @@ -0,0 +1,42 @@ +#!/usr/bin/python +# Estimates the performance of the C backend based on aggregating the unit-tests. +# Assumes a complete run over the unit-tests has been done. + +import os, glob + +def test_perf(d, test_pat, test_type): + couts = glob.glob(os.path.join(d, test_pat)) + if len(couts) == 0: return + + total_insts = 0 + total_msecs = 0 + for c in couts: + with open(c, "r") as f: + insts = 0 + msecs = 0 + perf = None + for l in f.readlines(): + if l.startswith("Instructions:"): insts = int(l.split()[1]) + if l.startswith("Execution:"): msecs = int(l.split()[1]) + if l.startswith("Perf:"): perf = l + #print("Test {0}: {1} insts, {2} msecs".format(c, insts, msecs)) + #if perf: print(perf) + total_insts += insts + total_msecs += msecs + + Kips = total_insts/total_msecs + print("Average {0} performance: {1} Kips".format(test_type, Kips)) + +def get_test_pat(iset, emode): + return "rv64{0}-{1}-*.cout".format(iset, emode) + +if __name__ == '__main__': + test_dir = os.path.join(os.path.dirname(__file__), "tests") + for mode in ["p", "v"]: + test_perf(test_dir, get_test_pat("ui", mode), "ui-{0}".format(mode)) + test_perf(test_dir, get_test_pat("um", mode), "um-{0}".format(mode)) + test_perf(test_dir, get_test_pat("ua", mode), "ua-{0}".format(mode)) + test_perf(test_dir, get_test_pat("uc", mode), "uc-{0}".format(mode)) + test_perf(test_dir, get_test_pat("si", mode), "si-{0}".format(mode)) + test_perf(test_dir, get_test_pat("mi", mode), "mi-{0}".format(mode)) + test_perf(test_dir, get_test_pat("*", mode), mode) diff --git a/test/run_tests.sh b/test/run_tests.sh index 5cb1455..04d72a2 100755 --- a/test/run_tests.sh +++ b/test/run_tests.sh @@ -77,7 +77,7 @@ else fi for test in $DIR/tests/*.elf; do - if timeout 5 $RISCVDIR/riscv_sim $test > ${test%.elf}.cout 2>&1 && grep -q SUCCESS ${test%.elf}.cout + if timeout 5 $RISCVDIR/riscv_sim -p $test > ${test%.elf}.cout 2>&1 && grep -q SUCCESS ${test%.elf}.cout then green "$(basename $test)" "ok" else -- cgit v1.1