| The Gaudi Framework v28r2p1 (f1a77ff4)

- 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 def scaleCores(n_threads):
54 effective_n_threads=n_threads
55 if effective_n_threads > PhCores:
56 ht_cores = n_threads-PhCores
57 effective_n_threads = PhCores + ht_cores * HtCoreWeight
58 return effective_n_threads
59
60 #--------------------
61
62 def getText(x,y,text,scale,angle,colour,font):
63 lat = TLatex(x,y,"#scale[%s]{#color[%s]{#font[%s]{%s}}}"%(scale,colour,font,text))
64 if angle!=0.:
65 lat.SetTextAngle(angle)
66 return lat
67
68 #--------------------
69
70 def formatGraphs(graph,graphc):
71 global graph_counter
72 graphc.SetLineStyle(LineStyle)
73 graphs=(graph,graphc)
74 for g in graphs:
75 g.SetLineWidth(LineWidth)
76 g.SetMarkerSize(MarkerSize)
77 g.SetMarkerStyle(MarkerStyles[graph_counter])
78 g.SetLineColor(LineColours[graph_counter])
79 g.SetMarkerColor(LineColours[graph_counter])
80 graph_counter+=1
81
82 #--------------------
83
84 def createFname(neif,nt,cFlag):
85 return fname_template %(neif,nt,cFlag)
86
87 #--------------------
88
89 def xtractTiming(neif,nt,cFlag):
90 filename = createFname(neif,nt,cFlag)
91 ifile = open(filename,"r")
92 seconds=-1
93 for line in ifile:
94 if "seconds" in line:
95 line=line[:-1]
96 seconds = float(line.split(" ")[-1])
97 break
98 ifile.close()
99 if seconds==-1:
100 seconds=xtractTiming(neif,nts[nts.index(nt)-1],cFlag)
101 return seconds
102
103 #--------------------
104
105 import sys
106 scaleThreads=False
107 if len(sys.argv)>1:
108 scaleThreads=True
109
110
111 # main loop: just printouts
112 for neif in neif_l:
113 print "Events in flight: %s" %neif
114 for tn in nts:
115 print "%s %s %s" %(tn, xtractTiming(neif,tn,False),xtractTiming(neif,tn,True))
116
117
118 len_nt=len(nts)+1
119 # Prepare ideal speedup graph
120 idealSpeedup = TGraph(2)
121 idealSpeedup.SetPoint(0,1,1)
122 idealSpeedup.SetPoint(1,TotalCores,TotalCores)
123 scaled_s=""
124 if scaleThreads:
125 scaled_s=" (scaled for HT)"
126 idealSpeedup.SetTitle("GaudiHive Speedup (Brunel, 100 evts);Thread Pool Size%s;Speedup wrt Serial Case"%scaled_s)
127 idealSpeedup.SetLineWidth(4)
128 idealSpeedup.SetLineColor(kGray-2)
129 idealSpeedup.SetLineStyle(2)
130
131 # Main Loop: fill all graphs
132 neif_graphs=[]
133 for neif in neif_l: # One graph per number of events in flight
134 graph = TGraph (len_nt)
135 graph.SetName("%s"%neif)
136 graph.SetPoint(0,1,1)
137
138 graphc = TGraph (len_nt)
139 graphc.SetName("%s clone"%neif)
140 graphc.SetPoint(0,1,1)
141 counter=1
142 for tn in nts:
143 scaled_tn=tn
144 if scaleThreads:
145 scaled_tn=scaleCores(tn)
146 time=xtractTiming(neif,tn,False)
147 graph.SetPoint(counter,scaled_tn,ScalarTime/time)
148 timec=xtractTiming(neif,tn,True)
149 graphc.SetPoint(counter,scaled_tn,ScalarTime/timec)
150 counter+=1
151 formatGraphs(graph,graphc)
152 neif_graphs.append([neif,graph,graphc])
153
154 neif_graphs.reverse()
155
156 # Now that all are complete, let's make the plot
157 canvas = TCanvas("Speedup","Speedup",2048,1800)
158 canvas.cd()
159 canvas.SetGrid()
160 idealSpeedup.Draw("APL")
161 idealSpeedup.GetYaxis().SetRangeUser(0.1,TotalCores+1) # only one 0
162
163 # Line
164 line = TLine(11,0,11,25)
165 line.SetLineColor(kRed)
166 line.SetLineWidth(4)
167 line.SetLineStyle(2)
168 line.Draw()
169
170 for neif,graph,graphc in neif_graphs:
171 graph.Draw("SamePL")
172 graphc.Draw("SamePL")
173
174 # Prepare Legend
175 legend = TLegend(.1,.45,.38,.9)
176 legend.SetFillColor(kWhite)
177 legend.SetHeader("# Simultaneous Evts")
178 for neif,graph,graphc in neif_graphs:
179 legend.AddEntry(graph,"%s"%neif,LegendDrawOpts)
180 legend.AddEntry(graphc,"%s (clone)"%neif,LegendDrawOpts)
181 legend.Draw()
182
183 # Labels
184 ph_cores=getText(10.5,15,"Physical Cores",LabelsSize,90,2,LabelsFont)
185 ph_cores.Draw()
186 ht_cores=getText(12.,15,"Hardware Threaded Regime",LabelsSize,90,2,LabelsFont)
187 ht_cores.Draw()
188 is_text=getText(16,16.5,"Ideal (linear) Speedup", LabelsSize, 45, 918, LabelsFont)
189 is_text.Draw()
190 ht_weight=0
191 if scaleThreads:
192 ht_weight=getText(18.5,8,"#splitline{Hardware threaded}{cores weight: %s}"%HtCoreWeight,LabelsSize,0,600,LabelsFont)
193 ht_weight.Draw()
194
195 if scaleThreads:
196 scaled_s="_HTScaled"
197 canvas.Print("GaudiHivePerfBrunelAllPoints%s.png"%scaled_s)
plotSpeedupsPyRoot.createFname
def createFname(neif, nt, cFlag)
Definition: plotSpeedupsPyRoot.py:84
plotSpeedupsPyRoot.getText
def getText(x, y, text, scale, angle, colour, font)
Definition: plotSpeedupsPyRoot.py:62
plotSpeedupsPyRoot.formatGraphs
def formatGraphs(graph, graphc)
Definition: plotSpeedupsPyRoot.py:70
plotSpeedupsPyRoot.scaleCores
def scaleCores(n_threads)
Definition: plotSpeedupsPyRoot.py:53
plotSpeedupsPyRoot.xtractTiming
def xtractTiming(neif, nt, cFlag)
Definition: plotSpeedupsPyRoot.py:89