-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot-x-cpu.py
More file actions
executable file
·121 lines (94 loc) · 3.66 KB
/
Copy pathplot-x-cpu.py
File metadata and controls
executable file
·121 lines (94 loc) · 3.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/usr/bin/env python
import argparse
import matplotlib.pyplot as plt
import matplotlib
from myplotlib import get_marker, get_color, change_aspect_ratio
from tlpperfparser import parse
fontsize = 22
lfontsize = 18
markersize = 14
linewidth = 2.4
lines = { "linewidth" : linewidth,
"markersize" : markersize,
"markeredgewidth" : linewidth, }
markers = { "fillstyle" : "none", }
plt.rc("lines", **lines)
plt.rc("markers", **markers)
matplotlib.rcParams['pdf.fonttype'] = 42
matplotlib.rcParams['ps.fonttype'] = 42
def main():
round_map = {
"G": 1000000000,
"M": 1000000,
"K": 1000,
}
parser = argparse.ArgumentParser()
parser.add_argument("-u", "--unit", help = "unit of bandwidth",
choices = ["bps", "tps"], default = "bps")
parser.add_argument("-d", "--direction", help = "DMA direction",
choices = ["read", "write"], default = "read")
parser.add_argument("-l", "--dmalen", help = "DMA length to be drawn",
action = "append")
parser.add_argument("-p", "--pattern", help = "access pattern",
choices = ["seq", "fix", "random"], default = "seq")
parser.add_argument("-r", "--round", help = "round up x axis",
choices = round_map.keys(),
default = list(round_map.keys())[0])
parser.add_argument("-R", "--ratio", help = "aspect ratio",
type = float, default = 1.5)
parser.add_argument("-o", "--output", help = "output pdf file name",
default = None)
args = parser.parse_args()
if not args.dmalen:
dma_lens = reversed([ 1, 4, 8, 16, 32, 64, 128, 256, 512, 1024 ])
else:
dma_lens = args.dmalen
cpu_nums = [ 1, 2, 4, 6, 8, 10, 12, 14, 16]
if not args.output:
pdffile = ("graph/graph_{}_x-cpu_".format(args.direction) +
"pattern-{}_".format(args.pattern) +
"{}.pdf".format(args.unit))
else:
pdffile = args.output
fig, ax= plt.subplots()
maximum = 0
for dma_len in dma_lens:
bpses = []
tpses = []
for cpu_num in cpu_nums:
f = ("output/{}_".format(args.direction) +
"pattern-{}_".format(args.pattern) +
"dmalen-{}_".format(dma_len) +
"cpu-{}.txt".format(cpu_num))
bps, tps = parse(f)
bpses.append(bps)
tpses.append(tps)
if args.unit == "bps":
yaxis = bpses
elif args.unit == "tps":
yaxis = tpses
# round up to K, M, or G
yaxis = list(map(lambda x: x / round_map[args.round], yaxis))
ax.plot(cpu_nums, yaxis, marker = get_marker(), color = get_color(),
label = "DMA {}B".format(dma_len))
print(f)
for x in range(len(cpu_nums)):
print("{}\t{}".format(cpu_nums[x], yaxis[x]))
print()
# save maximum y value
if maximum < max(yaxis) :
maximum = max(yaxis)
yticks = list(range(int(maximum) + 2)) # this code depends on round up Gig
plt.yticks(yticks, yticks)
plt.xticks(cpu_nums, cpu_nums)
ax.tick_params(labelsize = fontsize)
ax.set_ylabel("throughput ({}{})".format(args.round, args.unit),
fontsize = fontsize)
ax.set_xlabel("number of cores", fontsize = fontsize)
ax.grid(True, linestyle = "--", linewidth = 0.5)
ax.legend(fontsize = lfontsize)
change_aspect_ratio(ax, args.ratio)
print("save '{}'".format(pdffile))
plt.savefig(pdffile, bbox_inches = "tight", pad_inches = 0.05)
if __name__ == "__main__":
main()