From 54f5c1f8faffc956cc195578563fc67be6f42c88 Mon Sep 17 00:00:00 2001 From: Zihao Yu Date: Thu, 28 Jan 2021 00:00:35 +0800 Subject: [PATCH] microbench: add huge input --- benchmarks/microbench/README.md | 45 +++++++++++------------ benchmarks/microbench/include/benchmark.h | 38 ++++++++++++------- benchmarks/microbench/src/15pz/15pz.cc | 8 ++++ benchmarks/microbench/src/bench.c | 9 +++-- 4 files changed, 59 insertions(+), 41 deletions(-) diff --git a/benchmarks/microbench/README.md b/benchmarks/microbench/README.md index b332e2a..9bbc9a8 100644 --- a/benchmarks/microbench/README.md +++ b/benchmarks/microbench/README.md @@ -9,20 +9,19 @@ CPU正确性和性能测试用基准程序。对AbstractMachine的要求: ## 使用方法 -同一组程序分成三组:test,train和ref。 -test数据规模很小,作为测试用,不计时不评分。 -train数据规模中等,可用于在仿真环境研究微结构行为,计时不评分。 -ref数据规模较大,作为衡量CPU性能用,计时并评分。 +同一组程序分成四组:test,train,ref和huge。 -默认运行ref数据规模,使用 +| 名称 | 动态指令数 | 计时 | 计分 | 建议使用场景 | +| ----- | ----------- | ---- | ---- | ----- | +| test | 约300K | X | X | 正确性测试 | +| train | 约60M | O | X | 在RTL仿真环境中研究微结构行为 | +| ref | 约2B | O | O | 在模拟器或FPGA环境中评估处理器性能 | +| huge | 约50B | O | O | 衡量高性能处理器(如真机)的性能 | + +默认运行ref数据规模,可通过`mainargs`选择其它的数据规模, 如: ```bash -make ARCH=native run mainargs=test +make ARCH=native run mainargs=huge ``` -运行test数据规模,使用 -```bash -make ARCH=native run mainargs=train -``` -运行train数据规模。 ## 评分根据 @@ -32,18 +31,18 @@ make ARCH=native run mainargs=train ## 已有的基准程序 -| 名称 | 描述 | ref堆区使用 | -| ----- | ------------------------------------ | ----- | -| qsort | 快速排序随机整数数组 | 640KB | -| queen | 位运算实现的n皇后问题 | 0 | -| bf | Brainf**k解释器,快速排序输入的字符串 | 32KB | -| fib | Fibonacci数列f(n)=f(n-1)+…+f(n-m)的矩阵求解 | 256KB | -| sieve | Eratosthenes筛法求素数 | 2MB | -| 15pz | A*算法求解4x4数码问题 | 2MB | -| dinic | Dinic算法求解二分图最大流 | 1MB | -| lzip | Lzip数据压缩 | 4MB | -| ssort | Skew算法后缀排序 | 4MB | -| md5 | 计算长随机字符串的MD5校验和 | 16MB | +| 名称 | 描述 | ref堆区使用 | huge堆区使用 | +| ----- | -------------------------------------------- | ----- | ----- | +| qsort | 快速排序随机整数数组 | 640KB | 16MB | +| queen | 位运算实现的n皇后问题 | 0 | 0 | +| bf | Brainf**k解释器,快速排序输入的字符串 | 32KB | 32KB | +| fib | Fibonacci数列f(n)=f(n-1)+…+f(n-m)的矩阵求解 | 256KB | 2MB | +| sieve | Eratosthenes筛法求素数 | 2MB | 10MB | +| 15pz | A*算法求解4x4数码问题 | 2MB | 64MB | +| dinic | Dinic算法求解二分图最大流 | 680KB | 2MB | +| lzip | Lzip数据压缩 | 4MB | 64MB | +| ssort | Skew算法后缀排序 | 4MB | 64MB | +| md5 | 计算长随机字符串的MD5校验和 | 10MB | 64MB | ## 增加一个基准程序`foo` diff --git a/benchmarks/microbench/include/benchmark.h b/benchmarks/microbench/include/benchmark.h index 72ce9c8..7fb6062 100644 --- a/benchmarks/microbench/include/benchmark.h +++ b/benchmarks/microbench/include/benchmark.h @@ -21,49 +21,59 @@ extern "C" { #define QSORT_S { 100, 1 KB, 0, 0x08467105} #define QSORT_M { 30000, 128 KB, 0, 0xa3e99fe4} #define QSORT_L { 100000, 640 KB, 5114, 0xed8cff89} +#define QSORT_H { 4000000, 16 MB, 5114, 0xed8cff89} #define QUEEN_S { 8, 0 KB, 0, 0x0000005c} #define QUEEN_M { 11, 0 KB, 0, 0x00000a78} #define QUEEN_L { 12, 0 KB, 4707, 0x00003778} +#define QUEEN_H { 15, 0 KB, 4707, 0x00003778} #define BF_S { 2, 32 KB, 0, 0xa6f0079e} #define BF_M { 25, 32 KB, 0, 0xa88f8a65} #define BF_L { 180, 32 KB, 23673, 0x9221e2b3} +#define BF_H { 1360, 32 KB, 23673, 0x9221e2b3} #define FIB_S { 2, 1 KB, 0, 0x7cfeddf0} #define FIB_M { 23, 16 KB, 0, 0x94ad8800} #define FIB_L { 91, 256 KB, 28318, 0xebdc5f80} +#define FIB_H { 300, 2 MB, 28318, 0xebdc5f80} #define SIEVE_S { 100, 1 KB, 0, 0x00000019} #define SIEVE_M { 200000, 32 KB, 0, 0x00004640} #define SIEVE_L {10000000, 2 MB, 39361, 0x000a2403} +#define SIEVE_H {80000000, 10 MB, 39361, 0x000a2403} #define PZ15_S { 0, 1 KB, 0, 0x00000006} #define PZ15_M { 1, 256 KB, 0, 0x0000b0df} #define PZ15_L { 2, 2 MB, 4486, 0x00068b8c} +#define PZ15_H { 3, 48 MB, 4486, 0x00068b8c} #define DINIC_S { 10, 8 KB, 0, 0x0000019c} #define DINIC_M { 80, 512 KB, 0, 0x00004f99} -#define DINIC_L { 128, 1 MB, 10882, 0x0000c248} +#define DINIC_L { 128, 680 KB, 10882, 0x0000c248} +#define DINIC_H { 190, 2 MB, 10882, 0x0000c248} #define LZIP_S { 128, 128 KB, 0, 0xe05fc832} #define LZIP_M { 50000, 1 MB, 0, 0xdc93e90c} #define LZIP_L { 1048576, 4 MB, 7593, 0x8d62c81f} +#define LZIP_H {31457280, 64 MB, 7593, 0x8d62c81f} #define SSORT_S { 100, 4 KB, 0, 0x4c555e09} #define SSORT_M { 10000, 512 KB, 0, 0x0db7909b} #define SSORT_L { 100000, 4 MB, 4504, 0x4f0ab431} +#define SSORT_H { 3000000, 64 MB, 4504, 0x4f0ab431} #define MD5_S { 100, 1 KB, 0, 0xf902f28f} #define MD5_M { 200000, 256 KB, 0, 0xd4f9bc6d} -#define MD5_L {10000000, 16 MB, 17239, 0x27286a42} +#define MD5_L {10000000, 10 MB, 17239, 0x27286a42} +#define MD5_H {64000000, 64 MB, 17239, 0x27286a42} #define BENCHMARK_LIST(def) \ - def(qsort, "qsort", QSORT_S, QSORT_M, QSORT_L, "Quick sort") \ - def(queen, "queen", QUEEN_S, QUEEN_M, QUEEN_L, "Queen placement") \ - def( bf, "bf", BF_S, BF_M, BF_L, "Brainf**k interpreter") \ - def( fib, "fib", FIB_S, FIB_M, FIB_L, "Fibonacci number") \ - def(sieve, "sieve", SIEVE_S, SIEVE_M, SIEVE_L, "Eratosthenes sieve") \ - def( 15pz, "15pz", PZ15_S, PZ15_M, PZ15_L, "A* 15-puzzle search") \ - def(dinic, "dinic", DINIC_S, DINIC_M, DINIC_L, "Dinic's maxflow algorithm") \ - def( lzip, "lzip", LZIP_S, LZIP_M, LZIP_L, "Lzip compression") \ - def(ssort, "ssort", SSORT_S, SSORT_M, SSORT_L, "Suffix sort") \ - def( md5, "md5", MD5_S, MD5_M, MD5_L, "MD5 digest") \ + def(qsort, "qsort", QSORT_S, QSORT_M, QSORT_L, QSORT_H, "Quick sort") \ + def(queen, "queen", QUEEN_S, QUEEN_M, QUEEN_L, QUEEN_H, "Queen placement") \ + def( bf, "bf", BF_S, BF_M, BF_L, BF_H, "Brainf**k interpreter") \ + def( fib, "fib", FIB_S, FIB_M, FIB_L, FIB_H, "Fibonacci number") \ + def(sieve, "sieve", SIEVE_S, SIEVE_M, SIEVE_L, SIEVE_H, "Eratosthenes sieve") \ + def( 15pz, "15pz", PZ15_S, PZ15_M, PZ15_L, PZ15_H, "A* 15-puzzle search") \ + def(dinic, "dinic", DINIC_S, DINIC_M, DINIC_L, DINIC_H, "Dinic's maxflow algorithm") \ + def( lzip, "lzip", LZIP_S, LZIP_M, LZIP_L, LZIP_H, "Lzip compression") \ + def(ssort, "ssort", SSORT_S, SSORT_M, SSORT_L, SSORT_H, "Suffix sort") \ + def( md5, "md5", MD5_S, MD5_M, MD5_L, MD5_H, "MD5 digest") \ // Each benchmark will run REPEAT times -#define DECL(_name, _sname, _s, _m, _l, _desc) \ +#define DECL(_name, _sname, _s, _m, _l, _h, _desc) \ void bench_##_name##_prepare(); \ void bench_##_name##_run(); \ int bench_##_name##_validate(); @@ -81,7 +91,7 @@ typedef struct Benchmark { void (*run)(); int (*validate)(); const char *name, *desc; - Setting settings[3]; + Setting settings[4]; } Benchmark; extern Benchmark *current; diff --git a/benchmarks/microbench/src/15pz/15pz.cc b/benchmarks/microbench/src/15pz/15pz.cc index 3274699..e2a6f56 100644 --- a/benchmarks/microbench/src/15pz/15pz.cc +++ b/benchmarks/microbench/src/15pz/15pz.cc @@ -25,6 +25,13 @@ static int PUZZLE_L[N*N] = { 1, 15, 13, 14, }; +static int PUZZLE_H[N*N] = { + 2, 6, 8, 0, + 9, 15, 4, 12, + 5, 13, 11,14, + 1, 7, 3, 10, +}; + static int ans; extern "C" { @@ -40,6 +47,7 @@ void bench_15pz_run() { case 0: puzzle = N_puzzle(PUZZLE_S); MAXN = 10; break; case 1: puzzle = N_puzzle(PUZZLE_M); MAXN = 2048; break; case 2: puzzle = N_puzzle(PUZZLE_L); MAXN = 16384; break; + case 3: puzzle = N_puzzle(PUZZLE_H); MAXN = 786432; break; default: assert(0); } assert(puzzle.solvable()); diff --git a/benchmarks/microbench/src/bench.c b/benchmarks/microbench/src/bench.c index 140363c..a8330bf 100644 --- a/benchmarks/microbench/src/bench.c +++ b/benchmarks/microbench/src/bench.c @@ -12,13 +12,13 @@ static uint64_t uptime() { return io_read(AM_TIMER_UPTIME).us; } // The benchmark list -#define ENTRY(_name, _sname, _s, _m, _l, _desc) \ +#define ENTRY(_name, _sname, _s, _m, _l, _h, _desc) \ { .prepare = bench_##_name##_prepare, \ .run = bench_##_name##_run, \ .validate = bench_##_name##_validate, \ .name = _sname, \ .desc = _desc, \ - .settings = {_s, _m, _l}, }, + .settings = {_s, _m, _l, _h}, }, Benchmark benchmarks[] = { BENCHMARK_LIST(ENTRY) @@ -70,9 +70,10 @@ int main(const char *args) { if (strcmp(setting_name, "test" ) == 0) setting_id = 0; else if (strcmp(setting_name, "train") == 0) setting_id = 1; else if (strcmp(setting_name, "ref" ) == 0) setting_id = 2; + else if (strcmp(setting_name, "huge" ) == 0) setting_id = 3; else { printf("Invalid mainargs: \"%s\"; " - "must be in {test, train, ref}\n", setting_name); + "must be in {test, train, ref, huge}\n", setting_name); halt(1); } @@ -127,7 +128,7 @@ int main(const char *args) { printf("==================================================\n"); printf("MicroBench %s", pass ? "PASS" : "FAIL"); - if (setting_id == 2) { + if (setting_id >= 2) { printf(" %d Marks\n", (unsigned int)bench_score); printf(" vs. %d Marks (%s)\n", REF_SCORE, REF_CPU); } else {