blob: af5e671c3b17b9262e8e0ca6fdc57f70518dee51 [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:
Christophe Favergeon0dcf9a12020-05-27 15:55:27 +0200343 bars={'cols':columns,'cores':cores,'data':[]}
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200344 for row in dataForFunc.itertuples():
345 row=list(row)
346 if type(row[0]) is int:
347 row=[row[0]] + row[1:]
348 else:
349 row=list(row[0]) + row[1:]
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200350 if field=="MAXREGCOEF":
351 row=[("%.3f" % x) for x in row]
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200352 dataTable.addRow(row)
Christophe Favergeon0dcf9a12020-05-27 15:55:27 +0200353 bars['data'].append(row)
354 return(bars)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200355 else:
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200356 if field=="MAXREGCOEF":
357 dataForFunc=[("%.3f" % x) for x in dataForFunc]
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200358 dataTable.addRow(dataForFunc)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200359 return(list(zip(cores,dataForFunc)))
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200360
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200361def formatColumnName(c):
362 return("".join(joinit(c,":")))
363
364def getCoresForHistory(benchTable,compilerid,typeid,testid,runid):
365 vals=(compilerid,typeid,testid,runid)
366 result=c.execute(coresForHistory % benchTable,vals).fetchall()
367 ids=[(x[0],x[1]) for x in list(result)]
368 return(ids)
369
370def getCompilerForHistory(benchTable,coreid,typeid,testid,runid):
371 vals=(coreid,typeid,testid,runid)
372 result=c.execute(compilersForHistory % benchTable,vals).fetchall()
373 ids=[(x[0],x[1],x[2]) for x in list(result)]
374 return(ids)
375
376def getHistory(desc,testid,indexCols):
377 benchName,sectionID,typeid,runid = desc
378
379 #print(benchName)
380 #print(sectionID)
381 #print(typeid)
382 #print(testid)
383 columns = diff(indexCols,['name'])
384 #print(columns)
385 if args.byc:
386 coreid=sectionID
387 compilerids=getCompilerForHistory(benchName,coreid,typeid,testid,runid)
388 series={}
389 for compilerid,compilername,version in compilerids:
390 result=getColNamesAndHistory(benchName,compilerid,coreid,typeid,testid)
391 #print("%s:%s" % (compilername,version))
392 maxpos = result[0].index('MAX')
393 lrunid = result[0].index('runid')
394 r=[[int(x[lrunid]),int(x[maxpos])] for x in result[1:][0]]
395 series[corename]=r
396 hist=History(series,runid)
397 return(hist)
398 else:
399 compilerid=sectionID
400 coreids = getCoresForHistory(benchName,compilerid,typeid,testid,runid)
401 series={}
402 for coreid,corename in coreids:
403 result=getColNamesAndHistory(benchName,compilerid,coreid,typeid,testid)
404 #print(corename)
405 maxpos = result[0].index('MAX')
406 corepos = result[0].index('core')
407 lrunid = result[0].index('runid')
408 r=[[int(x[lrunid]),int(x[maxpos])] for x in result[1:][0]]
409 series[corename]=r
410 hist=History(series,runid)
411 return(hist)
412
413def formatTableBy(desc,byname,section,typeSection,testNames,cols,vals):
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200414 if vals.size != 0:
415 ref=pd.DataFrame(vals,columns=cols)
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200416 toSort=["name"]
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200417
418 for param in PARAMS:
419 if param in ref.columns:
420 ref[param]=pd.to_numeric(ref[param])
421 toSort.append(param)
422 if args.r:
423 # Regression table
424 ref['MAX']=pd.to_numeric(ref['MAX'])
425 ref['MAXREGCOEF']=pd.to_numeric(ref['MAXREGCOEF'])
426
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200427 indexCols=diff(cols,byname + ['Regression','MAXREGCOEF','MAX'] + section)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200428 valList = ['Regression']
429 else:
430 ref['CYCLES']=pd.to_numeric(ref['CYCLES'])
431
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200432 indexCols=diff(cols,byname + ['CYCLES'] + section)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200433 valList = ['CYCLES']
434
435
436
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200437 for testid,name in testNames:
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200438 if args.r:
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200439 testSection = Section(name)
440 typeSection.addSection(testSection)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200441
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200442 maxCyclesSection = Section("Max cycles")
443 testSection.addSection(maxCyclesSection)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200444 theCycles=regressionTableFor(byname,name,maxCyclesSection,ref,toSort,indexCols,'MAX')
Christophe Favergeon0dcf9a12020-05-27 15:55:27 +0200445 if type(theCycles) is dict:
446 nbParams=len(theCycles['cols'])
447 for bar in theCycles['data']:
448 params=bar[0:nbParams]
449 values=bar[nbParams:]
450 title=[("%s=%s" % x) for x in list(zip(theCycles['cols'],params))]
451 title="".join(joinit(title," "))
452 sec=Section(title)
453 maxCyclesSection.addSection(sec)
454 values=list(zip(theCycles['cores'],values))
455 barChart=BarChart(values)
456 sec.addContent(barChart)
457 else:
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200458 #print(theCycles)
Christophe Favergeon0dcf9a12020-05-27 15:55:27 +0200459 sec=Section("Graph")
460 maxCyclesSection.addSection(sec)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200461 barChart=BarChart(theCycles)
Christophe Favergeon0dcf9a12020-05-27 15:55:27 +0200462 sec.addContent(barChart)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200463
464 #history=getHistory(desc,testid,indexCols)
465 #testSection.addContent(history)
466
467 regressionSection = Section("Regression")
468 testSection.addSection(regressionSection)
469 regressionTableFor(byname,name,regressionSection,ref,toSort,indexCols,'Regression')
470
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200471
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200472 maxRegCoefSection = Section("Max Reg Coef")
473 testSection.addSection(maxRegCoefSection)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200474 regressionTableFor(byname,name,maxRegCoefSection,ref,toSort,indexCols,'MAXREGCOEF')
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200475
476 else:
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200477 data=ref.pivot_table(index=indexCols, columns=byname,
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200478 values=valList, aggfunc='first')
479
480 data=data.sort_values(toSort)
481
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200482 #print(list(data.columns))
483 columnsID = [formatColumnName(c[1:]) for c in list(data.columns)]
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200484 columns = diff(indexCols,['name'])
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200485
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200486 testSection = Section(name)
487 typeSection.addSection(testSection)
488
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200489 dataTable=Table(columns,columnsID)
490 testSection.addContent(dataTable)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200491
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200492 dataForFunc=data.loc[name]
493 if type(dataForFunc) is pd.DataFrame:
494 for row in dataForFunc.itertuples():
495 row=list(row)
496 if type(row[0]) is int:
497 row=[row[0]] + row[1:]
498 else:
499 row=list(row[0]) + row[1:]
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200500 dataTable.addRow(row)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200501 else:
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200502 dataTable.addRow(dataForFunc)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200503
504# Add a report for each table
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200505def addReportFor(document,runid,benchName):
Christophe Favergeone15894e2020-05-14 07:25:53 +0200506 nbElems = getNbElemsInBenchCmd(benchName)
507 if nbElems > 0:
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200508 categoryName = getCategoryName(benchName,runid)
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200509 benchSection = Section(categoryName)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200510 document.addSection(benchSection)
Christophe Favergeone15894e2020-05-14 07:25:53 +0200511 print("Process %s\n" % benchName)
Christophe Favergeone15894e2020-05-14 07:25:53 +0200512 allTypes = getExistingTypes(benchName)
513 # Add report for each type
514 for aTypeID in allTypes:
515 nbElems = getNbElemsInBenchAndTypeCmd(benchName,aTypeID)
516 if nbElems > 0:
517 typeName = getTypeName(aTypeID)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200518 typeSection = Section(typeName)
519 benchSection.addSection(typeSection)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200520 if args.byc:
521 ## Add report for each core
522 allCores = getExistingCores(benchName,aTypeID)
523 for core in allCores:
524 #print(core)
525 nbElems = getNbElemsInBenchAndTypeAndCoreCmd(benchName,core,aTypeID)
526 # Print test results for table, type, compiler
527 if nbElems > 0:
528 coreName=getCoreDesc(core)
529 coreSection = Section("%s" % coreName)
530 typeSection.addSection(coreSection)
531 cols,vals=getColNamesAndDataForCore(benchName,core,aTypeID)
532 desc=(benchName,core,aTypeID,runid)
533 names=getTestNamesForCore(benchName,core,aTypeID)
534 formatTableBy(desc,['compiler','version'],['core'],coreSection,names,cols,vals)
535 else:
536 ## Add report for each compiler
537 allCompilers = getExistingCompiler(benchName,aTypeID)
538 for compiler in allCompilers:
539 #print(compiler)
540 nbElems = getNbElemsInBenchAndTypeAndCompilerCmd(benchName,compiler,aTypeID)
541 # Print test results for table, type, compiler
542 if nbElems > 0:
543 compilerName,version=getCompilerDesc(compiler)
544 compilerSection = Section("%s (%s)" % (compilerName,version))
545 typeSection.addSection(compilerSection)
546 cols,vals=getColNamesAndDataForCompiler(benchName,compiler,aTypeID)
547 desc=(benchName,compiler,aTypeID,runid)
548 names=getTestNamesForCompiler(benchName,compiler,aTypeID)
549 formatTableBy(desc,['core'],['version','compiler'],compilerSection,names,cols,vals)
550
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200551
552
553
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200554toc=[Hierarchy("BasicMathsBenchmarks"),
555Hierarchy("ComplexMathsBenchmarks"),
556Hierarchy("FastMath"),
557Hierarchy("Filters",
558 [Hierarchy("FIR"),
559 Hierarchy("BIQUAD"),
560 Hierarchy("DECIM"),
561 Hierarchy("MISC")]),
562
563Hierarchy("Support Functions",
564 [Hierarchy("Support"),
565 Hierarchy("SupportBar")]),
566
567Hierarchy("Matrix Operations" ,
568 [Hierarchy("Binary"),
569 Hierarchy("Unary")]),
570Hierarchy("Transform"),
571
572]
573
574processed=[]
575
576def createDoc(document,sections,benchtables):
577 global processed
578 for s in sections:
579 if s.name in benchtables:
580 addReportFor(document,runid,s.name)
581 processed.append(s.name)
582 else:
583 section=Section(s.name)
584 document.addSection(section)
585 createDoc(section,s.sections,benchtables)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200586
587try:
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200588 benchtables=getBenchTables()
Christophe Favergeone15894e2020-05-14 07:25:53 +0200589 theDate = getrunIDDate(runid)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200590 document = Document(runid,theDate)
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200591 createDoc(document,toc,benchtables)
592 misc=Section("Miscellaneous")
593 document.addSection(misc)
594 remaining=diff(benchtables,processed)
595 for bench in remaining:
596 addReportFor(misc,runid,bench)
597
598 #for bench in benchtables:
599 # addReportFor(document,bench)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200600 with open(args.o,"w") as output:
601 if args.t=="md":
602 document.accept(Markdown(output))
603 if args.t=="html":
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200604 document.accept(HTML(output,args.r))
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200605
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200606finally:
607 c.close()
608
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200609
610
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200611