diff options
author | Prashanth Mundkur <prashanth.mundkur@gmail.com> | 2019-01-02 16:03:49 -0800 |
---|---|---|
committer | Prashanth Mundkur <prashanth.mundkur@gmail.com> | 2019-01-02 16:06:56 -0800 |
commit | 3c0168526eb9895292a6f92b42f243fce4fd1a9d (patch) | |
tree | dcfa2c6911fb8694c809ba790ab43d668a7cc795 /test | |
parent | de21f8aeaa092e68e220829ff8c3da4132e6f8fe (diff) | |
download | sail-riscv-3c0168526eb9895292a6f92b42f243fce4fd1a9d.zip sail-riscv-3c0168526eb9895292a6f92b42f243fce4fd1a9d.tar.gz sail-riscv-3c0168526eb9895292a6f92b42f243fce4fd1a9d.tar.bz2 |
Add support for performance measurements, and a script to estimate it over the unit-tests.
Diffstat (limited to 'test')
-rwxr-xr-x | test/get_perf.py | 42 | ||||
-rwxr-xr-x | test/run_tests.sh | 2 |
2 files changed, 43 insertions, 1 deletions
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 |