Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 1 | import argparse |
| 2 | import sqlite3 |
| 3 | import re |
| 4 | import pandas as pd |
| 5 | import numpy as np |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 6 | from TestScripts.doc.Structure import * |
| 7 | from TestScripts.doc.Format import * |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 8 | |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 14 | # Command to get last runid |
| 15 | lastID="""SELECT runid FROM RUN ORDER BY runid DESC LIMIT 1 |
| 16 | """ |
| 17 | |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 18 | # Command to get last runid and date |
| 19 | lastIDAndDate="""SELECT date FROM RUN WHERE runid=? |
| 20 | """ |
| 21 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 22 | def getLastRunID(): |
| 23 | r=c.execute(lastID) |
| 24 | return(int(r.fetchone()[0])) |
| 25 | |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 26 | def getrunIDDate(forID): |
| 27 | r=c.execute(lastIDAndDate,(forID,)) |
| 28 | return(r.fetchone()[0]) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 29 | |
| 30 | runid = 1 |
| 31 | |
| 32 | parser = argparse.ArgumentParser(description='Generate summary benchmarks') |
| 33 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 34 | parser.add_argument('-b', nargs='?',type = str, default="bench.db", help="Database") |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 35 | parser.add_argument('-o', nargs='?',type = str, default="full.md", help="Full summary") |
| 36 | parser.add_argument('-r', action='store_true', help="Regression database") |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 37 | parser.add_argument('-t', nargs='?',type = str, default="md", help="md,html") |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 38 | parser.add_argument('-byc', action='store_true', help="By Compiler") |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 39 | |
| 40 | # For runid or runid range |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 41 | parser.add_argument('others', nargs=argparse.REMAINDER,help="Run ID") |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 42 | |
| 43 | args = parser.parse_args() |
| 44 | |
| 45 | c = sqlite3.connect(args.b) |
| 46 | |
| 47 | if args.others: |
| 48 | runid=int(args.others[0]) |
| 49 | else: |
| 50 | runid=getLastRunID() |
| 51 | |
| 52 | # We extract data only from data tables |
| 53 | # Those tables below are used for descriptions |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 54 | REMOVETABLES=['TESTNAME','TESTDATE','RUN','CORE', 'PLATFORM', 'COMPILERKIND', 'COMPILER', 'TYPE', 'CATEGORY', 'CONFIG'] |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 55 | |
| 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 Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 61 | REMOVECOLUMNS=['runid','name','type','platform','category','coredef','OPTIMIZED','HARDFP','FASTMATH','NEON','HELIUM','UNROLL','ROUNDING','DATE','compilerkindid','date','categoryid', 'ID', 'platformid', 'coreid', 'compilerid', 'typeid'] |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 62 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 63 | REMOVECOLUMNSFORHISTORY=['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 Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 65 | # Get existing benchmark tables |
| 66 | def 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 |
| 75 | def getExistingTypes(benchTable): |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 76 | r=c.execute("select distinct typeid from %s order by typeid desc" % benchTable).fetchall() |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 77 | result=[x[0] for x in r] |
| 78 | return(result) |
| 79 | |
| 80 | # Get compilers from specific type and table |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 81 | allCompilers="""select distinct compilerid from %s WHERE typeid=?""" |
| 82 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 83 | # Get compilers from specific type and table |
| 84 | allCores="""select distinct coreid from %s WHERE typeid=?""" |
| 85 | |
| 86 | |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 87 | compilerDesc="""select compiler,version from COMPILER |
| 88 | INNER JOIN COMPILERKIND USING(compilerkindid) WHERE compilerid=?""" |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 89 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 90 | coreDesc="""select core from CORE WHERE coreid=?""" |
| 91 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 92 | # Get existing compiler in a table for a specific type |
| 93 | # (In case report is structured by types) |
| 94 | def getExistingCompiler(benchTable,typeid): |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 95 | r=c.execute(allCompilers % benchTable,(typeid,)).fetchall() |
| 96 | return([x[0] for x in r]) |
| 97 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 98 | def getExistingCores(benchTable,typeid): |
| 99 | r=c.execute(allCores % benchTable,(typeid,)).fetchall() |
| 100 | return([x[0] for x in r]) |
| 101 | |
| 102 | |
| 103 | |
| 104 | def getCoreDesc(compilerid): |
| 105 | r=c.execute(coreDesc,(compilerid,)).fetchone() |
| 106 | return(r) |
| 107 | |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 108 | def getCompilerDesc(compilerid): |
| 109 | r=c.execute(compilerDesc,(compilerid,)).fetchone() |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 110 | return(r) |
| 111 | |
| 112 | # Get type name from type id |
| 113 | def getTypeName(typeid): |
| 114 | r=c.execute("select type from TYPE where typeid=?",(typeid,)).fetchone() |
| 115 | return(r[0]) |
| 116 | |
| 117 | # Diff of 2 lists |
| 118 | def diff(first, second): |
| 119 | second = set(second) |
| 120 | return [item for item in first if item not in second] |
| 121 | |
| 122 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 123 | # Command to get data for specific core |
| 124 | # and type |
| 125 | historyCmd="""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 | |
| 136 | compilersForHistory="""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 |
| 144 | benchCmdForCore="""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 | |
| 155 | coresForHistory="""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 Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 160 | # Command to get data for specific compiler |
| 161 | # and type |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 162 | benchCmdForCompiler="""select %s from %s |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 163 | 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 Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 169 | INNER JOIN TESTNAME USING(testnameid) |
| 170 | WHERE compilerid=? AND typeid = ? AND runid = ? |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 171 | """ |
| 172 | |
| 173 | # Command to get test names for specific compiler |
| 174 | # and type |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 175 | benchNamesForCore="""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 |
| 184 | benchNamesForCompiler="""select distinct ID,name from %s |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 185 | INNER JOIN COMPILER USING(compilerid) |
| 186 | INNER JOIN COMPILERKIND USING(compilerkindid) |
| 187 | INNER JOIN TYPE USING(typeid) |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 188 | INNER JOIN TESTNAME USING(testnameid) |
| 189 | WHERE compilerid=? AND typeid = ? AND runid = ? |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 190 | """ |
| 191 | |
| 192 | # Command to get columns for specific table |
| 193 | benchCmdColumns="""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 Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 199 | INNER JOIN TESTNAME USING(testnameid) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 200 | INNER JOIN TYPE USING(typeid) |
| 201 | """ |
| 202 | |
| 203 | def 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) |
| 212 | def isNotIDColumn(col): |
| 213 | if re.match(r'^.*id$',col): |
| 214 | return(False) |
| 215 | else: |
| 216 | return(True) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 217 | |
| 218 | # Get test names |
| 219 | # for specific typeid and core (for the data) |
| 220 | def 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 Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 226 | # Get test names |
| 227 | # for specific typeid and compiler (for the data) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 228 | def getTestNamesForCompiler(benchTable,comp,typeid): |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 229 | vals=(comp,typeid,runid) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 230 | 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 |
| 236 | nbElemsInBenchAndTypeAndCoreCmd="""select count(*) from %s |
| 237 | WHERE coreid=? AND typeid = ? AND runid = ? |
| 238 | """ |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 239 | |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 240 | # Command to get data for specific compiler |
| 241 | # and type |
| 242 | nbElemsInBenchAndTypeAndCompilerCmd="""select count(*) from %s |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 243 | WHERE compilerid=? AND typeid = ? AND runid = ? |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 244 | """ |
| 245 | |
| 246 | nbElemsInBenchAndTypeCmd="""select count(*) from %s |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 247 | WHERE typeid = ? AND runid = ? |
| 248 | """ |
| 249 | |
| 250 | nbElemsInBenchCmd="""select count(*) from %s |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 251 | WHERE runid = ? |
| 252 | """ |
| 253 | |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 254 | categoryName="""select distinct category from %s |
| 255 | INNER JOIN CATEGORY USING(categoryid) |
| 256 | WHERE runid = ? |
| 257 | """ |
| 258 | |
| 259 | def getCategoryName(benchTable,runid): |
| 260 | result=c.execute(categoryName % benchTable,(runid,)).fetchone() |
| 261 | return(result[0]) |
| 262 | |
Christophe Favergeon | 4f75070 | 2020-05-13 15:56:15 +0200 | [diff] [blame] | 263 | # Get nb elems in a table |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 264 | def 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 Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 270 | def getNbElemsInBenchAndTypeAndCompilerCmd(benchTable,comp,typeid): |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 271 | vals=(comp,typeid,runid) |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 272 | result=c.execute(nbElemsInBenchAndTypeAndCompilerCmd % benchTable,vals).fetchone() |
| 273 | return(result[0]) |
| 274 | |
| 275 | def getNbElemsInBenchAndTypeCmd(benchTable,typeid): |
| 276 | vals=(typeid,runid) |
| 277 | result=c.execute(nbElemsInBenchAndTypeCmd % benchTable,vals).fetchone() |
| 278 | return(result[0]) |
| 279 | |
| 280 | def getNbElemsInBenchCmd(benchTable): |
| 281 | vals=(runid,) |
| 282 | result=c.execute(nbElemsInBenchCmd % benchTable,vals).fetchone() |
Christophe Favergeon | 4f75070 | 2020-05-13 15:56:15 +0200 | [diff] [blame] | 283 | return(result[0]) |
| 284 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 285 | # Get names of columns and data for a table |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 286 | # for specific typeid and coreid (for the data) |
| 287 | def 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) |
| 300 | def 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 Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 313 | # for specific typeid and compiler (for the data) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 314 | def getColNamesAndDataForCompiler(benchTable,comp,typeid): |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 315 | cursor=c.cursor() |
| 316 | result=cursor.execute(benchCmdColumns % (benchTable)) |
| 317 | cols= [member[0] for member in cursor.description] |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 318 | keepCols = ['name'] + [c for c in diff(cols , REMOVECOLUMNS) if isNotIDColumn(c)] |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 319 | keepColsStr = "".join(joinit(keepCols,",")) |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 320 | vals=(comp,typeid,runid) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 321 | result=cursor.execute(benchCmdForCompiler % (keepColsStr,benchTable),vals) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 322 | vals =np.array([list(x) for x in list(result)]) |
| 323 | return(keepCols,vals) |
| 324 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 325 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 326 | |
| 327 | PARAMS=["NB","NumTaps", "NBA", "NBB", "Factor", "NumStages","VECDIM","NBR","NBC","NBI","IFFT", "BITREV"] |
| 328 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 329 | def regressionTableFor(byname,name,section,ref,toSort,indexCols,field): |
| 330 | data=ref.pivot_table(index=indexCols, columns=byname, |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 331 | values=[field], aggfunc='first') |
| 332 | |
| 333 | data=data.sort_values(toSort) |
| 334 | |
| 335 | cores = [c[1] for c in list(data.columns)] |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 336 | columns = diff(indexCols,['name']) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 337 | |
Christophe Favergeon | 34d313a | 2020-05-14 15:09:41 +0200 | [diff] [blame] | 338 | dataTable=Table(columns,cores) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 339 | section.addContent(dataTable) |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 340 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 341 | 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 Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 349 | if field=="MAXREGCOEF": |
| 350 | row=[("%.3f" % x) for x in row] |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 351 | dataTable.addRow(row) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 352 | return(None) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 353 | else: |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 354 | if field=="MAXREGCOEF": |
| 355 | dataForFunc=[("%.3f" % x) for x in dataForFunc] |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 356 | dataTable.addRow(dataForFunc) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 357 | return(list(zip(cores,dataForFunc))) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 358 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 359 | def formatColumnName(c): |
| 360 | return("".join(joinit(c,":"))) |
| 361 | |
| 362 | def 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 | |
| 368 | def 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 | |
| 374 | def 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 | |
| 411 | def formatTableBy(desc,byname,section,typeSection,testNames,cols,vals): |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 412 | if vals.size != 0: |
| 413 | ref=pd.DataFrame(vals,columns=cols) |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 414 | toSort=["name"] |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 415 | |
| 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 Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 425 | indexCols=diff(cols,byname + ['Regression','MAXREGCOEF','MAX'] + section) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 426 | valList = ['Regression'] |
| 427 | else: |
| 428 | ref['CYCLES']=pd.to_numeric(ref['CYCLES']) |
| 429 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 430 | indexCols=diff(cols,byname + ['CYCLES'] + section) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 431 | valList = ['CYCLES'] |
| 432 | |
| 433 | |
| 434 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 435 | for testid,name in testNames: |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 436 | if args.r: |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 437 | testSection = Section(name) |
| 438 | typeSection.addSection(testSection) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 439 | |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 440 | maxCyclesSection = Section("Max cycles") |
| 441 | testSection.addSection(maxCyclesSection) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 442 | 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 Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 455 | |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 456 | maxRegCoefSection = Section("Max Reg Coef") |
| 457 | testSection.addSection(maxRegCoefSection) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 458 | regressionTableFor(byname,name,maxRegCoefSection,ref,toSort,indexCols,'MAXREGCOEF') |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 459 | |
| 460 | else: |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 461 | data=ref.pivot_table(index=indexCols, columns=byname, |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 462 | values=valList, aggfunc='first') |
| 463 | |
| 464 | data=data.sort_values(toSort) |
| 465 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 466 | #print(list(data.columns)) |
| 467 | columnsID = [formatColumnName(c[1:]) for c in list(data.columns)] |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 468 | columns = diff(indexCols,['name']) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 469 | |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 470 | testSection = Section(name) |
| 471 | typeSection.addSection(testSection) |
| 472 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 473 | dataTable=Table(columns,columnsID) |
| 474 | testSection.addContent(dataTable) |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 475 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 476 | 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 Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 484 | dataTable.addRow(row) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 485 | else: |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 486 | dataTable.addRow(dataForFunc) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 487 | |
| 488 | # Add a report for each table |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 489 | def addReportFor(document,runid,benchName): |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 490 | nbElems = getNbElemsInBenchCmd(benchName) |
| 491 | if nbElems > 0: |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 492 | categoryName = getCategoryName(benchName,runid) |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 493 | benchSection = Section(categoryName) |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 494 | document.addSection(benchSection) |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 495 | print("Process %s\n" % benchName) |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 496 | 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 Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 502 | typeSection = Section(typeName) |
| 503 | benchSection.addSection(typeSection) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame^] | 504 | 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 Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 535 | |
| 536 | |
| 537 | |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 538 | toc=[Hierarchy("BasicMathsBenchmarks"), |
| 539 | Hierarchy("ComplexMathsBenchmarks"), |
| 540 | Hierarchy("FastMath"), |
| 541 | Hierarchy("Filters", |
| 542 | [Hierarchy("FIR"), |
| 543 | Hierarchy("BIQUAD"), |
| 544 | Hierarchy("DECIM"), |
| 545 | Hierarchy("MISC")]), |
| 546 | |
| 547 | Hierarchy("Support Functions", |
| 548 | [Hierarchy("Support"), |
| 549 | Hierarchy("SupportBar")]), |
| 550 | |
| 551 | Hierarchy("Matrix Operations" , |
| 552 | [Hierarchy("Binary"), |
| 553 | Hierarchy("Unary")]), |
| 554 | Hierarchy("Transform"), |
| 555 | |
| 556 | ] |
| 557 | |
| 558 | processed=[] |
| 559 | |
| 560 | def 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 Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 570 | |
| 571 | try: |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 572 | benchtables=getBenchTables() |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 573 | theDate = getrunIDDate(runid) |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 574 | document = Document(runid,theDate) |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 575 | 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 Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 584 | with open(args.o,"w") as output: |
| 585 | if args.t=="md": |
| 586 | document.accept(Markdown(output)) |
| 587 | if args.t=="html": |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 588 | document.accept(HTML(output,args.r)) |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 589 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 590 | finally: |
| 591 | c.close() |
| 592 | |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 593 | |
| 594 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 595 | |