CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Functions | Variables
plotThroughput Namespace Reference

Functions

def findBounds
 
def main
 
def makePlot
 

Variables

list colors
 

Function Documentation

def plotThroughput.findBounds (   x,
  ys,
  xmin = None,
  ymin = None,
  xmax = None,
  ymax = None 
)

Definition at line 18 of file plotThroughput.py.

References makePlot(), SiStripPI.max, and SiStripPI.min.

Referenced by makePlot().

18 
19 def findBounds(x, ys, xmin=None, ymin=None, xmax=None, ymax=None):
20  if xmin is None:
21  xmin = min(x)
22  if xmax is None:
23  xmax = max(x)
24  if ymin is None:
25  ymin = min([min(y) for y in ys])
26  if ymax is None:
27  ymax = max([max(y) for y in ys]) * 1.1
28 
29  return (xmin, ymin, xmax, ymax)
30 
def plotThroughput.main (   argv)

Definition at line 92 of file plotThroughput.py.

References makePlot().

92 
93 def main(argv):
94  (inputfile, outputfile, graph_label) = argv[1:4]
95 
96  re_mt = re.compile("nTH(?P<th>\d+)_nEV(?P<ev>\d+)")
97  re_mp = re.compile("nJOB(?P<job>\d+)")
98 
99  mt = {}
100  mp = {}
101 
102  f = open(inputfile)
103  for line in f:
104  if not "AVX512" in line:
105  continue
106  comp = line.split(" ")
107  m = re_mt.search(comp[0])
108  if m:
109  if m.group("th") != m.group("ev"):
110  raise Exception("Can't handle yet different numbers of threads (%s) and events (%s)" % (m.group("th"), m.group("ev")))
111  mt[int(m.group("th"))] = float(comp[1])
112  continue
113  m = re_mp.search(comp[0])
114  if m:
115  mp[int(m.group("job"))] = float(comp[1])
116  f.close()
117 
118  ncores = sorted(list(set(mt.keys() + mp.keys())))
119  mt_y = [mt[n] for n in ncores]
120  mp_y = [mp[n] for n in ncores]
121  ideal1 = mt_y[0]/ncores[0]
122  ideal1_mp = mp_y[0]/ncores[0]
123 
124  makePlot(outputfile+"_throughput", ncores,
125  [mt_y, mp_y],
126  "Throughput (events/s)",
127  title=graph_label,
128  legends=["Multithreading", "Multiprocessing"],
129  ideal1=ideal1,
130  bounds=dict(ymin=0, xmin=0),
131  legendYmax=0.5
132  )
133 
134  eff = [mt_y[i]/mp_y[i] for i in xrange(0, len(ncores))]
135  makePlot(outputfile+"_efficiency", ncores,
136  [eff],
137  "Multithreading efficiency (MT/MP)",
138  title=graph_label,
139  bounds=dict(ymin=0.9, ymax=1.1)
140  )
141 
142  eff_vs_ideal_mt = [mt_y[i]/(ideal1*n) for i, n in enumerate(ncores)]
143  eff_vs_ideal_mp = [mp_y[i]/(ideal1*n) for i, n in enumerate(ncores)]
144  makePlot(outputfile+"_efficiency_ideal", ncores,
145  [eff_vs_ideal_mt, eff_vs_ideal_mp],
146  "Efficiency wrt. ideal",
147  title=graph_label,
148  legends=["Multithreading", "Multiprocessing"],
149  bounds=dict(ymin=0.8, ymax=1.01, xmax=65),
150  legendYmax=0.9
151  )
152 
153  speedup_mt = [mt_y[i]/ideal1 for i in xrange(0, len(ncores))]
154  speedup_mp = [mp_y[i]/ideal1 for i in xrange(0, len(ncores))]
155  makePlot(outputfile+"_speedup", ncores,
156  [speedup_mt, speedup_mp],
157  "Speedup wrt. 1 thread",
158  title=graph_label,
159  legends=["Multithreading", "Multiprocessing"],
160  ideal1=1,
161  bounds=dict(ymin=0, xmin=0),
162  legendYmax=0.5
163  )
164 
def plotThroughput.makePlot (   name,
  x,
  ys,
  ytitle,
  title = None,
  legends = None,
  ideal1 = None,
  bounds = {},
  legendYmax = 0.99 
)

Definition at line 37 of file plotThroughput.py.

References findBounds().

Referenced by findBounds(), and main().

37 
38  ):
39  canv = ROOT.TCanvas()
40  canv.cd()
41  canv.SetTickx(1)
42  canv.SetTicky(1)
43  canv.SetGridy(1)
44 
45  bounds = findBounds(x, ys, **bounds)
46  frame = canv.DrawFrame(*bounds)
47 
48  frame.GetXaxis().SetTitle("Number of threads")
49  frame.GetYaxis().SetTitle(ytitle)
50  if title is not None:
51  frame.SetTitle(title)
52  frame.Draw("")
53 
54  leg = None
55  if legends is not None:
56  leg = ROOT.TLegend(0.77,legendYmax-0.19,0.99,legendYmax)
57 
58  graphs = []
59 
60  if ideal1 is not None:
61  ymax = bounds[3]
62  ideal_y = [ideal1, ymax]
63  ideal_x = [1, ymax/ideal1]
64  gr = ROOT.TGraph(2, array.array("d", ideal_x), array.array("d", ideal_y))
65  gr.SetLineColor(ROOT.kBlack)
66  gr.SetLineStyle(3)
67  gr.Draw("same")
68  if leg:
69  leg.AddEntry(gr, "Ideal scaling", "l")
70  graphs.append(gr)
71 
72  for i, y in enumerate(ys):
73  gr = ROOT.TGraph(len(x), array.array("d", x), array.array("d", y))
74  color = colors[i]
75  gr.SetLineColor(color)
76  gr.SetMarkerColor(color)
77  gr.SetMarkerStyle(ROOT.kFullCircle)
78  gr.SetMarkerSize(1)
79 
80  gr.Draw("LP SAME")
81  if leg:
82  leg.AddEntry(gr, legends[i], "lp")
83 
84  graphs.append(gr)
85 
86  if leg:
87  leg.Draw("same")
88 
89  canv.SaveAs(name+".png")
90  canv.SaveAs(name+".pdf")
91 

Variable Documentation

list plotThroughput.colors
Initial value:
1 = [
2  ROOT.kBlue,
3  ROOT.kRed+1,
4  ROOT.kBlack
5 ]

Definition at line 12 of file plotThroughput.py.