From f0630bee3406ae0c9097f00e783024732ba1823b Mon Sep 17 00:00:00 2001 From: Aditya Badole Date: Fri, 30 Jun 2023 10:54:20 +0800 Subject: [PATCH] Add scripts to automatically run the tests and compile the results to a csv - The tests are run on combinations of tag cache size and its memside connection Change-Id: I19a4f1782ffd42dc9712c715e94b2314e7ba42a7 --- tests/capstone/o3/parse.py | 80 +++++++++++++++ tests/capstone/o3/perf_baseline.S | 82 ++++++++++++++++ tests/capstone/o3/perf_baseline_ckpt.S | 78 +++++++++++++++ tests/capstone/o3/perf_baseline_random.S | 80 +++++++++++++++ tests/capstone/o3/perf_baseline_random_ckpt.S | 81 ++++++++++++++++ tests/capstone/o3/perf_mixed.S | 81 ++++++++++++++++ tests/capstone/o3/perf_tcache.S | 82 ++++++++++++++++ tests/capstone/o3/perf_tcache_ckpt.S | 93 ++++++++++++++++++ tests/capstone/o3/perf_tcache_random.S | 84 ++++++++++++++++ tests/capstone/o3/perf_tcache_random_ckpt.S | 97 +++++++++++++++++++ tests/capstone/o3/runner.py | 48 +++++++++ tests/capstone/o3/runner_ckpt.py | 54 +++++++++++ 12 files changed, 940 insertions(+) create mode 100644 tests/capstone/o3/parse.py create mode 100644 tests/capstone/o3/perf_baseline.S create mode 100644 tests/capstone/o3/perf_baseline_ckpt.S create mode 100644 tests/capstone/o3/perf_baseline_random.S create mode 100644 tests/capstone/o3/perf_baseline_random_ckpt.S create mode 100644 tests/capstone/o3/perf_mixed.S create mode 100644 tests/capstone/o3/perf_tcache.S create mode 100644 tests/capstone/o3/perf_tcache_ckpt.S create mode 100644 tests/capstone/o3/perf_tcache_random.S create mode 100644 tests/capstone/o3/perf_tcache_random_ckpt.S create mode 100644 tests/capstone/o3/runner.py create mode 100644 tests/capstone/o3/runner_ckpt.py diff --git a/tests/capstone/o3/parse.py b/tests/capstone/o3/parse.py new file mode 100644 index 0000000000..54b44f5a4c --- /dev/null +++ b/tests/capstone/o3/parse.py @@ -0,0 +1,80 @@ +import os +import sys +import glob, csv +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument('--input-folder', type=str, default='', help='input folder to parse files from') + +arg_delimiter_idx = sys.argv.index('--') + +args = parser.parse_args(sys.argv[1:arg_delimiter_idx]) +commands = sys.argv[arg_delimiter_idx + 1:] + +binary = commands[0] +n = len(binary) + +os.chdir(args.input_folder) + +l2dict = {} +memdict = {} + +for filename in glob.glob("*.txt"): + val = filename[n+1:] + coord = val.split('_') + tuple1 = (coord[0], coord[2].split('.')[0]) + + file1 = open(filename, 'r') + Lines = file1.readlines() + + tcache_hits = "0" + tcache_misses = "0" + dcache_hits = "0" + dcache_misses = "0" + ncache_hits = "0" + ncache_misses = "0" + cycles = "" + + for line in Lines: + xyz = line.split() + if "simTicks" in line: + if coord[1] == 'l2': + cycles = "%d, %.2f" % (int(xyz[1])/1000, round(int(xyz[1])/(1000*int(coord[0])),2)) + else: + cycles = "%d, %.2f" % (int(xyz[1])/1000, round(int(xyz[1])/(1000*int(coord[0])),2)) + elif "tcache.overallHits::total" in line: + tcache_hits = xyz[1] + elif "tcache.overallMisses::total" in line: + tcache_misses = xyz[1] + elif "dcache.overallHits::total" in line: + dcache_hits = xyz[1] + elif "dcache.overallMisses::total" in line: + dcache_misses = xyz[1] + elif "ncache.overallHits::total" in line: + ncache_hits = xyz[1] + elif "ncache.overallMisses::total" in line: + ncache_misses = xyz[1] + + if coord[1] == 'l2': + l2dict[tuple1] = cycles + "\nTcache: "+tcache_hits+", "+tcache_misses + "\nDcache: "+dcache_hits+", "+dcache_misses + "\nNcache: "+ncache_hits+", "+ncache_misses + else: + memdict[tuple1] = cycles + "\nTcache: "+tcache_hits+", "+tcache_misses + "\nDcache: "+dcache_hits+", "+dcache_misses + "\nNcache: "+ncache_hits+", "+ncache_misses + + file1.close() + +def create_csv_sheet(data, filename): + rows = sorted(set(key[0] for key in data.keys()), key=len) + columns = sorted(set(key[1] for key in data.keys()), key=len) + + with open(filename, "w", newline="") as csvfile: + writer = csv.writer(csvfile, quoting=csv.QUOTE_ALL) + + # Write the column headers + writer.writerow([""] + columns) + + # Write the data rows + for row in rows: + writer.writerow([row] + [data.get((row, col), 0) for col in columns]) + +create_csv_sheet(l2dict, 'l2.csv') +create_csv_sheet(memdict, 'mem.csv') \ No newline at end of file diff --git a/tests/capstone/o3/perf_baseline.S b/tests/capstone/o3/perf_baseline.S new file mode 100644 index 0000000000..00e8ff2f0a --- /dev/null +++ b/tests/capstone/o3/perf_baseline.S @@ -0,0 +1,82 @@ +//Baseline test corresponding to the mixed load scenario +#include "asm_insn.h" + +.global _start +_start: + + INIT_RWX_CAP(a6) + li a1, 0x30000 + li a2, 0x10000000 + CAPBOUND(a6, a1, a2) + CAPPRINT(a6) + + /** + * store some dummy value and check if it can + * can be correctly loaded by the loaded capabilities + */ + li a7, 0x40000 + SCC(a6, a7) + li a1, 0x42 + sd a1, 0(a7) + + li a3, xx + li a5, 0 + li a7, 0x50000 + SCC(a6, a7) + +_loop: + addi a3,a3,-1 + //-------make cap-------// + CAPCREATE(a4) + li a2, CAP_TYPE_NONLIN + CAPTYPE(a4, a2) + li a1, NODE_ID_INVALID + ALLOC(a2, a1) + CAPNODE(a4, a2) + li a1, CAP_PERM_RO + CAPPERM(a4, a1) + li a1, 0x40000 + li a2, 0x50000 + CAPBOUND(a4, a1, a2) + //-------end make cap-------// + SDS(a6, a1) + addi a7, a7, 0x10 + SCC(a6, a7) + bne a3, a5, _loop + +//workaround for assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA)) +//for whatever reason that error is not coming anymore +//.rept 1000 +//nop +//.endr + +//-------warmup end-------// +li t3, 1 +li t4, 0 +M5_EXIT + +_end_loop: + addi t4, t4, 1 + li a3, xx + CAPPRINT(a3) + li a7, 0x50000 + SCC(a6, a7) + li a4, 0x42 + +_loop2: + addi a3,a3,-1 + ld a2, 0(a7) + addi a7, a7, 0x10 + //ld a1, 0(a2) + //fence -------> delete this + //bne a1, a4, _test_fail + SCC(a6, a7) + bne a3, a5, _loop2 + + bne t4, t3, _end_loop + j exit + +_test_fail: + li a0, 0 + li a7, 10 + ecall \ No newline at end of file diff --git a/tests/capstone/o3/perf_baseline_ckpt.S b/tests/capstone/o3/perf_baseline_ckpt.S new file mode 100644 index 0000000000..dbb1f0f2ae --- /dev/null +++ b/tests/capstone/o3/perf_baseline_ckpt.S @@ -0,0 +1,78 @@ +//Baseline test corresponding to the mixed load scenario +#include "asm_insn.h" + +.global _start +_start: + + INIT_RWX_CAP(a6) + li a1, 0x30000 + li a2, 0x10000000 + CAPBOUND(a6, a1, a2) + CAPPRINT(a6) + + /** + * store some dummy value and check if it can + * can be correctly loaded by the loaded capabilities + */ + li a7, 0x40000 + SCC(a6, a7) + li a1, 0x42 + sd a1, 0(a7) + + li a3, xx + li a5, 0 + li a7, 0x50000 + SCC(a6, a7) + +_loop: + addi a3,a3,-1 + //-------make cap-------// + CAPCREATE(a4) + li a2, CAP_TYPE_NONLIN + CAPTYPE(a4, a2) + li a1, NODE_ID_INVALID + ALLOC(a2, a1) + CAPNODE(a4, a2) + li a1, CAP_PERM_RO + CAPPERM(a4, a1) + li a1, 0x40000 + li a2, 0x50000 + CAPBOUND(a4, a1, a2) + //-------end make cap-------// + SDS(a6, a1) + addi a7, a7, 0x10 + SCC(a6, a7) + bne a3, a5, _loop + +//workaround for assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA)) +//for whatever reason that error is not coming anymore +//.rept 1000 +//nop +//.endr + +//-------warmup end-------// +M5_CHECKPOINT +li t3, 1 +li t4, 0 + +_end_loop: + addi t4, t4, 1 + li a3, xx + CAPPRINT(a3) + li a7, 0x50000 + li a4, 0x42 + +_loop2: + addi a3,a3,-1 + ld a2, 0(a7) + addi a7, a7, 0x10 + ld a1, 0(a2) + bne a1, a4, _test_fail + bne a3, a5, _loop2 + bne t4, t3, _end_loop + j exit + +_test_fail: + li a0, 0 + li a7, 10 + ecall \ No newline at end of file diff --git a/tests/capstone/o3/perf_baseline_random.S b/tests/capstone/o3/perf_baseline_random.S new file mode 100644 index 0000000000..9dca88a97e --- /dev/null +++ b/tests/capstone/o3/perf_baseline_random.S @@ -0,0 +1,80 @@ +//Baseline test corresponding to the mixed load scenario +#include "asm_insn.h" + +.global _start +_start: + + INIT_RWX_CAP(a6) + li a1, 0x30000 + li a2, 0x10000000 + CAPBOUND(a6, a1, a2) + CAPPRINT(a6) + + /** + * store some dummy value and check if it can + * can be correctly loaded by the loaded capabilities + */ + li a7, 0x40000 + SCC(a6, a7) + li a1, 0x42 + sd a1, 0(a7) + + li a3, xx + li a5, 0 + li a7, 0x50000 + SCC(a6, a7) + +_loop: + addi a3,a3,-1 + //-------make cap-------// + CAPCREATE(a4) + li a2, CAP_TYPE_NONLIN + CAPTYPE(a4, a2) + li a1, NODE_ID_INVALID + ALLOC(a2, a1) + CAPNODE(a4, a2) + li a1, CAP_PERM_RO + CAPPERM(a4, a1) + li a1, 0x40000 + li a2, 0x50000 + CAPBOUND(a4, a1, a2) + //-------end make cap-------// + SDS(a6, a1) + addi a7, a7, 0x10 + SCC(a6, a7) + bne a3, a5, _loop + +//workaround for assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA)) +//for whatever reason that error is not coming anymore +//.rept 1000 +//nop +//.endr + +//-------warmup end-------// +li t3, 1 +li t4, 0 +mv t6, a7 +M5_EXIT + +_end_loop: + addi t4, t4, 1 + li t5, 0x50000 + li a3, xx + CAPPRINT(a3) + GETRAND(a7, t5, t6) + li a4, 0x42 + +_loop2: + addi a3,a3,-1 + ld a2, 0(a7) + GETRAND(a7, t5, t6) + ld a1, 0(a2) + bne a1, a4, _test_fail + bne a3, a5, _loop2 + bne t4, t3, _end_loop + j exit + +_test_fail: + li a0, 0 + li a7, 10 + ecall \ No newline at end of file diff --git a/tests/capstone/o3/perf_baseline_random_ckpt.S b/tests/capstone/o3/perf_baseline_random_ckpt.S new file mode 100644 index 0000000000..ae5e1ac500 --- /dev/null +++ b/tests/capstone/o3/perf_baseline_random_ckpt.S @@ -0,0 +1,81 @@ +//Baseline test corresponding to the mixed load scenario +#include "asm_insn.h" + +.global _start +_start: + + INIT_RWX_CAP(a6) + li a1, 0x30000 + li a2, 0x10000000 + CAPBOUND(a6, a1, a2) + CAPPRINT(a6) + + /** + * store some dummy value and check if it can + * can be correctly loaded by the loaded capabilities + */ + li a7, 0x40000 + SCC(a6, a7) + li a1, 0x42 + sd a1, 0(a7) + + li a3, xx + li a5, 0 + li a7, 0x50000 + SCC(a6, a7) + +_loop: + addi a3,a3,-1 + //-------make cap-------// + CAPCREATE(a4) + li a2, CAP_TYPE_NONLIN + CAPTYPE(a4, a2) + li a1, NODE_ID_INVALID + ALLOC(a2, a1) + CAPNODE(a4, a2) + li a1, CAP_PERM_RO + CAPPERM(a4, a1) + li a1, 0x40000 + li a2, 0x50000 + CAPBOUND(a4, a1, a2) + //-------end make cap-------// + SDS(a6, a1) + addi a7, a7, 0x10 + SCC(a6, a7) + bne a3, a5, _loop + +//workaround for assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA)) +//for whatever reason that error is not coming anymore +//.rept 1000 +//nop +//.endr + +//-------warmup end-------// +M5_CHECKPOINT +li t3, 1 +li t4, 0 + +_end_loop: + addi t4, t4, 1 + li t5, 0x50000 + li a3, xx + slli t2, a3, 4 + add t6, t2, t5 + CAPPRINT(a3) + GETRAND(a7, t5, t6) + li a4, 0x42 + +_loop2: + addi a3,a3,-1 + ld a2, 0(a7) + GETRAND(a7, t5, t6) + ld a1, 0(a2) + bne a1, a4, _test_fail + bne a3, a5, _loop2 + bne t4, t3, _end_loop + j exit + +_test_fail: + li a0, 0 + li a7, 10 + ecall \ No newline at end of file diff --git a/tests/capstone/o3/perf_mixed.S b/tests/capstone/o3/perf_mixed.S new file mode 100644 index 0000000000..80aef2eff0 --- /dev/null +++ b/tests/capstone/o3/perf_mixed.S @@ -0,0 +1,81 @@ +//Stress both tcache and ncache +#include "asm_insn.h" + +.global _start +_start: + + INIT_RWX_CAP(a6) + li a1, 0x30000 + li a2, 0x10000000 + CAPBOUND(a6, a1, a2) + CAPPRINT(a6) + + /** + * store some dummy value and check if it can + * can be correctly loaded by the loaded capabilities + */ + li a7, 0x40000 + SCC(a6, a7) + li a1, 0x42 + SDS(a6, a1) + + li a3, xx + li a5, 0 + li a7, 0x50000 + SCC(a6, a7) + +_loop: + addi a3,a3,-1 + //-------make cap-------// + CAPCREATE(a4) + li a2, CAP_TYPE_NONLIN + CAPTYPE(a4, a2) + li a1, NODE_ID_INVALID + ALLOC(a2, a1) + CAPNODE(a4, a2) + li a1, 0x40000 + li a2, 0x50000 + CAPBOUND(a4, a1, a2) + li a1, CAP_PERM_RO + CAPPERM(a4, a1) + //-------end make cap-------// + STC(a6, a4) + addi a7, a7, 0x10 + SCC(a6, a7) + bne a3, a5, _loop + +//workaround for assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA)) +//for whatever reason that error is not coming anymore +//.rept 1000 +//nop +//.endr + +//-------warmup end-------// +li t3, 1 +li t4, 0 +M5_EXIT + +_end_loop: + addi t4, t4, 1 + li a3, xx + CAPPRINT(a3) + li a7, 0x50000 + SCC(a6, a7) + li a4, 0x42 + +_loop2: + addi a3,a3,-1 + LTC(a2, a6) #causes 1 read + 1 write access to tcache for linear types + addi a7, a7, 0x10 + LDS(a1, a2) + bne a1, a4, _test_fail + SCC(a6, a7) + bne a3, a5, _loop2 + + bne t4, t3, _end_loop + j exit + +_test_fail: + li a0, 0 + li a7, 10 + ecall \ No newline at end of file diff --git a/tests/capstone/o3/perf_tcache.S b/tests/capstone/o3/perf_tcache.S new file mode 100644 index 0000000000..a68ca096aa --- /dev/null +++ b/tests/capstone/o3/perf_tcache.S @@ -0,0 +1,82 @@ +//Stress tcache, seq access +#include "asm_insn.h" + +.global _start +_start: + + INIT_RWX_CAP(a6) + li a1, 0x30000 + li a2, 0x10000000 + CAPBOUND(a6, a1, a2) + CAPPRINT(a6) + + /** + * store some dummy value and check if it can + * can be correctly loaded by the loaded capabilities + */ + li a7, 0x40000 + SCC(a6, a7) + li a1, 0x42 + SDS(a6, a1) + + li a3, xx + li a5, 0 + li a7, 0x50000 + SCC(a6, a7) + + //-------make cap-------// + CAPCREATE(a4) + li a2, CAP_TYPE_NONLIN + CAPTYPE(a4, a2) + li a1, NODE_ID_INVALID + ALLOC(a2, a1) + CAPNODE(a4, a2) + li a1, 0x40000 + li a2, 0x50000 + CAPBOUND(a4, a1, a2) + li a1, CAP_PERM_RO + CAPPERM(a4, a1) + //-------end make cap-------// + +_loop: + addi a3,a3,-1 + STC(a6, a4) + addi a7, a7, 0x10 + SCC(a6, a7) + bne a3, a5, _loop + +//workaround for assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA)) +//for whatever reason that error is not coming anymore +//.rept 1000 +//nop +//.endr + +//-------warmup end-------// +li t3, 1 +li t4, 0 +M5_EXIT + +_end_loop: + addi t4, t4, 1 + li a3, xx + CAPPRINT(a3) + li a7, 0x50000 + SCC(a6, a7) + li a4, 0x42 + +_loop2: + addi a3,a3,-1 + LTC(a2, a6) #causes 1 read + 1 write access to tcache for linear types + addi a7, a7, 0x10 + LDS(a1, a2) + bne a1, a4, _test_fail + SCC(a6, a7) + bne a3, a5, _loop2 + + bne t4, t3, _end_loop + j exit + +_test_fail: + li a0, 0 + li a7, 10 + ecall \ No newline at end of file diff --git a/tests/capstone/o3/perf_tcache_ckpt.S b/tests/capstone/o3/perf_tcache_ckpt.S new file mode 100644 index 0000000000..be9b4bee63 --- /dev/null +++ b/tests/capstone/o3/perf_tcache_ckpt.S @@ -0,0 +1,93 @@ +//Stress tcache, seq access +#include "asm_insn.h" + +.global _start +_start: + + INIT_RWX_CAP(a6) + li a1, 0x30000 + li a2, 0x10000000 + CAPBOUND(a6, a1, a2) + CAPPRINT(a6) + + /** + * store some dummy value and check if it can + * can be correctly loaded by the loaded capabilities + */ + li a7, 0x40000 + SCC(a6, a7) + li a1, 0x42 + SDS(a6, a1) + + li a3, xx + li a5, 0 + li a7, 0x50000 + SCC(a6, a7) + + //-------make cap-------// + CAPCREATE(a4) + li a2, CAP_TYPE_NONLIN + CAPTYPE(a4, a2) + li a1, NODE_ID_INVALID + ALLOC(a2, a1) + CAPNODE(a4, a2) + li a1, 0x40000 + li a2, 0x50000 + CAPBOUND(a4, a1, a2) + li a1, CAP_PERM_RO + CAPPERM(a4, a1) + //-------end make cap-------// + +_loop: + addi a3,a3,-1 + STC(a6, a4) + addi a7, a7, 0x10 + SCC(a6, a7) + bne a3, a5, _loop + +//workaround for assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA)) +//for whatever reason that error is not coming anymore +//.rept 1000 +//nop +//.endr + +M5_CHECKPOINT +//-------warmup end-------// + CAPCREATE(a6) + li a2, CAP_TYPE_LIN + CAPTYPE(a6, a2) + li a1, 1 + CAPNODE(a6, a1) + li a1, 0x30000 + li a2, 0x10000000 + CAPBOUND(a6, a1, a2) + li a1, CAP_PERM_RWX + CAPPERM(a6, a1) + +li t3, 1 +li t4, 0 + +_end_loop: + addi t4, t4, 1 + li a3, xx + CAPPRINT(a3) + li a7, 0x50000 + SCC(a6, a7) + li a4, 0x42 + +_loop2: + addi a3,a3,-1 + LTC(a2, a6) #causes 1 read + 1 write access to tcache for linear types + addi a7, a7, 0x10 + LDS(a1, a2) + bne a1, a4, _test_fail + SCC(a6, a7) + bne a3, a5, _loop2 + + bne t4, t3, _end_loop + j exit + +_test_fail: + li a0, 0 + li a7, 10 + ecall \ No newline at end of file diff --git a/tests/capstone/o3/perf_tcache_random.S b/tests/capstone/o3/perf_tcache_random.S new file mode 100644 index 0000000000..e6d72ac3e5 --- /dev/null +++ b/tests/capstone/o3/perf_tcache_random.S @@ -0,0 +1,84 @@ +//Stress tcache, random accesses +#include "asm_insn.h" + +.global _start +_start: + + INIT_RWX_CAP(a6) + li a1, 0x30000 + li a2, 0x10000000 + CAPBOUND(a6, a1, a2) + CAPPRINT(a6) + + /** + * store some dummy value and check if it can + * can be correctly loaded by the loaded capabilities + */ + li a7, 0x40000 + SCC(a6, a7) + li a1, 0x42 + SDS(a6, a1) + + li a3, xx + li a5, 0 + li a7, 0x50000 + SCC(a6, a7) + + //-------make cap-------// + CAPCREATE(a4) + li a2, CAP_TYPE_NONLIN + CAPTYPE(a4, a2) + li a1, NODE_ID_INVALID + ALLOC(a2, a1) + CAPNODE(a4, a2) + li a1, 0x40000 + li a2, 0x50000 + CAPBOUND(a4, a1, a2) + li a1, CAP_PERM_RO + CAPPERM(a4, a1) + //-------end make cap-------// + +_loop: + addi a3,a3,-1 + STC(a6, a4) + addi a7, a7, 0x10 + SCC(a6, a7) + bne a3, a5, _loop + +//workaround for assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA)) +//for whatever reason that error is not coming anymore +//.rept 1000 +//nop +//.endr + +//-------warmup end-------// +li t3, 1 +li t4, 0 +mv t6, a7 +M5_EXIT + +_end_loop: + addi t4, t4, 1 + li a3, xx + CAPPRINT(a3) + li t5, 0x50000 + GETRAND(a7, t5, t6) + SCC(a6, a7) + li a4, 0x42 + +_loop2: + addi a3,a3,-1 + LTC(a2, a6) #causes 1 read + 1 write access to tcache for linear types + GETRAND(a7, t5, t6) + LDS(a1, a2) + bne a1, a4, _test_fail + SCC(a6, a7) + bne a3, a5, _loop2 + + bne t4, t3, _end_loop + j exit + +_test_fail: + li a0, 0 + li a7, 10 + ecall \ No newline at end of file diff --git a/tests/capstone/o3/perf_tcache_random_ckpt.S b/tests/capstone/o3/perf_tcache_random_ckpt.S new file mode 100644 index 0000000000..0d06ea00ca --- /dev/null +++ b/tests/capstone/o3/perf_tcache_random_ckpt.S @@ -0,0 +1,97 @@ +//Stress tcache, random accesses +#include "asm_insn.h" + +.global _start +_start: + + INIT_RWX_CAP(a6) + li a1, 0x30000 + li a2, 0x10000000 + CAPBOUND(a6, a1, a2) + CAPPRINT(a6) + + /** + * store some dummy value and check if it can + * can be correctly loaded by the loaded capabilities + */ + li a7, 0x40000 + SCC(a6, a7) + li a1, 0x42 + SDS(a6, a1) + + li a3, xx + li a5, 0 + li a7, 0x50000 + SCC(a6, a7) + + //-------make cap-------// + CAPCREATE(a4) + li a2, CAP_TYPE_NONLIN + CAPTYPE(a4, a2) + li a1, NODE_ID_INVALID + ALLOC(a2, a1) + CAPNODE(a4, a2) + li a1, 0x40000 + li a2, 0x50000 + CAPBOUND(a4, a1, a2) + li a1, CAP_PERM_RO + CAPPERM(a4, a1) + //-------end make cap-------// + +_loop: + addi a3,a3,-1 + STC(a6, a4) + addi a7, a7, 0x10 + SCC(a6, a7) + bne a3, a5, _loop + +//workaround for assert(flags.isSet(STATIC_DATA|DYNAMIC_DATA)) +//for whatever reason that error is not coming anymore +//.rept 1000 +//nop +//.endr + +M5_CHECKPOINT +//-------warmup end-------// + CAPCREATE(a6) + li a2, CAP_TYPE_LIN + CAPTYPE(a6, a2) + li a1, 1 + CAPNODE(a6, a1) + li a1, 0x30000 + li a2, 0x10000000 + CAPBOUND(a6, a1, a2) + li a1, CAP_PERM_RWX + CAPPERM(a6, a1) + +li t3, 1 +li t4, 0 +li t6, 0x70000 + +_end_loop: + addi t4, t4, 1 + li t5, 0x50000 + li a3, xx + slli t2, a3, 4 + add t6, t2, t5 + CAPPRINT(a3) + GETRAND(a7, t5, t6) + SCC(a6, a7) + li a4, 0x42 + +_loop2: + addi a3,a3,-1 + LTC(a2, a6) #causes 1 read + 1 write access to tcache for linear types + GETRAND(a7, t5, t6) + LDS(a1, a2) + bne a1, a4, _test_fail + SCC(a6, a7) + bne a3, a5, _loop2 + + bne t4, t3, _end_loop + j exit + +_test_fail: + li a0, 0 + li a7, 10 + ecall \ No newline at end of file diff --git a/tests/capstone/o3/runner.py b/tests/capstone/o3/runner.py new file mode 100644 index 0000000000..2a5cea85d2 --- /dev/null +++ b/tests/capstone/o3/runner.py @@ -0,0 +1,48 @@ +import subprocess +import sys +import argparse +import os +import multiprocessing + +parser = argparse.ArgumentParser() +parser.add_argument('--stats-folder', type=str, default='.', help='output folder for stats & config file') + +arg_delimiter_idx = sys.argv.index('--') + +args = parser.parse_args(sys.argv[1:arg_delimiter_idx]) +commands = sys.argv[arg_delimiter_idx + 1:] + +binary = commands[0] +binary_name = binary.split('.')[0] + +output_dir = "m5out/%s" % (args.stats_folder) +CHECK_FOLDER = os.path.isdir(output_dir) + +if not CHECK_FOLDER: + os.makedirs(output_dir) + +cache_sizes = ['8kB', '16kB', '32kB', '64kB', '128kB', '256kB', '512kB', '1MB'] +cache_config = ['l2', 'membus'] +# cache_sizes = ['8kB'] +# cache_config = ['l2'] +commands = [] + +for i in cache_config: + for j in cache_sizes: + k = 8192 + while k <= 524288: + testcase = "%s_%d_%s_%s" % (binary_name, k, i, j) + sed_command = "sed 's/xx/%d/g' %s > src/capstone/temp_%s.S" % (k, binary, testcase) + os.system(sed_command) + + command = "make run-temp_%s GEM5_FLAGS='--stats-file=%s/%s.txt --dump-config=%s/%s.ini' GEM5_CONFIG_FLAGS='--cpu=o3 --tcache-memside=%s --tcache-size=%s' GEM5_TEST_TIMEOUT=0" % (testcase, args.stats_folder, testcase, args.stats_folder, testcase, i, j) + commands.append(command) + k *= 2 + +def run_subprocess(cmd): + subprocess.run(cmd, shell=True) + +with multiprocessing.Pool(processes=12) as pool: + pool.map(run_subprocess, commands) + +subprocess.run("rm -rf src/capstone/temp*", shell=True) \ No newline at end of file diff --git a/tests/capstone/o3/runner_ckpt.py b/tests/capstone/o3/runner_ckpt.py new file mode 100644 index 0000000000..60ef3477fe --- /dev/null +++ b/tests/capstone/o3/runner_ckpt.py @@ -0,0 +1,54 @@ +import subprocess +import sys +import argparse +import os +import multiprocessing + +parser = argparse.ArgumentParser() +parser.add_argument('--stats-folder', type=str, default='.', help='output folder for stats & config file') + +arg_delimiter_idx = sys.argv.index('--') + +args = parser.parse_args(sys.argv[1:arg_delimiter_idx]) +commands = sys.argv[arg_delimiter_idx + 1:] + +binary = commands[0] +binary_name = binary.split('.')[0] + +output_dir = "m5out/%s" % (args.stats_folder) +CHECK_FOLDER = os.path.isdir(output_dir) + +if not CHECK_FOLDER: + os.makedirs(output_dir) + +if not os.path.isdir("m5out/ckp"): + os.makedirs("m5out/ckp") + +cache_sizes = ['8kB', '16kB', '32kB', '64kB', '128kB', '256kB', '512kB', '1MB'] +cache_config = ['l2', 'membus'] +# cache_sizes = ['8kB'] +# cache_config = ['l2'] +commands = [] + +for i in cache_config: + for j in cache_sizes: + k = 8192 + while k <= 524288: + testcase = "%s_%d_%s_%s" % (binary_name, k, i, j) + sed_command = "sed 's/xx/%d/g' %s > src/capstone/temp_%s.S" % (k, binary, testcase) + os.system(sed_command) + + command1 = "make run-temp_%s GEM5_FLAGS='--stats-file=%s/%s.txt --dump-config=%s/%s.ini' GEM5_CONFIG_FLAGS='--cpu=o3 --tcache-memside=%s --tcache-size=%s --ckpt-save=m5out/ckp/%s' GEM5_TEST_TIMEOUT=0" % (testcase, args.stats_folder, testcase, args.stats_folder, testcase, i, j, testcase) + command2 = "make run-temp_%s GEM5_FLAGS='--stats-file=%s/%s.txt --dump-config=%s/%s.ini' GEM5_CONFIG_FLAGS='--cpu=o3 --tcache-memside=%s --tcache-size=%s --ckpt=m5out/ckp/%s' GEM5_TEST_TIMEOUT=0" % (testcase, args.stats_folder, testcase, args.stats_folder, testcase, i, j, testcase) + commands.append((command1, command2)) + k *= 2 + +def run_subprocess(command_pair): + for cmd in command_pair: + subprocess.run(cmd, shell=True) + +with multiprocessing.Pool(processes=10) as pool: + pool.map(run_subprocess, commands) + +subprocess.run("rm -rf m5out/ckp", shell=True) +subprocess.run("rm -rf src/capstone/temp*", shell=True)