blob: 3b25756bdec4c1b1f541cf6da3817f0321b87ee9 [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
10
11
12
13
Christophe Favergeon8cb37302020-05-13 13:06:58 +020014# Command to get last runid
15lastID="""SELECT runid FROM RUN ORDER BY runid DESC LIMIT 1
16"""
17
Christophe Favergeone15894e2020-05-14 07:25:53 +020018# Command to get last runid and date
19lastIDAndDate="""SELECT date FROM RUN WHERE runid=?
20"""
21
Christophe Favergeon8cb37302020-05-13 13:06:58 +020022def getLastRunID():
23 r=c.execute(lastID)
24 return(int(r.fetchone()[0]))
25
Christophe Favergeone15894e2020-05-14 07:25:53 +020026def getrunIDDate(forID):
27 r=c.execute(lastIDAndDate,(forID,))
28 return(r.fetchone()[0])
Christophe Favergeon8cb37302020-05-13 13:06:58 +020029
30runid = 1
31
32parser = argparse.ArgumentParser(description='Generate summary benchmarks')
33
Christophe Favergeonfeb73932020-05-20 14:48:06 +020034parser.add_argument('-b', nargs='?',type = str, default="bench.db", help="Database")
Christophe Favergeon8cb37302020-05-13 13:06:58 +020035parser.add_argument('-o', nargs='?',type = str, default="full.md", help="Full summary")
36parser.add_argument('-r', action='store_true', help="Regression database")
Christophe Favergeonc3f455c2020-05-14 09:24:07 +020037parser.add_argument('-t', nargs='?',type = str, default="md", help="md,html")
Christophe Favergeonfeb73932020-05-20 14:48:06 +020038parser.add_argument('-byc', action='store_true', help="By Compiler")
Christophe Favergeon8cb37302020-05-13 13:06:58 +020039
40# For runid or runid range
Christophe Favergeon4fa1e232020-05-15 12:28:17 +020041parser.add_argument('others', nargs=argparse.REMAINDER,help="Run ID")
Christophe Favergeon8cb37302020-05-13 13:06:58 +020042
43args = parser.parse_args()
44
45c = sqlite3.connect(args.b)
46
47if args.others:
48 runid=int(args.others[0])
49else:
50 runid=getLastRunID()
51
52# We extract data only from data tables
53# Those tables below are used for descriptions
Christophe Favergeon4fa1e232020-05-15 12:28:17 +020054REMOVETABLES=['TESTNAME','TESTDATE','RUN','CORE', 'PLATFORM', 'COMPILERKIND', 'COMPILER', 'TYPE', 'CATEGORY', 'CONFIG']
Christophe Favergeon8cb37302020-05-13 13:06:58 +020055
56# This is assuming the database is generated by the regression script
57# So platform is the same for all benchmarks.
58# Category and type is coming from the test name in the yaml
59# So no need to add this information here
60# Name is removed here because it is added at the beginning
Christophe Favergeon4fa1e232020-05-15 12:28:17 +020061REMOVECOLUMNS=['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 +020062
Christophe Favergeonfeb73932020-05-20 14:48:06 +020063REMOVECOLUMNSFORHISTORY=['Regression','MAXREGCOEF','name','type','platform','category','coredef','OPTIMIZED','HARDFP','FASTMATH','NEON','HELIUM','UNROLL','ROUNDING','DATE','compilerkindid','date','categoryid', 'ID', 'platformid', 'coreid', 'compilerid', 'typeid']
64
Christophe Favergeon8cb37302020-05-13 13:06:58 +020065# Get existing benchmark tables
66def getBenchTables():
67 r=c.execute("SELECT name FROM sqlite_master WHERE type='table'")
68 benchtables=[]
69 for table in r:
70 if not table[0] in REMOVETABLES:
71 benchtables.append(table[0])
72 return(benchtables)
73
74# get existing types in a table
75def getExistingTypes(benchTable):
Christophe Favergeone15894e2020-05-14 07:25:53 +020076 r=c.execute("select distinct typeid from %s order by typeid desc" % benchTable).fetchall()
Christophe Favergeon8cb37302020-05-13 13:06:58 +020077 result=[x[0] for x in r]
78 return(result)
79
80# Get compilers from specific type and table
Christophe Favergeon4fa1e232020-05-15 12:28:17 +020081allCompilers="""select distinct compilerid from %s WHERE typeid=?"""
82
Christophe Favergeonfeb73932020-05-20 14:48:06 +020083# Get compilers from specific type and table
84allCores="""select distinct coreid from %s WHERE typeid=?"""
85
86
Christophe Favergeon4fa1e232020-05-15 12:28:17 +020087compilerDesc="""select compiler,version from COMPILER
88 INNER JOIN COMPILERKIND USING(compilerkindid) WHERE compilerid=?"""
Christophe Favergeon8cb37302020-05-13 13:06:58 +020089
Christophe Favergeonfeb73932020-05-20 14:48:06 +020090coreDesc="""select core from CORE WHERE coreid=?"""
91
Christophe Favergeon8cb37302020-05-13 13:06:58 +020092# Get existing compiler in a table for a specific type
93# (In case report is structured by types)
94def getExistingCompiler(benchTable,typeid):
Christophe Favergeon4fa1e232020-05-15 12:28:17 +020095 r=c.execute(allCompilers % benchTable,(typeid,)).fetchall()
96 return([x[0] for x in r])
97
Christophe Favergeonfeb73932020-05-20 14:48:06 +020098def getExistingCores(benchTable,typeid):
99 r=c.execute(allCores % benchTable,(typeid,)).fetchall()
100 return([x[0] for x in r])
101
102
103
104def getCoreDesc(compilerid):
105 r=c.execute(coreDesc,(compilerid,)).fetchone()
106 return(r)
107
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200108def getCompilerDesc(compilerid):
109 r=c.execute(compilerDesc,(compilerid,)).fetchone()
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200110 return(r)
111
112# Get type name from type id
113def getTypeName(typeid):
114 r=c.execute("select type from TYPE where typeid=?",(typeid,)).fetchone()
115 return(r[0])
116
117# Diff of 2 lists
118def diff(first, second):
119 second = set(second)
120 return [item for item in first if item not in second]
121
122
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200123# Command to get data for specific core
124# and type
125historyCmd="""select %s from %s
126 INNER JOIN CATEGORY USING(categoryid)
127 INNER JOIN PLATFORM USING(platformid)
128 INNER JOIN CORE USING(coreid)
129 INNER JOIN COMPILER USING(compilerid)
130 INNER JOIN COMPILERKIND USING(compilerkindid)
131 INNER JOIN TYPE USING(typeid)
132 INNER JOIN TESTNAME USING(testnameid)
133 WHERE compilerid=? AND coreid=? AND typeid = ? AND ID = ? AND runid > (? - 10)
134 """
135
136compilersForHistory="""select distinct compilerid,compiler,version from %s
137 INNER JOIN COMPILER USING(compilerid)
138 INNER JOIN COMPILERKIND USING(compilerkindid)
139 WHERE coreid=? AND typeid = ? AND ID = ? AND runid > (? - 10)
140 """
141
142# Command to get data for specific core
143# and type
144benchCmdForCore="""select %s from %s
145 INNER JOIN CATEGORY USING(categoryid)
146 INNER JOIN PLATFORM USING(platformid)
147 INNER JOIN CORE USING(coreid)
148 INNER JOIN COMPILER USING(compilerid)
149 INNER JOIN COMPILERKIND USING(compilerkindid)
150 INNER JOIN TYPE USING(typeid)
151 INNER JOIN TESTNAME USING(testnameid)
152 WHERE coreid=? AND typeid = ? AND runid = ?
153 """
154
155coresForHistory="""select distinct coreid,core from %s
156 INNER JOIN CORE USING(coreid)
157 WHERE compilerid=? AND typeid = ? AND ID = ? AND runid > (? - 10)
158 """
159
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200160# Command to get data for specific compiler
161# and type
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200162benchCmdForCompiler="""select %s from %s
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200163 INNER JOIN CATEGORY USING(categoryid)
164 INNER JOIN PLATFORM USING(platformid)
165 INNER JOIN CORE USING(coreid)
166 INNER JOIN COMPILER USING(compilerid)
167 INNER JOIN COMPILERKIND USING(compilerkindid)
168 INNER JOIN TYPE USING(typeid)
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200169 INNER JOIN TESTNAME USING(testnameid)
170 WHERE compilerid=? AND typeid = ? AND runid = ?
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200171 """
172
173# Command to get test names for specific compiler
174# and type
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200175benchNamesForCore="""select distinct ID,name from %s
176 INNER JOIN COMPILER USING(compilerid)
177 INNER JOIN COMPILERKIND USING(compilerkindid)
178 INNER JOIN TYPE USING(typeid)
179 INNER JOIN TESTNAME USING(testnameid)
180 WHERE coreid=? AND typeid = ? AND runid = ?
181 """
182# Command to get test names for specific compiler
183# and type
184benchNamesForCompiler="""select distinct ID,name from %s
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200185 INNER JOIN COMPILER USING(compilerid)
186 INNER JOIN COMPILERKIND USING(compilerkindid)
187 INNER JOIN TYPE USING(typeid)
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200188 INNER JOIN TESTNAME USING(testnameid)
189 WHERE compilerid=? AND typeid = ? AND runid = ?
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200190 """
191
192# Command to get columns for specific table
193benchCmdColumns="""select * from %s
194 INNER JOIN CATEGORY USING(categoryid)
195 INNER JOIN PLATFORM USING(platformid)
196 INNER JOIN CORE USING(coreid)
197 INNER JOIN COMPILER USING(compilerid)
198 INNER JOIN COMPILERKIND USING(compilerkindid)
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200199 INNER JOIN TESTNAME USING(testnameid)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200200 INNER JOIN TYPE USING(typeid)
201 """
202
203def joinit(iterable, delimiter):
204 it = iter(iterable)
205 yield next(it)
206 for x in it:
207 yield delimiter
208 yield x
209
210# Is not a column name finishing by id
211# (often primary key for thetable)
212def isNotIDColumn(col):
213 if re.match(r'^.*id$',col):
214 return(False)
215 else:
216 return(True)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200217
218# Get test names
219# for specific typeid and core (for the data)
220def getTestNamesForCore(benchTable,core,typeid):
221 vals=(core,typeid,runid)
222 result=c.execute(benchNamesForCore % benchTable,vals).fetchall()
223 names=[(x[0],x[1]) for x in list(result)]
224 return(names)
225
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200226# Get test names
227# for specific typeid and compiler (for the data)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200228def getTestNamesForCompiler(benchTable,comp,typeid):
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200229 vals=(comp,typeid,runid)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200230 result=c.execute(benchNamesForCompiler % benchTable,vals).fetchall()
231 names=[(x[0],x[1]) for x in list(result)]
232 return(names)
233
234# Command to get data for specific core
235# and type
236nbElemsInBenchAndTypeAndCoreCmd="""select count(*) from %s
237 WHERE coreid=? AND typeid = ? AND runid = ?
238 """
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200239
Christophe Favergeone15894e2020-05-14 07:25:53 +0200240# Command to get data for specific compiler
241# and type
242nbElemsInBenchAndTypeAndCompilerCmd="""select count(*) from %s
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200243 WHERE compilerid=? AND typeid = ? AND runid = ?
Christophe Favergeone15894e2020-05-14 07:25:53 +0200244 """
245
246nbElemsInBenchAndTypeCmd="""select count(*) from %s
Christophe Favergeone15894e2020-05-14 07:25:53 +0200247 WHERE typeid = ? AND runid = ?
248 """
249
250nbElemsInBenchCmd="""select count(*) from %s
Christophe Favergeone15894e2020-05-14 07:25:53 +0200251 WHERE runid = ?
252 """
253
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200254categoryName="""select distinct category from %s
255 INNER JOIN CATEGORY USING(categoryid)
256 WHERE runid = ?
257 """
258
259def getCategoryName(benchTable,runid):
260 result=c.execute(categoryName % benchTable,(runid,)).fetchone()
261 return(result[0])
262
Christophe Favergeon4f750702020-05-13 15:56:15 +0200263# Get nb elems in a table
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200264def getNbElemsInBenchAndTypeAndCoreCmd(benchTable,coreid,typeid):
265 vals=(coreid,typeid,runid)
266 result=c.execute(nbElemsInBenchAndTypeAndCoreCmd % benchTable,vals).fetchone()
267 return(result[0])
268
269# Get nb elems in a table
Christophe Favergeone15894e2020-05-14 07:25:53 +0200270def getNbElemsInBenchAndTypeAndCompilerCmd(benchTable,comp,typeid):
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200271 vals=(comp,typeid,runid)
Christophe Favergeone15894e2020-05-14 07:25:53 +0200272 result=c.execute(nbElemsInBenchAndTypeAndCompilerCmd % benchTable,vals).fetchone()
273 return(result[0])
274
275def getNbElemsInBenchAndTypeCmd(benchTable,typeid):
276 vals=(typeid,runid)
277 result=c.execute(nbElemsInBenchAndTypeCmd % benchTable,vals).fetchone()
278 return(result[0])
279
280def getNbElemsInBenchCmd(benchTable):
281 vals=(runid,)
282 result=c.execute(nbElemsInBenchCmd % benchTable,vals).fetchone()
Christophe Favergeon4f750702020-05-13 15:56:15 +0200283 return(result[0])
284
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200285# Get names of columns and data for a table
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200286# for specific typeid and coreid (for the data)
287def getColNamesAndHistory(benchTable,compiler,core,typeid,testid):
288 cursor=c.cursor()
289 result=cursor.execute(benchCmdColumns % (benchTable))
290 cols= [member[0] for member in cursor.description]
291 keepCols = ['name','runid'] + [c for c in diff(cols , REMOVECOLUMNSFORHISTORY) if isNotIDColumn(c)]
292 keepColsStr = "".join(joinit(keepCols,","))
293 vals=(compiler,core,typeid,testid,runid)
294 result=cursor.execute(historyCmd % (keepColsStr,benchTable),vals)
295 vals =np.array([list(x) for x in list(result)])
296 return(keepCols,vals)
297
298# Get names of columns and data for a table
299# for specific typeid and coreid (for the data)
300def getColNamesAndDataForCore(benchTable,core,typeid):
301 cursor=c.cursor()
302 result=cursor.execute(benchCmdColumns % (benchTable))
303 cols= [member[0] for member in cursor.description]
304 keepCols = ['name'] + [c for c in diff(cols , REMOVECOLUMNS) if isNotIDColumn(c)]
305 keepColsStr = "".join(joinit(keepCols,","))
306 vals=(core,typeid,runid)
307 result=cursor.execute(benchCmdForCore % (keepColsStr,benchTable),vals)
308 vals =np.array([list(x) for x in list(result)])
309 return(keepCols,vals)
310
311
312# Get names of columns and data for a table
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200313# for specific typeid and compiler (for the data)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200314def getColNamesAndDataForCompiler(benchTable,comp,typeid):
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200315 cursor=c.cursor()
316 result=cursor.execute(benchCmdColumns % (benchTable))
317 cols= [member[0] for member in cursor.description]
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200318 keepCols = ['name'] + [c for c in diff(cols , REMOVECOLUMNS) if isNotIDColumn(c)]
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200319 keepColsStr = "".join(joinit(keepCols,","))
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200320 vals=(comp,typeid,runid)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200321 result=cursor.execute(benchCmdForCompiler % (keepColsStr,benchTable),vals)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200322 vals =np.array([list(x) for x in list(result)])
323 return(keepCols,vals)
324
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200325
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200326
327PARAMS=["NB","NumTaps", "NBA", "NBB", "Factor", "NumStages","VECDIM","NBR","NBC","NBI","IFFT", "BITREV"]
328
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200329def regressionTableFor(byname,name,section,ref,toSort,indexCols,field):
330 data=ref.pivot_table(index=indexCols, columns=byname,
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200331 values=[field], aggfunc='first')
332
333 data=data.sort_values(toSort)
334
335 cores = [c[1] for c in list(data.columns)]
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200336 columns = diff(indexCols,['name'])
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200337
Christophe Favergeon34d313a2020-05-14 15:09:41 +0200338 dataTable=Table(columns,cores)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200339 section.addContent(dataTable)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200340
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200341 dataForFunc=data.loc[name]
342 if type(dataForFunc) is pd.DataFrame:
343 for row in dataForFunc.itertuples():
344 row=list(row)
345 if type(row[0]) is int:
346 row=[row[0]] + row[1:]
347 else:
348 row=list(row[0]) + row[1:]
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200349 if field=="MAXREGCOEF":
350 row=[("%.3f" % x) for x in row]
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200351 dataTable.addRow(row)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200352 return(None)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200353 else:
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200354 if field=="MAXREGCOEF":
355 dataForFunc=[("%.3f" % x) for x in dataForFunc]
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200356 dataTable.addRow(dataForFunc)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200357 return(list(zip(cores,dataForFunc)))
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200358
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200359def formatColumnName(c):
360 return("".join(joinit(c,":")))
361
362def getCoresForHistory(benchTable,compilerid,typeid,testid,runid):
363 vals=(compilerid,typeid,testid,runid)
364 result=c.execute(coresForHistory % benchTable,vals).fetchall()
365 ids=[(x[0],x[1]) for x in list(result)]
366 return(ids)
367
368def getCompilerForHistory(benchTable,coreid,typeid,testid,runid):
369 vals=(coreid,typeid,testid,runid)
370 result=c.execute(compilersForHistory % benchTable,vals).fetchall()
371 ids=[(x[0],x[1],x[2]) for x in list(result)]
372 return(ids)
373
374def getHistory(desc,testid,indexCols):
375 benchName,sectionID,typeid,runid = desc
376
377 #print(benchName)
378 #print(sectionID)
379 #print(typeid)
380 #print(testid)
381 columns = diff(indexCols,['name'])
382 #print(columns)
383 if args.byc:
384 coreid=sectionID
385 compilerids=getCompilerForHistory(benchName,coreid,typeid,testid,runid)
386 series={}
387 for compilerid,compilername,version in compilerids:
388 result=getColNamesAndHistory(benchName,compilerid,coreid,typeid,testid)
389 #print("%s:%s" % (compilername,version))
390 maxpos = result[0].index('MAX')
391 lrunid = result[0].index('runid')
392 r=[[int(x[lrunid]),int(x[maxpos])] for x in result[1:][0]]
393 series[corename]=r
394 hist=History(series,runid)
395 return(hist)
396 else:
397 compilerid=sectionID
398 coreids = getCoresForHistory(benchName,compilerid,typeid,testid,runid)
399 series={}
400 for coreid,corename in coreids:
401 result=getColNamesAndHistory(benchName,compilerid,coreid,typeid,testid)
402 #print(corename)
403 maxpos = result[0].index('MAX')
404 corepos = result[0].index('core')
405 lrunid = result[0].index('runid')
406 r=[[int(x[lrunid]),int(x[maxpos])] for x in result[1:][0]]
407 series[corename]=r
408 hist=History(series,runid)
409 return(hist)
410
411def formatTableBy(desc,byname,section,typeSection,testNames,cols,vals):
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200412 if vals.size != 0:
413 ref=pd.DataFrame(vals,columns=cols)
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200414 toSort=["name"]
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200415
416 for param in PARAMS:
417 if param in ref.columns:
418 ref[param]=pd.to_numeric(ref[param])
419 toSort.append(param)
420 if args.r:
421 # Regression table
422 ref['MAX']=pd.to_numeric(ref['MAX'])
423 ref['MAXREGCOEF']=pd.to_numeric(ref['MAXREGCOEF'])
424
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200425 indexCols=diff(cols,byname + ['Regression','MAXREGCOEF','MAX'] + section)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200426 valList = ['Regression']
427 else:
428 ref['CYCLES']=pd.to_numeric(ref['CYCLES'])
429
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200430 indexCols=diff(cols,byname + ['CYCLES'] + section)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200431 valList = ['CYCLES']
432
433
434
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200435 for testid,name in testNames:
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200436 if args.r:
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200437 testSection = Section(name)
438 typeSection.addSection(testSection)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200439
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200440 maxCyclesSection = Section("Max cycles")
441 testSection.addSection(maxCyclesSection)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200442 theCycles=regressionTableFor(byname,name,maxCyclesSection,ref,toSort,indexCols,'MAX')
443 if theCycles is not None:
444 #print(theCycles)
445 barChart=BarChart(theCycles)
446 maxCyclesSection.addContent(barChart)
447
448 #history=getHistory(desc,testid,indexCols)
449 #testSection.addContent(history)
450
451 regressionSection = Section("Regression")
452 testSection.addSection(regressionSection)
453 regressionTableFor(byname,name,regressionSection,ref,toSort,indexCols,'Regression')
454
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200455
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200456 maxRegCoefSection = Section("Max Reg Coef")
457 testSection.addSection(maxRegCoefSection)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200458 regressionTableFor(byname,name,maxRegCoefSection,ref,toSort,indexCols,'MAXREGCOEF')
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200459
460 else:
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200461 data=ref.pivot_table(index=indexCols, columns=byname,
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200462 values=valList, aggfunc='first')
463
464 data=data.sort_values(toSort)
465
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200466 #print(list(data.columns))
467 columnsID = [formatColumnName(c[1:]) for c in list(data.columns)]
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200468 columns = diff(indexCols,['name'])
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200469
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200470 testSection = Section(name)
471 typeSection.addSection(testSection)
472
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200473 dataTable=Table(columns,columnsID)
474 testSection.addContent(dataTable)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200475
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200476 dataForFunc=data.loc[name]
477 if type(dataForFunc) is pd.DataFrame:
478 for row in dataForFunc.itertuples():
479 row=list(row)
480 if type(row[0]) is int:
481 row=[row[0]] + row[1:]
482 else:
483 row=list(row[0]) + row[1:]
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200484 dataTable.addRow(row)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200485 else:
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200486 dataTable.addRow(dataForFunc)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200487
488# Add a report for each table
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200489def addReportFor(document,runid,benchName):
Christophe Favergeone15894e2020-05-14 07:25:53 +0200490 nbElems = getNbElemsInBenchCmd(benchName)
491 if nbElems > 0:
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200492 categoryName = getCategoryName(benchName,runid)
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200493 benchSection = Section(categoryName)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200494 document.addSection(benchSection)
Christophe Favergeone15894e2020-05-14 07:25:53 +0200495 print("Process %s\n" % benchName)
Christophe Favergeone15894e2020-05-14 07:25:53 +0200496 allTypes = getExistingTypes(benchName)
497 # Add report for each type
498 for aTypeID in allTypes:
499 nbElems = getNbElemsInBenchAndTypeCmd(benchName,aTypeID)
500 if nbElems > 0:
501 typeName = getTypeName(aTypeID)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200502 typeSection = Section(typeName)
503 benchSection.addSection(typeSection)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200504 if args.byc:
505 ## Add report for each core
506 allCores = getExistingCores(benchName,aTypeID)
507 for core in allCores:
508 #print(core)
509 nbElems = getNbElemsInBenchAndTypeAndCoreCmd(benchName,core,aTypeID)
510 # Print test results for table, type, compiler
511 if nbElems > 0:
512 coreName=getCoreDesc(core)
513 coreSection = Section("%s" % coreName)
514 typeSection.addSection(coreSection)
515 cols,vals=getColNamesAndDataForCore(benchName,core,aTypeID)
516 desc=(benchName,core,aTypeID,runid)
517 names=getTestNamesForCore(benchName,core,aTypeID)
518 formatTableBy(desc,['compiler','version'],['core'],coreSection,names,cols,vals)
519 else:
520 ## Add report for each compiler
521 allCompilers = getExistingCompiler(benchName,aTypeID)
522 for compiler in allCompilers:
523 #print(compiler)
524 nbElems = getNbElemsInBenchAndTypeAndCompilerCmd(benchName,compiler,aTypeID)
525 # Print test results for table, type, compiler
526 if nbElems > 0:
527 compilerName,version=getCompilerDesc(compiler)
528 compilerSection = Section("%s (%s)" % (compilerName,version))
529 typeSection.addSection(compilerSection)
530 cols,vals=getColNamesAndDataForCompiler(benchName,compiler,aTypeID)
531 desc=(benchName,compiler,aTypeID,runid)
532 names=getTestNamesForCompiler(benchName,compiler,aTypeID)
533 formatTableBy(desc,['core'],['version','compiler'],compilerSection,names,cols,vals)
534
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200535
536
537
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200538toc=[Hierarchy("BasicMathsBenchmarks"),
539Hierarchy("ComplexMathsBenchmarks"),
540Hierarchy("FastMath"),
541Hierarchy("Filters",
542 [Hierarchy("FIR"),
543 Hierarchy("BIQUAD"),
544 Hierarchy("DECIM"),
545 Hierarchy("MISC")]),
546
547Hierarchy("Support Functions",
548 [Hierarchy("Support"),
549 Hierarchy("SupportBar")]),
550
551Hierarchy("Matrix Operations" ,
552 [Hierarchy("Binary"),
553 Hierarchy("Unary")]),
554Hierarchy("Transform"),
555
556]
557
558processed=[]
559
560def createDoc(document,sections,benchtables):
561 global processed
562 for s in sections:
563 if s.name in benchtables:
564 addReportFor(document,runid,s.name)
565 processed.append(s.name)
566 else:
567 section=Section(s.name)
568 document.addSection(section)
569 createDoc(section,s.sections,benchtables)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200570
571try:
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200572 benchtables=getBenchTables()
Christophe Favergeone15894e2020-05-14 07:25:53 +0200573 theDate = getrunIDDate(runid)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200574 document = Document(runid,theDate)
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200575 createDoc(document,toc,benchtables)
576 misc=Section("Miscellaneous")
577 document.addSection(misc)
578 remaining=diff(benchtables,processed)
579 for bench in remaining:
580 addReportFor(misc,runid,bench)
581
582 #for bench in benchtables:
583 # addReportFor(document,bench)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200584 with open(args.o,"w") as output:
585 if args.t=="md":
586 document.accept(Markdown(output))
587 if args.t=="html":
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200588 document.accept(HTML(output,args.r))
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200589
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200590finally:
591 c.close()
592
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200593
594
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200595