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 | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 474 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 475 | |
| 476 | PARAMS=["NB","NumTaps", "NBA", "NBB", "Factor", "NumStages","VECDIM","NBR","NBC","NBI","IFFT", "BITREV"] |
| 477 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 478 | def regressionTableFor(byname,name,section,ref,toSort,indexCols,field): |
| 479 | data=ref.pivot_table(index=indexCols, columns=byname, |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 480 | values=[field], aggfunc='first') |
| 481 | |
| 482 | data=data.sort_values(toSort) |
| 483 | |
| 484 | cores = [c[1] for c in list(data.columns)] |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 485 | columns = diff(indexCols,['name']) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 486 | |
Christophe Favergeon | 34d313a | 2020-05-14 15:09:41 +0200 | [diff] [blame] | 487 | dataTable=Table(columns,cores) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 488 | section.addContent(dataTable) |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 489 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 490 | dataForFunc=data.loc[name] |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 491 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 492 | if type(dataForFunc) is pd.DataFrame: |
Christophe Favergeon | 0dcf9a1 | 2020-05-27 15:55:27 +0200 | [diff] [blame] | 493 | bars={'cols':columns,'cores':cores,'data':[]} |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 494 | for row in dataForFunc.itertuples(): |
| 495 | row=list(row) |
| 496 | if type(row[0]) is int: |
| 497 | row=[row[0]] + row[1:] |
| 498 | else: |
| 499 | row=list(row[0]) + row[1:] |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 500 | if field=="MAXREGCOEF": |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 501 | newrow = row |
| 502 | newrow[len(columns):] = [("%.3f" % x) for x in row[len(columns):]] |
| 503 | row=newrow |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 504 | dataTable.addRow(row) |
Christophe Favergeon | 0dcf9a1 | 2020-05-27 15:55:27 +0200 | [diff] [blame] | 505 | bars['data'].append(row) |
| 506 | return(bars) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 507 | else: |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 508 | if field=="MAXREGCOEF": |
| 509 | dataForFunc=[("%.3f" % x) for x in dataForFunc] |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 510 | dataTable.addRow(dataForFunc) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 511 | return(list(zip(cores,dataForFunc))) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 512 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 513 | def formatColumnName(c): |
| 514 | return("".join(joinit(c,":"))) |
| 515 | |
| 516 | def getCoresForHistory(benchTable,compilerid,typeid,testid,runid): |
| 517 | vals=(compilerid,typeid,testid,runid) |
| 518 | result=c.execute(coresForHistory % benchTable,vals).fetchall() |
| 519 | ids=[(x[0],x[1]) for x in list(result)] |
| 520 | return(ids) |
| 521 | |
| 522 | def getCompilerForHistory(benchTable,coreid,typeid,testid,runid): |
| 523 | vals=(coreid,typeid,testid,runid) |
| 524 | result=c.execute(compilersForHistory % benchTable,vals).fetchall() |
| 525 | ids=[(x[0],x[1],x[2]) for x in list(result)] |
| 526 | return(ids) |
| 527 | |
| 528 | def getHistory(desc,testid,indexCols): |
| 529 | benchName,sectionID,typeid,runid = desc |
| 530 | |
| 531 | #print(benchName) |
| 532 | #print(sectionID) |
| 533 | #print(typeid) |
| 534 | #print(testid) |
| 535 | columns = diff(indexCols,['name']) |
| 536 | #print(columns) |
| 537 | if args.byc: |
| 538 | coreid=sectionID |
| 539 | compilerids=getCompilerForHistory(benchName,coreid,typeid,testid,runid) |
| 540 | series={} |
| 541 | for compilerid,compilername,version in compilerids: |
| 542 | result=getColNamesAndHistory(benchName,compilerid,coreid,typeid,testid) |
| 543 | #print("%s:%s" % (compilername,version)) |
| 544 | maxpos = result[0].index('MAX') |
| 545 | lrunid = result[0].index('runid') |
| 546 | r=[[int(x[lrunid]),int(x[maxpos])] for x in result[1:][0]] |
| 547 | series[corename]=r |
| 548 | hist=History(series,runid) |
| 549 | return(hist) |
| 550 | else: |
| 551 | compilerid=sectionID |
| 552 | coreids = getCoresForHistory(benchName,compilerid,typeid,testid,runid) |
| 553 | series={} |
| 554 | for coreid,corename in coreids: |
| 555 | result=getColNamesAndHistory(benchName,compilerid,coreid,typeid,testid) |
| 556 | #print(corename) |
| 557 | maxpos = result[0].index('MAX') |
| 558 | corepos = result[0].index('core') |
| 559 | lrunid = result[0].index('runid') |
| 560 | r=[[int(x[lrunid]),int(x[maxpos])] for x in result[1:][0]] |
| 561 | series[corename]=r |
| 562 | hist=History(series,runid) |
| 563 | return(hist) |
| 564 | |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 565 | def convertRowToInt(r): |
| 566 | result=[] |
| 567 | for e in r: |
| 568 | if type(e) is float: |
| 569 | result.append(int(e)) |
| 570 | else: |
| 571 | result.append(e) |
| 572 | |
| 573 | return(result) |
| 574 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 575 | def formatTableBy(desc,byname,section,typeSection,testNames,cols,vals): |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 576 | if vals.size != 0: |
| 577 | ref=pd.DataFrame(vals,columns=cols) |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 578 | toSort=["name"] |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 579 | |
| 580 | for param in PARAMS: |
| 581 | if param in ref.columns: |
| 582 | ref[param]=pd.to_numeric(ref[param]) |
| 583 | toSort.append(param) |
| 584 | if args.r: |
| 585 | # Regression table |
| 586 | ref['MAX']=pd.to_numeric(ref['MAX']) |
| 587 | ref['MAXREGCOEF']=pd.to_numeric(ref['MAXREGCOEF']) |
| 588 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 589 | indexCols=diff(cols,byname + ['Regression','MAXREGCOEF','MAX'] + section) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 590 | valList = ['Regression'] |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 591 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 592 | else: |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 593 | ref['CYCLES']=pd.to_numeric(ref['CYCLES']).round(decimals=0) |
| 594 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 595 | indexCols=diff(cols,byname + ['CYCLES'] + section) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 596 | valList = ['CYCLES'] |
| 597 | |
| 598 | |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 599 | for name in testNames: |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 600 | if args.r: |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 601 | testSection = Section(name) |
| 602 | typeSection.addSection(testSection) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 603 | |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 604 | maxCyclesSection = Section("Max cycles") |
| 605 | testSection.addSection(maxCyclesSection) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 606 | theCycles=regressionTableFor(byname,name,maxCyclesSection,ref,toSort,indexCols,'MAX') |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 607 | if args.g: |
| 608 | if type(theCycles) is dict: |
| 609 | nbParams=len(theCycles['cols']) |
| 610 | for bar in theCycles['data']: |
| 611 | params=bar[0:nbParams] |
| 612 | values=bar[nbParams:] |
| 613 | title=[("%s=%s" % x) for x in list(zip(theCycles['cols'],params))] |
| 614 | title="".join(joinit(title," ")) |
| 615 | sec=Section(title) |
| 616 | maxCyclesSection.addSection(sec) |
| 617 | values=list(zip(theCycles['cores'],values)) |
| 618 | barChart=BarChart(values) |
| 619 | sec.addContent(barChart) |
| 620 | else: |
| 621 | #print(theCycles) |
| 622 | sec=Section("Graph") |
Christophe Favergeon | 0dcf9a1 | 2020-05-27 15:55:27 +0200 | [diff] [blame] | 623 | maxCyclesSection.addSection(sec) |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 624 | barChart=BarChart(theCycles) |
Christophe Favergeon | 0dcf9a1 | 2020-05-27 15:55:27 +0200 | [diff] [blame] | 625 | sec.addContent(barChart) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 626 | |
Christophe Favergeon | 670b167 | 2020-05-28 12:47:58 +0200 | [diff] [blame] | 627 | #history=getHistory(desc,testid,indexCols) |
| 628 | #testSection.addContent(history) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 629 | |
| 630 | regressionSection = Section("Regression") |
| 631 | testSection.addSection(regressionSection) |
| 632 | regressionTableFor(byname,name,regressionSection,ref,toSort,indexCols,'Regression') |
| 633 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 634 | |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 635 | maxRegCoefSection = Section("Max Reg Coef") |
| 636 | testSection.addSection(maxRegCoefSection) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 637 | regressionTableFor(byname,name,maxRegCoefSection,ref,toSort,indexCols,'MAXREGCOEF') |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 638 | |
| 639 | else: |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 640 | data=ref.pivot_table(index=indexCols, columns=byname, |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 641 | values=valList, aggfunc='first') |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 642 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 643 | data=data.sort_values(toSort) |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 644 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 645 | #print(list(data.columns)) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 646 | |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 647 | testSection = Section(name) |
| 648 | typeSection.addSection(testSection) |
| 649 | |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 650 | dataForFunc=data.loc[name] |
| 651 | dataForFunc = dataForFunc.dropna(axis=1) |
| 652 | |
| 653 | columnsID = [formatColumnName(c[1:]) for c in list(dataForFunc.columns)] |
| 654 | columns = diff(indexCols,['name']) |
| 655 | |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 656 | dataTable=Table(columns,columnsID) |
| 657 | testSection.addContent(dataTable) |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 658 | |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 659 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 660 | if type(dataForFunc) is pd.DataFrame: |
| 661 | for row in dataForFunc.itertuples(): |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 662 | if type(row[0]) is int: |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 663 | row=list([row[0]] + list(row[1:])) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 664 | else: |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 665 | row=list(row[0]) + list(row[1:]) |
| 666 | dataTable.addRow(convertRowToInt(row)) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 667 | else: |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 668 | dataTable.addRow(convertRowToInt(dataForFunc)) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 669 | |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 670 | referenceCoreID = None |
| 671 | |
| 672 | |
| 673 | |
| 674 | coreidSQL="select distinct coreid from CORE where coredef==?" |
| 675 | |
| 676 | def getCoreID(corename): |
| 677 | r=c.execute(coreidSQL,(corename,)) |
| 678 | t=r.fetchone() |
| 679 | if t is None: |
| 680 | print("Unrecognized reference core") |
| 681 | quit() |
| 682 | return(t[0]) |
| 683 | |
| 684 | refCore="""CREATE TEMP VIEW if not exists refCore AS |
| 685 | select * from %s where (coreid = %s) and (typeid = %s) |
| 686 | and %s |
| 687 | and compilerid = %s""" |
| 688 | |
| 689 | allOtherCores="""CREATE TEMP VIEW if not exists otherCore AS |
| 690 | select * from %s where (coreid != %s) and (typeid = %s) |
| 691 | and %s |
| 692 | and compilerid = %s""" |
| 693 | |
| 694 | otherCore="""CREATE TEMP VIEW if not exists otherCore AS |
| 695 | select * from %s where (coreid = %s) and (typeid = %s) |
| 696 | and %s |
| 697 | and compilerid = %s""" |
| 698 | |
| 699 | refCoreAllTypes="""CREATE TEMP VIEW if not exists refCore AS |
| 700 | select * from %s where (coreid = %s) |
| 701 | and %s |
| 702 | and compilerid = %s""" |
| 703 | |
| 704 | otherCoreAllTypes="""CREATE TEMP VIEW if not exists otherCore AS |
| 705 | select * from %s where (coreid = %s) |
| 706 | and %s |
| 707 | and compilerid = %s""" |
| 708 | |
| 709 | |
| 710 | ratioSQL="""select name,otherCore.compilerid as compilerid,CORE.core as core,%s(CAST(otherCore.MAX as FLOAT) / CAST(refCore.MAX AS FLOAT)) AS RATIO |
| 711 | from otherCore |
| 712 | INNER JOIN refCore ON (refCore.categoryid = otherCore.categoryid |
| 713 | AND refCore.testnameid = otherCore.testnameid |
| 714 | AND refCore.typeid = otherCore.typeid |
| 715 | AND refCore.runid = otherCore.runid |
| 716 | AND refCore.compilerid = otherCore.compilerid |
| 717 | ) |
| 718 | INNER JOIN TESTNAME ON TESTNAME.testnameid = refCore.testnameid |
| 719 | INNER JOIN CORE USING(coreid) |
| 720 | %s""" |
| 721 | |
| 722 | ratioSQLAllTypes="""select name,otherCore.compilerid as compilerid,TYPE.type as type,%s(CAST(otherCore.MAX as FLOAT) / CAST(refCore.MAX AS FLOAT)) AS RATIO |
| 723 | from otherCore |
| 724 | INNER JOIN refCore ON (refCore.categoryid = otherCore.categoryid |
| 725 | AND refCore.testnameid = otherCore.testnameid |
| 726 | AND refCore.typeid = otherCore.typeid |
| 727 | AND refCore.runid = otherCore.runid |
| 728 | AND refCore.compilerid = otherCore.compilerid |
| 729 | ) |
| 730 | INNER JOIN TESTNAME ON TESTNAME.testnameid = refCore.testnameid |
| 731 | INNER JOIN TYPE USING(typeid) |
| 732 | %s""" |
| 733 | |
| 734 | ratioTestNamesSQL="""select distinct TESTNAME.name |
| 735 | from otherCore |
| 736 | INNER JOIN refCore ON (refCore.categoryid = otherCore.categoryid |
| 737 | AND refCore.testnameid = otherCore.testnameid |
| 738 | AND refCore.typeid = otherCore.typeid |
| 739 | AND refCore.runid = otherCore.runid |
| 740 | AND refCore.compilerid = otherCore.compilerid |
| 741 | ) |
| 742 | INNER JOIN TESTNAME ON TESTNAME.testnameid = refCore.testnameid |
| 743 | INNER JOIN CORE USING(coreid) |
| 744 | %s""" |
| 745 | |
| 746 | |
| 747 | dropViewsRef="""drop view refCore""" |
| 748 | |
| 749 | dropViewsOther="""drop view otherCore""" |
| 750 | |
| 751 | def getTableParams(benchTable): |
| 752 | cursor=c.cursor() |
| 753 | result=cursor.execute("select * from %s limit 1" % (benchTable)) |
| 754 | cols= [member[0] for member in cursor.description] |
| 755 | params=[] |
| 756 | for x in cols: |
| 757 | if x in PARAMS: |
| 758 | params.append(x) |
| 759 | return(params) |
| 760 | |
| 761 | def computeRatio(benchName,viewParams,refMkViewCmd,otherMkViewCmd,byd): |
| 762 | params = getTableParams(benchName) |
| 763 | cols=["ratio"] |
| 764 | paramscmd="" |
| 765 | paramscols="" |
| 766 | paramsnames = ["refCore.%s as %s" % (x,x) for x in params] |
| 767 | paramseq = ["refCore.%s = otherCore.%s" % (x,x) for x in params] |
| 768 | if len(params) > 0: |
| 769 | cols = ["%s" % x for x in params] |
| 770 | cols.append("ratio") |
| 771 | paramscols= ("".join(joinit(paramsnames," , ")) + ",") |
| 772 | paramscmd = "WHERE " + "".join(joinit(paramseq," AND ")) |
| 773 | if byd: |
| 774 | ratioCmd = ratioSQLAllTypes % (paramscols,paramscmd) |
| 775 | else: |
| 776 | ratioCmd = ratioSQL % (paramscols,paramscmd) |
| 777 | ratioTestNames = ratioTestNamesSQL % (paramscmd) |
| 778 | |
| 779 | #print(refMkViewCmd) |
| 780 | #print(otherMkViewCmd) |
| 781 | # |
| 782 | #print(ratioCmd) |
| 783 | # |
| 784 | #print(dropViewsRef) |
| 785 | #print(dropViewsOther) |
| 786 | #quit() |
| 787 | |
| 788 | c.execute(refMkViewCmd) |
| 789 | c.execute(otherMkViewCmd) |
| 790 | |
| 791 | ratio=c.execute(ratioCmd).fetchall() |
| 792 | testNames=c.execute(ratioTestNames).fetchall() |
| 793 | testNames=[x[0] for x in testNames] |
| 794 | |
| 795 | c.execute(dropViewsRef) |
| 796 | c.execute(dropViewsOther) |
| 797 | |
| 798 | #print(ratio) |
| 799 | #quit() |
| 800 | if byd: |
| 801 | return(['name','compilerid','type'] + cols,params,ratio,testNames) |
| 802 | else: |
| 803 | return(['name','compilerid','core'] + cols,params,ratio,testNames) |
| 804 | |
| 805 | # Compute for all core for a given type |
| 806 | def computeRatioTable(benchName,referenceCore,typeID,compiler): |
| 807 | viewParams = (benchName,referenceCore,typeID,runidVIEWcmd,compiler) |
| 808 | refMkViewCmd = refCore % viewParams |
| 809 | otherMkViewCmd = allOtherCores % viewParams |
| 810 | if args.keep: |
| 811 | keepCoreID = getCoreID(args.keep) |
| 812 | otherParams = (benchName,keepCoreID,typeID,runidVIEWcmd,compiler) |
| 813 | otherMkViewCmd = otherCore % otherParams |
| 814 | return(computeRatio(benchName,viewParams,refMkViewCmd,otherMkViewCmd,False)) |
| 815 | |
| 816 | |
| 817 | def computeRatioTableForCore(benchName,referenceCore,otherCoreID,compiler): |
| 818 | viewParams = (benchName,referenceCore,runidVIEWcmd,compiler) |
| 819 | refMkViewCmd = refCoreAllTypes % viewParams |
| 820 | otherParams = (benchName,otherCoreID,runidVIEWcmd,compiler) |
| 821 | otherMkViewCmd = otherCoreAllTypes % otherParams |
| 822 | return(computeRatio(benchName,viewParams,refMkViewCmd,otherMkViewCmd,True)) |
| 823 | |
| 824 | def formatPerfRatio(s): |
| 825 | result=[] |
| 826 | for t in s: |
| 827 | if type(t) is float: |
| 828 | if args.clamp: |
| 829 | if t > args.clampval: |
| 830 | t = args.clampval |
Christophe Favergeon | 0adf05c | 2020-08-19 07:04:32 +0200 | [diff] [blame] | 831 | if t < 0.0: |
| 832 | result.append("NA") |
| 833 | else: |
| 834 | result.append(("%.3f" % t)) |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 835 | else: |
| 836 | result.append(s) |
| 837 | |
| 838 | return(result) |
| 839 | |
| 840 | def addRatioTable(cols,params,data,section,testNames,byd): |
| 841 | ref=pd.DataFrame(data,columns=cols) |
| 842 | toSort=["name"] + params |
| 843 | for param in PARAMS: |
| 844 | if param in ref.columns: |
| 845 | ref[param]=pd.to_numeric(ref[param]) |
| 846 | |
| 847 | #print(testNames) |
| 848 | for name in testNames: |
| 849 | testSection = Section(name) |
| 850 | section.addSection(testSection) |
| 851 | |
| 852 | ratioSection = Section("Ratios") |
| 853 | testSection.addSection(ratioSection) |
| 854 | |
| 855 | #print(toSort) |
| 856 | #print(ref) |
| 857 | |
| 858 | if byd: |
| 859 | data=ref.pivot_table(index=toSort, columns=['type'], |
Christophe Favergeon | 0adf05c | 2020-08-19 07:04:32 +0200 | [diff] [blame] | 860 | values=["ratio"], aggfunc='first',fill_value=-1.0) |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 861 | else: |
| 862 | data=ref.pivot_table(index=toSort, columns=['core'], |
| 863 | values=["ratio"], aggfunc='first') |
| 864 | |
| 865 | data=data.sort_values(toSort) |
| 866 | |
| 867 | #print(data) |
| 868 | dataForFunc=data.loc[name] |
| 869 | |
| 870 | cores = [c[1] for c in list(data.columns)] |
| 871 | |
| 872 | dataTable=Table(params,cores) |
| 873 | |
Christophe Favergeon | 0adf05c | 2020-08-19 07:04:32 +0200 | [diff] [blame] | 874 | if args.g: |
| 875 | if type(dataForFunc) is not pd.DataFrame: |
| 876 | sec=Section("Graph") |
| 877 | testSection.addSection(sec) |
| 878 | |
| 879 | barChart=BarChart(zip(cores,dataForFunc)) |
| 880 | sec.addContent(barChart) |
| 881 | |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 882 | ratioSection.addContent(Text("A bigger ratio means the reference core \"%s\" is better" % refCoreName)) |
| 883 | |
| 884 | ratioSection.addContent(dataTable) |
| 885 | |
| 886 | if type(dataForFunc) is pd.DataFrame: |
| 887 | for row in dataForFunc.itertuples(): |
| 888 | row=list(row) |
| 889 | if type(row[0]) is int: |
| 890 | row=[row[0]] + formatPerfRatio(row[1:]) |
| 891 | else: |
| 892 | row=list(row[0]) + formatPerfRatio(row[1:]) |
| 893 | dataTable.addRow(row) |
| 894 | else: |
| 895 | row=list(dataForFunc) |
| 896 | dataTable.addRow(formatPerfRatio(row)) |
| 897 | |
| 898 | |
| 899 | |
| 900 | |
| 901 | |
| 902 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 903 | # Add a report for each table |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 904 | def addReportFor(document,benchName): |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 905 | nbElems = getNbElemsInBenchCmd(benchName) |
| 906 | if nbElems > 0: |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 907 | categoryName = getCategoryName(benchName) |
Christophe Favergeon | 4fa1e23 | 2020-05-15 12:28:17 +0200 | [diff] [blame] | 908 | benchSection = Section(categoryName) |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 909 | document.addSection(benchSection) |
Christophe Favergeon | e15894e | 2020-05-14 07:25:53 +0200 | [diff] [blame] | 910 | print("Process %s\n" % benchName) |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 911 | if args.byd: |
| 912 | allCores=getAllExistingCores(benchName) |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 913 | if args.ratio: |
| 914 | allCores.remove(referenceCoreID) |
| 915 | if args.keep: |
| 916 | allCores=[getCoreID(args.keep)] |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 917 | for aCoreID in allCores: |
| 918 | nbElems = getNbElemsInBenchAndCoreCmd(benchName,aCoreID) |
| 919 | if nbElems > 0: |
| 920 | coreName=getCoreDesc(aCoreID) |
| 921 | coreSection = Section("%s" % coreName) |
| 922 | benchSection.addSection(coreSection) |
| 923 | allCompilers = getExistingCompilerForCore(benchName,aCoreID) |
| 924 | for compiler in allCompilers: |
| 925 | #print(compiler) |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 926 | if args.ratio: |
| 927 | cols,params,ratios,testNames=computeRatioTableForCore(benchName,referenceCoreID,aCoreID,compiler) |
| 928 | #print(cols) |
| 929 | #print(ratios) |
| 930 | #print(" ") |
| 931 | if len(ratios)>0: |
| 932 | compilerName,version=getCompilerDesc(compiler) |
| 933 | compilerSection = Section("%s (%s)" % (compilerName,version)) |
| 934 | coreSection.addSection(compilerSection) |
| 935 | addRatioTable(cols,params,ratios,compilerSection,testNames,True) |
| 936 | |
| 937 | else: |
| 938 | nbElems = getNbElemsInBenchAndCoreAndCompilerCmd(benchName,compiler,aCoreID) |
| 939 | |
| 940 | # Print test results for table, type, compiler |
| 941 | if nbElems > 0: |
| 942 | compilerName,version=getCompilerDesc(compiler) |
| 943 | compilerSection = Section("%s (%s)" % (compilerName,version)) |
| 944 | coreSection.addSection(compilerSection) |
| 945 | cols,vals=getColNamesAndDataForCoreCompiler(benchName,compiler,aCoreID) |
| 946 | desc=(benchName,compiler,aCoreID) |
| 947 | names=getTestNamesForCoreCompiler(benchName,compiler,aCoreID) |
| 948 | |
| 949 | formatTableBy(desc,['type'],['core','version','compiler'],compilerSection,names,cols,vals) |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 950 | |
| 951 | else: |
| 952 | allTypes = getExistingTypes(benchName) |
| 953 | # Add report for each type |
| 954 | for aTypeID in allTypes: |
| 955 | nbElems = getNbElemsInBenchAndTypeCmd(benchName,aTypeID) |
| 956 | if nbElems > 0: |
| 957 | typeName = getTypeName(aTypeID) |
| 958 | typeSection = Section(typeName) |
| 959 | benchSection.addSection(typeSection) |
| 960 | if args.byc: |
| 961 | ## Add report for each core |
| 962 | allCores = getExistingCores(benchName,aTypeID) |
| 963 | for core in allCores: |
| 964 | #print(core) |
| 965 | nbElems = getNbElemsInBenchAndTypeAndCoreCmd(benchName,core,aTypeID) |
| 966 | # Print test results for table, type, compiler |
| 967 | if nbElems > 0: |
| 968 | coreName=getCoreDesc(core) |
| 969 | coreSection = Section("%s" % coreName) |
| 970 | typeSection.addSection(coreSection) |
| 971 | cols,vals=getColNamesAndDataForCore(benchName,core,aTypeID) |
| 972 | desc=(benchName,core,aTypeID) |
| 973 | names=getTestNamesForCore(benchName,core,aTypeID) |
| 974 | formatTableBy(desc,['compiler','version'],['core'],coreSection,names,cols,vals) |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 975 | elif args.ratio: |
| 976 | allCompilers = getExistingCompiler(benchName,aTypeID) |
| 977 | for compiler in allCompilers: |
| 978 | cols,params,ratios,testNames=computeRatioTable(benchName,referenceCoreID,aTypeID,compiler) |
| 979 | #print(cols) |
| 980 | #print(ratios) |
| 981 | #print(" ") |
| 982 | if len(ratios)>0: |
| 983 | compilerName,version=getCompilerDesc(compiler) |
| 984 | compilerSection = Section("%s (%s)" % (compilerName,version)) |
| 985 | typeSection.addSection(compilerSection) |
| 986 | addRatioTable(cols,params,ratios,compilerSection,testNames,False) |
| 987 | |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 988 | else: |
| 989 | ## Add report for each compiler |
| 990 | allCompilers = getExistingCompiler(benchName,aTypeID) |
| 991 | for compiler in allCompilers: |
| 992 | #print(compiler) |
| 993 | nbElems = getNbElemsInBenchAndTypeAndCompilerCmd(benchName,compiler,aTypeID) |
| 994 | # Print test results for table, type, compiler |
| 995 | if nbElems > 0: |
| 996 | compilerName,version=getCompilerDesc(compiler) |
| 997 | compilerSection = Section("%s (%s)" % (compilerName,version)) |
| 998 | typeSection.addSection(compilerSection) |
| 999 | cols,vals=getColNamesAndDataForCompiler(benchName,compiler,aTypeID) |
| 1000 | desc=(benchName,compiler,aTypeID) |
| 1001 | names=getTestNamesForCompiler(benchName,compiler,aTypeID) |
| 1002 | formatTableBy(desc,['core'],['version','compiler'],compilerSection,names,cols,vals) |
Christophe Favergeon | feb7393 | 2020-05-20 14:48:06 +0200 | [diff] [blame] | 1003 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 1004 | |
| 1005 | |
| 1006 | |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 1007 | toc=[Hierarchy("BasicMathsBenchmarks"), |
| 1008 | Hierarchy("ComplexMathsBenchmarks"), |
| 1009 | Hierarchy("FastMath"), |
| 1010 | Hierarchy("Filters", |
| 1011 | [Hierarchy("FIR"), |
| 1012 | Hierarchy("BIQUAD"), |
| 1013 | Hierarchy("DECIM"), |
| 1014 | Hierarchy("MISC")]), |
| 1015 | |
| 1016 | Hierarchy("Support Functions", |
| 1017 | [Hierarchy("Support"), |
| 1018 | Hierarchy("SupportBar")]), |
| 1019 | |
| 1020 | Hierarchy("Matrix Operations" , |
| 1021 | [Hierarchy("Binary"), |
| 1022 | Hierarchy("Unary")]), |
| 1023 | Hierarchy("Transform"), |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 1024 | Hierarchy("Stats"), |
| 1025 | Hierarchy("Classical ML",[ |
| 1026 | Hierarchy("Bayes"), |
| 1027 | Hierarchy("SVM"), |
| 1028 | Hierarchy("Distance"), |
| 1029 | ]), |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 1030 | |
| 1031 | ] |
| 1032 | |
| 1033 | processed=[] |
| 1034 | |
Christophe Favergeon | 66de4ac | 2020-07-31 13:38:09 +0200 | [diff] [blame] | 1035 | def addComments(document): |
| 1036 | if os.path.exists(args.comments): |
| 1037 | section=Section("Measurement Context") |
| 1038 | |
| 1039 | document.addSection(section) |
| 1040 | para="" |
| 1041 | with open(args.comments,"r") as r: |
| 1042 | for l in r: |
| 1043 | if l.strip(): |
| 1044 | para += l |
| 1045 | else: |
| 1046 | section.addContent(Text(para)) |
| 1047 | para="" |
| 1048 | if para: |
| 1049 | section.addContent(Text(para)) |
| 1050 | |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 1051 | if args.ratio: |
| 1052 | section.addContent(Text("Reference core for the ratio is %s" % refCoreName)) |
| 1053 | section.addContent(Text("A bigger ratio means the reference code is better")) |
| 1054 | |
| 1055 | |
| 1056 | |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 1057 | def createDoc(document,sections,benchtables): |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 1058 | global processed,referenceCoreID |
| 1059 | |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 1060 | for s in sections: |
| 1061 | if s.name in benchtables: |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 1062 | addReportFor(document,s.name) |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 1063 | processed.append(s.name) |
| 1064 | else: |
| 1065 | section=Section(s.name) |
| 1066 | document.addSection(section) |
| 1067 | createDoc(section,s.sections,benchtables) |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 1068 | |
| 1069 | try: |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 1070 | benchtables=getBenchTables() |
Christophe Favergeon | 66de4ac | 2020-07-31 13:38:09 +0200 | [diff] [blame] | 1071 | document = Document(runidHeader) |
| 1072 | |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 1073 | if args.ratio: |
| 1074 | referenceCoreID= getCoreID(args.ref) |
| 1075 | refCoreName=getCoreDesc(referenceCoreID) |
| 1076 | |
Christophe Favergeon | 66de4ac | 2020-07-31 13:38:09 +0200 | [diff] [blame] | 1077 | addComments(document) |
| 1078 | |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 1079 | |
| 1080 | |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 1081 | createDoc(document,toc,benchtables) |
Christophe Favergeon | 66de4ac | 2020-07-31 13:38:09 +0200 | [diff] [blame] | 1082 | |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 1083 | misc=Section("Miscellaneous") |
| 1084 | document.addSection(misc) |
| 1085 | remaining=diff(benchtables,processed) |
| 1086 | for bench in remaining: |
Christophe Favergeon | 6ef1bb2 | 2020-08-14 12:07:47 +0200 | [diff] [blame] | 1087 | addReportFor(misc,bench) |
Christophe Favergeon | ed0eab8 | 2020-05-18 08:43:38 +0200 | [diff] [blame] | 1088 | |
| 1089 | #for bench in benchtables: |
| 1090 | # addReportFor(document,bench) |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 1091 | with open(args.o,"w") as output: |
| 1092 | if args.t=="md": |
| 1093 | document.accept(Markdown(output)) |
| 1094 | if args.t=="html": |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 1095 | reorder=NORMALFORMAT |
Christophe Favergeon | f1a8780 | 2020-08-17 07:36:05 +0200 | [diff] [blame] | 1096 | if args.byc: |
Christophe Favergeon | bb86f04 | 2020-08-17 14:58:47 +0200 | [diff] [blame] | 1097 | reorder=BYCFORMAT |
| 1098 | if args.byd: |
| 1099 | reorder=BYDFORMAT |
Christophe Favergeon | 1ff5458 | 2020-08-18 14:47:01 +0200 | [diff] [blame] | 1100 | document.accept(HTML(output,args.r,args.ratio,reorder)) |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 1101 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 1102 | finally: |
| 1103 | c.close() |
| 1104 | |
Christophe Favergeon | c3f455c | 2020-05-14 09:24:07 +0200 | [diff] [blame] | 1105 | |
| 1106 | |
Christophe Favergeon | 8cb3730 | 2020-05-13 13:06:58 +0200 | [diff] [blame] | 1107 | |