CMS 3D CMS Logo

Functions
makeBenchmarkPlots Namespace Reference

Functions

def makeplots (arch, sample, build, vals, nC, text)
 
def run ()
 

Function Documentation

◆ makeplots()

def makeBenchmarkPlots.makeplots (   arch,
  sample,
  build,
  vals,
  nC,
  text 
)

Definition at line 63 of file makeBenchmarkPlots.py.

References nano_mu_digi_cff.float, FastTimerService_cff.range, and run().

Referenced by run().

63 def makeplots(arch,sample,build,vals,nC,text):
64  # position in logs
65  if build == 'BH' : pos = 8
66  elif build == 'STD' : pos = 11
67  elif build == 'CE' : pos = 14
68  elif build == 'FV' : pos = 17
69  else :
70  print build,'is not a valid test! Exiting...'
71  sys.exit(0)
72 
73  # time
74  print arch,sample,build,text
75 
76  # define tgraphs vs absolute time and speedup
77  g_time = ROOT.TGraphErrors(len(vals)-1)
78  g_speedup = ROOT.TGraphErrors(len(vals)-1)
79 
80  # make separate plot for intrinsics measurement
81  if text is 'VU' :
82  g_time_int = ROOT.TGraphErrors(1)
83  g_speedup_int = ROOT.TGraphErrors(1)
84 
85  point = 0
86  for val in vals :
87  if val is '16int': xval = 16.0
88  elif val is '8int' : xval = 8.0
89  else : xval = float(val)
90 
91  # array of time values
92  yvals = array.array('d');
93 
94  # always skip the first event
95  firstFound = False
96 
97  # open the correct log file, store times into temp file
98  if text is 'VU' : os.system('grep Matriplex log_'+arch+'_'+sample+'_'+build+'_NVU'+val+'_NTH'+nC +'.txt >& log_'+arch+'_'+sample+'_'+build+'_'+text+'.txt')
99  elif text is 'TH' : os.system('grep Matriplex log_'+arch+'_'+sample+'_'+build+'_NVU'+nC +'_NTH'+val+'.txt >& log_'+arch+'_'+sample+'_'+build+'_'+text+'.txt')
100  else :
101  print 'VU or TH are the only options for extra text! Exiting...'
102  exit
103 
104  # open temp file, store event times into yvals
105  with open('log_'+arch+'_'+sample+'_'+build+'_'+text+'.txt') as f :
106  for line in f :
107  if 'Matriplex' not in line : continue
108  if 'Total' in line : continue
109  if not firstFound :
110  firstFound = True
111  continue
112  lsplit = line.split()
113  yvals.append(float(lsplit[pos]))
114 
115  # Compute mean and uncertainty on mean from yvals
116  sum = 0.;
117  for yval in range(0,len(yvals)):
118  sum = sum + yvals[yval]
119  if len(yvals) > 0 :
120  mean = sum/len(yvals)
121  else :
122  mean = 0
123  emean = 0.;
124  for yval in range(0,len(yvals)):
125  emean = emean + ((yvals[yval] - mean) * (yvals[yval] - mean))
126  if len(yvals) > 1 :
127  emean = math.sqrt(emean / (len(yvals) - 1))
128  emean = emean/math.sqrt(len(yvals))
129  else :
130  emean = 0
131 
132  # Printout value for good measure
133  print val,mean,'+/-',emean
134 
135  # store intrinsics val into separate plot
136  if 'int' not in val :
137  g_time.SetPoint(point,xval,mean)
138  g_time.SetPointError(point,0,emean)
139  point = point+1
140  else :
141  g_time_int.SetPoint(0,xval,mean)
142  g_time_int.SetPointError(0,0,emean)
143 
144  # always write out the standard plot
145  g_time.Write('g_'+build+'_'+text+'_time')
146 
147  # write out separate intrinsics plot
148  if text is 'VU' :
149  g_time_int.Write('g_'+build+'_'+text+'_time_int')
150 
151  # Speedup calculation
152  xval0 = array.array('d',[0])
153  yval0 = array.array('d',[0])
154  yerr0 = array.array('d',[0])
155 
156  # Get first point to divide by
157  g_time.GetPoint(0,xval0,yval0)
158  yerr0.append(g_time.GetErrorY(0))
159 
160  point = 0
161  for val in vals :
162  # set up inputs
163  xval = array.array('d',[0])
164  yval = array.array('d',[0])
165  yerr = array.array('d',[0])
166 
167  # get standard plots from standard plot
168  if 'int' not in val :
169  g_time.GetPoint(point,xval,yval)
170  yerr.append(g_time.GetErrorY(point))
171  else :
172  g_time_int.GetPoint(0,xval,yval)
173  yerr.append(g_time_int.GetErrorY(0))
174 
175  speedup = 0.
176  espeedup = 0.
177  if yval[0] > 0. and yval0[0] > 0. :
178  speedup = yval0[0]/yval[0]
179  espeedup = speedup * math.sqrt(math.pow(yerr0[0]/yval0[0],2) + math.pow(yerr[0]/yval[0],2))
180 
181  # store in the correct plot
182  if 'int' not in val :
183  g_speedup.SetPoint(point,xval[0],speedup)
184  g_speedup.SetPointError(point,0,espeedup)
185  point = point+1
186  else :
187  g_speedup_int.SetPoint(0,xval[0],speedup)
188  g_speedup_int.SetPointError(0,0,espeedup)
189 
190  # always write out the standard plot
191  g_speedup.Write('g_'+build+'_'+text+'_speedup')
192 
193  # write out separate intrinsics plot
194  if text is 'VU' :
195  g_speedup_int.Write('g_'+build+'_'+text+'_speedup_int')
196 
197  # all done
198  return
199 
def makeplots(arch, sample, build, vals, nC, text)

