-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.xhtml
447 lines (431 loc) · 20.5 KB
/
main.xhtml
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
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
<!DOCTYPE html>
<html>
<head>
<title> Math function compiler </title>
<link rel="stylesheet"
href="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.18.0/build/styles/default.min.css"/>
<script src="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@9.18.0/build/highlight.min.js"></script>
<script src="https://unpkg.com/muuri@0.8.0/dist/muuri.min.js"></script>
<script>
hljs.initHighlightingOnLoad();
/* Global counter for optimization pass number.
* used to generate a new id for a new pass */
var pass_number = ${len(registered_pass_list)};
</script>
<style>
.board {
position: relative;
width: 100%;
margin-left: 1%;
}
.board-column {
position: absolute;
left: 0;
right: 0;
width: 90%;
margin: 0 1.5%;
background: #f0f0f0;
border-radius: 3px;
z-index: 1;
}
.board-column.muuri-item-releasing {
z-index: 2;
}
.board-column.muuri-item-dragging {
z-index: 3;
cursor: move;
}
.board-column-header {
position: relative;
height: 35px;
line-height: 35px;
overflow: hidden;
padding: 0 20px;
text-align: center;
background: #333;
color: #fff;
border-radius: 3px 3px 0 0;
}
@media (max-width: 600px) {
.board-column-header {
text-indent: -1000px;
}
}
.board-column.todo .board-column-header {
background: #4A9FF9;
}
.board-column.working .board-column-header {
background: #f9944a;
}
.board-column.done .board-column-header {
background: #2ac06d;
}
.board-column-content {
position: relative;
border: 10px solid transparent;
min-height: 95px;
}
.board-item {
position: absolute;
width: 100%;
margin: 5px 0;
}
.board-item.muuri-item-releasing {
z-index: 9998;
}
.board-item.muuri-item-dragging {
z-index: 9999;
cursor: move;
}
.board-item.muuri-item-hidden {
z-index: 0;
}
.board-item-content {
position: relative;
padding: 10px;
background: #fff;
border-radius: 4px;
font-size: 17px;
cursor: pointer;
-webkit-box-shadow: 0px 1px 3px 0 rgba(0,0,0,0.2);
box-shadow: 0px 1px 3px 0 rgba(0,0,0,0.2);
}
@media (max-width: 600px) {
.board-item-content {
text-align: center;
}
.board-item-content span {
display: none;
}
}
.option_select {
width: 250px;
}
.option_label {
font-weight: bold;
}
.option_label_cell {
text-align: right;
}
</style>
</head>
<body>
<center>
<table>
<tr>
<td colspan="2">
<h1> Math function compiler </h1>
<h2> (version ${version_info})</h2>
<p>
Math function compiler generates source code from a function expression.
This web application is based on the tools <b>metalibm-lugdunum</b>, available on <a href="https://github.com/kalray/metalibm"> Kalray's github page </a>
</p>
<p> <b>Metalibm-lugdunum</b> is a code generator for elementary functions. It is part of a larger project <a href="http://metalibm.org"> metalibm.org</a>.
</p>
<p>
You can report issue with the web application <a href="https://github.com/metalibm/MetalibmWepApp/issues/new">there</a> and with metalibm <a href="https://github.com/kalray/metalibm/issues/new"> here </a>.
</p>
</td>
</tr>
<tr>
<td>
<b>Generation options:</b><br/>
</td>
<td>
<b>Code result:</b>
<py:if test="not total_time is None">
<i> (generated in ${"{:.3f}".format(total_time)} second(s) </i>
</py:if>
<br/>
</td>
</tr>
<tr>
<td width="500px" valign="top">
<form action="function" method="get" >
<table>
<tr>
<td width="150px" class="option_label_cell">
<label class="option_label">Function expression:</label>
</td>
<td width="350px">
<input name="fct_expr" id="fct_expr" value="${fct_expr}" style="text-align: right;" />
</td>
</tr>
<tr>
<td class="option_label_cell">
<label class="option_label">Format:</label>
</td>
<td>
<select name="io_format" id="io_format" class="option_select">
<py:for each="io_format in format_list">
<py:if test="precision == io_format">
<option value="${io_format}" selected="selected">${io_format}</option>
</py:if><py:else>
<option value="${io_format}">${io_format}</option>
</py:else>
</py:for>
</select>
</td>
</tr>
<tr>
<td class="option_label_cell">
<label class="option_label">Input Range:</label>
</td>
<td>
<input id="range_lo" size="5" name="range_lo" value="${range_lo}"></input>
<input id="range_hi" size="5" name="range_hi" value="${range_hi}"></input>
<py:if test="range_nan">
<input type="checkbox" name="range_nan" id="range_nan" value="True" checked="true"/>
</py:if><py:else>
<input type="checkbox" name="range_nan" id="range_nan" value="True"/>
</py:else>
NaN included.
</td>
</tr>
<tr>
<td class="option_label_cell">
<label class="option_label">Debug:</label>
</td>
<td>
<py:if test="debug">
<input type="checkbox" name="debug" id="debug" value="True" checked="true"/>
</py:if><py:else>
<input type="checkbox" name="debug" id="debug" value="True"/>
</py:else>
</td>
</tr>
<tr>
<td class="option_label_cell">
<label class="option_label">Vector size:</label>
</td>
<td>
<select name="vector_size" id="vector_size" class="option_select">
<py:for each="possible_vector_size in vector_size_list">
<py:if test="possible_vector_size == vector_size">
<option value="${possible_vector_size}" selected="selected">${possible_vector_size}</option>
</py:if><py:else>
<option value="${possible_vector_size}">${possible_vector_size}</option>
</py:else>
</py:for>
</select>
</td>
</tr>
<tr>
<td class="option_label_cell">
<label class="option_label">Sub-Vector size:</label>
</td>
<td>
<select name="sub_vector_size" id="sub_vector_size" class="option_select">
<py:for each="possible_sub_vector_size in sub_vector_size_list">
<py:if test="possible_sub_vector_size == sub_vector_size">
<option selected="selected" value="${possible_sub_vector_size}"> ${possible_sub_vector_size}</option>
</py:if><py:else>
<option value="${possible_sub_vector_size}">${possible_sub_vector_size or 'default'}</option>
</py:else>
</py:for>
</select>
</td>
</tr>
<tr>
<td class="option_label_cell">
<label class="option_label">Target:</label>
</td>
<td>
<select name="target" id="target" class="option_select">
<py:for each="possible_target in target_list">
<py:if test="possible_target == target">
<option value="${possible_target}" selected="selected">${possible_target}</option>
</py:if><py:else>
<option value="${possible_target}">${possible_target}</option>
</py:else>
</py:for>
</select>
</td>
</tr>
<tr>
<td class="option_label_cell">
<label class="option_label">Language:</label>
</td>
<td>
<select name="language" id="language" class="option_select">
<py:for each="possible_language in language_list">
<py:if test="possible_language == language">
<option value="${possible_language}" selected="selected">${possible_language}</option>
</py:if><py:else>
<option value="${possible_language}">${possible_language}</option>
</py:else>
</py:for>
</select>
</td>
</tr>
<tr>
<td valign="top" class="option_label_cell">
<label class="option_label">Pass List:</label>
</td>
<td>
<div class="board">
<div class="board-column todo">
<div class="board-column-header">Pass List</div>
<div class="board-column-content">
<py:for each="pass_index, registered_pass in enumerate(registered_pass_list)">
<div class="board-item" id="pass_${pass_index}-${registered_pass}">
<div class="board-item-content" id="${registered_pass}">
${registered_pass}
<!--<a onclick="remove_pass('pass_${pass_index}-${registered_pass}')">Del</a>-->
</div>
</div>
</py:for>
</div>
</div>
</div>
</td>
</tr>
<tr>
<td class="option_label_cell">
<label class="option_label">Add a new pass:</label>
</td>
<td>
<select name="new_pass" id="new_pass" class="option_select">
<py:for each="possible_pass in available_pass_list">
<option value="${possible_pass}">${possible_pass}</option>
</py:for>
</select>
<input type="button" value="Add" onclick="add_new_pass()"/>
<input type="hidden" id="registered_pass_list" name="registered_pass_list" value="${','.join(registered_pass_list)}"/>
</td>
</tr>
<tr>
<td class="option_label_cell" style="text-align: center;" colspan="2">
<label class="option_label">Pre-configured flows</label><br/>
</td>
</tr>
<tr>
<td>
<p style="text-align: center; font-size: 15px; font-weight: bold; color: red;"> Will clear every other registered passes </p>
</td>
<td>
<select style="width: 300px" id="preconf_flow">
<py:for each="flow in sorted(preconf_flow)">
<option value="${flow}">${preconf_flow[flow]['title']}</option>
</py:for>
</select>
<script>
${literal(preconf_flow_script)}
</script>
<br/>
<center>
<input type="button" value="Clear and Add" onclick="add_preconf_flow()"/>
</center>
</td>
</tr>
<tr>
<td class="option_label_cell">
<label class="option_label"> Evaluate error: </label>
</td>
<td>
<py:if test="eval_error">
<input type="checkbox" name="eval_error" checked="true" value="True"/>
</py:if><py:else>
<input type="checkbox" name="eval_error" value="True"/>
</py:else>
</td>
</tr>
<tr>
<td colspan="2">
<br/>
<div style="text-align:center;">
<input type="submit" value="Generate!"/>
<input type="button" value="Clear!" onclick="window.location.href = '${localhost}';"/>
</div>
</td>
<td>
</td>
</tr>
<tr>
</tr>
</table>
</form>
</td>
<py:if test="error is None">
<td width="500px">
<pre>
<code class="C" style="overflow-y: scroll;height:500px; width: 500px; overflow-x: scroll;" id="rawSourceCode">
${code}
</code>
</pre>
<p>
<py:if test="not max_error is None">
Evaluated error: ${"{:.2f}".format(float(max_error))} ulp(s)
</py:if>
<br/>
<b> Note: </b> This error was evaluated on random inputs from a subset of the input range.
It is not a certificate for implementation error. The actual error may
be much worse than this metric.
</p>
<!-- The button used to copy the text -->
<input type="hidden" id="sourceCode" value="${code}"/>
<center>
<button onclick="copyCodeToClipboard()">Copy source code to clipboard</button>
</center>
Metalibm's single-header support library can be downloaded <a href="https://raw.githubusercontent.com/kalray/metalibm/generic_lowering/metalibm_core/support_lib/ml_support_lib.h">here </a>
<b> Build Command: </b> <br/>
<code class="bash" style="overflow-y: scroll;height:100px; width: 500px; overflow-x: scroll;" id="rawSourceCode">
${build_cmd}
</code>
</td>
</py:if><py:else>
<td>
<div>
Error encountered:
<p py:content="literal(error)"></p>
</div>
<a href="${report_issue_url}"> Click here to report an issue </a>
</td>
</py:else>
</tr>
<tr>
<td colspan="2" width="1000px">
<b><u>Help:</u></b>
<p> <b>Function expression</b> is the function expression to be generated. x and y are valid input varibles. The 4 basic operations (+, -, / and *) are supported. The following elementary functions are supported: exp, log, log2, log10, exp2, expm1, sqrt, cbrt, cos, sin, cosh, sinh, tanh.</p>
<p> <b>Format </b> is the input and output format.</p>
<p> <b>Input range</b> is the input interval. By adding the pass <i> numerical_simplification</i> you can enable Metalibm to optimize the function using this range information. If <i>NaN included</i> is selected the range is forced to the full range of floating-point values in the given format. </p>
<p> <b>Debug </b> triggers the insertion of various dynamic value print in the source code.</p>
<p> <b>Vector size </b> is the input and output vector size. 1 corresponds to a scalar function. </p>
<p> <b>Sub vector size </b> indicates which size of vector must be used to implement the vector function. Metalibm will generate replicated implementation for this sub-vector size and aggregate them to generate the full vector size implementation. </p>
<p> <b>Target </b> indicates which backend must be used for code generation. </p>
<p> <b>Language </b> indicates the output language. </p>
<p> <b>Pass list</b> is the list of optimization pass executed on the intermediate representation. Select a new pass in the <b> Add a new pass</b> menu and click "Add" to insert it at the end of the optimization pipeline. You can re-order passes by dragging and dropping them. You can delete a pass by dragging it and dropping outside of the pass list box.
</p>
<p> <b> Evaluate error</b> triggers the comparison of the generated source against expected value on random inputs. The relative error is reported here (in terms of ulp(s) for a suitable definition of ulp).</p>
<p>
<b><u>Some examples:</u></b>
<ul>
<py:for each="example_tag in example_map">
<li><a href="${example_map[example_tag]}">${example_tag}</a></li>
</py:for>
</ul>
</p>
<p> <b>To execute the generated source code:</b> </p>
</td>
</tr>
<tr>
<td colspan="2" width="1000px">
<b><u>Changelog:</u></b>
<ul>
<li> New interface to describe a function expression </li>
<li> Each target defines a default optimization pipeline (no need to add required passes anymore).</li>
<li> Adding default sub-vector size option to let the target chose the sub-vector size value. </li>
<li> Adding new optimization pass <b>evaluate_range</b> to evaluate nodes' intervals.</li>
</ul>
</td>
</tr>
<tr>
<td colspan="2">
<p> <i> This page is propulsed by <a href="https://turbogears.org/">TurboGears</a> and uses <a href="https://github.com/nandoflorestan/kajiki">kajiki</a> template, <a href="https://haltu.github.io/muuri/">muuri</a> and <a href="https://highlightjs.org/">highlightjs </a> </i></p>
</td>
</tr>
</table>
</center>
</body>
<script src="${localhost}/mwa.js"></script>
</html>