| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

plotSpeedupsPyRoot.py
Go to the documentation of this file.
1 from ROOT import *
2
3 '''
4 Script to parse all the logs and produce the speedup plot.
5 Usage:
6 plotSpeedupsPyRoot.py --> vanilla plot
7 plotSpeedupsPyRoot.py 1 --> HT scaled plot
8 The variable fname_template contains the template of the file names to be
9 opened and parsed and is FIXED for all the logs.
10 The word "seconds" is looked for in the log and then the total runtime of the
11 event loop is extracted. This allows to discard the time spent in calibration
12 and so on.
13 '''
14
15 # Configuration ----------------------------------------------------------------
16 fname_template = "measurement_BrunelScenario_n100_eif%s_aif100_nthreads%s_c%s_dqFalse_v5.log"
17 # Number of events in flight
18 neif_l = [1, 2, 3, 5, 20, 30]
19 # Number of Threads
20 nts = [2, 3, 5, 10, 11, 12, 13, 15, 23]
21 # Clone Flag
22 cFlags = ["True", "False"]
23
24 ScalarTime = 1640.87
25
26 # Style
27 LegendDrawOpts = "lp"
28 LineColours = [kRed,
29 kBlue,
30 kGreen + 2,
31 kOrange,
32 kPink + 10,
33 kViolet + 10]
34 MarkerStyles = [kFullCircle,
35 kOpenCross,
36 kFullTriangleUp,
37 kOpenStar,
38 kFullCross,
39 kOpenCircle]
40 MarkerSize = 4
41 LineWidth = 6
42 LineStyle = 7
43 graph_counter = 0
44
45 PhCores = 11
46 TotalCores = 24
47 HtCoreWeight = 0.4
48
49 LabelsFont = 12
50 LabelsSize = .6
51 #--------------------
52
53
54 def scaleCores(n_threads):
55 effective_n_threads = n_threads
56 if effective_n_threads > PhCores:
57 ht_cores = n_threads - PhCores
58 effective_n_threads = PhCores + ht_cores * HtCoreWeight
59 return effective_n_threads
60
61 #--------------------
62
63
64 def getText(x, y, text, scale, angle, colour, font):
65 lat = TLatex(x, y, "#scale[%s]{#color[%s]{#font[%s]{%s}}}" % (
66 scale, colour, font, text))
67 if angle != 0.:
68 lat.SetTextAngle(angle)
69 return lat
70
71 #--------------------
72
73
74 def formatGraphs(graph, graphc):
75 global graph_counter
76 graphc.SetLineStyle(LineStyle)
77 graphs = (graph, graphc)
78 for g in graphs:
79 g.SetLineWidth(LineWidth)
80 g.SetMarkerSize(MarkerSize)
81 g.SetMarkerStyle(MarkerStyles[graph_counter])
82 g.SetLineColor(LineColours[graph_counter])
83 g.SetMarkerColor(LineColours[graph_counter])
84 graph_counter += 1
85
86 #--------------------
87
88
89 def createFname(neif, nt, cFlag):
90 return fname_template % (neif, nt, cFlag)
91
92 #--------------------
93
94
95 def xtractTiming(neif, nt, cFlag):
96 filename = createFname(neif, nt, cFlag)
97 ifile = open(filename, "r")
98 seconds = -1
99 for line in ifile:
100 if "seconds" in line:
101 line = line[:-1]
102 seconds = float(line.split(" ")[-1])
103 break
104 ifile.close()
105 if seconds == -1:
106 seconds = xtractTiming(neif, nts[nts.index(nt) - 1], cFlag)
107 return seconds
108
109 #--------------------
110
111
112 import sys
113 scaleThreads = False
114 if len(sys.argv) > 1:
115 scaleThreads = True
116
117
118 # main loop: just printouts
119 for neif in neif_l:
120 print "Events in flight: %s" % neif
121 for tn in nts:
122 print "%s %s %s" % (tn, xtractTiming(neif, tn, False), xtractTiming(neif, tn, True))
123
124
125 len_nt = len(nts) + 1
126 # Prepare ideal speedup graph
127 idealSpeedup = TGraph(2)
128 idealSpeedup.SetPoint(0, 1, 1)
129 idealSpeedup.SetPoint(1, TotalCores, TotalCores)
130 scaled_s = ""
131 if scaleThreads:
132 scaled_s = " (scaled for HT)"
133 idealSpeedup.SetTitle(
134 "GaudiHive Speedup (Brunel, 100 evts);Thread Pool Size%s;Speedup wrt Serial Case" % scaled_s)
135 idealSpeedup.SetLineWidth(4)
136 idealSpeedup.SetLineColor(kGray - 2)
137 idealSpeedup.SetLineStyle(2)
138
139 # Main Loop: fill all graphs
140 neif_graphs = []
141 for neif in neif_l: # One graph per number of events in flight
142 graph = TGraph(len_nt)
143 graph.SetName("%s" % neif)
144 graph.SetPoint(0, 1, 1)
145
146 graphc = TGraph(len_nt)
147 graphc.SetName("%s clone" % neif)
148 graphc.SetPoint(0, 1, 1)
149 counter = 1
150 for tn in nts:
151 scaled_tn = tn
152 if scaleThreads:
153 scaled_tn = scaleCores(tn)
154 time = xtractTiming(neif, tn, False)
155 graph.SetPoint(counter, scaled_tn, ScalarTime / time)
156 timec = xtractTiming(neif, tn, True)
157 graphc.SetPoint(counter, scaled_tn, ScalarTime / timec)
158 counter += 1
159 formatGraphs(graph, graphc)
160 neif_graphs.append([neif, graph, graphc])
161
162 neif_graphs.reverse()
163
164 # Now that all are complete, let's make the plot
165 canvas = TCanvas("Speedup", "Speedup", 2048, 1800)
166 canvas.cd()
167 canvas.SetGrid()
168 idealSpeedup.Draw("APL")
169 idealSpeedup.GetYaxis().SetRangeUser(0.1, TotalCores + 1) # only one 0
170
171 # Line
172 line = TLine(11, 0, 11, 25)
173 line.SetLineColor(kRed)
174 line.SetLineWidth(4)
175 line.SetLineStyle(2)
176 line.Draw()
177
178 for neif, graph, graphc in neif_graphs:
179 graph.Draw("SamePL")
180 graphc.Draw("SamePL")
181
182 # Prepare Legend
183 legend = TLegend(.1, .45, .38, .9)
184 legend.SetFillColor(kWhite)
185 legend.SetHeader("# Simultaneous Evts")
186 for neif, graph, graphc in neif_graphs:
187 legend.AddEntry(graph, "%s" % neif, LegendDrawOpts)
188 legend.AddEntry(graphc, "%s (clone)" % neif, LegendDrawOpts)
189 legend.Draw()
190
191 # Labels
192 ph_cores = getText(10.5, 15, "Physical Cores", LabelsSize, 90, 2, LabelsFont)
193 ph_cores.Draw()
194 ht_cores = getText(12., 15, "Hardware Threaded Regime",
195 LabelsSize, 90, 2, LabelsFont)
196 ht_cores.Draw()
197 is_text = getText(16, 16.5, "Ideal (linear) Speedup",
198 LabelsSize, 45, 918, LabelsFont)
199 is_text.Draw()
200 ht_weight = 0
201 if scaleThreads:
202 ht_weight = getText(
203 18.5, 8, "#splitline{Hardware threaded}{cores weight: %s}" % HtCoreWeight, LabelsSize, 0, 600, LabelsFont)
204 ht_weight.Draw()
205
206 if scaleThreads:
207 scaled_s = "_HTScaled"
208 canvas.Print("GaudiHivePerfBrunelAllPoints%s.png" % scaled_s)
plotSpeedupsPyRoot.createFname
def createFname(neif, nt, cFlag)
Definition: plotSpeedupsPyRoot.py:89
plotSpeedupsPyRoot.getText
def getText(x, y, text, scale, angle, colour, font)
Definition: plotSpeedupsPyRoot.py:64
plotSpeedupsPyRoot.formatGraphs
def formatGraphs(graph, graphc)
Definition: plotSpeedupsPyRoot.py:74
plotSpeedupsPyRoot.scaleCores
def scaleCores(n_threads)
Definition: plotSpeedupsPyRoot.py:54
plotSpeedupsPyRoot.xtractTiming
def xtractTiming(neif, nt, cFlag)
Definition: plotSpeedupsPyRoot.py:95