blob: 2f0a47ec1e382ce41f222d8449c91309a5df8ec0 [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 Favergeon8cb37302020-05-13 13:06:58 +020020def getLastRunID():
21 r=c.execute(lastID)
22 return(int(r.fetchone()[0]))
23
Christophe Favergeone15894e2020-05-14 07:25:53 +020024def getrunIDDate(forID):
25 r=c.execute(lastIDAndDate,(forID,))
26 return(r.fetchone()[0])
Christophe Favergeon8cb37302020-05-13 13:06:58 +020027
28runid = 1
29
30parser = argparse.ArgumentParser(description='Generate summary benchmarks')
31
Christophe Favergeonfeb73932020-05-20 14:48:06 +020032parser.add_argument('-b', nargs='?',type = str, default="bench.db", help="Database")
Christophe Favergeon8cb37302020-05-13 13:06:58 +020033parser.add_argument('-o', nargs='?',type = str, default="full.md", help="Full summary")
34parser.add_argument('-r', action='store_true', help="Regression database")
Christophe Favergeonc3f455c2020-05-14 09:24:07 +020035parser.add_argument('-t', nargs='?',type = str, default="md", help="md,html")
Christophe Favergeonfeb73932020-05-20 14:48:06 +020036parser.add_argument('-byc', action='store_true', help="By Compiler")
Christophe Favergeon670b1672020-05-28 12:47:58 +020037parser.add_argument('-g', action='store_true', help="Include graphs in regression report")
Christophe Favergeon8cb37302020-05-13 13:06:58 +020038
39# For runid or runid range
Christophe Favergeon4fa1e232020-05-15 12:28:17 +020040parser.add_argument('others', nargs=argparse.REMAINDER,help="Run ID")
Christophe Favergeon8cb37302020-05-13 13:06:58 +020041
42args = parser.parse_args()
43
44c = sqlite3.connect(args.b)
45
46if args.others:
Christophe Favergeon670b1672020-05-28 12:47:58 +020047 if len(args.others) == 1:
48 runid=int(args.others[0])
49 runidval = (runid,)
50 else:
51 runidCMD = "runid >= ? AND runid <= ?"
52 runid=int(args.others[1])
53 runidLOW=int(args.others[0])
54 runidval = (runidLOW,runid)
Christophe Favergeon8cb37302020-05-13 13:06:58 +020055else:
56 runid=getLastRunID()
Christophe Favergeon670b1672020-05-28 12:47:58 +020057 print("Last run ID = %d\n" % runid)
58 runidval=(runid,)
Christophe Favergeon8cb37302020-05-13 13:06:58 +020059
60# We extract data only from data tables
61# Those tables below are used for descriptions
Christophe Favergeon4fa1e232020-05-15 12:28:17 +020062REMOVETABLES=['TESTNAME','TESTDATE','RUN','CORE', 'PLATFORM', 'COMPILERKIND', 'COMPILER', 'TYPE', 'CATEGORY', 'CONFIG']
Christophe Favergeon8cb37302020-05-13 13:06:58 +020063
64# This is assuming the database is generated by the regression script
65# So platform is the same for all benchmarks.
66# Category and type is coming from the test name in the yaml
67# So no need to add this information here
68# Name is removed here because it is added at the beginning
Christophe Favergeon4fa1e232020-05-15 12:28:17 +020069REMOVECOLUMNS=['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 +020070
Christophe Favergeonfeb73932020-05-20 14:48:06 +020071REMOVECOLUMNSFORHISTORY=['Regression','MAXREGCOEF','name','type','platform','category','coredef','OPTIMIZED','HARDFP','FASTMATH','NEON','HELIUM','UNROLL','ROUNDING','DATE','compilerkindid','date','categoryid', 'ID', 'platformid', 'coreid', 'compilerid', 'typeid']
72
Christophe Favergeon8cb37302020-05-13 13:06:58 +020073# Get existing benchmark tables
74def getBenchTables():
75 r=c.execute("SELECT name FROM sqlite_master WHERE type='table'")
76 benchtables=[]
77 for table in r:
78 if not table[0] in REMOVETABLES:
79 benchtables.append(table[0])
80 return(benchtables)
81
82# get existing types in a table
83def getExistingTypes(benchTable):
Christophe Favergeone15894e2020-05-14 07:25:53 +020084 r=c.execute("select distinct typeid from %s order by typeid desc" % benchTable).fetchall()
Christophe Favergeon8cb37302020-05-13 13:06:58 +020085 result=[x[0] for x in r]
86 return(result)
87
88# Get compilers from specific type and table
Christophe Favergeon4fa1e232020-05-15 12:28:17 +020089allCompilers="""select distinct compilerid from %s WHERE typeid=?"""
90
Christophe Favergeonfeb73932020-05-20 14:48:06 +020091# Get compilers from specific type and table
92allCores="""select distinct coreid from %s WHERE typeid=?"""
93
94
Christophe Favergeon4fa1e232020-05-15 12:28:17 +020095compilerDesc="""select compiler,version from COMPILER
96 INNER JOIN COMPILERKIND USING(compilerkindid) WHERE compilerid=?"""
Christophe Favergeon8cb37302020-05-13 13:06:58 +020097
Christophe Favergeonfeb73932020-05-20 14:48:06 +020098coreDesc="""select core from CORE WHERE coreid=?"""
99
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200100# Get existing compiler in a table for a specific type
101# (In case report is structured by types)
102def getExistingCompiler(benchTable,typeid):
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200103 r=c.execute(allCompilers % benchTable,(typeid,)).fetchall()
104 return([x[0] for x in r])
105
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200106def getExistingCores(benchTable,typeid):
107 r=c.execute(allCores % benchTable,(typeid,)).fetchall()
108 return([x[0] for x in r])
109
110
111
112def getCoreDesc(compilerid):
113 r=c.execute(coreDesc,(compilerid,)).fetchone()
114 return(r)
115
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200116def getCompilerDesc(compilerid):
117 r=c.execute(compilerDesc,(compilerid,)).fetchone()
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200118 return(r)
119
120# Get type name from type id
121def getTypeName(typeid):
122 r=c.execute("select type from TYPE where typeid=?",(typeid,)).fetchone()
123 return(r[0])
124
125# Diff of 2 lists
126def diff(first, second):
127 second = set(second)
128 return [item for item in first if item not in second]
129
130
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200131# Command to get data for specific core
132# and type
133historyCmd="""select %s from %s
134 INNER JOIN CATEGORY USING(categoryid)
135 INNER JOIN PLATFORM USING(platformid)
136 INNER JOIN CORE USING(coreid)
137 INNER JOIN COMPILER USING(compilerid)
138 INNER JOIN COMPILERKIND USING(compilerkindid)
139 INNER JOIN TYPE USING(typeid)
140 INNER JOIN TESTNAME USING(testnameid)
141 WHERE compilerid=? AND coreid=? AND typeid = ? AND ID = ? AND runid > (? - 10)
142 """
143
144compilersForHistory="""select distinct compilerid,compiler,version from %s
145 INNER JOIN COMPILER USING(compilerid)
146 INNER JOIN COMPILERKIND USING(compilerkindid)
147 WHERE coreid=? AND typeid = ? AND ID = ? AND runid > (? - 10)
148 """
149
150# Command to get data for specific core
151# and type
152benchCmdForCore="""select %s from %s
153 INNER JOIN CATEGORY USING(categoryid)
154 INNER JOIN PLATFORM USING(platformid)
155 INNER JOIN CORE USING(coreid)
156 INNER JOIN COMPILER USING(compilerid)
157 INNER JOIN COMPILERKIND USING(compilerkindid)
158 INNER JOIN TYPE USING(typeid)
159 INNER JOIN TESTNAME USING(testnameid)
Christophe Favergeon670b1672020-05-28 12:47:58 +0200160 WHERE coreid=? AND typeid = ? AND %s
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200161 """
162
163coresForHistory="""select distinct coreid,core from %s
164 INNER JOIN CORE USING(coreid)
165 WHERE compilerid=? AND typeid = ? AND ID = ? AND runid > (? - 10)
166 """
167
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200168# Command to get data for specific compiler
169# and type
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200170benchCmdForCompiler="""select %s from %s
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200171 INNER JOIN CATEGORY USING(categoryid)
172 INNER JOIN PLATFORM USING(platformid)
173 INNER JOIN CORE USING(coreid)
174 INNER JOIN COMPILER USING(compilerid)
175 INNER JOIN COMPILERKIND USING(compilerkindid)
176 INNER JOIN TYPE USING(typeid)
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200177 INNER JOIN TESTNAME USING(testnameid)
Christophe Favergeon670b1672020-05-28 12:47:58 +0200178 WHERE compilerid=? AND typeid = ? AND %s
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200179 """
180
181# Command to get test names for specific compiler
182# and type
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200183benchNamesForCore="""select distinct ID,name from %s
184 INNER JOIN COMPILER USING(compilerid)
185 INNER JOIN COMPILERKIND USING(compilerkindid)
186 INNER JOIN TYPE USING(typeid)
187 INNER JOIN TESTNAME USING(testnameid)
Christophe Favergeon670b1672020-05-28 12:47:58 +0200188 WHERE coreid=? AND typeid = ? AND %s
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200189 """
190# Command to get test names for specific compiler
191# and type
192benchNamesForCompiler="""select distinct ID,name from %s
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200193 INNER JOIN COMPILER USING(compilerid)
194 INNER JOIN COMPILERKIND USING(compilerkindid)
195 INNER JOIN TYPE USING(typeid)
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200196 INNER JOIN TESTNAME USING(testnameid)
Christophe Favergeon670b1672020-05-28 12:47:58 +0200197 WHERE compilerid=? AND typeid = ? AND %s
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200198 """
199
200# Command to get columns for specific table
201benchCmdColumns="""select * from %s
202 INNER JOIN CATEGORY USING(categoryid)
203 INNER JOIN PLATFORM USING(platformid)
204 INNER JOIN CORE USING(coreid)
205 INNER JOIN COMPILER USING(compilerid)
206 INNER JOIN COMPILERKIND USING(compilerkindid)
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200207 INNER JOIN TESTNAME USING(testnameid)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200208 INNER JOIN TYPE USING(typeid)
209 """
210
211def joinit(iterable, delimiter):
212 it = iter(iterable)
213 yield next(it)
214 for x in it:
215 yield delimiter
216 yield x
217
218# Is not a column name finishing by id
219# (often primary key for thetable)
220def isNotIDColumn(col):
221 if re.match(r'^.*id$',col):
222 return(False)
223 else:
224 return(True)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200225
226# Get test names
227# for specific typeid and core (for the data)
228def getTestNamesForCore(benchTable,core,typeid):
Christophe Favergeon670b1672020-05-28 12:47:58 +0200229 vals=(core,typeid) + runidval
230 result=c.execute(benchNamesForCore % (benchTable,runidCMD),vals).fetchall()
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200231 names=[(x[0],x[1]) for x in list(result)]
232 return(names)
233
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200234# Get test names
235# for specific typeid and compiler (for the data)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200236def getTestNamesForCompiler(benchTable,comp,typeid):
Christophe Favergeon670b1672020-05-28 12:47:58 +0200237 vals=(comp,typeid) + runidval
238 result=c.execute(benchNamesForCompiler % (benchTable,runidCMD),vals).fetchall()
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200239 names=[(x[0],x[1]) for x in list(result)]
240 return(names)
241
242# Command to get data for specific core
243# and type
244nbElemsInBenchAndTypeAndCoreCmd="""select count(*) from %s
Christophe Favergeon670b1672020-05-28 12:47:58 +0200245 WHERE coreid=? AND typeid = ? AND %s
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200246 """
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200247
Christophe Favergeone15894e2020-05-14 07:25:53 +0200248# Command to get data for specific compiler
249# and type
250nbElemsInBenchAndTypeAndCompilerCmd="""select count(*) from %s
Christophe Favergeon670b1672020-05-28 12:47:58 +0200251 WHERE compilerid=? AND typeid = ? AND %s
Christophe Favergeone15894e2020-05-14 07:25:53 +0200252 """
253
254nbElemsInBenchAndTypeCmd="""select count(*) from %s
Christophe Favergeon670b1672020-05-28 12:47:58 +0200255 WHERE typeid = ? AND %s
Christophe Favergeone15894e2020-05-14 07:25:53 +0200256 """
257
258nbElemsInBenchCmd="""select count(*) from %s
Christophe Favergeon670b1672020-05-28 12:47:58 +0200259 WHERE %s
Christophe Favergeone15894e2020-05-14 07:25:53 +0200260 """
261
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200262categoryName="""select distinct category from %s
263 INNER JOIN CATEGORY USING(categoryid)
Christophe Favergeon670b1672020-05-28 12:47:58 +0200264 WHERE %s
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200265 """
266
267def getCategoryName(benchTable,runid):
Christophe Favergeon670b1672020-05-28 12:47:58 +0200268 result=c.execute(categoryName % (benchTable,runidCMD),runidval).fetchone()
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200269 return(result[0])
270
Christophe Favergeon4f750702020-05-13 15:56:15 +0200271# Get nb elems in a table
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200272def getNbElemsInBenchAndTypeAndCoreCmd(benchTable,coreid,typeid):
Christophe Favergeon670b1672020-05-28 12:47:58 +0200273 vals=(coreid,typeid) + runidval
274 result=c.execute(nbElemsInBenchAndTypeAndCoreCmd % (benchTable,runidCMD),vals).fetchone()
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200275 return(result[0])
276
277# Get nb elems in a table
Christophe Favergeone15894e2020-05-14 07:25:53 +0200278def getNbElemsInBenchAndTypeAndCompilerCmd(benchTable,comp,typeid):
Christophe Favergeon670b1672020-05-28 12:47:58 +0200279 vals=(comp,typeid) + runidval
280 result=c.execute(nbElemsInBenchAndTypeAndCompilerCmd % (benchTable,runidCMD),vals).fetchone()
Christophe Favergeone15894e2020-05-14 07:25:53 +0200281 return(result[0])
282
283def getNbElemsInBenchAndTypeCmd(benchTable,typeid):
Christophe Favergeon670b1672020-05-28 12:47:58 +0200284 vals=(typeid,) + runidval
285 result=c.execute(nbElemsInBenchAndTypeCmd % (benchTable,runidCMD),vals).fetchone()
Christophe Favergeone15894e2020-05-14 07:25:53 +0200286 return(result[0])
287
288def getNbElemsInBenchCmd(benchTable):
Christophe Favergeon670b1672020-05-28 12:47:58 +0200289 result=c.execute(nbElemsInBenchCmd % (benchTable,runidCMD),runidval).fetchone()
Christophe Favergeon4f750702020-05-13 15:56:15 +0200290 return(result[0])
291
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200292# Get names of columns and data for a table
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200293# for specific typeid and coreid (for the data)
294def getColNamesAndHistory(benchTable,compiler,core,typeid,testid):
295 cursor=c.cursor()
296 result=cursor.execute(benchCmdColumns % (benchTable))
297 cols= [member[0] for member in cursor.description]
298 keepCols = ['name','runid'] + [c for c in diff(cols , REMOVECOLUMNSFORHISTORY) if isNotIDColumn(c)]
299 keepColsStr = "".join(joinit(keepCols,","))
300 vals=(compiler,core,typeid,testid,runid)
301 result=cursor.execute(historyCmd % (keepColsStr,benchTable),vals)
302 vals =np.array([list(x) for x in list(result)])
303 return(keepCols,vals)
304
305# Get names of columns and data for a table
306# for specific typeid and coreid (for the data)
307def getColNamesAndDataForCore(benchTable,core,typeid):
308 cursor=c.cursor()
309 result=cursor.execute(benchCmdColumns % (benchTable))
310 cols= [member[0] for member in cursor.description]
311 keepCols = ['name'] + [c for c in diff(cols , REMOVECOLUMNS) if isNotIDColumn(c)]
312 keepColsStr = "".join(joinit(keepCols,","))
Christophe Favergeon670b1672020-05-28 12:47:58 +0200313 vals=(core,typeid) + runidval
314 result=cursor.execute(benchCmdForCore % (keepColsStr,benchTable,runidCMD),vals)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200315 vals =np.array([list(x) for x in list(result)])
316 return(keepCols,vals)
317
318
319# Get names of columns and data for a table
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200320# for specific typeid and compiler (for the data)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200321def getColNamesAndDataForCompiler(benchTable,comp,typeid):
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200322 cursor=c.cursor()
323 result=cursor.execute(benchCmdColumns % (benchTable))
324 cols= [member[0] for member in cursor.description]
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200325 keepCols = ['name'] + [c for c in diff(cols , REMOVECOLUMNS) if isNotIDColumn(c)]
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200326 keepColsStr = "".join(joinit(keepCols,","))
Christophe Favergeon670b1672020-05-28 12:47:58 +0200327 vals=(comp,typeid) + runidval
328 result=cursor.execute(benchCmdForCompiler % (keepColsStr,benchTable,runidCMD),vals)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200329 vals =np.array([list(x) for x in list(result)])
330 return(keepCols,vals)
331
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200332
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200333
334PARAMS=["NB","NumTaps", "NBA", "NBB", "Factor", "NumStages","VECDIM","NBR","NBC","NBI","IFFT", "BITREV"]
335
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200336def regressionTableFor(byname,name,section,ref,toSort,indexCols,field):
337 data=ref.pivot_table(index=indexCols, columns=byname,
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200338 values=[field], aggfunc='first')
339
340 data=data.sort_values(toSort)
341
342 cores = [c[1] for c in list(data.columns)]
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200343 columns = diff(indexCols,['name'])
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200344
Christophe Favergeon34d313a2020-05-14 15:09:41 +0200345 dataTable=Table(columns,cores)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200346 section.addContent(dataTable)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200347
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200348 dataForFunc=data.loc[name]
349 if type(dataForFunc) is pd.DataFrame:
Christophe Favergeon0dcf9a12020-05-27 15:55:27 +0200350 bars={'cols':columns,'cores':cores,'data':[]}
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200351 for row in dataForFunc.itertuples():
352 row=list(row)
353 if type(row[0]) is int:
354 row=[row[0]] + row[1:]
355 else:
356 row=list(row[0]) + row[1:]
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200357 if field=="MAXREGCOEF":
Christophe Favergeon670b1672020-05-28 12:47:58 +0200358 newrow = row
359 newrow[len(columns):] = [("%.3f" % x) for x in row[len(columns):]]
360 row=newrow
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200361 dataTable.addRow(row)
Christophe Favergeon0dcf9a12020-05-27 15:55:27 +0200362 bars['data'].append(row)
363 return(bars)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200364 else:
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200365 if field=="MAXREGCOEF":
366 dataForFunc=[("%.3f" % x) for x in dataForFunc]
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200367 dataTable.addRow(dataForFunc)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200368 return(list(zip(cores,dataForFunc)))
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200369
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200370def formatColumnName(c):
371 return("".join(joinit(c,":")))
372
373def getCoresForHistory(benchTable,compilerid,typeid,testid,runid):
374 vals=(compilerid,typeid,testid,runid)
375 result=c.execute(coresForHistory % benchTable,vals).fetchall()
376 ids=[(x[0],x[1]) for x in list(result)]
377 return(ids)
378
379def getCompilerForHistory(benchTable,coreid,typeid,testid,runid):
380 vals=(coreid,typeid,testid,runid)
381 result=c.execute(compilersForHistory % benchTable,vals).fetchall()
382 ids=[(x[0],x[1],x[2]) for x in list(result)]
383 return(ids)
384
385def getHistory(desc,testid,indexCols):
386 benchName,sectionID,typeid,runid = desc
387
388 #print(benchName)
389 #print(sectionID)
390 #print(typeid)
391 #print(testid)
392 columns = diff(indexCols,['name'])
393 #print(columns)
394 if args.byc:
395 coreid=sectionID
396 compilerids=getCompilerForHistory(benchName,coreid,typeid,testid,runid)
397 series={}
398 for compilerid,compilername,version in compilerids:
399 result=getColNamesAndHistory(benchName,compilerid,coreid,typeid,testid)
400 #print("%s:%s" % (compilername,version))
401 maxpos = result[0].index('MAX')
402 lrunid = result[0].index('runid')
403 r=[[int(x[lrunid]),int(x[maxpos])] for x in result[1:][0]]
404 series[corename]=r
405 hist=History(series,runid)
406 return(hist)
407 else:
408 compilerid=sectionID
409 coreids = getCoresForHistory(benchName,compilerid,typeid,testid,runid)
410 series={}
411 for coreid,corename in coreids:
412 result=getColNamesAndHistory(benchName,compilerid,coreid,typeid,testid)
413 #print(corename)
414 maxpos = result[0].index('MAX')
415 corepos = result[0].index('core')
416 lrunid = result[0].index('runid')
417 r=[[int(x[lrunid]),int(x[maxpos])] for x in result[1:][0]]
418 series[corename]=r
419 hist=History(series,runid)
420 return(hist)
421
422def formatTableBy(desc,byname,section,typeSection,testNames,cols,vals):
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200423 if vals.size != 0:
424 ref=pd.DataFrame(vals,columns=cols)
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200425 toSort=["name"]
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200426
427 for param in PARAMS:
428 if param in ref.columns:
429 ref[param]=pd.to_numeric(ref[param])
430 toSort.append(param)
431 if args.r:
432 # Regression table
433 ref['MAX']=pd.to_numeric(ref['MAX'])
434 ref['MAXREGCOEF']=pd.to_numeric(ref['MAXREGCOEF'])
435
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200436 indexCols=diff(cols,byname + ['Regression','MAXREGCOEF','MAX'] + section)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200437 valList = ['Regression']
438 else:
439 ref['CYCLES']=pd.to_numeric(ref['CYCLES'])
440
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200441 indexCols=diff(cols,byname + ['CYCLES'] + section)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200442 valList = ['CYCLES']
443
444
445
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200446 for testid,name in testNames:
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200447 if args.r:
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200448 testSection = Section(name)
449 typeSection.addSection(testSection)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200450
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200451 maxCyclesSection = Section("Max cycles")
452 testSection.addSection(maxCyclesSection)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200453 theCycles=regressionTableFor(byname,name,maxCyclesSection,ref,toSort,indexCols,'MAX')
Christophe Favergeon670b1672020-05-28 12:47:58 +0200454 if args.g:
455 if type(theCycles) is dict:
456 nbParams=len(theCycles['cols'])
457 for bar in theCycles['data']:
458 params=bar[0:nbParams]
459 values=bar[nbParams:]
460 title=[("%s=%s" % x) for x in list(zip(theCycles['cols'],params))]
461 title="".join(joinit(title," "))
462 sec=Section(title)
463 maxCyclesSection.addSection(sec)
464 values=list(zip(theCycles['cores'],values))
465 barChart=BarChart(values)
466 sec.addContent(barChart)
467 else:
468 #print(theCycles)
469 sec=Section("Graph")
Christophe Favergeon0dcf9a12020-05-27 15:55:27 +0200470 maxCyclesSection.addSection(sec)
Christophe Favergeon670b1672020-05-28 12:47:58 +0200471 barChart=BarChart(theCycles)
Christophe Favergeon0dcf9a12020-05-27 15:55:27 +0200472 sec.addContent(barChart)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200473
Christophe Favergeon670b1672020-05-28 12:47:58 +0200474 #history=getHistory(desc,testid,indexCols)
475 #testSection.addContent(history)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200476
477 regressionSection = Section("Regression")
478 testSection.addSection(regressionSection)
479 regressionTableFor(byname,name,regressionSection,ref,toSort,indexCols,'Regression')
480
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200481
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200482 maxRegCoefSection = Section("Max Reg Coef")
483 testSection.addSection(maxRegCoefSection)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200484 regressionTableFor(byname,name,maxRegCoefSection,ref,toSort,indexCols,'MAXREGCOEF')
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200485
486 else:
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200487 data=ref.pivot_table(index=indexCols, columns=byname,
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200488 values=valList, aggfunc='first')
489
490 data=data.sort_values(toSort)
491
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200492 #print(list(data.columns))
493 columnsID = [formatColumnName(c[1:]) for c in list(data.columns)]
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200494 columns = diff(indexCols,['name'])
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200495
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200496 testSection = Section(name)
497 typeSection.addSection(testSection)
498
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200499 dataTable=Table(columns,columnsID)
500 testSection.addContent(dataTable)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200501
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200502 dataForFunc=data.loc[name]
503 if type(dataForFunc) is pd.DataFrame:
504 for row in dataForFunc.itertuples():
505 row=list(row)
506 if type(row[0]) is int:
507 row=[row[0]] + row[1:]
508 else:
509 row=list(row[0]) + row[1:]
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200510 dataTable.addRow(row)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200511 else:
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200512 dataTable.addRow(dataForFunc)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200513
514# Add a report for each table
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200515def addReportFor(document,runid,benchName):
Christophe Favergeone15894e2020-05-14 07:25:53 +0200516 nbElems = getNbElemsInBenchCmd(benchName)
517 if nbElems > 0:
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200518 categoryName = getCategoryName(benchName,runid)
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200519 benchSection = Section(categoryName)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200520 document.addSection(benchSection)
Christophe Favergeone15894e2020-05-14 07:25:53 +0200521 print("Process %s\n" % benchName)
Christophe Favergeone15894e2020-05-14 07:25:53 +0200522 allTypes = getExistingTypes(benchName)
523 # Add report for each type
524 for aTypeID in allTypes:
525 nbElems = getNbElemsInBenchAndTypeCmd(benchName,aTypeID)
526 if nbElems > 0:
527 typeName = getTypeName(aTypeID)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200528 typeSection = Section(typeName)
529 benchSection.addSection(typeSection)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200530 if args.byc:
531 ## Add report for each core
532 allCores = getExistingCores(benchName,aTypeID)
533 for core in allCores:
534 #print(core)
535 nbElems = getNbElemsInBenchAndTypeAndCoreCmd(benchName,core,aTypeID)
536 # Print test results for table, type, compiler
537 if nbElems > 0:
538 coreName=getCoreDesc(core)
539 coreSection = Section("%s" % coreName)
540 typeSection.addSection(coreSection)
541 cols,vals=getColNamesAndDataForCore(benchName,core,aTypeID)
542 desc=(benchName,core,aTypeID,runid)
543 names=getTestNamesForCore(benchName,core,aTypeID)
544 formatTableBy(desc,['compiler','version'],['core'],coreSection,names,cols,vals)
545 else:
546 ## Add report for each compiler
547 allCompilers = getExistingCompiler(benchName,aTypeID)
548 for compiler in allCompilers:
549 #print(compiler)
550 nbElems = getNbElemsInBenchAndTypeAndCompilerCmd(benchName,compiler,aTypeID)
551 # Print test results for table, type, compiler
552 if nbElems > 0:
553 compilerName,version=getCompilerDesc(compiler)
554 compilerSection = Section("%s (%s)" % (compilerName,version))
555 typeSection.addSection(compilerSection)
556 cols,vals=getColNamesAndDataForCompiler(benchName,compiler,aTypeID)
557 desc=(benchName,compiler,aTypeID,runid)
558 names=getTestNamesForCompiler(benchName,compiler,aTypeID)
559 formatTableBy(desc,['core'],['version','compiler'],compilerSection,names,cols,vals)
560
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200561
562
563
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200564toc=[Hierarchy("BasicMathsBenchmarks"),
565Hierarchy("ComplexMathsBenchmarks"),
566Hierarchy("FastMath"),
567Hierarchy("Filters",
568 [Hierarchy("FIR"),
569 Hierarchy("BIQUAD"),
570 Hierarchy("DECIM"),
571 Hierarchy("MISC")]),
572
573Hierarchy("Support Functions",
574 [Hierarchy("Support"),
575 Hierarchy("SupportBar")]),
576
577Hierarchy("Matrix Operations" ,
578 [Hierarchy("Binary"),
579 Hierarchy("Unary")]),
580Hierarchy("Transform"),
581
582]
583
584processed=[]
585
586def createDoc(document,sections,benchtables):
587 global processed
588 for s in sections:
589 if s.name in benchtables:
590 addReportFor(document,runid,s.name)
591 processed.append(s.name)
592 else:
593 section=Section(s.name)
594 document.addSection(section)
595 createDoc(section,s.sections,benchtables)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200596
597try:
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200598 benchtables=getBenchTables()
Christophe Favergeone15894e2020-05-14 07:25:53 +0200599 theDate = getrunIDDate(runid)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200600 document = Document(runid,theDate)
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200601 createDoc(document,toc,benchtables)
602 misc=Section("Miscellaneous")
603 document.addSection(misc)
604 remaining=diff(benchtables,processed)
605 for bench in remaining:
606 addReportFor(misc,runid,bench)
607
608 #for bench in benchtables:
609 # addReportFor(document,bench)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200610 with open(args.o,"w") as output:
611 if args.t=="md":
612 document.accept(Markdown(output))
613 if args.t=="html":
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200614 document.accept(HTML(output,args.r))
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200615
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200616finally:
617 c.close()
618
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200619
620
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200621