CMS 3D CMS Logo

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

Functions

def makeplots
 
def run
 

Function Documentation

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

Definition at line 63 of file makeBenchmarkPlots.py.

References sistrip::SpyUtilities.range(), and run().

Referenced by run().

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

Definition at line 8 of file makeBenchmarkPlots.py.

References makeplots().

Referenced by makeplots().

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