diff --git a/.gitignore b/.gitignore index 8345e2a..9a956c8 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ make.config +bazel-* diff --git a/BUILD b/BUILD new file mode 100644 index 0000000..603dea6 --- /dev/null +++ b/BUILD @@ -0,0 +1,11 @@ +cc_library( + name = "common", + hdrs = ["common.h"], + visibility = ["//visibility:public"], +) + +py_binary( + name = "rand_c_arr", + srcs = ["rand_c_arr.py"], + visibility = ["//visibility:public"], +) diff --git a/CCa/BUILD b/CCa/BUILD new file mode 100644 index 0000000..fbdec1f --- /dev/null +++ b/CCa/BUILD @@ -0,0 +1,4 @@ +load("//:base.bzl", "bench") + +bench( +) diff --git a/CCe/BUILD b/CCe/BUILD new file mode 100644 index 0000000..9832cab --- /dev/null +++ b/CCe/BUILD @@ -0,0 +1,5 @@ +load("//:base.bzl", "bench") + +bench( + randArr = True +) diff --git a/CCe/bench.c b/CCe/bench.c index f34038d..2726946 100644 --- a/CCe/bench.c +++ b/CCe/bench.c @@ -1,5 +1,5 @@ #include -#include "randArr.h" +#include "CCe/randArr.h" #include "common.h" #define ASIZE 2048 diff --git a/CCh/BUILD b/CCh/BUILD new file mode 100644 index 0000000..9832cab --- /dev/null +++ b/CCh/BUILD @@ -0,0 +1,5 @@ +load("//:base.bzl", "bench") + +bench( + randArr = True +) diff --git a/CCh/bench.c b/CCh/bench.c index ced8c6a..f137917 100644 --- a/CCh/bench.c +++ b/CCh/bench.c @@ -1,5 +1,5 @@ #include -#include "randArr.h" +#include "CCh/randArr.h" #include "common.h" #define ASIZE 0 @@ -23,8 +23,8 @@ int loop(int zero) { int main(int argc, char* argv[]) { argc&=10000; - ROI_BEGIN(); - int t=loop(argc); + ROI_BEGIN(); + int t=loop(argc); ROI_END(); volatile int a = t; } diff --git a/README.md b/README.md index 67214c5..7efa7d1 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # microbench Extremely Simple Microbenchmarks -To build X86 binaries, +To build X86 binaries, ```shell make ``` @@ -21,43 +21,57 @@ To build X86, ARM, and RISCV binaries, make all ``` -To set the path to X86 compiler, change `$CC_X86` in `make.config` file. -To set the path to ARM compiler, change `$CC_ARM` in `make.config` file. -To set the path to RISCV compiler, change `$CC_RISCV` in `make.config` file. +To set the path to X86 compiler, change `$CC_X86` in `make.config` file. +To set the path to ARM compiler, change `$CC_ARM` in `make.config` file. +To set the path to RISCV compiler, change `$CC_RISCV` in `make.config` file. The binaries are named `bench.X86`, `bench.ARM`, and `bench.RISCV` on each subdirectory. From the original README file, > Hi, -> +> > This is an *extremely* simple microbenchmark suite. -> -> Its intended purpose is in the validation of general purpose out-of-order -> cores, by targetting individual micro-architectural features or effects. -> Of course this is by no means an exhaustive collection of necessary bencharks -> to test every mechanism in an OOO processor. This is merely a starting point. -> -> To use this, you should only need bash, make and python. -> -> Configure the versions of the compiler and python (tested with python-2.7): +> +> Its intended purpose is in the validation of general purpose out-of-order +> cores, by targetting individual micro-architectural features or effects. +> Of course this is by no means an exhaustive collection of necessary bencharks +> to test every mechanism in an OOO processor. This is merely a starting point. +> +> To use this, you should only need bash, make and python. +> +> Configure the versions of the compiler and python (tested with python-2.7): > > vim make.config -> -> To make the benchmarks: +> +> To make the benchmarks: > > make -> -> Clean the benchmarks: +> +> Clean the benchmarks: > > make clean -> -> Describe basically what each benchmark is for: +> +> Describe basically what each benchmark is for: > > describe.sh -> -> Run a benchmark: (no args on any current benchmark) -> > cd CCa +> +> Run a benchmark: (no args on any current benchmark) +> > cd CCa > > ./test -> -> Tony Nowatzki -> Tuesday, April 14th, 2015 -> -> PS: Also, some benchmarks use an LFSR setting to get a particular working set. -> Please see lfsr_settings.txt for example values. (bench ML2 uses this) +> +> Tony Nowatzki +> Tuesday, April 14th, 2015 +> +> PS: Also, some benchmarks use an LFSR setting to get a particular working set. +> Please see lfsr_settings.txt for example values. (bench ML2 uses this) + +# Building with Bazel + +List all benchmarks + +``` +bazel query 'kind("cc_binary", //...)' +``` + +Build all benchmarks + +``` +bazel build $(bazel query 'kind("cc_binary", //...)') +``` diff --git a/WORKSPACE b/WORKSPACE new file mode 100644 index 0000000..74d4d2f --- /dev/null +++ b/WORKSPACE @@ -0,0 +1,3 @@ +workspace( + name = "edu_wisc_vertical_microbench" +) diff --git a/base.bzl b/base.bzl new file mode 100644 index 0000000..4f77128 --- /dev/null +++ b/base.bzl @@ -0,0 +1,26 @@ +# Note: we should probably have a name parameter +def bench(randArr=False): + dps = ["//:common"] + if randArr: + dps += ["libRandArr"] + + # It would probably be better to have a unique name. + native.cc_binary( + name = "bench", + srcs = ["bench.c"], + deps = dps + ) + + native.cc_library( + name = "libRandArr", + hdrs = ["randArr.h"], + visibility = ["//visibility:private"] + ) + + native.genrule( + name = "randArr", + srcs = ["rand_arr_args.txt"], + outs = ["randArr.h"], + tools = ["//:rand_c_arr"], + cmd = "./$(location //:rand_c_arr) `cat $(location rand_arr_args.txt)` > $@", + ) diff --git a/rand_c_arr.py b/rand_c_arr.py index 4a77c1d..da451c2 100755 --- a/rand_c_arr.py +++ b/rand_c_arr.py @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/python3 import random import argparse @@ -20,29 +20,29 @@ else: args.data_type='int' -out_file = open(args.output,'w') -out_file.write(args.data_type + " " + args.name + "[] = {\n") +#out_file = open(args.output,'w') +print(args.data_type + " " + args.name + "[] = {\n", end='') for i in range(0,args.len): if args.non_random: - out_file.write(str(i%args.range)) + print(str(i%args.range), end='') else: - out_file.write(str(random.randint(0,args.range-1))) - + print(str(random.randint(0,args.range-1)), end='') + if i!=args.len-1: - out_file.write(",") + print(",", end='') if args.range<=9: if i % 64 == 63: - out_file.write("\n") + print("\n", end='') elif args.range<=99: if i % 32 == 31: - out_file.write("\n") + print("\n", end='') else : if i % 16 == 15: - out_file.write("\n") + print("\n", end='') -out_file.write("};") +print("};", end='') -out_file.close() +#out_file.close()