#!/usr/bin/python from sys import maxsize import xml.etree.ElementTree as ET import argparse from utils import * def getLink(instrNode, text, arch, tool, linkType, anchor=None): url = '/tmp/html-' + linkType + '/' + arch + '/' + canonicalizeInstrString(instrNode.attrib['string']) + '-' + tool + '.html' if anchor: url += '#' + anchor return '' + text + '' def main(): parser = argparse.ArgumentParser(description='Generates a basic HTML table with the results for a microarchitecture') parser.add_argument("-input", help="Input XML file", default='result.xml') parser.add_argument("-arch", help="Consider only this architecture") args = parser.parse_args() root = ET.parse(args.input) TPSame = 0 TPDiff = 0 with open('instructions.html', "w") as f: f.write('\n' '
\n' '\n' ' | Lat | \n' 'TP (ports) | \n' 'TP (m) | \n' 'uops | \n' 'Ports | \n' '
---|---|---|---|---|---|
' + XMLInstr.attrib['string'] + ' | \n') lat = '' latTableEntry = getLatencyTableEntry(resultNode) if latTableEntry is not None: lat = str(latTableEntry[0]) f.write('' + getLink(XMLInstr, lat, args.arch, 'Measurements', 'lat') + ' | \n') TPPorts = float(resultNode.attrib.get('TP_ports', float("inf"))) TPPortsStr = ("{:.2f}".format(TPPorts) if TPPorts < float("inf") else '') f.write('' + TPPortsStr + ' | \n') TPMeasured = min(float(resultNode.attrib.get('TP_loop', float("inf"))), float(resultNode.attrib.get('TP_unrolled', float("inf")))) TPMeasuredStr = ("{:.2f}".format(TPMeasured) if TPMeasured < float("inf") else '') uopsMS = int(resultNode.attrib.get('uops_MS', sys.maxsize)) color = '' if TPPortsStr and TPMeasuredStr and (uopsMS == 0): if abs(TPMeasured - TPPorts) < .02: color = ' bgcolor="green"' TPSame += 1 else: color = ' bgcolor="orange"' TPDiff += 1 f.write('' + getLink(XMLInstr, TPMeasuredStr, args.arch, 'Measurements', 'tp') + ' | \n') f.write('' + resultNode.attrib.get('uops', '') + ' | \n') f.write('' + getLink(XMLInstr, resultNode.attrib.get('ports', ''), args.arch, 'Measurements', 'ports') + ' | \n') f.write('