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 | 66de4ac | 2020-07-31 13:38:09 +0200 | [diff] [blame] | 8 | import os.path |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 9 | |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 10 | refCoreName="" |
| 11 | |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 12 | runidCMD = "runid = ?" |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 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 | fe27d87 | 2020-07-31 07:20:18 +0200 | [diff] [blame] | 22 | # Command to get last runid |
| 23 | runIDDetails="""SELECT distinct core FROM %s |
| 24 | INNER JOIN CORE USING(coreid) |
| 25 | WHERE %s |
| 26 | """ |
| 27 | |
Christophe Favergeon | 0e0449a | 2020-07-28 09:44:14 +0200 | [diff] [blame] | 28 | def joinit(iterable, delimiter): |
| 29 | # Intersperse a delimiter between element of a list |
| 30 | it = iter(iterable) |
| 31 | yield next(it) |
| 32 | for x in it: |
| 33 | yield delimiter |
| 34 | yield x |
| 35 | |
| 36 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 37 | def getLastRunID(): |
| 38 | r=c.execute(lastID) |
| 39 | return(int(r.fetchone()[0])) |
| 40 | |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 41 | def getrunIDDate(forID): |
| 42 | r=c.execute(lastIDAndDate,(forID,)) |
| 43 | return(r.fetchone()[0]) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 44 | |
Christophe Favergeon | fe27d87 | 2020-07-31 07:20:18 +0200 | [diff] [blame] | 45 | |
| 46 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 47 | |
| 48 | parser = argparse.ArgumentParser(description='Generate summary benchmarks') |
| 49 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 50 | parser.add_argument('-b', nargs='?',type = str, default="bench.db", help="Database") |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 51 | parser.add_argument('-o', nargs='?',type = str, default="full.md", help="Full summary") |
| 52 | parser.add_argument('-r', action='store_true', help="Regression database") |
Christophe Favergeon | fe27d87 | 2020-07-31 07:20:18 +0200 | [diff] [blame] | 53 | parser.add_argument('-t', nargs='?',type = str, default="md", help="type md or html") |
| 54 | parser.add_argument('-byc', action='store_true', help="Result oganized by Compiler") |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 55 | parser.add_argument('-g', action='store_true', help="Include graphs in regression report") |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 56 | |
Christophe Favergeon | fe27d87 | 2020-07-31 07:20:18 +0200 | [diff] [blame] | 57 | parser.add_argument('-details', action='store_true', help="Details about runids") |
| 58 | parser.add_argument('-lastid', action='store_true', help="Get last ID") |
Christophe Favergeon | 66de4ac | 2020-07-31 13:38:09 +0200 | [diff] [blame] | 59 | parser.add_argument('-comments', nargs='?',type = str, default="comments.txt", help="Comment section") |
Christophe Favergeon | f1a8780 | 2020-08-17 07:36:05 +0200 | [diff] [blame] | 60 | parser.add_argument('-byd', action='store_true', help="Result oganized by datatype") |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 61 | parser.add_argument('-ratio', action='store_true', help="Compute ratios for regression by core instead of cycles") |
| 62 | parser.add_argument('-ref', nargs='?',type = str, default="M55", help="Reference COREDEF for ratio in db") |
| 63 | parser.add_argument('-clampval', nargs='?',type = float, default=8.0, help="Clamp for ratio") |
| 64 | parser.add_argument('-clamp', action='store_true', help="Clamp enabled for ratio") |
| 65 | parser.add_argument('-keep', nargs='?',type = str, help="Core to keep for ratio") |
Christophe Favergeon | fe27d87 | 2020-07-31 07:20:18 +0200 | [diff] [blame] | 66 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 67 | # For runid or runid range |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 68 | parser.add_argument('others', nargs=argparse.REMAINDER,help="Run ID") |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 69 | |
| 70 | args = parser.parse_args() |
| 71 | |
| 72 | c = sqlite3.connect(args.b) |
| 73 | |
| 74 | if args.others: |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 75 | vals=[] |
| 76 | runidCMD=[] |
| 77 | runidHeader=[] |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 78 | runidVIEWcmd=[] |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 79 | for t in args.others: |
| 80 | if re.search(r'-',t): |
| 81 | bounds=[int(x) for x in t.split("-")] |
| 82 | vals += bounds |
| 83 | runidHeader += ["%d <= runid <= %d" % tuple(bounds)] |
| 84 | runidCMD += ["(runid >= ? AND runid <= ?)"] |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 85 | runidVIEWcmd += ["(runid >= %d AND runid <= %d) " % tuple(bounds)] |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 86 | else: |
| 87 | theid=int(t) |
| 88 | runidHeader += ["runid == %d" % theid] |
| 89 | runidCMD += ["runid == ?"] |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 90 | runidVIEWcmd += ["runid == %d" % theid] |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 91 | vals.append(theid) |
| 92 | |
| 93 | runidval = tuple(vals) |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 94 | runidHeader = "(" + "".join(joinit(runidHeader," OR ")) + ")" |
| 95 | runidCMD = "(" + "".join(joinit(runidCMD," OR ")) + ")" |
| 96 | runidVIEWcmd = "(" + "".join(joinit(runidVIEWcmd," OR ")) + ")" |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 97 | else: |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 98 | theid=getLastRunID() |
| 99 | print("Last run ID = %d\n" % theid) |
| 100 | runidval=(theid,) |
| 101 | runidHeader="%d" % theid |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 102 | runidVIEWcmd="(runid = %d)" % theid |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 103 | |
Christophe Favergeon | fe27d87 | 2020-07-31 07:20:18 +0200 | [diff] [blame] | 104 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 105 | # We extract data only from data tables |
| 106 | # Those tables below are used for descriptions |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 107 | REMOVETABLES=['TESTNAME','TESTDATE','RUN','CORE', 'PLATFORM', 'COMPILERKIND', 'COMPILER', 'TYPE', 'CATEGORY', 'CONFIG'] |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 108 | |
| 109 | # This is assuming the database is generated by the regression script |
| 110 | # So platform is the same for all benchmarks. |
| 111 | # Category and type is coming from the test name in the yaml |
| 112 | # So no need to add this information here |
| 113 | # Name is removed here because it is added at the beginning |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 114 | 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] | 115 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 116 | REMOVECOLUMNSFORHISTORY=['Regression','MAXREGCOEF','name','type','platform','category','coredef','OPTIMIZED','HARDFP','FASTMATH','NEON','HELIUM','UNROLL','ROUNDING','DATE','compilerkindid','date','categoryid', 'ID', 'platformid', 'coreid', 'compilerid', 'typeid'] |
| 117 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 118 | # Get existing benchmark tables |
| 119 | def getBenchTables(): |
| 120 | r=c.execute("SELECT name FROM sqlite_master WHERE type='table'") |
| 121 | benchtables=[] |
| 122 | for table in r: |
| 123 | if not table[0] in REMOVETABLES: |
| 124 | benchtables.append(table[0]) |
| 125 | return(benchtables) |
| 126 | |
| 127 | # get existing types in a table |
| 128 | def getExistingTypes(benchTable): |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 129 | r=c.execute("select distinct typeid from %s WHERE %s order by typeid desc " % (benchTable,runidCMD),runidval).fetchall() |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 130 | result=[x[0] for x in r] |
| 131 | return(result) |
| 132 | |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 133 | # Get existing cores in a table |
| 134 | def getAllExistingCores(benchTable): |
| 135 | r=c.execute("select distinct coreid from %s WHERE %s order by coreid desc " % (benchTable,runidCMD),runidval).fetchall() |
| 136 | result=[x[0] for x in r] |
| 137 | return(result) |
| 138 | |
Christophe Favergeon | fe27d87 | 2020-07-31 07:20:18 +0200 | [diff] [blame] | 139 | def getrunIDDetails(): |
| 140 | tables=getBenchTables() |
| 141 | r=[] |
| 142 | for table in tables: |
| 143 | r += [x[0] for x in c.execute(runIDDetails % (table,runidCMD),runidval).fetchall()] |
| 144 | r=list(set(r)) |
| 145 | print(r) |
| 146 | |
| 147 | if args.lastid: |
| 148 | quit() |
| 149 | |
| 150 | if args.details: |
| 151 | getrunIDDetails() |
| 152 | quit() |
| 153 | |
| 154 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 155 | # Get compilers from specific type and table |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 156 | allCompilers="""select distinct compilerid from %s WHERE typeid=?""" |
| 157 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 158 | # Get compilers from specific type and table |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 159 | allCompilerForCore="""select distinct compilerid from %s WHERE coreid=?""" |
| 160 | |
| 161 | # Get compilers from specific type and table |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 162 | allCores="""select distinct coreid from %s WHERE typeid=? AND (%s)""" |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 163 | |
| 164 | |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 165 | compilerDesc="""select compiler,version from COMPILER |
| 166 | INNER JOIN COMPILERKIND USING(compilerkindid) WHERE compilerid=?""" |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 167 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 168 | coreDesc="""select core from CORE WHERE coreid=?""" |
| 169 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 170 | # Get existing compiler in a table for a specific type |
| 171 | # (In case report is structured by types) |
| 172 | def getExistingCompiler(benchTable,typeid): |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 173 | r=c.execute(allCompilers % benchTable,(typeid,)).fetchall() |
| 174 | return([x[0] for x in r]) |
| 175 | |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 176 | |
| 177 | # Get existing compiler in a table for a specific core |
| 178 | # (In case report is structured by core) |
| 179 | def getExistingCompilerForCore(benchTable,coreid): |
| 180 | r=c.execute(allCompilerForCore % benchTable,(coreid,)).fetchall() |
| 181 | return([x[0] for x in r]) |
| 182 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 183 | def getExistingCores(benchTable,typeid): |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 184 | vals = (typeid,) + runidval |
| 185 | r=c.execute(allCores % (benchTable,runidCMD),vals).fetchall() |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 186 | return([x[0] for x in r]) |
| 187 | |
| 188 | |
| 189 | |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 190 | def getCoreDesc(coreid): |
| 191 | r=c.execute(coreDesc,(coreid,)).fetchone() |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 192 | return(r) |
| 193 | |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 194 | def getCompilerDesc(compilerid): |
| 195 | r=c.execute(compilerDesc,(compilerid,)).fetchone() |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 196 | return(r) |
| 197 | |
| 198 | # Get type name from type id |
| 199 | def getTypeName(typeid): |
| 200 | r=c.execute("select type from TYPE where typeid=?",(typeid,)).fetchone() |
| 201 | return(r[0]) |
| 202 | |
| 203 | # Diff of 2 lists |
| 204 | def diff(first, second): |
| 205 | second = set(second) |
| 206 | return [item for item in first if item not in second] |
| 207 | |
| 208 | |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 209 | # Command to get data for specific compiler |
| 210 | # and type |
| 211 | benchCmdForCoreCompiler="""select %s from %s |
| 212 | INNER JOIN CATEGORY USING(categoryid) |
| 213 | INNER JOIN PLATFORM USING(platformid) |
| 214 | INNER JOIN CORE USING(coreid) |
| 215 | INNER JOIN COMPILER USING(compilerid) |
| 216 | INNER JOIN COMPILERKIND USING(compilerkindid) |
| 217 | INNER JOIN TYPE USING(typeid) |
| 218 | INNER JOIN TESTNAME USING(testnameid) |
| 219 | WHERE coreid=? AND compilerid = ? AND (%s) |
| 220 | """ |
| 221 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 222 | # Command to get data for specific core |
| 223 | # and type |
| 224 | historyCmd="""select %s from %s |
| 225 | INNER JOIN CATEGORY USING(categoryid) |
| 226 | INNER JOIN PLATFORM USING(platformid) |
| 227 | INNER JOIN CORE USING(coreid) |
| 228 | INNER JOIN COMPILER USING(compilerid) |
| 229 | INNER JOIN COMPILERKIND USING(compilerkindid) |
| 230 | INNER JOIN TYPE USING(typeid) |
| 231 | INNER JOIN TESTNAME USING(testnameid) |
| 232 | WHERE compilerid=? AND coreid=? AND typeid = ? AND ID = ? AND runid > (? - 10) |
| 233 | """ |
| 234 | |
| 235 | compilersForHistory="""select distinct compilerid,compiler,version from %s |
| 236 | INNER JOIN COMPILER USING(compilerid) |
| 237 | INNER JOIN COMPILERKIND USING(compilerkindid) |
| 238 | WHERE coreid=? AND typeid = ? AND ID = ? AND runid > (? - 10) |
| 239 | """ |
| 240 | |
| 241 | # Command to get data for specific core |
| 242 | # and type |
| 243 | benchCmdForCore="""select %s from %s |
| 244 | INNER JOIN CATEGORY USING(categoryid) |
| 245 | INNER JOIN PLATFORM USING(platformid) |
| 246 | INNER JOIN CORE USING(coreid) |
| 247 | INNER JOIN COMPILER USING(compilerid) |
| 248 | INNER JOIN COMPILERKIND USING(compilerkindid) |
| 249 | INNER JOIN TYPE USING(typeid) |
| 250 | INNER JOIN TESTNAME USING(testnameid) |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 251 | WHERE coreid=? AND typeid = ? AND (%s) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 252 | """ |
| 253 | |
| 254 | coresForHistory="""select distinct coreid,core from %s |
| 255 | INNER JOIN CORE USING(coreid) |
| 256 | WHERE compilerid=? AND typeid = ? AND ID = ? AND runid > (? - 10) |
| 257 | """ |
| 258 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 259 | # Command to get data for specific compiler |
| 260 | # and type |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 261 | benchCmdForCompiler="""select %s from %s |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 262 | INNER JOIN CATEGORY USING(categoryid) |
| 263 | INNER JOIN PLATFORM USING(platformid) |
| 264 | INNER JOIN CORE USING(coreid) |
| 265 | INNER JOIN COMPILER USING(compilerid) |
| 266 | INNER JOIN COMPILERKIND USING(compilerkindid) |
| 267 | INNER JOIN TYPE USING(typeid) |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 268 | INNER JOIN TESTNAME USING(testnameid) |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 269 | WHERE compilerid=? AND typeid = ? AND (%s) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 270 | """ |
| 271 | |
| 272 | # Command to get test names for specific compiler |
| 273 | # and type |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 274 | benchNamesForCore="""select distinct name from %s |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 275 | INNER JOIN COMPILER USING(compilerid) |
| 276 | INNER JOIN COMPILERKIND USING(compilerkindid) |
| 277 | INNER JOIN TYPE USING(typeid) |
| 278 | INNER JOIN TESTNAME USING(testnameid) |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 279 | WHERE coreid=? AND typeid = ? AND (%s) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 280 | """ |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 281 | |
| 282 | # Command to get test names for specific core |
| 283 | # and compiler |
| 284 | benchNamesForCoreCompiler="""select distinct name from %s |
| 285 | INNER JOIN COMPILER USING(compilerid) |
| 286 | INNER JOIN COMPILERKIND USING(compilerkindid) |
| 287 | INNER JOIN TYPE USING(typeid) |
| 288 | INNER JOIN TESTNAME USING(testnameid) |
| 289 | WHERE coreid=? AND compilerid = ? AND (%s) |
| 290 | """ |
| 291 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 292 | # Command to get test names for specific compiler |
| 293 | # and type |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 294 | benchNamesForCompiler="""select distinct name from %s |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 295 | INNER JOIN COMPILER USING(compilerid) |
| 296 | INNER JOIN COMPILERKIND USING(compilerkindid) |
| 297 | INNER JOIN TYPE USING(typeid) |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 298 | INNER JOIN TESTNAME USING(testnameid) |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 299 | WHERE compilerid=? AND typeid = ? AND (%s) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 300 | """ |
| 301 | |
| 302 | # Command to get columns for specific table |
| 303 | benchCmdColumns="""select * from %s |
| 304 | INNER JOIN CATEGORY USING(categoryid) |
| 305 | INNER JOIN PLATFORM USING(platformid) |
| 306 | INNER JOIN CORE USING(coreid) |
| 307 | INNER JOIN COMPILER USING(compilerid) |
| 308 | INNER JOIN COMPILERKIND USING(compilerkindid) |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 309 | INNER JOIN TESTNAME USING(testnameid) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 310 | INNER JOIN TYPE USING(typeid) |
| 311 | """ |
| 312 | |
| 313 | def joinit(iterable, delimiter): |
| 314 | it = iter(iterable) |
| 315 | yield next(it) |
| 316 | for x in it: |
| 317 | yield delimiter |
| 318 | yield x |
| 319 | |
| 320 | # Is not a column name finishing by id |
| 321 | # (often primary key for thetable) |
| 322 | def isNotIDColumn(col): |
| 323 | if re.match(r'^.*id$',col): |
| 324 | return(False) |
| 325 | else: |
| 326 | return(True) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 327 | |
| 328 | # Get test names |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 329 | # for specific core and compiler (for the data) |
| 330 | def getTestNamesForCoreCompiler(benchTable,compilerid,core): |
| 331 | vals=(core,compilerid) + runidval |
| 332 | result=c.execute(benchNamesForCoreCompiler % (benchTable,runidCMD),vals).fetchall() |
| 333 | names=[x[0] for x in list(result)] |
| 334 | return(names) |
| 335 | |
| 336 | # Get test names |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 337 | # for specific typeid and core (for the data) |
| 338 | def getTestNamesForCore(benchTable,core,typeid): |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 339 | vals=(core,typeid) + runidval |
| 340 | result=c.execute(benchNamesForCore % (benchTable,runidCMD),vals).fetchall() |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 341 | names=[x[0] for x in list(result)] |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 342 | return(names) |
| 343 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 344 | # Get test names |
| 345 | # for specific typeid and compiler (for the data) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 346 | def getTestNamesForCompiler(benchTable,comp,typeid): |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 347 | vals=(comp,typeid) + runidval |
| 348 | result=c.execute(benchNamesForCompiler % (benchTable,runidCMD),vals).fetchall() |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 349 | names=[x[0] for x in list(result)] |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 350 | return(names) |
| 351 | |
| 352 | # Command to get data for specific core |
| 353 | # and type |
| 354 | nbElemsInBenchAndTypeAndCoreCmd="""select count(*) from %s |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 355 | WHERE coreid=? AND typeid = ? AND (%s) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 356 | """ |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 357 | |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 358 | # Command to get data for specific compiler |
| 359 | # and type |
| 360 | nbElemsInBenchAndTypeAndCompilerCmd="""select count(*) from %s |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 361 | WHERE compilerid=? AND typeid = ? AND (%s) |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 362 | """ |
| 363 | |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 364 | # Command to get data for specific compiler |
| 365 | # and type |
| 366 | nbElemsInBenchAndCoreAndCompilerCmd="""select count(*) from %s |
| 367 | WHERE compilerid=? AND coreid = ? AND (%s) |
| 368 | """ |
| 369 | |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 370 | nbElemsInBenchAndTypeCmd="""select count(*) from %s |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 371 | WHERE typeid = ? AND (%s) |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 372 | """ |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 373 | nbElemsInBenchAndCoreCmd="""select count(*) from %s |
| 374 | WHERE coreid = ? AND (%s) |
| 375 | """ |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 376 | |
| 377 | nbElemsInBenchCmd="""select count(*) from %s |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 378 | WHERE %s |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 379 | """ |
| 380 | |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 381 | categoryName="""select distinct category from %s |
| 382 | INNER JOIN CATEGORY USING(categoryid) |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 383 | WHERE %s |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 384 | """ |
| 385 | |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 386 | def getCategoryName(benchTable): |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 387 | result=c.execute(categoryName % (benchTable,runidCMD),runidval).fetchone() |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 388 | return(result[0]) |
| 389 | |
Christophe Favergeon | 4f75070 | 2020-05-13 15:56:15 +0200 | [diff] [blame] | 390 | # Get nb elems in a table |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 391 | def getNbElemsInBenchAndTypeAndCoreCmd(benchTable,coreid,typeid): |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 392 | vals=(coreid,typeid) + runidval |
| 393 | result=c.execute(nbElemsInBenchAndTypeAndCoreCmd % (benchTable,runidCMD),vals).fetchone() |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 394 | return(result[0]) |
| 395 | |
| 396 | # Get nb elems in a table |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 397 | def getNbElemsInBenchAndTypeAndCompilerCmd(benchTable,comp,typeid): |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 398 | vals=(comp,typeid) + runidval |
| 399 | result=c.execute(nbElemsInBenchAndTypeAndCompilerCmd % (benchTable,runidCMD),vals).fetchone() |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 400 | return(result[0]) |
| 401 | |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 402 | # Get nb elems in a table |
| 403 | def getNbElemsInBenchAndCoreAndCompilerCmd(benchTable,comp,coreid): |
| 404 | vals=(comp,coreid) + runidval |
| 405 | result=c.execute(nbElemsInBenchAndCoreAndCompilerCmd % (benchTable,runidCMD),vals).fetchone() |
| 406 | return(result[0]) |
| 407 | |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 408 | def getNbElemsInBenchAndTypeCmd(benchTable,typeid): |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 409 | vals=(typeid,) + runidval |
| 410 | result=c.execute(nbElemsInBenchAndTypeCmd % (benchTable,runidCMD),vals).fetchone() |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 411 | return(result[0]) |
| 412 | |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 413 | def getNbElemsInBenchAndCoreCmd(benchTable,coreid): |
| 414 | vals=(coreid,) + runidval |
| 415 | result=c.execute(nbElemsInBenchAndCoreCmd % (benchTable,runidCMD),vals).fetchone() |
| 416 | return(result[0]) |
| 417 | |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 418 | def getNbElemsInBenchCmd(benchTable): |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 419 | result=c.execute(nbElemsInBenchCmd % (benchTable,runidCMD),runidval).fetchone() |
Christophe Favergeon | 4f75070 | 2020-05-13 15:56:15 +0200 | [diff] [blame] | 420 | return(result[0]) |
| 421 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 422 | # Get names of columns and data for a table |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 423 | # for specific typeid and coreid (for the data) |
| 424 | def getColNamesAndHistory(benchTable,compiler,core,typeid,testid): |
| 425 | cursor=c.cursor() |
| 426 | result=cursor.execute(benchCmdColumns % (benchTable)) |
| 427 | cols= [member[0] for member in cursor.description] |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 428 | keepCols = ['name'] + [c for c in diff(cols , REMOVECOLUMNSFORHISTORY) if isNotIDColumn(c)] |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 429 | keepColsStr = "".join(joinit(keepCols,",")) |
| 430 | vals=(compiler,core,typeid,testid,runid) |
| 431 | result=cursor.execute(historyCmd % (keepColsStr,benchTable),vals) |
| 432 | vals =np.array([list(x) for x in list(result)]) |
| 433 | return(keepCols,vals) |
| 434 | |
| 435 | # Get names of columns and data for a table |
| 436 | # for specific typeid and coreid (for the data) |
| 437 | def getColNamesAndDataForCore(benchTable,core,typeid): |
| 438 | cursor=c.cursor() |
| 439 | result=cursor.execute(benchCmdColumns % (benchTable)) |
| 440 | cols= [member[0] for member in cursor.description] |
| 441 | keepCols = ['name'] + [c for c in diff(cols , REMOVECOLUMNS) if isNotIDColumn(c)] |
| 442 | keepColsStr = "".join(joinit(keepCols,",")) |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 443 | vals=(core,typeid) + runidval |
| 444 | result=cursor.execute(benchCmdForCore % (keepColsStr,benchTable,runidCMD),vals) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 445 | vals =np.array([list(x) for x in list(result)]) |
| 446 | return(keepCols,vals) |
| 447 | |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 448 | # Get names of columns and data for a table |
| 449 | # for specific coreid and compilerid (for the data) |
| 450 | def getColNamesAndDataForCoreCompiler(benchTable,compilerid,core): |
| 451 | cursor=c.cursor() |
| 452 | result=cursor.execute(benchCmdColumns % (benchTable)) |
| 453 | cols= [member[0] for member in cursor.description] |
| 454 | keepCols = ['name','type'] + [c for c in diff(cols , REMOVECOLUMNS) if isNotIDColumn(c)] |
| 455 | keepColsStr = "".join(joinit(keepCols,",")) |
| 456 | vals=(core,compilerid) + runidval |
| 457 | result=cursor.execute(benchCmdForCoreCompiler % (keepColsStr,benchTable,runidCMD),vals) |
| 458 | vals =np.array([list(x) for x in list(result)]) |
| 459 | return(keepCols,vals) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 460 | |
| 461 | # Get names of columns and data for a table |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 462 | # for specific typeid and compiler (for the data) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 463 | def getColNamesAndDataForCompiler(benchTable,comp,typeid): |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 464 | cursor=c.cursor() |
| 465 | result=cursor.execute(benchCmdColumns % (benchTable)) |
| 466 | cols= [member[0] for member in cursor.description] |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 467 | keepCols = ['name'] + [c for c in diff(cols , REMOVECOLUMNS) if isNotIDColumn(c)] |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 468 | keepColsStr = "".join(joinit(keepCols,",")) |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 469 | vals=(comp,typeid) + runidval |
| 470 | result=cursor.execute(benchCmdForCompiler % (keepColsStr,benchTable,runidCMD),vals) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 471 | vals =np.array([list(x) for x in list(result)]) |
| 472 | return(keepCols,vals) |
| 473 | |
Christophe Favergeon | 8700f50 | 2020-09-18 14:14:27 +0200 | [diff] [blame^] | 474 | def formatFloat(s): |
| 475 | result=[] |
| 476 | for t in s: |
| 477 | if type(t) is float: |
| 478 | result.append(("%.3f" % t)) |
| 479 | else: |
| 480 | result.append(t) |
| 481 | return(result) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 482 | |
| 483 | PARAMS=["NB","NumTaps", "NBA", "NBB", "Factor", "NumStages","VECDIM","NBR","NBC","NBI","IFFT", "BITREV"] |
| 484 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 485 | def regressionTableFor(byname,name,section,ref,toSort,indexCols,field): |
| 486 | data=ref.pivot_table(index=indexCols, columns=byname, |
Christophe Favergeon | 8700f50 | 2020-09-18 14:14:27 +0200 | [diff] [blame^] | 487 | values=[field], aggfunc='first',fill_value="NA") |
| 488 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 489 | data=data.sort_values(toSort) |
| 490 | |
| 491 | cores = [c[1] for c in list(data.columns)] |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 492 | columns = diff(indexCols,['name']) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 493 | |
Christophe Favergeon | 34d313a | 2020-05-14 15:09:41 +0200 | [diff] [blame] | 494 | dataTable=Table(columns,cores) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 495 | section.addContent(dataTable) |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 496 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 497 | dataForFunc=data.loc[name] |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 498 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 499 | if type(dataForFunc) is pd.DataFrame: |
Christophe Favergeon | 0dcf9a1 | 2020-05-27 15:55:27 +0200 | [diff] [blame] | 500 | bars={'cols':columns,'cores':cores,'data':[]} |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 501 | for row in dataForFunc.itertuples(): |
| 502 | row=list(row) |
| 503 | if type(row[0]) is int: |
| 504 | row=[row[0]] + row[1:] |
| 505 | else: |
| 506 | row=list(row[0]) + row[1:] |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 507 | if field=="MAXREGCOEF": |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 508 | newrow = row |
Christophe Favergeon | 8700f50 | 2020-09-18 14:14:27 +0200 | [diff] [blame^] | 509 | newrow[len(columns):] = formatFloat(row[len(columns):]) |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 510 | row=newrow |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 511 | dataTable.addRow(row) |
Christophe Favergeon | 0dcf9a1 | 2020-05-27 15:55:27 +0200 | [diff] [blame] | 512 | bars['data'].append(row) |
| 513 | return(bars) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 514 | else: |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 515 | if field=="MAXREGCOEF": |
Christophe Favergeon | 8700f50 | 2020-09-18 14:14:27 +0200 | [diff] [blame^] | 516 | dataForFunc=formatFloat(dataForFunc) |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 517 | dataTable.addRow(dataForFunc) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 518 | return(list(zip(cores,dataForFunc))) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 519 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 520 | def formatColumnName(c): |
| 521 | return("".join(joinit(c,":"))) |
| 522 | |
| 523 | def getCoresForHistory(benchTable,compilerid,typeid,testid,runid): |
| 524 | vals=(compilerid,typeid,testid,runid) |
| 525 | result=c.execute(coresForHistory % benchTable,vals).fetchall() |
| 526 | ids=[(x[0],x[1]) for x in list(result)] |
| 527 | return(ids) |
| 528 | |
| 529 | def getCompilerForHistory(benchTable,coreid,typeid,testid,runid): |
| 530 | vals=(coreid,typeid,testid,runid) |
| 531 | result=c.execute(compilersForHistory % benchTable,vals).fetchall() |
| 532 | ids=[(x[0],x[1],x[2]) for x in list(result)] |
| 533 | return(ids) |
| 534 | |
| 535 | def getHistory(desc,testid,indexCols): |
| 536 | benchName,sectionID,typeid,runid = desc |
| 537 | |
| 538 | #print(benchName) |
| 539 | #print(sectionID) |
| 540 | #print(typeid) |
| 541 | #print(testid) |
| 542 | columns = diff(indexCols,['name']) |
| 543 | #print(columns) |
| 544 | if args.byc: |
| 545 | coreid=sectionID |
| 546 | compilerids=getCompilerForHistory(benchName,coreid,typeid,testid,runid) |
| 547 | series={} |
| 548 | for compilerid,compilername,version in compilerids: |
| 549 | result=getColNamesAndHistory(benchName,compilerid,coreid,typeid,testid) |
| 550 | #print("%s:%s" % (compilername,version)) |
| 551 | maxpos = result[0].index('MAX') |
| 552 | lrunid = result[0].index('runid') |
| 553 | r=[[int(x[lrunid]),int(x[maxpos])] for x in result[1:][0]] |
| 554 | series[corename]=r |
| 555 | hist=History(series,runid) |
| 556 | return(hist) |
| 557 | else: |
| 558 | compilerid=sectionID |
| 559 | coreids = getCoresForHistory(benchName,compilerid,typeid,testid,runid) |
| 560 | series={} |
| 561 | for coreid,corename in coreids: |
| 562 | result=getColNamesAndHistory(benchName,compilerid,coreid,typeid,testid) |
| 563 | #print(corename) |
| 564 | maxpos = result[0].index('MAX') |
| 565 | corepos = result[0].index('core') |
| 566 | lrunid = result[0].index('runid') |
| 567 | r=[[int(x[lrunid]),int(x[maxpos])] for x in result[1:][0]] |
| 568 | series[corename]=r |
| 569 | hist=History(series,runid) |
| 570 | return(hist) |
| 571 | |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 572 | def convertRowToInt(r): |
| 573 | result=[] |
| 574 | for e in r: |
| 575 | if type(e) is float: |
| 576 | result.append(int(e)) |
| 577 | else: |
| 578 | result.append(e) |
| 579 | |
| 580 | return(result) |
| 581 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 582 | def formatTableBy(desc,byname,section,typeSection,testNames,cols,vals): |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 583 | if vals.size != 0: |
| 584 | ref=pd.DataFrame(vals,columns=cols) |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 585 | toSort=["name"] |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 586 | |
| 587 | for param in PARAMS: |
| 588 | if param in ref.columns: |
| 589 | ref[param]=pd.to_numeric(ref[param]) |
| 590 | toSort.append(param) |
| 591 | if args.r: |
| 592 | # Regression table |
| 593 | ref['MAX']=pd.to_numeric(ref['MAX']) |
| 594 | ref['MAXREGCOEF']=pd.to_numeric(ref['MAXREGCOEF']) |
| 595 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 596 | indexCols=diff(cols,byname + ['Regression','MAXREGCOEF','MAX'] + section) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 597 | valList = ['Regression'] |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 598 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 599 | else: |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 600 | ref['CYCLES']=pd.to_numeric(ref['CYCLES']).round(decimals=0) |
| 601 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 602 | indexCols=diff(cols,byname + ['CYCLES'] + section) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 603 | valList = ['CYCLES'] |
| 604 | |
| 605 | |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 606 | for name in testNames: |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 607 | if args.r: |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 608 | testSection = Section(name) |
Christophe Favergeon | 8700f50 | 2020-09-18 14:14:27 +0200 | [diff] [blame^] | 609 | testSection.setTest() |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 610 | typeSection.addSection(testSection) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 611 | |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 612 | maxCyclesSection = Section("Max cycles") |
| 613 | testSection.addSection(maxCyclesSection) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 614 | theCycles=regressionTableFor(byname,name,maxCyclesSection,ref,toSort,indexCols,'MAX') |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 615 | if args.g: |
| 616 | if type(theCycles) is dict: |
| 617 | nbParams=len(theCycles['cols']) |
| 618 | for bar in theCycles['data']: |
| 619 | params=bar[0:nbParams] |
| 620 | values=bar[nbParams:] |
| 621 | title=[("%s=%s" % x) for x in list(zip(theCycles['cols'],params))] |
| 622 | title="".join(joinit(title," ")) |
| 623 | sec=Section(title) |
| 624 | maxCyclesSection.addSection(sec) |
| 625 | values=list(zip(theCycles['cores'],values)) |
| 626 | barChart=BarChart(values) |
| 627 | sec.addContent(barChart) |
| 628 | else: |
| 629 | #print(theCycles) |
| 630 | sec=Section("Graph") |
Christophe Favergeon | 0dcf9a1 | 2020-05-27 15:55:27 +0200 | [diff] [blame] | 631 | maxCyclesSection.addSection(sec) |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 632 | barChart=BarChart(theCycles) |
Christophe Favergeon | 0dcf9a1 | 2020-05-27 15:55:27 +0200 | [diff] [blame] | 633 | sec.addContent(barChart) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 634 | |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 635 | #history=getHistory(desc,testid,indexCols) |
| 636 | #testSection.addContent(history) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 637 | |
| 638 | regressionSection = Section("Regression") |
| 639 | testSection.addSection(regressionSection) |
| 640 | regressionTableFor(byname,name,regressionSection,ref,toSort,indexCols,'Regression') |
| 641 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 642 | |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 643 | maxRegCoefSection = Section("Max Reg Coef") |
| 644 | testSection.addSection(maxRegCoefSection) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 645 | regressionTableFor(byname,name,maxRegCoefSection,ref,toSort,indexCols,'MAXREGCOEF') |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 646 | |
| 647 | else: |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 648 | data=ref.pivot_table(index=indexCols, columns=byname, |
Christophe Favergeon | 8700f50 | 2020-09-18 14:14:27 +0200 | [diff] [blame^] | 649 | values=valList, aggfunc='first',fill_value="NA") |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 650 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 651 | data=data.sort_values(toSort) |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 652 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 653 | #print(list(data.columns)) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 654 | |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 655 | testSection = Section(name) |
Christophe Favergeon | 8700f50 | 2020-09-18 14:14:27 +0200 | [diff] [blame^] | 656 | testSection.setTest() |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 657 | typeSection.addSection(testSection) |
| 658 | |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 659 | dataForFunc=data.loc[name] |
| 660 | dataForFunc = dataForFunc.dropna(axis=1) |
| 661 | |
| 662 | columnsID = [formatColumnName(c[1:]) for c in list(dataForFunc.columns)] |
| 663 | columns = diff(indexCols,['name']) |
| 664 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 665 | dataTable=Table(columns,columnsID) |
| 666 | testSection.addContent(dataTable) |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 667 | |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 668 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 669 | if type(dataForFunc) is pd.DataFrame: |
| 670 | for row in dataForFunc.itertuples(): |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 671 | if type(row[0]) is int: |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 672 | row=list([row[0]] + list(row[1:])) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 673 | else: |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 674 | row=list(row[0]) + list(row[1:]) |
| 675 | dataTable.addRow(convertRowToInt(row)) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 676 | else: |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 677 | dataTable.addRow(convertRowToInt(dataForFunc)) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 678 | |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 679 | referenceCoreID = None |
| 680 | |
| 681 | |
| 682 | |
| 683 | coreidSQL="select distinct coreid from CORE where coredef==?" |
| 684 | |
| 685 | def getCoreID(corename): |
| 686 | r=c.execute(coreidSQL,(corename,)) |
| 687 | t=r.fetchone() |
| 688 | if t is None: |
| 689 | print("Unrecognized reference core") |
| 690 | quit() |
| 691 | return(t[0]) |
| 692 | |
| 693 | refCore="""CREATE TEMP VIEW if not exists refCore AS |
| 694 | select * from %s where (coreid = %s) and (typeid = %s) |
| 695 | and %s |
| 696 | and compilerid = %s""" |
| 697 | |
| 698 | allOtherCores="""CREATE TEMP VIEW if not exists otherCore AS |
| 699 | select * from %s where (coreid != %s) and (typeid = %s) |
| 700 | and %s |
| 701 | and compilerid = %s""" |
| 702 | |
| 703 | otherCore="""CREATE TEMP VIEW if not exists otherCore AS |
| 704 | select * from %s where (coreid = %s) and (typeid = %s) |
| 705 | and %s |
| 706 | and compilerid = %s""" |
| 707 | |
| 708 | refCoreAllTypes="""CREATE TEMP VIEW if not exists refCore AS |
| 709 | select * from %s where (coreid = %s) |
| 710 | and %s |
| 711 | and compilerid = %s""" |
| 712 | |
| 713 | otherCoreAllTypes="""CREATE TEMP VIEW if not exists otherCore AS |
| 714 | select * from %s where (coreid = %s) |
| 715 | and %s |
| 716 | and compilerid = %s""" |
| 717 | |
| 718 | |
| 719 | ratioSQL="""select name,otherCore.compilerid as compilerid,CORE.core as core,%s(CAST(otherCore.MAX as FLOAT) / CAST(refCore.MAX AS FLOAT)) AS RATIO |
| 720 | from otherCore |
| 721 | INNER JOIN refCore ON (refCore.categoryid = otherCore.categoryid |
| 722 | AND refCore.testnameid = otherCore.testnameid |
| 723 | AND refCore.typeid = otherCore.typeid |
| 724 | AND refCore.runid = otherCore.runid |
| 725 | AND refCore.compilerid = otherCore.compilerid |
| 726 | ) |
| 727 | INNER JOIN TESTNAME ON TESTNAME.testnameid = refCore.testnameid |
| 728 | INNER JOIN CORE USING(coreid) |
| 729 | %s""" |
| 730 | |
| 731 | ratioSQLAllTypes="""select name,otherCore.compilerid as compilerid,TYPE.type as type,%s(CAST(otherCore.MAX as FLOAT) / CAST(refCore.MAX AS FLOAT)) AS RATIO |
| 732 | from otherCore |
| 733 | INNER JOIN refCore ON (refCore.categoryid = otherCore.categoryid |
| 734 | AND refCore.testnameid = otherCore.testnameid |
| 735 | AND refCore.typeid = otherCore.typeid |
| 736 | AND refCore.runid = otherCore.runid |
| 737 | AND refCore.compilerid = otherCore.compilerid |
| 738 | ) |
| 739 | INNER JOIN TESTNAME ON TESTNAME.testnameid = refCore.testnameid |
| 740 | INNER JOIN TYPE USING(typeid) |
| 741 | %s""" |
| 742 | |
| 743 | ratioTestNamesSQL="""select distinct TESTNAME.name |
| 744 | from otherCore |
| 745 | INNER JOIN refCore ON (refCore.categoryid = otherCore.categoryid |
| 746 | AND refCore.testnameid = otherCore.testnameid |
| 747 | AND refCore.typeid = otherCore.typeid |
| 748 | AND refCore.runid = otherCore.runid |
| 749 | AND refCore.compilerid = otherCore.compilerid |
| 750 | ) |
| 751 | INNER JOIN TESTNAME ON TESTNAME.testnameid = refCore.testnameid |
| 752 | INNER JOIN CORE USING(coreid) |
| 753 | %s""" |
| 754 | |
| 755 | |
| 756 | dropViewsRef="""drop view refCore""" |
| 757 | |
| 758 | dropViewsOther="""drop view otherCore""" |
| 759 | |
| 760 | def getTableParams(benchTable): |
| 761 | cursor=c.cursor() |
| 762 | result=cursor.execute("select * from %s limit 1" % (benchTable)) |
| 763 | cols= [member[0] for member in cursor.description] |
| 764 | params=[] |
| 765 | for x in cols: |
| 766 | if x in PARAMS: |
| 767 | params.append(x) |
| 768 | return(params) |
| 769 | |
| 770 | def computeRatio(benchName,viewParams,refMkViewCmd,otherMkViewCmd,byd): |
| 771 | params = getTableParams(benchName) |
| 772 | cols=["ratio"] |
| 773 | paramscmd="" |
| 774 | paramscols="" |
| 775 | paramsnames = ["refCore.%s as %s" % (x,x) for x in params] |
| 776 | paramseq = ["refCore.%s = otherCore.%s" % (x,x) for x in params] |
| 777 | if len(params) > 0: |
| 778 | cols = ["%s" % x for x in params] |
| 779 | cols.append("ratio") |
| 780 | paramscols= ("".join(joinit(paramsnames," , ")) + ",") |
| 781 | paramscmd = "WHERE " + "".join(joinit(paramseq," AND ")) |
| 782 | if byd: |
| 783 | ratioCmd = ratioSQLAllTypes % (paramscols,paramscmd) |
| 784 | else: |
| 785 | ratioCmd = ratioSQL % (paramscols,paramscmd) |
| 786 | ratioTestNames = ratioTestNamesSQL % (paramscmd) |
| 787 | |
| 788 | #print(refMkViewCmd) |
| 789 | #print(otherMkViewCmd) |
| 790 | # |
| 791 | #print(ratioCmd) |
| 792 | # |
| 793 | #print(dropViewsRef) |
| 794 | #print(dropViewsOther) |
| 795 | #quit() |
| 796 | |
| 797 | c.execute(refMkViewCmd) |
| 798 | c.execute(otherMkViewCmd) |
| 799 | |
| 800 | ratio=c.execute(ratioCmd).fetchall() |
| 801 | testNames=c.execute(ratioTestNames).fetchall() |
| 802 | testNames=[x[0] for x in testNames] |
| 803 | |
| 804 | c.execute(dropViewsRef) |
| 805 | c.execute(dropViewsOther) |
| 806 | |
| 807 | #print(ratio) |
| 808 | #quit() |
| 809 | if byd: |
| 810 | return(['name','compilerid','type'] + cols,params,ratio,testNames) |
| 811 | else: |
| 812 | return(['name','compilerid','core'] + cols,params,ratio,testNames) |
| 813 | |
| 814 | # Compute for all core for a given type |
| 815 | def computeRatioTable(benchName,referenceCore,typeID,compiler): |
| 816 | viewParams = (benchName,referenceCore,typeID,runidVIEWcmd,compiler) |
| 817 | refMkViewCmd = refCore % viewParams |
| 818 | otherMkViewCmd = allOtherCores % viewParams |
| 819 | if args.keep: |
| 820 | keepCoreID = getCoreID(args.keep) |
| 821 | otherParams = (benchName,keepCoreID,typeID,runidVIEWcmd,compiler) |
| 822 | otherMkViewCmd = otherCore % otherParams |
| 823 | return(computeRatio(benchName,viewParams,refMkViewCmd,otherMkViewCmd,False)) |
| 824 | |
| 825 | |
| 826 | def computeRatioTableForCore(benchName,referenceCore,otherCoreID,compiler): |
| 827 | viewParams = (benchName,referenceCore,runidVIEWcmd,compiler) |
| 828 | refMkViewCmd = refCoreAllTypes % viewParams |
| 829 | otherParams = (benchName,otherCoreID,runidVIEWcmd,compiler) |
| 830 | otherMkViewCmd = otherCoreAllTypes % otherParams |
| 831 | return(computeRatio(benchName,viewParams,refMkViewCmd,otherMkViewCmd,True)) |
| 832 | |
| 833 | def formatPerfRatio(s): |
| 834 | result=[] |
| 835 | for t in s: |
| 836 | if type(t) is float: |
| 837 | if args.clamp: |
| 838 | if t > args.clampval: |
| 839 | t = args.clampval |
Christophe Favergeon | 0adf05c | 2020-08-19 07:04:32 +0200 | [diff] [blame] | 840 | if t < 0.0: |
| 841 | result.append("NA") |
| 842 | else: |
| 843 | result.append(("%.3f" % t)) |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 844 | else: |
| 845 | result.append(s) |
| 846 | |
| 847 | return(result) |
| 848 | |
Christophe Favergeon | 8700f50 | 2020-09-18 14:14:27 +0200 | [diff] [blame^] | 849 | |
| 850 | |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 851 | def addRatioTable(cols,params,data,section,testNames,byd): |
| 852 | ref=pd.DataFrame(data,columns=cols) |
| 853 | toSort=["name"] + params |
| 854 | for param in PARAMS: |
| 855 | if param in ref.columns: |
| 856 | ref[param]=pd.to_numeric(ref[param]) |
| 857 | |
| 858 | #print(testNames) |
| 859 | for name in testNames: |
| 860 | testSection = Section(name) |
Christophe Favergeon | 8700f50 | 2020-09-18 14:14:27 +0200 | [diff] [blame^] | 861 | testSection.setTest() |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 862 | section.addSection(testSection) |
| 863 | |
| 864 | ratioSection = Section("Ratios") |
| 865 | testSection.addSection(ratioSection) |
| 866 | |
| 867 | #print(toSort) |
| 868 | #print(ref) |
| 869 | |
| 870 | if byd: |
| 871 | data=ref.pivot_table(index=toSort, columns=['type'], |
Christophe Favergeon | 0adf05c | 2020-08-19 07:04:32 +0200 | [diff] [blame] | 872 | values=["ratio"], aggfunc='first',fill_value=-1.0) |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 873 | else: |
| 874 | data=ref.pivot_table(index=toSort, columns=['core'], |
| 875 | values=["ratio"], aggfunc='first') |
| 876 | |
| 877 | data=data.sort_values(toSort) |
| 878 | |
| 879 | #print(data) |
| 880 | dataForFunc=data.loc[name] |
| 881 | |
| 882 | cores = [c[1] for c in list(data.columns)] |
| 883 | |
| 884 | dataTable=Table(params,cores) |
| 885 | |
Christophe Favergeon | 0adf05c | 2020-08-19 07:04:32 +0200 | [diff] [blame] | 886 | if args.g: |
| 887 | if type(dataForFunc) is not pd.DataFrame: |
| 888 | sec=Section("Graph") |
| 889 | testSection.addSection(sec) |
| 890 | |
| 891 | barChart=BarChart(zip(cores,dataForFunc)) |
| 892 | sec.addContent(barChart) |
| 893 | |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 894 | ratioSection.addContent(Text("A bigger ratio means the reference core \"%s\" is better" % refCoreName)) |
| 895 | |
| 896 | ratioSection.addContent(dataTable) |
| 897 | |
| 898 | if type(dataForFunc) is pd.DataFrame: |
| 899 | for row in dataForFunc.itertuples(): |
| 900 | row=list(row) |
| 901 | if type(row[0]) is int: |
| 902 | row=[row[0]] + formatPerfRatio(row[1:]) |
| 903 | else: |
| 904 | row=list(row[0]) + formatPerfRatio(row[1:]) |
| 905 | dataTable.addRow(row) |
| 906 | else: |
| 907 | row=list(dataForFunc) |
| 908 | dataTable.addRow(formatPerfRatio(row)) |
| 909 | |
| 910 | |
| 911 | |
| 912 | |
| 913 | |
| 914 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 915 | # Add a report for each table |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 916 | def addReportFor(document,benchName): |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 917 | nbElems = getNbElemsInBenchCmd(benchName) |
| 918 | if nbElems > 0: |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 919 | categoryName = getCategoryName(benchName) |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 920 | benchSection = Section(categoryName) |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 921 | document.addSection(benchSection) |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 922 | print("Process %s\n" % benchName) |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 923 | if args.byd: |
| 924 | allCores=getAllExistingCores(benchName) |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 925 | if args.ratio: |
| 926 | allCores.remove(referenceCoreID) |
| 927 | if args.keep: |
| 928 | allCores=[getCoreID(args.keep)] |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 929 | for aCoreID in allCores: |
| 930 | nbElems = getNbElemsInBenchAndCoreCmd(benchName,aCoreID) |
| 931 | if nbElems > 0: |
| 932 | coreName=getCoreDesc(aCoreID) |
| 933 | coreSection = Section("%s" % coreName) |
| 934 | benchSection.addSection(coreSection) |
| 935 | allCompilers = getExistingCompilerForCore(benchName,aCoreID) |
| 936 | for compiler in allCompilers: |
| 937 | #print(compiler) |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 938 | if args.ratio: |
| 939 | cols,params,ratios,testNames=computeRatioTableForCore(benchName,referenceCoreID,aCoreID,compiler) |
| 940 | #print(cols) |
| 941 | #print(ratios) |
| 942 | #print(" ") |
| 943 | if len(ratios)>0: |
| 944 | compilerName,version=getCompilerDesc(compiler) |
| 945 | compilerSection = Section("%s (%s)" % (compilerName,version)) |
| 946 | coreSection.addSection(compilerSection) |
| 947 | addRatioTable(cols,params,ratios,compilerSection,testNames,True) |
| 948 | |
| 949 | else: |
| 950 | nbElems = getNbElemsInBenchAndCoreAndCompilerCmd(benchName,compiler,aCoreID) |
| 951 | |
| 952 | # Print test results for table, type, compiler |
| 953 | if nbElems > 0: |
| 954 | compilerName,version=getCompilerDesc(compiler) |
| 955 | compilerSection = Section("%s (%s)" % (compilerName,version)) |
| 956 | coreSection.addSection(compilerSection) |
| 957 | cols,vals=getColNamesAndDataForCoreCompiler(benchName,compiler,aCoreID) |
| 958 | desc=(benchName,compiler,aCoreID) |
| 959 | names=getTestNamesForCoreCompiler(benchName,compiler,aCoreID) |
| 960 | |
| 961 | formatTableBy(desc,['type'],['core','version','compiler'],compilerSection,names,cols,vals) |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 962 | |
| 963 | else: |
| 964 | allTypes = getExistingTypes(benchName) |
| 965 | # Add report for each type |
| 966 | for aTypeID in allTypes: |
| 967 | nbElems = getNbElemsInBenchAndTypeCmd(benchName,aTypeID) |
| 968 | if nbElems > 0: |
| 969 | typeName = getTypeName(aTypeID) |
| 970 | typeSection = Section(typeName) |
| 971 | benchSection.addSection(typeSection) |
| 972 | if args.byc: |
| 973 | ## Add report for each core |
| 974 | allCores = getExistingCores(benchName,aTypeID) |
| 975 | for core in allCores: |
| 976 | #print(core) |
| 977 | nbElems = getNbElemsInBenchAndTypeAndCoreCmd(benchName,core,aTypeID) |
| 978 | # Print test results for table, type, compiler |
| 979 | if nbElems > 0: |
| 980 | coreName=getCoreDesc(core) |
| 981 | coreSection = Section("%s" % coreName) |
| 982 | typeSection.addSection(coreSection) |
| 983 | cols,vals=getColNamesAndDataForCore(benchName,core,aTypeID) |
| 984 | desc=(benchName,core,aTypeID) |
| 985 | names=getTestNamesForCore(benchName,core,aTypeID) |
| 986 | formatTableBy(desc,['compiler','version'],['core'],coreSection,names,cols,vals) |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 987 | elif args.ratio: |
| 988 | allCompilers = getExistingCompiler(benchName,aTypeID) |
| 989 | for compiler in allCompilers: |
| 990 | cols,params,ratios,testNames=computeRatioTable(benchName,referenceCoreID,aTypeID,compiler) |
| 991 | #print(cols) |
| 992 | #print(ratios) |
| 993 | #print(" ") |
| 994 | if len(ratios)>0: |
| 995 | compilerName,version=getCompilerDesc(compiler) |
| 996 | compilerSection = Section("%s (%s)" % (compilerName,version)) |
| 997 | typeSection.addSection(compilerSection) |
| 998 | addRatioTable(cols,params,ratios,compilerSection,testNames,False) |
| 999 | |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 1000 | else: |
| 1001 | ## Add report for each compiler |
| 1002 | allCompilers = getExistingCompiler(benchName,aTypeID) |
| 1003 | for compiler in allCompilers: |
| 1004 | #print(compiler) |
| 1005 | nbElems = getNbElemsInBenchAndTypeAndCompilerCmd(benchName,compiler,aTypeID) |
| 1006 | # Print test results for table, type, compiler |
| 1007 | if nbElems > 0: |
| 1008 | compilerName,version=getCompilerDesc(compiler) |
| 1009 | compilerSection = Section("%s (%s)" % (compilerName,version)) |
| 1010 | typeSection.addSection(compilerSection) |
| 1011 | cols,vals=getColNamesAndDataForCompiler(benchName,compiler,aTypeID) |
| 1012 | desc=(benchName,compiler,aTypeID) |
| 1013 | names=getTestNamesForCompiler(benchName,compiler,aTypeID) |
| 1014 | formatTableBy(desc,['core'],['version','compiler'],compilerSection,names,cols,vals) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 1015 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 1016 | |
| 1017 | |
| 1018 | |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 1019 | toc=[Hierarchy("BasicMathsBenchmarks"), |
| 1020 | Hierarchy("ComplexMathsBenchmarks"), |
| 1021 | Hierarchy("FastMath"), |
| 1022 | Hierarchy("Filters", |
| 1023 | [Hierarchy("FIR"), |
| 1024 | Hierarchy("BIQUAD"), |
| 1025 | Hierarchy("DECIM"), |
| 1026 | Hierarchy("MISC")]), |
| 1027 | |
| 1028 | Hierarchy("Support Functions", |
| 1029 | [Hierarchy("Support"), |
| 1030 | Hierarchy("SupportBar")]), |
| 1031 | |
| 1032 | Hierarchy("Matrix Operations" , |
| 1033 | [Hierarchy("Binary"), |
| 1034 | Hierarchy("Unary")]), |
| 1035 | Hierarchy("Transform"), |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 1036 | Hierarchy("Stats"), |
| 1037 | Hierarchy("Classical ML",[ |
| 1038 | Hierarchy("Bayes"), |
| 1039 | Hierarchy("SVM"), |
| 1040 | Hierarchy("Distance"), |
| 1041 | ]), |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 1042 | |
| 1043 | ] |
| 1044 | |
| 1045 | processed=[] |
| 1046 | |
Christophe Favergeon | 66de4ac | 2020-07-31 13:38:09 +0200 | [diff] [blame] | 1047 | def addComments(document): |
| 1048 | if os.path.exists(args.comments): |
| 1049 | section=Section("Measurement Context") |
| 1050 | |
| 1051 | document.addSection(section) |
| 1052 | para="" |
| 1053 | with open(args.comments,"r") as r: |
| 1054 | for l in r: |
| 1055 | if l.strip(): |
| 1056 | para += l |
| 1057 | else: |
| 1058 | section.addContent(Text(para)) |
| 1059 | para="" |
| 1060 | if para: |
| 1061 | section.addContent(Text(para)) |
| 1062 | |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 1063 | if args.ratio: |
| 1064 | section.addContent(Text("Reference core for the ratio is %s" % refCoreName)) |
| 1065 | section.addContent(Text("A bigger ratio means the reference code is better")) |
| 1066 | |
| 1067 | |
| 1068 | |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 1069 | def createDoc(document,sections,benchtables): |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 1070 | global processed,referenceCoreID |
| 1071 | |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 1072 | for s in sections: |
| 1073 | if s.name in benchtables: |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 1074 | addReportFor(document,s.name) |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 1075 | processed.append(s.name) |
| 1076 | else: |
| 1077 | section=Section(s.name) |
| 1078 | document.addSection(section) |
| 1079 | createDoc(section,s.sections,benchtables) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 1080 | |
| 1081 | try: |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 1082 | benchtables=getBenchTables() |
Christophe Favergeon | 66de4ac | 2020-07-31 13:38:09 +0200 | [diff] [blame] | 1083 | document = Document(runidHeader) |
| 1084 | |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 1085 | if args.ratio: |
| 1086 | referenceCoreID= getCoreID(args.ref) |
| 1087 | refCoreName=getCoreDesc(referenceCoreID) |
| 1088 | |
Christophe Favergeon | 66de4ac | 2020-07-31 13:38:09 +0200 | [diff] [blame] | 1089 | addComments(document) |
| 1090 | |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 1091 | |
| 1092 | |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 1093 | createDoc(document,toc,benchtables) |
Christophe Favergeon | 66de4ac | 2020-07-31 13:38:09 +0200 | [diff] [blame] | 1094 | |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 1095 | misc=Section("Miscellaneous") |
| 1096 | document.addSection(misc) |
| 1097 | remaining=diff(benchtables,processed) |
| 1098 | for bench in remaining: |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 1099 | addReportFor(misc,bench) |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 1100 | |
| 1101 | #for bench in benchtables: |
| 1102 | # addReportFor(document,bench) |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 1103 | with open(args.o,"w") as output: |
| 1104 | if args.t=="md": |
| 1105 | document.accept(Markdown(output)) |
| 1106 | if args.t=="html": |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 1107 | reorder=NORMALFORMAT |
Christophe Favergeon | f1a8780 | 2020-08-17 07:36:05 +0200 | [diff] [blame] | 1108 | if args.byc: |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 1109 | reorder=BYCFORMAT |
| 1110 | if args.byd: |
| 1111 | reorder=BYDFORMAT |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 1112 | document.accept(HTML(output,args.r,args.ratio,reorder)) |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 1113 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 1114 | finally: |
| 1115 | c.close() |
| 1116 | |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 1117 | |
| 1118 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 1119 | |