CMSIS-DSP: Improve formatting scripts
diff --git a/CMSIS/DSP/Testing/TestScripts/doc/Format.py b/CMSIS/DSP/Testing/TestScripts/doc/Format.py
index b4d4a62..dffb339 100755
--- a/CMSIS/DSP/Testing/TestScripts/doc/Format.py
+++ b/CMSIS/DSP/Testing/TestScripts/doc/Format.py
@@ -1,4 +1,8 @@
import math
+from datetime import date
+
+
+
def joinit(iterable, delimiter):
it = iter(iterable)
yield next(it)
@@ -6,6 +10,28 @@
yield delimiter
yield x
+# To format, in HTML, the cores in the right order.
+# First we order tje categories
+# Then we order the cores in each category
+# The final ORDEREDCORES is what is used
+# to order tjhe values
+# Since some cores may be missing, each atble display
+# is computing a rstricted ordered core list with only the available cores.
+CORTEXCATEGORIES=["Cortex-M","Cortex-R","Cortex-A"]
+CORECATEGORIES={"Cortex-M":["m0","m4", "m7", "m33" , "m55 scalar", "m55 mve"],
+"Cortex-R":["r8","r52"],
+"Cortex-A":["a32"]
+}
+ORDEREDCORES=[]
+for cat in CORTEXCATEGORIES:
+ cores=[]
+ if cat in CORECATEGORIES:
+ for core in CORECATEGORIES[cat]:
+ cores.append(core)
+ else:
+ print("Error core %s not found" % cat)
+ quit()
+ ORDEREDCORES += cores
class Markdown:
def __init__(self,output):
@@ -54,7 +80,7 @@
self._id = self._id - 1
def visitDocument(self,document):
- self._output.write("Run number %d on %s\n" % (document.runid, str(document.date)))
+ self._output.write("Document generated frun run ids : %s\n" % document.runidHeader)
def leaveDocument(self,document):
pass
@@ -439,6 +465,24 @@
def leaveDocument(self,document):
self._output.write("</ul></div>%s\n" % script)
+def permutation(ordered,unordered):
+ result=[]
+ restricted=[]
+ for c in ORDEREDCORES:
+ if c in unordered:
+ restricted.append(c)
+
+ for c in unordered:
+ result.append(restricted.index(c))
+
+ return(result,restricted)
+
+def reorder(p,v):
+ result=[0 for x in v]
+ for val,i in zip(v,p):
+ result[i]=val
+
+ return(result)
class HTML:
def __init__(self,output,regMode):
@@ -486,7 +530,9 @@
self._histID = self._histID + 1
def visitText(self,text):
- pass
+ self._output.write("<p>\n")
+ self._output.write(text.text)
+ self._output.write("</p>\n")
def visitTable(self,table):
self._output.write("<table>\n")
@@ -498,7 +544,10 @@
self._output.write("<th class=\"param\">")
self._output.write(str(col))
self._output.write("</th>\n")
- for col in table.cores:
+
+ perm,restricted=permutation(ORDEREDCORES,table.cores)
+
+ for col in restricted:
if firstCore:
self._output.write("<th class=\"firstcore\">")
else:
@@ -513,6 +562,16 @@
for row in table.rows:
self._output.write("<tr>\n")
i = 0
+
+ row=list(row)
+
+ #print(row)
+
+ params=row[0:nbParams]
+ values=row[nbParams:]
+
+ row = params + reorder(perm,values)
+
for elem in row:
if i < nbParams:
self._output.write("<td class=\"param\">")
@@ -549,7 +608,12 @@
self._output.write("<h1>ECPS Benchmark Regressions</h1>\n")
else:
self._output.write("<h1>ECPS Benchmark Summary</h1>\n")
- self._output.write("<p>Run number %d on %s</p>\n" % (document.runid, str(document.date)))
+
+ self._output.write("<p>Document generated for run ids : %s</p>\n" % document.runidHeader)
+ today = date.today()
+ d2 = today.strftime("%B %d, %Y")
+ self._output.write("<p>Document generated on %s</p>\n" % d2)
+
self._output.write(barscript)
def leaveDocument(self,document):
diff --git a/CMSIS/DSP/Testing/TestScripts/doc/Structure.py b/CMSIS/DSP/Testing/TestScripts/doc/Structure.py
index 50956ea..6abd76a 100755
--- a/CMSIS/DSP/Testing/TestScripts/doc/Structure.py
+++ b/CMSIS/DSP/Testing/TestScripts/doc/Structure.py
@@ -31,14 +31,13 @@
class Document:
- def __init__(self,runid,date):
- self._runid = runid
- self._date = date
+ def __init__(self,runidHeader):
+ self._runidHeader = runidHeader
self._sections = []
@property
- def runid(self):
- return(self._runid)
+ def runidHeader(self):
+ return(self._runidHeader)
@property
def date(self):
diff --git a/CMSIS/DSP/Testing/createDb.sql b/CMSIS/DSP/Testing/createDb.sql
index 1c74cc1..2ef823d 100755
--- a/CMSIS/DSP/Testing/createDb.sql
+++ b/CMSIS/DSP/Testing/createDb.sql
@@ -105,15 +105,22 @@
INSERT INTO CORE VALUES(13,"a15","ARMCA15");
INSERT INTO CORE VALUES(14,"m55mvef","ARMv81MML_DSP_DP_MVE_FP");
+
+# Second item is text as displayed in UI
+# Third is CONFIGID generated by run script
+# and different from COREID as was used before
+# Above we have entries with COREIDs but it is
+# no more used
INSERT INTO CORE VALUES(15,"m0","M0");
INSERT INTO CORE VALUES(16,"m7","M7");
INSERT INTO CORE VALUES(17,"m33","M33");
INSERT INTO CORE VALUES(18,"m4","M4");
INSERT INTO CORE VALUES(19,"m55 mve","M55");
INSERT INTO CORE VALUES(20,"m55 scalar","M55SCALAR");
-INSERT INTO CORE VALUES(21,"r8","ARMCR8");
-INSERT INTO CORE VALUES(22,"r5","ARMCR5");
-INSERT INTO CORE VALUES(23,"a32","ARMCA32");
+INSERT INTO CORE VALUES(21,"r8","R8");
+INSERT INTO CORE VALUES(22,"r5","R5");
+INSERT INTO CORE VALUES(23,"a32","A32");
+INSERT INTO CORE VALUES(24,"r52","R52");
.quit
diff --git a/CMSIS/DSP/Testing/extractDb.py b/CMSIS/DSP/Testing/extractDb.py
index b3f7298..a7b9e94 100755
--- a/CMSIS/DSP/Testing/extractDb.py
+++ b/CMSIS/DSP/Testing/extractDb.py
@@ -5,7 +5,7 @@
import numpy as np
from TestScripts.doc.Structure import *
from TestScripts.doc.Format import *
-
+import os.path
runidCMD = "runid = ?"
@@ -55,6 +55,7 @@
parser.add_argument('-details', action='store_true', help="Details about runids")
parser.add_argument('-lastid', action='store_true', help="Get last ID")
+parser.add_argument('-comments', nargs='?',type = str, default="comments.txt", help="Comment section")
# For runid or runid range
parser.add_argument('others', nargs=argparse.REMAINDER,help="Run ID")
@@ -69,19 +70,23 @@
runidval=tuple([int(x) for x in args.others[0].split(",")])
runidCMD=["runid == ?" for x in runidval]
runidCMD = "".join(joinit(runidCMD," OR "))
+ runidHeader="".join(joinit([str(x) for x in runidval]," , "))
runidCMD = "(" + runidCMD + ")"
else:
runid=int(args.others[0])
+ runidHeader="%d" % runid
runidval = (runid,)
else:
runidCMD = "runid >= ? AND runid <= ?"
runid=int(args.others[1])
runidLOW=int(args.others[0])
runidval = (runidLOW,runid)
+ runidHeader="%d <= runid <= %d" % runidval
else:
runid=getLastRunID()
print("Last run ID = %d\n" % runid)
runidval=(runid,)
+ runidHeader="%d" % runid
# We extract data only from data tables
@@ -626,6 +631,22 @@
processed=[]
+def addComments(document):
+ if os.path.exists(args.comments):
+ section=Section("Measurement Context")
+
+ document.addSection(section)
+ para=""
+ with open(args.comments,"r") as r:
+ for l in r:
+ if l.strip():
+ para += l
+ else:
+ section.addContent(Text(para))
+ para=""
+ if para:
+ section.addContent(Text(para))
+
def createDoc(document,sections,benchtables):
global processed
for s in sections:
@@ -640,8 +661,12 @@
try:
benchtables=getBenchTables()
theDate = getrunIDDate(runid)
- document = Document(runid,theDate)
+ document = Document(runidHeader)
+
+ addComments(document)
+
createDoc(document,toc,benchtables)
+
misc=Section("Miscellaneous")
document.addSection(misc)
remaining=diff(benchtables,processed)