◆ run()

def makeBenchmarkPlots.run ( )

Definition at line 8 of file makeBenchmarkPlots.py.

References makeplots().

Referenced by makeplots().

8 def run():
9  # command line input
10  arch = sys.argv[1] # SNB, KNL, SKL-SP
11  sample = sys.argv[2]
12  build = sys.argv[3] # BH, STD, CE, FV
13  isVU = sys.argv[4] # 'true' or 'false': if no argument passed, will not do VU plots
14  isTH = sys.argv[5] # 'true' or 'false': if no argument passed, will not do TH plots
15 
16  # reopen file for writing
17  g = ROOT.TFile('benchmark_'+arch+'_'+sample+'.root','update')
18 
19  # Vectorization data points
20  vuvals = ['1','2','4','8']
21  nth = '1'
22 
23  if arch == 'KNL' or arch == 'SKL-SP' or arch == 'LNX-G' or arch == 'LNX-S':
24  vuvals.append('16')
25  vuvals.append('16int')
26  elif arch == 'SNB' :
27  vuvals.append('8int')
28  else :
29  print arch,'is not a valid architecture! Exiting...'
30  sys.exit(0)
31 
32  # call the make plots function
33  if isVU == 'true' :
34  makeplots(arch,sample,build,vuvals,nth,'VU')
35 
36  # Parallelization datapoints
37  if arch == 'KNL' :
38  nvu = '16int'
39  thvals = ['1','2','4','8','16','32','64','96','128','160','192','224','256']
40  elif arch == 'SNB' :
41  nvu = '8int'
42  thvals = ['1','2','4','6','8','12','16','20','24']
43  elif arch == 'SKL-SP' :
44  nvu = '16int'
45  thvals = ['1','2','4','8','16','32','48','64']
46  elif arch == 'LNX-G' :
47  nvu = '16int'
48  thvals = ['1','2','4','8','16','32','48','64']
49  elif arch == 'LNX-S' :
50  nvu = '16int'
51  thvals = ['1','2','4','8','16','32','48','64']
52  else :
53  print arch,'is not a valid architecture! Exiting...'
54  sys.exit(0)
55 
56  # call the make plots function
57  if isTH == 'true' :
58  makeplots(arch,sample,build,thvals,nvu,'TH')
59 
60  g.Write()
61  g.Close()
62 
def makeplots(arch, sample, build, vals, nC, text)