blob: b256808c91d57caa5196b5cc5b6d0890bed0b0bc [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 Favergeon0e0449a2020-07-28 09:44:14 +020020def joinit(iterable, delimiter):
21 # Intersperse a delimiter between element of a list
22 it = iter(iterable)
23 yield next(it)
24 for x in it:
25 yield delimiter
26 yield x
27
28
Christophe Favergeon8cb37302020-05-13 13:06:58 +020029def getLastRunID():
30 r=c.execute(lastID)
31 return(int(r.fetchone()[0]))
32
Christophe Favergeone15894e2020-05-14 07:25:53 +020033def getrunIDDate(forID):
34 r=c.execute(lastIDAndDate,(forID,))
35 return(r.fetchone()[0])
Christophe Favergeon8cb37302020-05-13 13:06:58 +020036
37runid = 1
38
39parser = argparse.ArgumentParser(description='Generate summary benchmarks')
40
Christophe Favergeonfeb73932020-05-20 14:48:06 +020041parser.add_argument('-b', nargs='?',type = str, default="bench.db", help="Database")
Christophe Favergeon8cb37302020-05-13 13:06:58 +020042parser.add_argument('-o', nargs='?',type = str, default="full.md", help="Full summary")
43parser.add_argument('-r', action='store_true', help="Regression database")
Christophe Favergeonc3f455c2020-05-14 09:24:07 +020044parser.add_argument('-t', nargs='?',type = str, default="md", help="md,html")
Christophe Favergeonfeb73932020-05-20 14:48:06 +020045parser.add_argument('-byc', action='store_true', help="By Compiler")
Christophe Favergeon670b1672020-05-28 12:47:58 +020046parser.add_argument('-g', action='store_true', help="Include graphs in regression report")
Christophe Favergeon8cb37302020-05-13 13:06:58 +020047
48# For runid or runid range
Christophe Favergeon4fa1e232020-05-15 12:28:17 +020049parser.add_argument('others', nargs=argparse.REMAINDER,help="Run ID")
Christophe Favergeon8cb37302020-05-13 13:06:58 +020050
51args = parser.parse_args()
52
53c = sqlite3.connect(args.b)
54
55if args.others:
Christophe Favergeon670b1672020-05-28 12:47:58 +020056 if len(args.others) == 1:
Christophe Favergeon0e0449a2020-07-28 09:44:14 +020057 if re.search(r'[,]',args.others[0]):
58 runidval=tuple([int(x) for x in args.others[0].split(",")])
59 runidCMD=["runid == ?" for x in runidval]
60 runidCMD = "".join(joinit(runidCMD," OR "))
61 runidCMD = "(" + runidCMD + ")"
62 else:
63 runid=int(args.others[0])
64 runidval = (runid,)
Christophe Favergeon670b1672020-05-28 12:47:58 +020065 else:
66 runidCMD = "runid >= ? AND runid <= ?"
67 runid=int(args.others[1])
68 runidLOW=int(args.others[0])
69 runidval = (runidLOW,runid)
Christophe Favergeon8cb37302020-05-13 13:06:58 +020070else:
71 runid=getLastRunID()
Christophe Favergeon670b1672020-05-28 12:47:58 +020072 print("Last run ID = %d\n" % runid)
73 runidval=(runid,)
Christophe Favergeon8cb37302020-05-13 13:06:58 +020074
75# We extract data only from data tables
76# Those tables below are used for descriptions
Christophe Favergeon4fa1e232020-05-15 12:28:17 +020077REMOVETABLES=['TESTNAME','TESTDATE','RUN','CORE', 'PLATFORM', 'COMPILERKIND', 'COMPILER', 'TYPE', 'CATEGORY', 'CONFIG']
Christophe Favergeon8cb37302020-05-13 13:06:58 +020078
79# This is assuming the database is generated by the regression script
80# So platform is the same for all benchmarks.
81# Category and type is coming from the test name in the yaml
82# So no need to add this information here
83# Name is removed here because it is added at the beginning
Christophe Favergeon4fa1e232020-05-15 12:28:17 +020084REMOVECOLUMNS=['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 +020085
Christophe Favergeonfeb73932020-05-20 14:48:06 +020086REMOVECOLUMNSFORHISTORY=['Regression','MAXREGCOEF','name','type','platform','category','coredef','OPTIMIZED','HARDFP','FASTMATH','NEON','HELIUM','UNROLL','ROUNDING','DATE','compilerkindid','date','categoryid', 'ID', 'platformid', 'coreid', 'compilerid', 'typeid']
87
Christophe Favergeon8cb37302020-05-13 13:06:58 +020088# Get existing benchmark tables
89def getBenchTables():
90 r=c.execute("SELECT name FROM sqlite_master WHERE type='table'")
91 benchtables=[]
92 for table in r:
93 if not table[0] in REMOVETABLES:
94 benchtables.append(table[0])
95 return(benchtables)
96
97# get existing types in a table
98def getExistingTypes(benchTable):
Christophe Favergeone15894e2020-05-14 07:25:53 +020099 r=c.execute("select distinct typeid from %s order by typeid desc" % benchTable).fetchall()
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200100 result=[x[0] for x in r]
101 return(result)
102
103# Get compilers from specific type and table
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200104allCompilers="""select distinct compilerid from %s WHERE typeid=?"""
105
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200106# Get compilers from specific type and table
107allCores="""select distinct coreid from %s WHERE typeid=?"""
108
109
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200110compilerDesc="""select compiler,version from COMPILER
111 INNER JOIN COMPILERKIND USING(compilerkindid) WHERE compilerid=?"""
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200112
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200113coreDesc="""select core from CORE WHERE coreid=?"""
114
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200115# Get existing compiler in a table for a specific type
116# (In case report is structured by types)
117def getExistingCompiler(benchTable,typeid):
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200118 r=c.execute(allCompilers % benchTable,(typeid,)).fetchall()
119 return([x[0] for x in r])
120
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200121def getExistingCores(benchTable,typeid):
122 r=c.execute(allCores % benchTable,(typeid,)).fetchall()
123 return([x[0] for x in r])
124
125
126
127def getCoreDesc(compilerid):
128 r=c.execute(coreDesc,(compilerid,)).fetchone()
129 return(r)
130
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200131def getCompilerDesc(compilerid):
132 r=c.execute(compilerDesc,(compilerid,)).fetchone()
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200133 return(r)
134
135# Get type name from type id
136def getTypeName(typeid):
137 r=c.execute("select type from TYPE where typeid=?",(typeid,)).fetchone()
138 return(r[0])
139
140# Diff of 2 lists
141def diff(first, second):
142 second = set(second)
143 return [item for item in first if item not in second]
144
145
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200146# Command to get data for specific core
147# and type
148historyCmd="""select %s from %s
149 INNER JOIN CATEGORY USING(categoryid)
150 INNER JOIN PLATFORM USING(platformid)
151 INNER JOIN CORE USING(coreid)
152 INNER JOIN COMPILER USING(compilerid)
153 INNER JOIN COMPILERKIND USING(compilerkindid)
154 INNER JOIN TYPE USING(typeid)
155 INNER JOIN TESTNAME USING(testnameid)
156 WHERE compilerid=? AND coreid=? AND typeid = ? AND ID = ? AND runid > (? - 10)
157 """
158
159compilersForHistory="""select distinct compilerid,compiler,version from %s
160 INNER JOIN COMPILER USING(compilerid)
161 INNER JOIN COMPILERKIND USING(compilerkindid)
162 WHERE coreid=? AND typeid = ? AND ID = ? AND runid > (? - 10)
163 """
164
165# Command to get data for specific core
166# and type
167benchCmdForCore="""select %s from %s
168 INNER JOIN CATEGORY USING(categoryid)
169 INNER JOIN PLATFORM USING(platformid)
170 INNER JOIN CORE USING(coreid)
171 INNER JOIN COMPILER USING(compilerid)
172 INNER JOIN COMPILERKIND USING(compilerkindid)
173 INNER JOIN TYPE USING(typeid)
174 INNER JOIN TESTNAME USING(testnameid)
Christophe Favergeon670b1672020-05-28 12:47:58 +0200175 WHERE coreid=? AND typeid = ? AND %s
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200176 """
177
178coresForHistory="""select distinct coreid,core from %s
179 INNER JOIN CORE USING(coreid)
180 WHERE compilerid=? AND typeid = ? AND ID = ? AND runid > (? - 10)
181 """
182
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200183# Command to get data for specific compiler
184# and type
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200185benchCmdForCompiler="""select %s from %s
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200186 INNER JOIN CATEGORY USING(categoryid)
187 INNER JOIN PLATFORM USING(platformid)
188 INNER JOIN CORE USING(coreid)
189 INNER JOIN COMPILER USING(compilerid)
190 INNER JOIN COMPILERKIND USING(compilerkindid)
191 INNER JOIN TYPE USING(typeid)
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200192 INNER JOIN TESTNAME USING(testnameid)
Christophe Favergeon670b1672020-05-28 12:47:58 +0200193 WHERE compilerid=? AND typeid = ? AND %s
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200194 """
195
196# Command to get test names for specific compiler
197# and type
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200198benchNamesForCore="""select distinct ID,name from %s
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# Command to get test names for specific compiler
206# and type
207benchNamesForCompiler="""select distinct ID,name from %s
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200208 INNER JOIN COMPILER USING(compilerid)
209 INNER JOIN COMPILERKIND USING(compilerkindid)
210 INNER JOIN TYPE USING(typeid)
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200211 INNER JOIN TESTNAME USING(testnameid)
Christophe Favergeon670b1672020-05-28 12:47:58 +0200212 WHERE compilerid=? AND typeid = ? AND %s
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200213 """
214
215# Command to get columns for specific table
216benchCmdColumns="""select * from %s
217 INNER JOIN CATEGORY USING(categoryid)
218 INNER JOIN PLATFORM USING(platformid)
219 INNER JOIN CORE USING(coreid)
220 INNER JOIN COMPILER USING(compilerid)
221 INNER JOIN COMPILERKIND USING(compilerkindid)
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200222 INNER JOIN TESTNAME USING(testnameid)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200223 INNER JOIN TYPE USING(typeid)
224 """
225
226def joinit(iterable, delimiter):
227 it = iter(iterable)
228 yield next(it)
229 for x in it:
230 yield delimiter
231 yield x
232
233# Is not a column name finishing by id
234# (often primary key for thetable)
235def isNotIDColumn(col):
236 if re.match(r'^.*id$',col):
237 return(False)
238 else:
239 return(True)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200240
241# Get test names
242# for specific typeid and core (for the data)
243def getTestNamesForCore(benchTable,core,typeid):
Christophe Favergeon670b1672020-05-28 12:47:58 +0200244 vals=(core,typeid) + runidval
245 result=c.execute(benchNamesForCore % (benchTable,runidCMD),vals).fetchall()
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200246 names=[(x[0],x[1]) for x in list(result)]
247 return(names)
248
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200249# Get test names
250# for specific typeid and compiler (for the data)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200251def getTestNamesForCompiler(benchTable,comp,typeid):
Christophe Favergeon670b1672020-05-28 12:47:58 +0200252 vals=(comp,typeid) + runidval
253 result=c.execute(benchNamesForCompiler % (benchTable,runidCMD),vals).fetchall()
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200254 names=[(x[0],x[1]) for x in list(result)]
255 return(names)
256
257# Command to get data for specific core
258# and type
259nbElemsInBenchAndTypeAndCoreCmd="""select count(*) from %s
Christophe Favergeon670b1672020-05-28 12:47:58 +0200260 WHERE coreid=? AND typeid = ? AND %s
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200261 """
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200262
Christophe Favergeone15894e2020-05-14 07:25:53 +0200263# Command to get data for specific compiler
264# and type
265nbElemsInBenchAndTypeAndCompilerCmd="""select count(*) from %s
Christophe Favergeon670b1672020-05-28 12:47:58 +0200266 WHERE compilerid=? AND typeid = ? AND %s
Christophe Favergeone15894e2020-05-14 07:25:53 +0200267 """
268
269nbElemsInBenchAndTypeCmd="""select count(*) from %s
Christophe Favergeon670b1672020-05-28 12:47:58 +0200270 WHERE typeid = ? AND %s
Christophe Favergeone15894e2020-05-14 07:25:53 +0200271 """
272
273nbElemsInBenchCmd="""select count(*) from %s
Christophe Favergeon670b1672020-05-28 12:47:58 +0200274 WHERE %s
Christophe Favergeone15894e2020-05-14 07:25:53 +0200275 """
276
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200277categoryName="""select distinct category from %s
278 INNER JOIN CATEGORY USING(categoryid)
Christophe Favergeon670b1672020-05-28 12:47:58 +0200279 WHERE %s
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200280 """
281
282def getCategoryName(benchTable,runid):
Christophe Favergeon670b1672020-05-28 12:47:58 +0200283 result=c.execute(categoryName % (benchTable,runidCMD),runidval).fetchone()
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200284 return(result[0])
285
Christophe Favergeon4f750702020-05-13 15:56:15 +0200286# Get nb elems in a table
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200287def getNbElemsInBenchAndTypeAndCoreCmd(benchTable,coreid,typeid):
Christophe Favergeon670b1672020-05-28 12:47:58 +0200288 vals=(coreid,typeid) + runidval
289 result=c.execute(nbElemsInBenchAndTypeAndCoreCmd % (benchTable,runidCMD),vals).fetchone()
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200290 return(result[0])
291
292# Get nb elems in a table
Christophe Favergeone15894e2020-05-14 07:25:53 +0200293def getNbElemsInBenchAndTypeAndCompilerCmd(benchTable,comp,typeid):
Christophe Favergeon670b1672020-05-28 12:47:58 +0200294 vals=(comp,typeid) + runidval
295 result=c.execute(nbElemsInBenchAndTypeAndCompilerCmd % (benchTable,runidCMD),vals).fetchone()
Christophe Favergeone15894e2020-05-14 07:25:53 +0200296 return(result[0])
297
298def getNbElemsInBenchAndTypeCmd(benchTable,typeid):
Christophe Favergeon670b1672020-05-28 12:47:58 +0200299 vals=(typeid,) + runidval
300 result=c.execute(nbElemsInBenchAndTypeCmd % (benchTable,runidCMD),vals).fetchone()
Christophe Favergeone15894e2020-05-14 07:25:53 +0200301 return(result[0])
302
303def getNbElemsInBenchCmd(benchTable):
Christophe Favergeon670b1672020-05-28 12:47:58 +0200304 result=c.execute(nbElemsInBenchCmd % (benchTable,runidCMD),runidval).fetchone()
Christophe Favergeon4f750702020-05-13 15:56:15 +0200305 return(result[0])
306
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200307# Get names of columns and data for a table
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200308# for specific typeid and coreid (for the data)
309def getColNamesAndHistory(benchTable,compiler,core,typeid,testid):
310 cursor=c.cursor()
311 result=cursor.execute(benchCmdColumns % (benchTable))
312 cols= [member[0] for member in cursor.description]
313 keepCols = ['name','runid'] + [c for c in diff(cols , REMOVECOLUMNSFORHISTORY) if isNotIDColumn(c)]
314 keepColsStr = "".join(joinit(keepCols,","))
315 vals=(compiler,core,typeid,testid,runid)
316 result=cursor.execute(historyCmd % (keepColsStr,benchTable),vals)
317 vals =np.array([list(x) for x in list(result)])
318 return(keepCols,vals)
319
320# Get names of columns and data for a table
321# for specific typeid and coreid (for the data)
322def getColNamesAndDataForCore(benchTable,core,typeid):
323 cursor=c.cursor()
324 result=cursor.execute(benchCmdColumns % (benchTable))
325 cols= [member[0] for member in cursor.description]
326 keepCols = ['name'] + [c for c in diff(cols , REMOVECOLUMNS) if isNotIDColumn(c)]
327 keepColsStr = "".join(joinit(keepCols,","))
Christophe Favergeon670b1672020-05-28 12:47:58 +0200328 vals=(core,typeid) + runidval
329 result=cursor.execute(benchCmdForCore % (keepColsStr,benchTable,runidCMD),vals)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200330 vals =np.array([list(x) for x in list(result)])
331 return(keepCols,vals)
332
333
334# Get names of columns and data for a table
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200335# for specific typeid and compiler (for the data)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200336def getColNamesAndDataForCompiler(benchTable,comp,typeid):
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200337 cursor=c.cursor()
338 result=cursor.execute(benchCmdColumns % (benchTable))
339 cols= [member[0] for member in cursor.description]
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200340 keepCols = ['name'] + [c for c in diff(cols , REMOVECOLUMNS) if isNotIDColumn(c)]
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200341 keepColsStr = "".join(joinit(keepCols,","))
Christophe Favergeon670b1672020-05-28 12:47:58 +0200342 vals=(comp,typeid) + runidval
343 result=cursor.execute(benchCmdForCompiler % (keepColsStr,benchTable,runidCMD),vals)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200344 vals =np.array([list(x) for x in list(result)])
345 return(keepCols,vals)
346
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200347
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200348
349PARAMS=["NB","NumTaps", "NBA", "NBB", "Factor", "NumStages","VECDIM","NBR","NBC","NBI","IFFT", "BITREV"]
350
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200351def regressionTableFor(byname,name,section,ref,toSort,indexCols,field):
352 data=ref.pivot_table(index=indexCols, columns=byname,
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200353 values=[field], aggfunc='first')
354
355 data=data.sort_values(toSort)
356
357 cores = [c[1] for c in list(data.columns)]
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200358 columns = diff(indexCols,['name'])
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200359
Christophe Favergeon34d313a2020-05-14 15:09:41 +0200360 dataTable=Table(columns,cores)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200361 section.addContent(dataTable)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200362
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200363 dataForFunc=data.loc[name]
364 if type(dataForFunc) is pd.DataFrame:
Christophe Favergeon0dcf9a12020-05-27 15:55:27 +0200365 bars={'cols':columns,'cores':cores,'data':[]}
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200366 for row in dataForFunc.itertuples():
367 row=list(row)
368 if type(row[0]) is int:
369 row=[row[0]] + row[1:]
370 else:
371 row=list(row[0]) + row[1:]
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200372 if field=="MAXREGCOEF":
Christophe Favergeon670b1672020-05-28 12:47:58 +0200373 newrow = row
374 newrow[len(columns):] = [("%.3f" % x) for x in row[len(columns):]]
375 row=newrow
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200376 dataTable.addRow(row)
Christophe Favergeon0dcf9a12020-05-27 15:55:27 +0200377 bars['data'].append(row)
378 return(bars)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200379 else:
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200380 if field=="MAXREGCOEF":
381 dataForFunc=[("%.3f" % x) for x in dataForFunc]
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200382 dataTable.addRow(dataForFunc)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200383 return(list(zip(cores,dataForFunc)))
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200384
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200385def formatColumnName(c):
386 return("".join(joinit(c,":")))
387
388def getCoresForHistory(benchTable,compilerid,typeid,testid,runid):
389 vals=(compilerid,typeid,testid,runid)
390 result=c.execute(coresForHistory % benchTable,vals).fetchall()
391 ids=[(x[0],x[1]) for x in list(result)]
392 return(ids)
393
394def getCompilerForHistory(benchTable,coreid,typeid,testid,runid):
395 vals=(coreid,typeid,testid,runid)
396 result=c.execute(compilersForHistory % benchTable,vals).fetchall()
397 ids=[(x[0],x[1],x[2]) for x in list(result)]
398 return(ids)
399
400def getHistory(desc,testid,indexCols):
401 benchName,sectionID,typeid,runid = desc
402
403 #print(benchName)
404 #print(sectionID)
405 #print(typeid)
406 #print(testid)
407 columns = diff(indexCols,['name'])
408 #print(columns)
409 if args.byc:
410 coreid=sectionID
411 compilerids=getCompilerForHistory(benchName,coreid,typeid,testid,runid)
412 series={}
413 for compilerid,compilername,version in compilerids:
414 result=getColNamesAndHistory(benchName,compilerid,coreid,typeid,testid)
415 #print("%s:%s" % (compilername,version))
416 maxpos = result[0].index('MAX')
417 lrunid = result[0].index('runid')
418 r=[[int(x[lrunid]),int(x[maxpos])] for x in result[1:][0]]
419 series[corename]=r
420 hist=History(series,runid)
421 return(hist)
422 else:
423 compilerid=sectionID
424 coreids = getCoresForHistory(benchName,compilerid,typeid,testid,runid)
425 series={}
426 for coreid,corename in coreids:
427 result=getColNamesAndHistory(benchName,compilerid,coreid,typeid,testid)
428 #print(corename)
429 maxpos = result[0].index('MAX')
430 corepos = result[0].index('core')
431 lrunid = result[0].index('runid')
432 r=[[int(x[lrunid]),int(x[maxpos])] for x in result[1:][0]]
433 series[corename]=r
434 hist=History(series,runid)
435 return(hist)
436
437def formatTableBy(desc,byname,section,typeSection,testNames,cols,vals):
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200438 if vals.size != 0:
439 ref=pd.DataFrame(vals,columns=cols)
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200440 toSort=["name"]
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200441
442 for param in PARAMS:
443 if param in ref.columns:
444 ref[param]=pd.to_numeric(ref[param])
445 toSort.append(param)
446 if args.r:
447 # Regression table
448 ref['MAX']=pd.to_numeric(ref['MAX'])
449 ref['MAXREGCOEF']=pd.to_numeric(ref['MAXREGCOEF'])
450
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200451 indexCols=diff(cols,byname + ['Regression','MAXREGCOEF','MAX'] + section)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200452 valList = ['Regression']
453 else:
454 ref['CYCLES']=pd.to_numeric(ref['CYCLES'])
455
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200456 indexCols=diff(cols,byname + ['CYCLES'] + section)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200457 valList = ['CYCLES']
458
459
460
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200461 for testid,name in testNames:
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200462 if args.r:
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200463 testSection = Section(name)
464 typeSection.addSection(testSection)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200465
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200466 maxCyclesSection = Section("Max cycles")
467 testSection.addSection(maxCyclesSection)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200468 theCycles=regressionTableFor(byname,name,maxCyclesSection,ref,toSort,indexCols,'MAX')
Christophe Favergeon670b1672020-05-28 12:47:58 +0200469 if args.g:
470 if type(theCycles) is dict:
471 nbParams=len(theCycles['cols'])
472 for bar in theCycles['data']:
473 params=bar[0:nbParams]
474 values=bar[nbParams:]
475 title=[("%s=%s" % x) for x in list(zip(theCycles['cols'],params))]
476 title="".join(joinit(title," "))
477 sec=Section(title)
478 maxCyclesSection.addSection(sec)
479 values=list(zip(theCycles['cores'],values))
480 barChart=BarChart(values)
481 sec.addContent(barChart)
482 else:
483 #print(theCycles)
484 sec=Section("Graph")
Christophe Favergeon0dcf9a12020-05-27 15:55:27 +0200485 maxCyclesSection.addSection(sec)
Christophe Favergeon670b1672020-05-28 12:47:58 +0200486 barChart=BarChart(theCycles)
Christophe Favergeon0dcf9a12020-05-27 15:55:27 +0200487 sec.addContent(barChart)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200488
Christophe Favergeon670b1672020-05-28 12:47:58 +0200489 #history=getHistory(desc,testid,indexCols)
490 #testSection.addContent(history)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200491
492 regressionSection = Section("Regression")
493 testSection.addSection(regressionSection)
494 regressionTableFor(byname,name,regressionSection,ref,toSort,indexCols,'Regression')
495
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200496
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200497 maxRegCoefSection = Section("Max Reg Coef")
498 testSection.addSection(maxRegCoefSection)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200499 regressionTableFor(byname,name,maxRegCoefSection,ref,toSort,indexCols,'MAXREGCOEF')
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200500
501 else:
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200502 data=ref.pivot_table(index=indexCols, columns=byname,
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200503 values=valList, aggfunc='first')
504
505 data=data.sort_values(toSort)
506
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200507 #print(list(data.columns))
508 columnsID = [formatColumnName(c[1:]) for c in list(data.columns)]
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200509 columns = diff(indexCols,['name'])
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200510
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200511 testSection = Section(name)
512 typeSection.addSection(testSection)
513
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200514 dataTable=Table(columns,columnsID)
515 testSection.addContent(dataTable)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200516
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200517 dataForFunc=data.loc[name]
518 if type(dataForFunc) is pd.DataFrame:
519 for row in dataForFunc.itertuples():
520 row=list(row)
521 if type(row[0]) is int:
522 row=[row[0]] + row[1:]
523 else:
524 row=list(row[0]) + row[1:]
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200525 dataTable.addRow(row)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200526 else:
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200527 dataTable.addRow(dataForFunc)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200528
529# Add a report for each table
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200530def addReportFor(document,runid,benchName):
Christophe Favergeone15894e2020-05-14 07:25:53 +0200531 nbElems = getNbElemsInBenchCmd(benchName)
532 if nbElems > 0:
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200533 categoryName = getCategoryName(benchName,runid)
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200534 benchSection = Section(categoryName)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200535 document.addSection(benchSection)
Christophe Favergeone15894e2020-05-14 07:25:53 +0200536 print("Process %s\n" % benchName)
Christophe Favergeone15894e2020-05-14 07:25:53 +0200537 allTypes = getExistingTypes(benchName)
538 # Add report for each type
539 for aTypeID in allTypes:
540 nbElems = getNbElemsInBenchAndTypeCmd(benchName,aTypeID)
541 if nbElems > 0:
542 typeName = getTypeName(aTypeID)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200543 typeSection = Section(typeName)
544 benchSection.addSection(typeSection)
Christophe Favergeonfeb73932020-05-20 14:48:06 +0200545 if args.byc:
546 ## Add report for each core
547 allCores = getExistingCores(benchName,aTypeID)
548 for core in allCores:
549 #print(core)
550 nbElems = getNbElemsInBenchAndTypeAndCoreCmd(benchName,core,aTypeID)
551 # Print test results for table, type, compiler
552 if nbElems > 0:
553 coreName=getCoreDesc(core)
554 coreSection = Section("%s" % coreName)
555 typeSection.addSection(coreSection)
556 cols,vals=getColNamesAndDataForCore(benchName,core,aTypeID)
557 desc=(benchName,core,aTypeID,runid)
558 names=getTestNamesForCore(benchName,core,aTypeID)
559 formatTableBy(desc,['compiler','version'],['core'],coreSection,names,cols,vals)
560 else:
561 ## Add report for each compiler
562 allCompilers = getExistingCompiler(benchName,aTypeID)
563 for compiler in allCompilers:
564 #print(compiler)
565 nbElems = getNbElemsInBenchAndTypeAndCompilerCmd(benchName,compiler,aTypeID)
566 # Print test results for table, type, compiler
567 if nbElems > 0:
568 compilerName,version=getCompilerDesc(compiler)
569 compilerSection = Section("%s (%s)" % (compilerName,version))
570 typeSection.addSection(compilerSection)
571 cols,vals=getColNamesAndDataForCompiler(benchName,compiler,aTypeID)
572 desc=(benchName,compiler,aTypeID,runid)
573 names=getTestNamesForCompiler(benchName,compiler,aTypeID)
574 formatTableBy(desc,['core'],['version','compiler'],compilerSection,names,cols,vals)
575
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200576
577
578
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200579toc=[Hierarchy("BasicMathsBenchmarks"),
580Hierarchy("ComplexMathsBenchmarks"),
581Hierarchy("FastMath"),
582Hierarchy("Filters",
583 [Hierarchy("FIR"),
584 Hierarchy("BIQUAD"),
585 Hierarchy("DECIM"),
586 Hierarchy("MISC")]),
587
588Hierarchy("Support Functions",
589 [Hierarchy("Support"),
590 Hierarchy("SupportBar")]),
591
592Hierarchy("Matrix Operations" ,
593 [Hierarchy("Binary"),
594 Hierarchy("Unary")]),
595Hierarchy("Transform"),
596
597]
598
599processed=[]
600
601def createDoc(document,sections,benchtables):
602 global processed
603 for s in sections:
604 if s.name in benchtables:
605 addReportFor(document,runid,s.name)
606 processed.append(s.name)
607 else:
608 section=Section(s.name)
609 document.addSection(section)
610 createDoc(section,s.sections,benchtables)
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200611
612try:
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200613 benchtables=getBenchTables()
Christophe Favergeone15894e2020-05-14 07:25:53 +0200614 theDate = getrunIDDate(runid)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200615 document = Document(runid,theDate)
Christophe Favergeoned0eab82020-05-18 08:43:38 +0200616 createDoc(document,toc,benchtables)
617 misc=Section("Miscellaneous")
618 document.addSection(misc)
619 remaining=diff(benchtables,processed)
620 for bench in remaining:
621 addReportFor(misc,runid,bench)
622
623 #for bench in benchtables:
624 # addReportFor(document,bench)
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200625 with open(args.o,"w") as output:
626 if args.t=="md":
627 document.accept(Markdown(output))
628 if args.t=="html":
Christophe Favergeon4fa1e232020-05-15 12:28:17 +0200629 document.accept(HTML(output,args.r))
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200630
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200631finally:
632 c.close()
633
Christophe Favergeonc3f455c2020-05-14 09:24:07 +0200634
635
Christophe Favergeon8cb37302020-05-13 13:06:58 +0200636