File indexing completed on 2023-03-17 11:22:37
0001 import os.path, glob, sys
0002 import ROOT
0003 import array
0004 import math
0005
0006
0007
0008 def run():
0009
0010 arch = sys.argv[1]
0011 sample = sys.argv[2]
0012 build = sys.argv[3]
0013 isVU = sys.argv[4]
0014 isTH = sys.argv[5]
0015
0016
0017 g = ROOT.TFile('benchmark_'+arch+'_'+sample+'.root','update')
0018
0019
0020 vuvals = ['1','2','4','8']
0021 nth = '1'
0022
0023 if arch == 'KNL' or arch == 'SKL-SP' or arch == 'LNX-G' or arch == 'LNX-S':
0024 vuvals.append('16')
0025 vuvals.append('16int')
0026 elif arch == 'SNB' :
0027 vuvals.append('8int')
0028 else :
0029 print arch,'is not a valid architecture! Exiting...'
0030 sys.exit(0)
0031
0032
0033 if isVU == 'true' :
0034 makeplots(arch,sample,build,vuvals,nth,'VU')
0035
0036
0037 if arch == 'KNL' :
0038 nvu = '16int'
0039 thvals = ['1','2','4','8','16','32','64','96','128','160','192','224','256']
0040 elif arch == 'SNB' :
0041 nvu = '8int'
0042 thvals = ['1','2','4','6','8','12','16','20','24']
0043 elif arch == 'SKL-SP' :
0044 nvu = '16int'
0045 thvals = ['1','2','4','8','16','32','48','64']
0046 elif arch == 'LNX-G' :
0047 nvu = '16int'
0048 thvals = ['1','2','4','8','16','32','48','64']
0049 elif arch == 'LNX-S' :
0050 nvu = '16int'
0051 thvals = ['1','2','4','8','16','32','48','64']
0052 else :
0053 print arch,'is not a valid architecture! Exiting...'
0054 sys.exit(0)
0055
0056
0057 if isTH == 'true' :
0058 makeplots(arch,sample,build,thvals,nvu,'TH')
0059
0060 g.Write()
0061 g.Close()
0062
0063 def makeplots(arch,sample,build,vals,nC,text):
0064
0065 if build == 'BH' : pos = 8
0066 elif build == 'STD' : pos = 11
0067 elif build == 'CE' : pos = 14
0068 elif build == 'FV' : pos = 17
0069 else :
0070 print build,'is not a valid test! Exiting...'
0071 sys.exit(0)
0072
0073
0074 print arch,sample,build,text
0075
0076
0077 g_time = ROOT.TGraphErrors(len(vals)-1)
0078 g_speedup = ROOT.TGraphErrors(len(vals)-1)
0079
0080
0081 if text is 'VU' :
0082 g_time_int = ROOT.TGraphErrors(1)
0083 g_speedup_int = ROOT.TGraphErrors(1)
0084
0085 point = 0
0086 for val in vals :
0087 if val is '16int': xval = 16.0
0088 elif val is '8int' : xval = 8.0
0089 else : xval = float(val)
0090
0091
0092 yvals = array.array('d');
0093
0094
0095 firstFound = False
0096
0097
0098 if text is 'VU' : os.system('grep Matriplex log_'+arch+'_'+sample+'_'+build+'_NVU'+val+'_NTH'+nC +'.txt >& log_'+arch+'_'+sample+'_'+build+'_'+text+'.txt')
0099 elif text is 'TH' : os.system('grep Matriplex log_'+arch+'_'+sample+'_'+build+'_NVU'+nC +'_NTH'+val+'.txt >& log_'+arch+'_'+sample+'_'+build+'_'+text+'.txt')
0100 else :
0101 print 'VU or TH are the only options for extra text! Exiting...'
0102 exit
0103
0104
0105 with open('log_'+arch+'_'+sample+'_'+build+'_'+text+'.txt') as f :
0106 for line in f :
0107 if 'Matriplex' not in line : continue
0108 if 'Total' in line : continue
0109 if not firstFound :
0110 firstFound = True
0111 continue
0112 lsplit = line.split()
0113 yvals.append(float(lsplit[pos]))
0114
0115
0116 sum = 0.;
0117 for yval in range(0,len(yvals)):
0118 sum = sum + yvals[yval]
0119 if len(yvals) > 0 :
0120 mean = sum/len(yvals)
0121 else :
0122 mean = 0
0123 emean = 0.;
0124 for yval in range(0,len(yvals)):
0125 emean = emean + ((yvals[yval] - mean) * (yvals[yval] - mean))
0126 if len(yvals) > 1 :
0127 emean = math.sqrt(emean / (len(yvals) - 1))
0128 emean = emean/math.sqrt(len(yvals))
0129 else :
0130 emean = 0
0131
0132
0133 print val,mean,'+/-',emean
0134
0135
0136 if 'int' not in val :
0137 g_time.SetPoint(point,xval,mean)
0138 g_time.SetPointError(point,0,emean)
0139 point = point+1
0140 else :
0141 g_time_int.SetPoint(0,xval,mean)
0142 g_time_int.SetPointError(0,0,emean)
0143
0144
0145 g_time.Write('g_'+build+'_'+text+'_time')
0146
0147
0148 if text is 'VU' :
0149 g_time_int.Write('g_'+build+'_'+text+'_time_int')
0150
0151
0152 xval0 = array.array('d',[0])
0153 yval0 = array.array('d',[0])
0154 yerr0 = array.array('d',[0])
0155
0156
0157 g_time.GetPoint(0,xval0,yval0)
0158 yerr0.append(g_time.GetErrorY(0))
0159
0160 point = 0
0161 for val in vals :
0162
0163 xval = array.array('d',[0])
0164 yval = array.array('d',[0])
0165 yerr = array.array('d',[0])
0166
0167
0168 if 'int' not in val :
0169 g_time.GetPoint(point,xval,yval)
0170 yerr.append(g_time.GetErrorY(point))
0171 else :
0172 g_time_int.GetPoint(0,xval,yval)
0173 yerr.append(g_time_int.GetErrorY(0))
0174
0175 speedup = 0.
0176 espeedup = 0.
0177 if yval[0] > 0. and yval0[0] > 0. :
0178 speedup = yval0[0]/yval[0]
0179 espeedup = speedup * math.sqrt(math.pow(yerr0[0]/yval0[0],2) + math.pow(yerr[0]/yval[0],2))
0180
0181
0182 if 'int' not in val :
0183 g_speedup.SetPoint(point,xval[0],speedup)
0184 g_speedup.SetPointError(point,0,espeedup)
0185 point = point+1
0186 else :
0187 g_speedup_int.SetPoint(0,xval[0],speedup)
0188 g_speedup_int.SetPointError(0,0,espeedup)
0189
0190
0191 g_speedup.Write('g_'+build+'_'+text+'_speedup')
0192
0193
0194 if text is 'VU' :
0195 g_speedup_int.Write('g_'+build+'_'+text+'_speedup_int')
0196
0197
0198 return
0199
0200 if __name__ == "__main__":
0201 run()