-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcodesize.html
177 lines (168 loc) · 7.34 KB
/
codesize.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AArch64 Cost model tests</title>
<script>
function load(label, type) {
fetch("data-" + label + type + ".json")
.then(response => {
if (!response.ok) {
fetch("data-" + label + ".json")
.then(response => response.json())
.then(json => drawTable(json, label))
.catch(reason => console.log(reason));
return Promise.reject()
}
return response.json()
})
.then(json => drawTable(json, label))
.catch(reason => console.log(reason));
}
function reload(type) {
load("int", type)
load("fp", type)
load("castint", type)
load("castfp", type)
load("vec", type)
}
document.addEventListener("DOMContentLoaded", function() {
reload('')
});
function drawTable(json, label) {
var instrs = {};
var tys = []
json.forEach(j => {
instrs[j.instr] ??= {};
instrs[j.instr][j.variant] ??= {};
instrs[j.instr][j.variant][j.ty] = j
if (!tys.includes(j.ty))
tys.push(j.ty);
});
const table = document.getElementById('table-'+label)
table.innerHTML = ""
head = table.createTHead();
tr = head.insertRow(0);
tr.insertCell().outerHTML = "<th>Instr</th>"
tr.insertCell().outerHTML = "<th>Variant</th>"
for (var ty in tys) {
tr.insertCell().outerHTML = "<th>"+escape(tys[ty])+"</th>"
}
body = table.createTBody();
for (var instr in instrs) {
var first = true
for (var variant in instrs[instr]) {
tr = body.insertRow();
if (first) {
tr.insertCell().outerHTML = "<th rowspan='"+Object.keys(instrs[instr]).length+"' valign='top'>"+instr+"</th>"
first = false
}
tr.insertCell().outerHTML = "<th>"+variant+"</th>"
for (var ty in tys) {
cell = tr.insertCell()
j = instrs[instr][variant][tys[ty]]
if (!j) {
cell.innerHTML = "-"
} else {
cell.innerHTML = j.codesize - j.size
cell.onclick = function() {
let _j = j
let _label = label
return function() { drawDetails(_label, _j); }
}()
}
}
}
}
}
function escape(s) {
return s.replaceAll('<','<').replaceAll('>','>').replaceAll('#', '\#')
}
function drawDetails(label, j) {
var details = document.getElementById('details-'+label);
txt = "<h3>Details</h3>"
txt += j.instr + " " + j.variant + " " + escape(j.ty) + "\n";
txt += "Codesize cost:"+j.codesize+"\n"
txt += "Measured size:"+j.size+" (gisize:"+j.gisize+")\n"
txt += "Othercosts: thru:"+j.thru+" lat:"+j.lat+" sizelat:"+j.sizelat+"\n"
txt += "\nIR:\n<code>"+escape(j.ll)+"</code>\n"
txt += "\nAsm:\n<code>"+escape(j.asm)+"</code>\n"
txt += "\nCodesize cost output:\n<code>"+escape(j.costoutput)+"</code>\n"
details.innerHTML = txt.replaceAll('\n', '<br>');
}
</script>
<style>
h1 {
font-family: verdana;
font-size: 24px;
}
h3 {
font-family: verdana;
font-size: 20px;
}
table {
width: 60%;
margin: 10px auto;
border-collapse: collapse;
background: white;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
}
th, td {
padding: 10px;
border: 1px solid #ddd;
text-align: left;
}
th {
background-color: #4c79aa;
color: white;
}
tr:nth-child(even) {
background-color: #f2f2f2;
}
td:hover {
background-color: #ddd;
}
code {
font-family: Consolas,"courier new";
}
button:focus {
background: #c3c3c3;
}
</style>
</head>
<body>
<h1>Cost model tests</h1>
<p>This attempts to compare the first-order output of the cost model compared to the measured codesize. It generates simple snippets of IR and compares the output of opt -passes=print<cost-model> -cost-kind=codesize and the assembly generated from llc. The assembly output of llc is sometimes filtered to remove loop invariant instructions.</p>
<p>The table lists the difference between the two cost models (i.e. zero is good). Not all the scores are expected to match exactly. More details and the costs can be found by clicking on a table entry.</p>
<div style="display: flex border=10px;">
<button onclick="reload('')">Base</button>
<button onclick="reload('-fullfp16')">FP16</button>
<button onclick="reload('-sve2')">SVE</button>
</div>
<h3>Integer diffs</h3>
<div style="display: flex;">
<div width="60%" style="flex: 0 0 60%;"><table id="table-int" class="dataframe" border="1"><th>Loading</th></table></div>
<div width="40%" style="position: sticky; top: 10px; align-self: flex-start; white-space: pre; padding: 10px;" id="details-int"><h3>Details</h3></div>
</div>
<h3>FP diffs</h3>
<div style="display: flex;">
<div width="60%" style="flex: 0 0 60%;"><table id="table-fp" class="dataframe" border="1"><th>Loading</th></table></div>
<div width="40%" style="position: sticky; top: 10px; align-self: flex-start; white-space: pre; padding: 10px;" id="details-fp"><h3>Details</h3></div>
</div>
<h3>Integer-Cast diffs</h3>
<div style="display: flex;">
<div width="60%" style="flex: 0 0 60%;"><table id="table-castint" class="dataframe" border="1"><th>Loading</th></table></div>
<div width="40%" style="position: sticky; top: 10px; align-self: flex-start; white-space: pre; padding: 10px;" id="details-castint"><h3>Details</h3></div>
</div>
<h3>FP-Cast diffs</h3>
<div style="display: flex;">
<div width="60%" style="flex: 0 0 60%;"><table id="table-castfp" class="dataframe" border="1"><th>Loading</th></table></div>
<div width="40%" style="position: sticky; top: 10px; align-self: flex-start; white-space: pre; padding: 10px;" id="details-castfp"><h3>Details</h3></div>
</div>
<h3>Vec diffs</h3>
<div style="display: flex;">
<div width="60%" style="flex: 0 0 60%;"><table id="table-vec" class="dataframe" border="1"><th>Loading</th></table></div>
<div width="40%" style="position: sticky; top: 10px; align-self: flex-start; white-space: pre; padding: 10px;" id="details-vec"><h3>Details</h3></div>
</div>
</body>
</html>