[2f6a9391] | 1 | import os
|
---|
| 2 | import sys
|
---|
| 3 | import time
|
---|
[4912520] | 4 | import itertools
|
---|
[2f6a9391] | 5 | import matplotlib.pyplot as plt
|
---|
| 6 | import matplotlib.ticker as ticks
|
---|
| 7 | import math
|
---|
| 8 | from scipy import stats as st
|
---|
| 9 | import numpy as np
|
---|
| 10 | from enum import Enum
|
---|
| 11 | from statistics import median
|
---|
| 12 |
|
---|
| 13 | import matplotlib
|
---|
| 14 | matplotlib.use("pgf")
|
---|
| 15 | matplotlib.rcParams.update({
|
---|
| 16 | "pgf.texsystem": "pdflatex",
|
---|
| 17 | 'font.family': 'serif',
|
---|
| 18 | 'text.usetex': True,
|
---|
| 19 | 'pgf.rcfonts': False,
|
---|
[4912520] | 20 | 'font.size': 16
|
---|
[2f6a9391] | 21 | })
|
---|
[4912520] | 22 | marker = itertools.cycle(('o', 's', 'D', 'x', 'p', '^', 'h', '*', 'v' ))
|
---|
[2f6a9391] | 23 |
|
---|
| 24 | readfile = open(sys.argv[1], "r")
|
---|
| 25 |
|
---|
| 26 | machineName = ""
|
---|
| 27 |
|
---|
| 28 | if len(sys.argv) > 2:
|
---|
| 29 | machineName = sys.argv[2]
|
---|
| 30 |
|
---|
| 31 | # first line has num times per experiment
|
---|
| 32 | line = readfile.readline()
|
---|
| 33 | numTimes = int(line)
|
---|
| 34 |
|
---|
| 35 | # second line has processor args
|
---|
| 36 | line = readfile.readline()
|
---|
| 37 | procs = []
|
---|
| 38 | for val in line.split():
|
---|
| 39 | procs.append(int(val))
|
---|
| 40 |
|
---|
[d24b1985] | 41 | # 3rd line has number of variants
|
---|
[2f6a9391] | 42 | line = readfile.readline()
|
---|
| 43 | names = line.split()
|
---|
| 44 | numVariants = len(names)
|
---|
| 45 |
|
---|
| 46 | lines = (line.rstrip() for line in readfile) # All lines including the blank ones
|
---|
| 47 | lines = (line for line in lines if line) # Non-blank lines
|
---|
| 48 |
|
---|
[d24b1985] | 49 | class Bench(Enum):
|
---|
| 50 | Unset = 0
|
---|
| 51 | Contend = 1
|
---|
| 52 | Zero = 2
|
---|
| 53 | Barrier = 3
|
---|
| 54 | Churn = 4
|
---|
| 55 | Daisy_Chain = 5
|
---|
| 56 | Hot_Potato = 6
|
---|
| 57 | Pub_Sub = 7
|
---|
| 58 |
|
---|
[2f6a9391] | 59 | nameSet = False
|
---|
[d24b1985] | 60 | currBench = Bench.Unset # default val
|
---|
[2f6a9391] | 61 | count = 0
|
---|
| 62 | procCount = 0
|
---|
| 63 | currVariant = 0
|
---|
[d24b1985] | 64 | name = ""
|
---|
[2f6a9391] | 65 | var_name = ""
|
---|
| 66 | sendData = [0.0 for j in range(numVariants)]
|
---|
| 67 | data = [[0.0 for i in range(len(procs))] for j in range(numVariants)]
|
---|
| 68 | bars = [[[0.0 for i in range(len(procs))],[0.0 for k in range(len(procs))]] for j in range(numVariants)]
|
---|
| 69 | tempData = [0.0 for i in range(numTimes)]
|
---|
| 70 | for idx, line in enumerate(lines):
|
---|
| 71 | # print(line)
|
---|
| 72 |
|
---|
[d24b1985] | 73 | if currBench == Bench.Unset:
|
---|
| 74 | if line == "contend:":
|
---|
[6e1e2d0] | 75 | name = "Channel Contention"
|
---|
[d24b1985] | 76 | currBench = Bench.Contend
|
---|
| 77 | elif line == "zero:":
|
---|
| 78 | name = "Zero"
|
---|
| 79 | currBench = Bench.Zero
|
---|
| 80 | elif line == "barrier:":
|
---|
| 81 | name = "Barrier"
|
---|
| 82 | currBench = Bench.Barrier
|
---|
| 83 | elif line == "churn:":
|
---|
| 84 | name = "Churn"
|
---|
| 85 | currBench = Bench.Churn
|
---|
| 86 | elif line == "daisy_chain:":
|
---|
| 87 | name = "Daisy_Chain"
|
---|
| 88 | currBench = Bench.Daisy_Chain
|
---|
| 89 | elif line == "hot_potato:":
|
---|
| 90 | name = "Hot_Potato"
|
---|
| 91 | currBench = Bench.Hot_Potato
|
---|
| 92 | elif line == "pub_sub:":
|
---|
| 93 | name = "Pub_Sub"
|
---|
| 94 | currBench = Bench.Pub_Sub
|
---|
| 95 | else:
|
---|
| 96 | print("Expected benchmark name")
|
---|
| 97 | print("Line: " + line)
|
---|
| 98 | sys.exit()
|
---|
[2f6a9391] | 99 | continue
|
---|
| 100 |
|
---|
| 101 | if line[0:5] == "cores":
|
---|
| 102 | continue
|
---|
| 103 |
|
---|
| 104 | if not nameSet:
|
---|
| 105 | nameSet = True
|
---|
| 106 | continue
|
---|
| 107 |
|
---|
| 108 | lineArr = line.split()
|
---|
| 109 | tempData[count] = float(lineArr[-1])
|
---|
| 110 | count += 1
|
---|
| 111 | if count == numTimes:
|
---|
| 112 | currMedian = median( tempData )
|
---|
| 113 | data[currVariant][procCount] = currMedian
|
---|
| 114 | lower, upper = st.t.interval(0.95, numTimes - 1, loc=np.mean(tempData), scale=st.sem(tempData))
|
---|
| 115 | bars[currVariant][0][procCount] = currMedian - lower
|
---|
| 116 | bars[currVariant][1][procCount] = upper - currMedian
|
---|
| 117 | count = 0
|
---|
| 118 | procCount += 1
|
---|
| 119 |
|
---|
| 120 | if procCount == len(procs):
|
---|
| 121 | procCount = 0
|
---|
| 122 | nameSet = False
|
---|
| 123 | currVariant += 1
|
---|
| 124 |
|
---|
| 125 | if currVariant == numVariants:
|
---|
[1803d4d] | 126 | fig, ax = plt.subplots(layout='constrained')
|
---|
[d24b1985] | 127 | plt.title(name + " Benchmark")
|
---|
| 128 | plt.ylabel("Throughput (channel operations)")
|
---|
[2f6a9391] | 129 | plt.xlabel("Cores")
|
---|
| 130 | for idx, arr in enumerate(data):
|
---|
[4912520] | 131 | plt.errorbar( procs, arr, [bars[idx][0], bars[idx][1]], capsize=2, marker=next(marker) )
|
---|
[60f4919] | 132 | marker = itertools.cycle(('o', 's', 'D', 'x', 'p', '^', 'h', '*', 'v' ))
|
---|
[2f6a9391] | 133 | plt.yscale("log")
|
---|
[d24b1985] | 134 | # plt.ylim(1, None)
|
---|
| 135 | # ax.get_yaxis().set_major_formatter(ticks.ScalarFormatter())
|
---|
| 136 | # else:
|
---|
| 137 | # plt.ylim(0, None)
|
---|
[2f6a9391] | 138 | plt.xticks(procs)
|
---|
| 139 | ax.legend(names)
|
---|
[d24b1985] | 140 | # fig.savefig("plots/" + machineName + name + ".png")
|
---|
| 141 | plt.savefig("plots/" + machineName + name + ".pgf")
|
---|
[2f6a9391] | 142 | fig.clf()
|
---|
| 143 |
|
---|
| 144 | # reset
|
---|
[d24b1985] | 145 | currBench = Bench.Unset
|
---|
[2f6a9391] | 146 | currVariant = 0
|
---|