blob: b3f72985ccade5c077f92a18780b3c7c538bf2b8 [file] [log] [blame]
Christophe Favergeon8cb37302020-05-13 13:06:58 +02001import argparse
2import sqlite3
3import re
4import pandas as pd
5import numpy as np
Christophe Favergeoned0eab82020-05-18 08:43:38 +02006from TestScripts.doc.Structure import *
7from TestScripts.doc.Format import *
Christophe Favergeonc3f455c2020-05-14 09:24:07 +02008
Christophe Favergeonc3f455c2020-05-14 09:24:07 +02009
Christophe Favergeon670b1672020-05-28 12:47:58 +020010runidCMD = "runid = ?"
Christophe Favergeonc3f455c2020-05-14 09:24:07 +020011
Christophe Favergeon8cb37302020-05-13 13:06:58 +020012# Command to get last runid
13lastID="""SELECT runid FROM RUN ORDER BY runid DESC LIMIT 1
14"""
15
Christophe Favergeone15894e2020-05-14 07:25:53 +020016# Command to get last runid and date
17lastIDAndDate="""SELECT date FROM RUN WHERE runid=?
18"""
19
Christophe Favergeonfe27d872020-07-31 07:20:18 +020020# Command to get last runid
21runIDDetails="""SELECT distinct core FROM %s
22INNER JOIN CORE USING(coreid)
23WHERE %s
24"""
25
Christophe Favergeon0e0449a2020-07-28 09:44:14 +020026def joinit(iterable, delimiter):
27 # Intersperse a delimiter between element of a list
28 it = iter(iterable)
29 yield next(it)
30 for x in it:
31 yield delimiter
32 yield x
33
34
Christophe Favergeon8cb37302020-05-13 13:06:58 +020035def getLastRunID():
36 r=c.execute(lastID)
37 return(int(r.fetchone()[0]))
38
Christophe Favergeone15894e2020-05-14 07:25:53 +020039def getrunIDDate(forID):
40 r=c.execute(lastIDAndDate,(forID,))
41 return(r.fetchone()[0])
Christophe Favergeon8cb37302020-05-13 13:06:58 +020042
Christophe Favergeonfe27d872020-07-31 07:20:18 +020043
44
Christophe Favergeon8cb37302020-05-13 13:06:58 +020045runid = 1
46
47parser = argparse.ArgumentParser(description='Generate summary benchmarks')
48
Christophe Favergeonfeb73932020-05-20 14:48:06 +020049parser.add_argument('-b', nargs='?',type = str, default="bench.db", help="Database")
Christophe Favergeon8cb37302020-05-13 13:06:58 +020050parser.add_argument('-o', nargs='?',type = str, default="full.md", help="Full summary")
51parser.add_argument('-r', action='store_true', help="Regression database")
Christophe Favergeonfe27d872020-07-31 07:20:18 +020052parser.add_argument('-t', nargs='?',type = str, default="md", help="type md or html")
53parser.add_argument('-byc', action='store_true', help="Result oganized by Compiler")
Christophe Favergeon670b1672020-05-28 12:47:58 +020054parser.add_argument('-g', action='store_true', help="Include graphs in regression report")
Christophe Favergeon8cb37302020-05-13 13:06:58 +020055
Christophe Favergeonfe27d872020-07-31 07:20:18 +020056parser.add_argument('-details', action='store_true', help="Details about runids")
57parser.add_argument('-lastid', action='store_true', help="Get last ID")
58
Christophe Favergeon8cb37302020-05-13 13:06:58 +020059# For runid or runid range
Christophe Favergeon4fa1e232020-05-15 12:28:17 +020060parser.add_argument('others', nargs=argparse.REMAINDER,help="Run ID")
Christophe Favergeon8cb37302020-05-13 13:06:58 +020061
62args = parser.parse_args()
63
64c = sqlite3.connect(args.b)
65
66if args.others:
Christophe Favergeon670b1672020-05-28 12:47:58 +020067 if len(args.others) == 1:
Christophe Favergeon0e0449a2020-07-28 09:44:14 +020068 if re.search(r'[,]',args.others[0]):
69 runidval=tuple([int(x) for x in args.others[0].split(",")])
70 runidCMD=["runid == ?" for x in runidval]
71 runidCMD = "".join(joinit(runidCMD," OR "))
72 runidCMD = "(" + runidCMD + ")"
73 else:
74 runid=int(args.others[0])
75 runidval = (runid,)
Christophe Favergeon670b1672020-05-28 12:47:58 +020076 else:
77 runidCMD = "runid >= ? AND runid <= ?"
78 runid=int(args.others[1])
79 runidLOW=int(args.others[0])
80 runidval = (runidLOW,runid)
Christophe Favergeon8cb37302020-05-13 13:06:58 +020081else:
82 runid=getLastRunID()
Christophe Favergeon670b1672020-05-28 12:47:58 +020083 print("Last run ID = %d\n" % runid)
84 runidval=(runid,)
Christophe Favergeon8cb37302020-05-13 13:06:58 +020085
Christophe Favergeonfe27d872020-07-31 07:20:18 +020086
Christophe Favergeon8cb37302020-05-13 13:06:58 +020087# We extract data only from data tables
88# Those tables below are used for descriptions
Christophe Favergeon4fa1e232020-05-15 12:28:17 +020089REMOVETABLES=['TESTNAME','TESTDATE','RUN','CORE', 'PLATFORM', 'COMPILERKIND', 'COMPILER', 'TYPE', 'CATEGORY', 'CONFIG']
Christophe Favergeon8cb37302020-05-13 13:06:58 +020090
91# This is assuming the database is generated by the regression script
92# So platform is the same for all benchmarks.
93# Category and type is coming from the test name in the yaml
94# So no need to add this information here
95# Name is removed here because it is added at the beginning
Christophe Favergeon4fa1e232020-05-15 12:28:17 +020096REMOVECOLUMNS=['runid','name','type','platform','category','coredef','OPTIMIZED','HARDFP','FASTMATH','NEON','HELIUM','UNROLL','ROUNDING','DATE','compilerkindid','date','categoryid', 'ID', 'platformid', 'coreid', 'compilerid', 'typeid']
Christophe Favergeon8cb37302020-05-13 13:06:58 +020097
Christophe Favergeonfeb73932020-05-20 14:48:06 +020098REMOVECOLUMNSFORHISTORY=['Regression','MAXREGCOEF','name','type','platform','category','coredef','OPTIMIZED','HARDFP','FASTMATH','NEON','HELIUM','UNROLL','ROUNDING','DATE','compilerkindid','date','categoryid', 'ID', 'platformid', 'coreid', 'compilerid', 'typeid']
99
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200100# Get existing benchmark tables
101def getBenchTables():
102 r=c.execute("SELECT name FROM sqlite_master WHERE type='table'")
103 benchtables=[]
104 for table in r:
105 if not table[0] in REMOVETABLES:
106 benchtables.append(table[0])
107 return(benchtables)
108
109# get existing types in a table
110def getExistingTypes(benchTable):
Christophe Favergeone15894e2020-05-14 07:25:53 +0200111 r=c.execute("select distinct typeid from %s order by typeid desc" % benchTable).fetchall()
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200112 result=[x[0] for x in r]
113 return(result)
114
Christophe Favergeonfe27d872020-07-31 07:20:18 +0200115def getrunIDDetails():
116 tables=getBenchTables()
117 r=[]
118 for table in tables:
119 r += [x[0] for x in c.execute(runIDDetails % (table,runidCMD),runidval).fetchall()]
120 r=list(set(r))
121 print(r)
122
123if args.lastid:
124 quit()
125
126if args.details:
127 getrunIDDetails()
128 quit()
129
130
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200131# Get compilers from specific type and table
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200132allCompilers="""select distinct compilerid from %s WHERE typeid=?"""
133
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200134# Get compilers from specific type and table
135allCores="""select distinct coreid from %s WHERE typeid=?"""
136
137
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200138compilerDesc="""select compiler,version from COMPILER
139 INNER JOIN COMPILERKIND USING(compilerkindid) WHERE compilerid=?"""
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200140
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200141coreDesc="""select core from CORE WHERE coreid=?"""
142
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200143# Get existing compiler in a table for a specific type
144# (In case report is structured by types)
145def getExistingCompiler(benchTable,typeid):
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200146 r=c.execute(allCompilers % benchTable,(typeid,)).fetchall()
147 return([x[0] for x in r])
148
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200149def getExistingCores(benchTable,typeid):
150 r=c.execute(allCores % benchTable,(typeid,)).fetchall()
151 return([x[0] for x in r])
152
153
154
155def getCoreDesc(compilerid):
156 r=c.execute(coreDesc,(compilerid,)).fetchone()
157 return(r)
158
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200159def getCompilerDesc(compilerid):
160 r=c.execute(compilerDesc,(compilerid,)).fetchone()
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200161 return(r)
162
163# Get type name from type id
164def getTypeName(typeid):
165 r=c.execute("select type from TYPE where typeid=?",(typeid,)).fetchone()
166 return(r[0])
167
168# Diff of 2 lists
169def diff(first, second):
170 second = set(second)
171 return [item for item in first if item not in second]
172
173
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200174# Command to get data for specific core
175# and type
176historyCmd="""select %s from %s
177 INNER JOIN CATEGORY USING(categoryid)
178 INNER JOIN PLATFORM USING(platformid)
179 INNER JOIN CORE USING(coreid)
180 INNER JOIN COMPILER USING(compilerid)
181 INNER JOIN COMPILERKIND USING(compilerkindid)
182 INNER JOIN TYPE USING(typeid)
183 INNER JOIN TESTNAME USING(testnameid)
184 WHERE compilerid=? AND coreid=? AND typeid = ? AND ID = ? AND runid > (? - 10)
185 """
186
187compilersForHistory="""select distinct compilerid,compiler,version from %s
188 INNER JOIN COMPILER USING(compilerid)
189 INNER JOIN COMPILERKIND USING(compilerkindid)
190 WHERE coreid=? AND typeid = ? AND ID = ? AND runid > (? - 10)
191 """
192
193# Command to get data for specific core
194# and type
195benchCmdForCore="""select %s from %s
196 INNER JOIN CATEGORY USING(categoryid)
197 INNER JOIN PLATFORM USING(platformid)
198 INNER JOIN CORE USING(coreid)
199 INNER JOIN COMPILER USING(compilerid)
200 INNER JOIN COMPILERKIND USING(compilerkindid)
201 INNER JOIN TYPE USING(typeid)
202 INNER JOIN TESTNAME USING(testnameid)
Christophe Favergeon670b1672020-05-28 12:47:58 +0200203 WHERE coreid=? AND typeid = ? AND %s
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200204 """
205
206coresForHistory="""select distinct coreid,core from %s
207 INNER JOIN CORE USING(coreid)
208 WHERE compilerid=? AND typeid = ? AND ID = ? AND runid > (? - 10)
209 """
210
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200211# Command to get data for specific compiler
212# and type
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200213benchCmdForCompiler="""select %s from %s
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200214 INNER JOIN CATEGORY USING(categoryid)
215 INNER JOIN PLATFORM USING(platformid)
216 INNER JOIN CORE USING(coreid)
217 INNER JOIN COMPILER USING(compilerid)
218 INNER JOIN COMPILERKIND USING(compilerkindid)
219 INNER JOIN TYPE USING(typeid)
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200220 INNER JOIN TESTNAME USING(testnameid)
Christophe Favergeon670b1672020-05-28 12:47:58 +0200221 WHERE compilerid=? AND typeid = ? AND %s
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200222 """
223
224# Command to get test names for specific compiler
225# and type
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200226benchNamesForCore="""select distinct ID,name from %s
227 INNER JOIN COMPILER USING(compilerid)
228 INNER JOIN COMPILERKIND USING(compilerkindid)
229 INNER JOIN TYPE USING(typeid)
230 INNER JOIN TESTNAME USING(testnameid)
Christophe Favergeon670b1672020-05-28 12:47:58 +0200231 WHERE coreid=? AND typeid = ? AND %s
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200232 """
233# Command to get test names for specific compiler
234# and type
235benchNamesForCompiler="""select distinct ID,name from %s
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200236 INNER JOIN COMPILER USING(compilerid)
237 INNER JOIN COMPILERKIND USING(compilerkindid)
238 INNER JOIN TYPE USING(typeid)
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200239 INNER JOIN TESTNAME USING(testnameid)
Christophe Favergeon670b1672020-05-28 12:47:58 +0200240 WHERE compilerid=? AND typeid = ? AND %s
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200241 """
242
243# Command to get columns for specific table
244benchCmdColumns="""select * from %s
245 INNER JOIN CATEGORY USING(categoryid)
246 INNER JOIN PLATFORM USING(platformid)
247 INNER JOIN CORE USING(coreid)
248 INNER JOIN COMPILER USING(compilerid)
249 INNER JOIN COMPILERKIND USING(compilerkindid)
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200250 INNER JOIN TESTNAME USING(testnameid)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200251 INNER JOIN TYPE USING(typeid)
252 """
253
254def joinit(iterable, delimiter):
255 it = iter(iterable)
256 yield next(it)
257 for x in it:
258 yield delimiter
259 yield x
260
261# Is not a column name finishing by id
262# (often primary key for thetable)
263def isNotIDColumn(col):
264 if re.match(r'^.*id$',col):
265 return(False)
266 else:
267 return(True)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200268
269# Get test names
270# for specific typeid and core (for the data)
271def getTestNamesForCore(benchTable,core,typeid):
Christophe Favergeon670b1672020-05-28 12:47:58 +0200272 vals=(core,typeid) + runidval
273 result=c.execute(benchNamesForCore % (benchTable,runidCMD),vals).fetchall()
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200274 names=[(x[0],x[1]) for x in list(result)]
275 return(names)
276
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200277# Get test names
278# for specific typeid and compiler (for the data)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200279def getTestNamesForCompiler(benchTable,comp,typeid):
Christophe Favergeon670b1672020-05-28 12:47:58 +0200280 vals=(comp,typeid) + runidval
281 result=c.execute(benchNamesForCompiler % (benchTable,runidCMD),vals).fetchall()
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200282 names=[(x[0],x[1]) for x in list(result)]
283 return(names)
284
285# Command to get data for specific core
286# and type
287nbElemsInBenchAndTypeAndCoreCmd="""select count(*) from %s
Christophe Favergeon670b1672020-05-28 12:47:58 +0200288 WHERE coreid=? AND typeid = ? AND %s
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200289 """
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200290
Christophe Favergeone15894e2020-05-14 07:25:53 +0200291# Command to get data for specific compiler
292# and type
293nbElemsInBenchAndTypeAndCompilerCmd="""select count(*) from %s
Christophe Favergeon670b1672020-05-28 12:47:58 +0200294 WHERE compilerid=? AND typeid = ? AND %s
Christophe Favergeone15894e2020-05-14 07:25:53 +0200295 """
296
297nbElemsInBenchAndTypeCmd="""select count(*) from %s
Christophe Favergeon670b1672020-05-28 12:47:58 +0200298 WHERE typeid = ? AND %s
Christophe Favergeone15894e2020-05-14 07:25:53 +0200299 """
300
301nbElemsInBenchCmd="""select count(*) from %s
Christophe Favergeon670b1672020-05-28 12:47:58 +0200302 WHERE %s
Christophe Favergeone15894e2020-05-14 07:25:53 +0200303 """
304
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200305categoryName="""select distinct category from %s
306 INNER JOIN CATEGORY USING(categoryid)
Christophe Favergeon670b1672020-05-28 12:47:58 +0200307 WHERE %s
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200308 """
309
310def getCategoryName(benchTable,runid):
Christophe Favergeon670b1672020-05-28 12:47:58 +0200311 result=c.execute(categoryName % (benchTable,runidCMD),runidval).fetchone()
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200312 return(result[0])
313
Christophe Favergeon4f750702020-05-13 15:56:15 +0200314# Get nb elems in a table
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200315def getNbElemsInBenchAndTypeAndCoreCmd(benchTable,coreid,typeid):
Christophe Favergeon670b1672020-05-28 12:47:58 +0200316 vals=(coreid,typeid) + runidval
317 result=c.execute(nbElemsInBenchAndTypeAndCoreCmd % (benchTable,runidCMD),vals).fetchone()
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200318 return(result[0])
319
320# Get nb elems in a table
Christophe Favergeone15894e2020-05-14 07:25:53 +0200321def getNbElemsInBenchAndTypeAndCompilerCmd(benchTable,comp,typeid):
Christophe Favergeon670b1672020-05-28 12:47:58 +0200322 vals=(comp,typeid) + runidval
323 result=c.execute(nbElemsInBenchAndTypeAndCompilerCmd % (benchTable,runidCMD),vals).fetchone()
Christophe Favergeone15894e2020-05-14 07:25:53 +0200324 return(result[0])
325
326def getNbElemsInBenchAndTypeCmd(benchTable,typeid):
Christophe Favergeon670b1672020-05-28 12:47:58 +0200327 vals=(typeid,) + runidval
328 result=c.execute(nbElemsInBenchAndTypeCmd % (benchTable,runidCMD),vals).fetchone()
Christophe Favergeone15894e2020-05-14 07:25:53 +0200329 return(result[0])
330
331def getNbElemsInBenchCmd(benchTable):
Christophe Favergeon670b1672020-05-28 12:47:58 +0200332 result=c.execute(nbElemsInBenchCmd % (benchTable,runidCMD),runidval).fetchone()
Christophe Favergeon4f750702020-05-13 15:56:15 +0200333 return(result[0])
334
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200335# Get names of columns and data for a table
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200336# for specific typeid and coreid (for the data)
337def getColNamesAndHistory(benchTable,compiler,core,typeid,testid):
338 cursor=c.cursor()
339 result=cursor.execute(benchCmdColumns % (benchTable))
340 cols= [member[0] for member in cursor.description]
341 keepCols = ['name','runid'] + [c for c in diff(cols , REMOVECOLUMNSFORHISTORY) if isNotIDColumn(c)]
342 keepColsStr = "".join(joinit(keepCols,","))
343 vals=(compiler,core,typeid,testid,runid)
344 result=cursor.execute(historyCmd % (keepColsStr,benchTable),vals)
345 vals =np.array([list(x) for x in list(result)])
346 return(keepCols,vals)
347
348# Get names of columns and data for a table
349# for specific typeid and coreid (for the data)
350def getColNamesAndDataForCore(benchTable,core,typeid):
351 cursor=c.cursor()
352 result=cursor.execute(benchCmdColumns % (benchTable))
353 cols= [member[0] for member in cursor.description]
354 keepCols = ['name'] + [c for c in diff(cols , REMOVECOLUMNS) if isNotIDColumn(c)]
355 keepColsStr = "".join(joinit(keepCols,","))
Christophe Favergeon670b1672020-05-28 12:47:58 +0200356 vals=(core,typeid) + runidval
357 result=cursor.execute(benchCmdForCore % (keepColsStr,benchTable,runidCMD),vals)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200358 vals =np.array([list(x) for x in list(result)])
359 return(keepCols,vals)
360
361
362# Get names of columns and data for a table
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200363# for specific typeid and compiler (for the data)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200364def getColNamesAndDataForCompiler(benchTable,comp,typeid):
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200365 cursor=c.cursor()
366 result=cursor.execute(benchCmdColumns % (benchTable))
367 cols= [member[0] for member in cursor.description]
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200368 keepCols = ['name'] + [c for c in diff(cols , REMOVECOLUMNS) if isNotIDColumn(c)]
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200369 keepColsStr = "".join(joinit(keepCols,","))
Christophe Favergeon670b1672020-05-28 12:47:58 +0200370 vals=(comp,typeid) + runidval
371 result=cursor.execute(benchCmdForCompiler % (keepColsStr,benchTable,runidCMD),vals)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200372 vals =np.array([list(x) for x in list(result)])
373 return(keepCols,vals)
374
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200375
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200376
377PARAMS=["NB","NumTaps", "NBA", "NBB", "Factor", "NumStages","VECDIM","NBR","NBC","NBI","IFFT", "BITREV"]
378
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200379def regressionTableFor(byname,name,section,ref,toSort,indexCols,field):
380 data=ref.pivot_table(index=indexCols, columns=byname,
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200381 values=[field], aggfunc='first')
382
383 data=data.sort_values(toSort)
384
385 cores = [c[1] for c in list(data.columns)]
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200386 columns = diff(indexCols,['name'])
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200387
Christophe Favergeon34d313a2020-05-14 15:09:41 +0200388 dataTable=Table(columns,cores)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200389 section.addContent(dataTable)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200390
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200391 dataForFunc=data.loc[name]
392 if type(dataForFunc) is pd.DataFrame:
Christophe Favergeon0dcf9a12020-05-27 15:55:27 +0200393 bars={'cols':columns,'cores':cores,'data':[]}
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200394 for row in dataForFunc.itertuples():
395 row=list(row)
396 if type(row[0]) is int:
397 row=[row[0]] + row[1:]
398 else:
399 row=list(row[0]) + row[1:]
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200400 if field=="MAXREGCOEF":
Christophe Favergeon670b1672020-05-28 12:47:58 +0200401 newrow = row
402 newrow[len(columns):] = [("%.3f" % x) for x in row[len(columns):]]
403 row=newrow
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200404 dataTable.addRow(row)
Christophe Favergeon0dcf9a12020-05-27 15:55:27 +0200405 bars['data'].append(row)
406 return(bars)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200407 else:
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200408 if field=="MAXREGCOEF":
409 dataForFunc=[("%.3f" % x) for x in dataForFunc]
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200410 dataTable.addRow(dataForFunc)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200411 return(list(zip(cores,dataForFunc)))
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200412
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200413def formatColumnName(c):
414 return("".join(joinit(c,":")))
415
416def getCoresForHistory(benchTable,compilerid,typeid,testid,runid):
417 vals=(compilerid,typeid,testid,runid)
418 result=c.execute(coresForHistory % benchTable,vals).fetchall()
419 ids=[(x[0],x[1]) for x in list(result)]
420 return(ids)
421
422def getCompilerForHistory(benchTable,coreid,typeid,testid,runid):
423 vals=(coreid,typeid,testid,runid)
424 result=c.execute(compilersForHistory % benchTable,vals).fetchall()
425 ids=[(x[0],x[1],x[2]) for x in list(result)]
426 return(ids)
427
428def getHistory(desc,testid,indexCols):
429 benchName,sectionID,typeid,runid = desc
430
431 #print(benchName)
432 #print(sectionID)
433 #print(typeid)
434 #print(testid)
435 columns = diff(indexCols,['name'])
436 #print(columns)
437 if args.byc:
438 coreid=sectionID
439 compilerids=getCompilerForHistory(benchName,coreid,typeid,testid,runid)
440 series={}
441 for compilerid,compilername,version in compilerids:
442 result=getColNamesAndHistory(benchName,compilerid,coreid,typeid,testid)
443 #print("%s:%s" % (compilername,version))
444 maxpos = result[0].index('MAX')
445 lrunid = result[0].index('runid')
446 r=[[int(x[lrunid]),int(x[maxpos])] for x in result[1:][0]]
447 series[corename]=r
448 hist=History(series,runid)
449 return(hist)
450 else:
451 compilerid=sectionID
452 coreids = getCoresForHistory(benchName,compilerid,typeid,testid,runid)
453 series={}
454 for coreid,corename in coreids:
455 result=getColNamesAndHistory(benchName,compilerid,coreid,typeid,testid)
456 #print(corename)
457 maxpos = result[0].index('MAX')
458 corepos = result[0].index('core')
459 lrunid = result[0].index('runid')
460 r=[[int(x[lrunid]),int(x[maxpos])] for x in result[1:][0]]
461 series[corename]=r
462 hist=History(series,runid)
463 return(hist)
464
465def formatTableBy(desc,byname,section,typeSection,testNames,cols,vals):
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200466 if vals.size != 0:
467 ref=pd.DataFrame(vals,columns=cols)
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200468 toSort=["name"]
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200469
470 for param in PARAMS:
471 if param in ref.columns:
472 ref[param]=pd.to_numeric(ref[param])
473 toSort.append(param)
474 if args.r:
475 # Regression table
476 ref['MAX']=pd.to_numeric(ref['MAX'])
477 ref['MAXREGCOEF']=pd.to_numeric(ref['MAXREGCOEF'])
478
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200479 indexCols=diff(cols,byname + ['Regression','MAXREGCOEF','MAX'] + section)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200480 valList = ['Regression']
481 else:
482 ref['CYCLES']=pd.to_numeric(ref['CYCLES'])
483
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200484 indexCols=diff(cols,byname + ['CYCLES'] + section)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200485 valList = ['CYCLES']
486
487
488
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200489 for testid,name in testNames:
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200490 if args.r:
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200491 testSection = Section(name)
492 typeSection.addSection(testSection)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200493
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200494 maxCyclesSection = Section("Max cycles")
495 testSection.addSection(maxCyclesSection)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200496 theCycles=regressionTableFor(byname,name,maxCyclesSection,ref,toSort,indexCols,'MAX')
Christophe Favergeon670b1672020-05-28 12:47:58 +0200497 if args.g:
498 if type(theCycles) is dict:
499 nbParams=len(theCycles['cols'])
500 for bar in theCycles['data']:
501 params=bar[0:nbParams]
502 values=bar[nbParams:]
503 title=[("%s=%s" % x) for x in list(zip(theCycles['cols'],params))]
504 title="".join(joinit(title," "))
505 sec=Section(title)
506 maxCyclesSection.addSection(sec)
507 values=list(zip(theCycles['cores'],values))
508 barChart=BarChart(values)
509 sec.addContent(barChart)
510 else:
511 #print(theCycles)
512 sec=Section("Graph")
Christophe Favergeon0dcf9a12020-05-27 15:55:27 +0200513 maxCyclesSection.addSection(sec)
Christophe Favergeon670b1672020-05-28 12:47:58 +0200514 barChart=BarChart(theCycles)
Christophe Favergeon0dcf9a12020-05-27 15:55:27 +0200515 sec.addContent(barChart)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200516
Christophe Favergeon670b1672020-05-28 12:47:58 +0200517 #history=getHistory(desc,testid,indexCols)
518 #testSection.addContent(history)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200519
520 regressionSection = Section("Regression")
521 testSection.addSection(regressionSection)
522 regressionTableFor(byname,name,regressionSection,ref,toSort,indexCols,'Regression')
523
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200524
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200525 maxRegCoefSection = Section("Max Reg Coef")
526 testSection.addSection(maxRegCoefSection)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200527 regressionTableFor(byname,name,maxRegCoefSection,ref,toSort,indexCols,'MAXREGCOEF')
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200528
529 else:
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200530 data=ref.pivot_table(index=indexCols, columns=byname,
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200531 values=valList, aggfunc='first')
532
533 data=data.sort_values(toSort)
534
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200535 #print(list(data.columns))
536 columnsID = [formatColumnName(c[1:]) for c in list(data.columns)]
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200537 columns = diff(indexCols,['name'])
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200538
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200539 testSection = Section(name)
540 typeSection.addSection(testSection)
541
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200542 dataTable=Table(columns,columnsID)
543 testSection.addContent(dataTable)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200544
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200545 dataForFunc=data.loc[name]
546 if type(dataForFunc) is pd.DataFrame:
547 for row in dataForFunc.itertuples():
548 row=list(row)
549 if type(row[0]) is int:
550 row=[row[0]] + row[1:]
551 else:
552 row=list(row[0]) + row[1:]
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200553 dataTable.addRow(row)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200554 else:
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200555 dataTable.addRow(dataForFunc)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200556
557# Add a report for each table
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200558def addReportFor(document,runid,benchName):
Christophe Favergeone15894e2020-05-14 07:25:53 +0200559 nbElems = getNbElemsInBenchCmd(benchName)
560 if nbElems > 0:
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200561 categoryName = getCategoryName(benchName,runid)
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200562 benchSection = Section(categoryName)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200563 document.addSection(benchSection)
Christophe Favergeone15894e2020-05-14 07:25:53 +0200564 print("Process %s\n" % benchName)
Christophe Favergeone15894e2020-05-14 07:25:53 +0200565 allTypes = getExistingTypes(benchName)
566 # Add report for each type
567 for aTypeID in allTypes:
568 nbElems = getNbElemsInBenchAndTypeCmd(benchName,aTypeID)
569 if nbElems > 0:
570 typeName = getTypeName(aTypeID)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200571 typeSection = Section(typeName)
572 benchSection.addSection(typeSection)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200573 if args.byc:
574 ## Add report for each core
575 allCores = getExistingCores(benchName,aTypeID)
576 for core in allCores:
577 #print(core)
578 nbElems = getNbElemsInBenchAndTypeAndCoreCmd(benchName,core,aTypeID)
579 # Print test results for table, type, compiler
580 if nbElems > 0:
581 coreName=getCoreDesc(core)
582 coreSection = Section("%s" % coreName)
583 typeSection.addSection(coreSection)
584 cols,vals=getColNamesAndDataForCore(benchName,core,aTypeID)
585 desc=(benchName,core,aTypeID,runid)
586 names=getTestNamesForCore(benchName,core,aTypeID)
587 formatTableBy(desc,['compiler','version'],['core'],coreSection,names,cols,vals)
588 else:
589 ## Add report for each compiler
590 allCompilers = getExistingCompiler(benchName,aTypeID)
591 for compiler in allCompilers:
592 #print(compiler)
593 nbElems = getNbElemsInBenchAndTypeAndCompilerCmd(benchName,compiler,aTypeID)
594 # Print test results for table, type, compiler
595 if nbElems > 0:
596 compilerName,version=getCompilerDesc(compiler)
597 compilerSection = Section("%s (%s)" % (compilerName,version))
598 typeSection.addSection(compilerSection)
599 cols,vals=getColNamesAndDataForCompiler(benchName,compiler,aTypeID)
600 desc=(benchName,compiler,aTypeID,runid)
601 names=getTestNamesForCompiler(benchName,compiler,aTypeID)
602 formatTableBy(desc,['core'],['version','compiler'],compilerSection,names,cols,vals)
603
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200604
605
606
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200607toc=[Hierarchy("BasicMathsBenchmarks"),
608Hierarchy("ComplexMathsBenchmarks"),
609Hierarchy("FastMath"),
610Hierarchy("Filters",
611 [Hierarchy("FIR"),
612 Hierarchy("BIQUAD"),
613 Hierarchy("DECIM"),
614 Hierarchy("MISC")]),
615
616Hierarchy("Support Functions",
617 [Hierarchy("Support"),
618 Hierarchy("SupportBar")]),
619
620Hierarchy("Matrix Operations" ,
621 [Hierarchy("Binary"),
622 Hierarchy("Unary")]),
623Hierarchy("Transform"),
624
625]
626
627processed=[]
628
629def createDoc(document,sections,benchtables):
630 global processed
631 for s in sections:
632 if s.name in benchtables:
633 addReportFor(document,runid,s.name)
634 processed.append(s.name)
635 else:
636 section=Section(s.name)
637 document.addSection(section)
638 createDoc(section,s.sections,benchtables)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200639
640try:
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200641 benchtables=getBenchTables()
Christophe Favergeone15894e2020-05-14 07:25:53 +0200642 theDate = getrunIDDate(runid)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200643 document = Document(runid,theDate)
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200644 createDoc(document,toc,benchtables)
645 misc=Section("Miscellaneous")
646 document.addSection(misc)
647 remaining=diff(benchtables,processed)
648 for bench in remaining:
649 addReportFor(misc,runid,bench)
650
651 #for bench in benchtables:
652 # addReportFor(document,bench)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200653 with open(args.o,"w") as output:
654 if args.t=="md":
655 document.accept(Markdown(output))
656 if args.t=="html":
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200657 document.accept(HTML(output,args.r))
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200658
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200659finally:
660 c.close()
661
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200662
663
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200664