def __init__(self, args): self.rv32 = args.rv32 no_arm = args.no_arm if GOPTS.rv32 == "rv8" or GOPTS.rv32 == "ovp": rv32 = RV32 no_arm = True xarchs = [] else: rv32 = RV32_LINUX xarchs = [(rv32, X86)] if no_arm: self.narchs = [rv32, X86] self.xarchs = xarchs else: self.narchs = [rv32, X86, ARM] self.xarchs = [(rv32, X86), (rv32, ARM)] self.srcdir = path(DIR.top, "mibench") self.dstdir = path(DIR.build, "mibench") self.stack_large = ["-stack-size=131072"] # 128K self.stack_huge = ["-stack-size=1048576"] # 1M self.bflags = "--sbtobjs=runtime" if GOPTS.mmx: self.bflags_mmx = ('--llcflags-x86="-march=x86 -mcpu=pentium-mmx' + ' -mattr=mmx" --gccflags-x86="-march=pentium-mmx"') else: self.bflags_mmx = "" self.bflags_no_fp_contract = \ "--gccflags=-ffp-contract=off --oflags=-fp-contract=off" self.txt = '' self.benchs = None
def __init__(self, name, url, dir=None, clone_flags=None): self.name = name if dir == "top": self.dstdir = TOPDIR self.parent_dir = None else: self.parent_dir = path(TOPDIR, "submodules") self.dstdir = path(self.parent_dir, name) self.url = url self.clone_flags = clone_flags self.update = True
def build(self, force): dir = path(DOCKER_DIR, self.name) done = path(dir, "done") # skip if done if not force and os.path.exists(done): return # docker build with cd(DOCKER_DIR): shell("docker build -t {} {}".format(self.img, self.name)) self._build() shell("touch " + done)
def volstr(bind): src = Helper.cygpath(TOPDIR) dst = "/riscv-sbt" bmount = "--mount type=bind,source={},destination={}" vstr = bmount.format(src, dst) if bind: vstr = cat( vstr, bmount.format(path(src, "toolchain"), path(dst, "toolchain"))) else: vstr = cat(vstr, VOLS.volstr()) return vstr
def _bench(self, name, dir, ins, runs, dstdir=None, ctor=Bench, bflags=None, xflags=None, sbtflags=[], cc=None, rvcc=None, **kwargs): dstdir = dstdir if dstdir else path(self.dstdir, dir) bflags = cat(self.bflags, bflags) if GOPTS.rv_soft_float(): sbtflags = sbtflags + ["-soft-float-abi"] return ctor( name=name, dir=dir, ins=ins, runs=runs, srcdir=path(self.srcdir, dir), dstdir=dstdir, bflags=bflags, xflags=xflags, sbtflags=sbtflags, narchs=self.narchs, xarchs=self.xarchs, cc=cc, rvcc=rvcc, rv32=self.rv32, **kwargs)
def _lame(self): srcs = [ "main.c", "brhist.c", "formatBitstream.c", "fft.c", "get_audio.c", "l3bitstream.c", "id3tag.c", "ieeefloat.c", "lame.c", "newmdct.c", "parse.c", "portableio.c", "psymodel.c", "quantize.c", "quantize-pvt.c", "vbrquantize.c", "reservoir.c", "tables.c", "takehiro.c", "timestatus.c", "util.c", "VbrTag.c", "version.c", "gtkanal.c", "gpkplotting.c", "mpglib/common.c", "mpglib/dct64_i386.c", "mpglib/decode_i386.c", "mpglib/layer3.c", "mpglib/tabinit.c", "mpglib/interface.c", "mpglib/main.c" ] srcs = [path("lame3.70", src) for src in srcs] dir = "consumer/lame" _in = mpath(self.srcdir, dir, "large.wav") out = mpath(self.dstdir, dir, "{prefix}output_large{mode}.mp3") runs = Runs([Run([_in, out], outidx=1)]) bflags = '--cflags="-DLAMEPARSE -DLAMESNDFILE"' sbtflags = self.stack_huge return self._bench("lame", dir, srcs, runs, bflags=bflags, sbtflags=sbtflags)
def _gen_epilogue(self): names = [b.name for b in self.benchs] csv_header = self._gen_csv_header() self.append("""\ .PHONY: lame-dirs {0}: \tmkdir -p {0} .PHONY: benchs benchs: {0} {1} .PHONY: benchs-test benchs-test: {2} .PHONY: csv-header csv-header: \techo "{3}" > mibench.csv \techo "{4}" >> mibench.csv .PHONY: benchs-measure benchs-measure: csv-header {5} .PHONY: benchs-arm-copy benchs-arm-copy: benchs arm-dstdir {6} plot: mibench.csv \t{7} -x mibench.csv -m globals locals abi -c 6 7 > mibench_slowdown.csv \tsed 1,2d mibench_slowdown.csv | grep -v geomean | tr , ' ' | \ \t\tawk 'BEGIN{{i=1}} {{print i++ " " $$0}}' > mibench_slowdown.dat \t./mibench.gnuplot """.format( path(self.dstdir, "consumer/lame/lame3.70/mpglib"), " ".join(names), " ".join([name + "-test" for name in names]), ",".join(csv_header[0]), ",".join(csv_header[1]), " ".join([name + "-measure" for name in names]), " ".join([name + "-copy" for name in names]), TOOLS.measure, ))
def __init__(self, topdir, docker_dir): self.topdir = topdir self.commits_txt = path(docker_dir, "commits.txt")
#!/usr/bin/env python3 from auto.utils import cat, cd, mkdir_if_needed, mpath, path, shell import argparse import re import os import sys TOPDIR = os.environ["TOPDIR"] DOCKER_DIR = path(TOPDIR, "docker") # # Helper # class Helper: @staticmethod def is_cygwin(): try: shell("uname | grep -i cygwin >/dev/null", quiet=True) return True except: return False @staticmethod def cygpath(path): if Helper.is_cygwin(): return shell("cygpath -m " + path, save_out=True).strip() else:
def gen(self): self._gen_prologue() self.benchs = [ self._bench("dijkstra", "network/dijkstra", ["dijkstra_large.c"], self._single_run( [path(self.srcdir, "network/dijkstra/input.dat")])), self._bench("crc32", "telecomm/CRC32", ["crc_32.c"], self._single_run( [path(self.srcdir, "telecomm/adpcm/data/large.pcm")])), self._rijndael(), self._bench("sha", "security/sha", ["sha_driver.c", "sha.c"], self._single_run( [path(self.srcdir, "security/sha/input_large.asc")]), sbtflags=["-stack-size=16384"], bflags=self.bflags_mmx), self._bench("adpcm-encode", "telecomm/adpcm/src", ["rawcaudio.c", "adpcm.c"], self._single_run([], stdin=path(self.srcdir, "telecomm/adpcm/data/large.pcm"), rflags="--bin"), dstdir=path(self.dstdir, "telecomm/adpcm/rawcaudio")), self._bench("adpcm-decode", "telecomm/adpcm/src", ["rawdaudio.c", "adpcm.c"], self._single_run([], stdin=path(self.srcdir, "telecomm/adpcm/data/large.adpcm"), rflags="--bin"), dstdir=path(self.dstdir, "telecomm/adpcm/rawdaudio")), self._bench("stringsearch", "office/stringsearch", ["bmhasrch.c", "bmhisrch.c", "bmhsrch.c", "pbmsrch_large.c"], self._single_run([]), bflags=self.bflags_mmx, sbtflags=self.stack_large), self._bf(), self._bench("basicmath", "automotive/basicmath", ["basicmath_large.c", "rad2deg.c", "cubic.c", "isqrt.c"], self._single_run([]), sbtflags=self.stack_large), self._bench("bitcount", "automotive/bitcount", ["bitcnt_1.c", "bitcnt_2.c", "bitcnt_3.c", "bitcnt_4.c", "bitcnts.c", "bitfiles.c", "bitstrng.c", "bstr_i.c"], self._single_run(["1125000"]), sbtflags=self.stack_large+["-icall-int-only"]) .out_filter("sed 's/Time:[^;]*; //;/^Best/d;/^Worst/d'"), self._bench("fft", "telecomm/FFT", ["main.c", "fftmisc.c", "fourierf.c"], Runs([ Run(["8", "32768"], "std"), Run(["8", "32768", "-i"], "inv") ]), sbtflags=self.stack_large, bflags=self.bflags_no_fp_contract), self._bench("patricia", "network/patricia", ["patricia.c", "patricia_test.c"], self._single_run( [path(self.srcdir, "network/patricia/large.udp")], rflags="--exp-rc=1"), mflags=["--exp-rc=1"]), self._susan(), self._lame() ] for bench in self.benchs: self.append(bench.gen()) self._gen_epilogue() self._write()