CMS 3D CMS Logo

makeMEIFBenchmarkPlots.py
Go to the documentation of this file.
1 import os.path, glob, sys
2 import ROOT
3 import array
4 import math
5 
6 # N.B.: Consult ./xeon_scripts/benchmark-cmssw-ttbar-fulldet-build.sh for info on nTHs, nVUs, and text file names
7 
8 arch = sys.argv[1] # SNB, KNL, SKL-SP
9 sample = sys.argv[2]
10 build = sys.argv[3] # CE, FV
11 
12 g = ROOT.TFile('benchmarkMEIF_'+arch+'_'+sample+'_'+build+'.root','recreate')
13 
14 # Parallelization datapoints
15 if arch == 'KNL' :
16  nvu = '16int'
17  thvals = ['1','2','4','8','16','32','64','96','128','160','192','224','256']
18  evvals = ['1','2','4','8','16','32','64','128']
19 elif arch == 'SNB' :
20  nvu = '8int'
21  thvals = ['1','2','4','6','8','12','16','20','24']
22  evvals = ['1','2','4','8','12']
23 elif arch == 'SKL-SP' :
24  nvu = '16int'
25  thvals = ['1','2','4','8','16','32','48','64']
26  evvals = ['1','2','4','8','16','32','64']
27 elif arch == 'LNX-G' :
28  nvu = '16int'
29  thvals = ['1','2','4','8','16','32','48','64']
30  evvals = ['1','2','4','8','16','32','64']
31 elif arch == 'LNX-S' :
32  nvu = '16int'
33  thvals = ['1','2','4','8','16','32','48','64']
34  evvals = ['1','2','4','8','16','32','64']
35 else :
36  print(arch,"is not a valid architecture! Exiting...")
37  sys.exit(0)
38 
39 # extra text label
40 text = 'MEIF'
41 
42 # text for grepping
43 grepnEV = '=== TOTAL for'
44 grepTime = 'Total event loop time'
45 
46 # needed for speedups
47 xval0 = array.array('d',[0])
48 yval0 = array.array('d',[0])
49 
50 # time
51 for evval in evvals :
52  print(arch,sample,build,"nEV:",evval)
53 
54  # define event float
55  ev = float(evval)
56 
57  # define tgraphs vs absolute time and speedup
58  g_time = ROOT.TGraph()
59  g_speedup = ROOT.TGraph()
60 
61  point = 0
62  for thval in thvals :
63  xval = float(thval)
64  if ev > xval: continue;
65 
66  # extracted time
67  yval = float(0)
68  nev = float(1)
69 
70  # open log file, grep for relevant lines
71  with open('log_'+arch+'_'+sample+'_'+build+'_NVU'+nvu+'_NTH'+thval+'_NEV'+evval+'.txt') as f :
72  for line in f :
73  if grepnEV in line :
74  lsplit = line.split()
75  nev = float(lsplit[3])
76  elif grepTime in line :
77  lsplit = line.split()
78  yval = float(lsplit[4])
79 
80  yval /= nev
81 
82  # Printout value for good measure
83  print(xval,yval)
84 
85  # store val
86  g_time.SetPoint(point,xval,yval)
87  point = point+1
88 
89  # write out the plot
90  g_time.Write('g_'+build+'_'+text+'_nEV'+evval+'_time')
91 
92  # needed for speedup calculation
93  if evval is '1' :
94  g_time.GetPoint(0,xval0,yval0)
95 
96  # speedup plots
97  point = 0
98  for thval in thvals :
99  xval = float(thval)
100  if ev > xval: continue;
101 
102  # set up inputs
103  xval = array.array('d',[0])
104  yval = array.array('d',[0])
105 
106  # get point from time
107  g_time.GetPoint(point,xval,yval)
108 
109  speedup = 0.
110  if yval[0] > 0. :
111  speedup = yval0[0]/yval[0]
112 
113  # store in speedup plot
114  g_speedup.SetPoint(point,xval[0],speedup)
115  point = point+1
116 
117  # always write out speedup
118  g_speedup.Write('g_'+build+'_'+text+'_nEV'+evval+'_speedup')
119 
120 g.Write()
121 g.Close()
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
Definition: Utilities.cc:47