-
Notifications
You must be signed in to change notification settings - Fork 5
/
sylvesterTest.html
73 lines (62 loc) · 2.22 KB
/
sylvesterTest.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
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"></script>
<!--<script type="text/javascript" src="static/OriginalSylvester.js"> </script>test-->
<script type="text/javascript" src="static/sylvester.js"> </script>
<script>
function createArrayMatrix(width, height, valueOne, valueTwo){
arrayMatrix = []
row = []
for(i = 0; i < width; ++i){
if(i % 2 == 0)
row[row.length] = valueOne;
if(i % 2 == 1){
if(valueTwo)
row[row.length] = valueTwo;
else
row[row.length] = valueOne;
}
}
for(i = 0; i < height; ++i){
arrayMatrix[arrayMatrix.length] = row.slice();
}
return arrayMatrix;
}
$(document).ready(function(){
$("#execute").click(function(){
var startDate = new Date();
one = $M(createArrayMatrix(1024, 1024, 1, 2));
other = $M(createArrayMatrix(1024, 1024, 1));
two = one.multiply(other);
alert((new Date() - startDate) / 1000.0);
});
$("#executeSample").click(function(){
var one = $M([[1,2], [1,2]]);
var two= $M([[1,2], [1,2]]);
var result = one.multiply(two)
alert(result.elements);
});
});
</script>
</head>
<body>
<div style="padding: 5px; border: 1px solid black; position:relative; width:500px">
This page includes the sylvester library, modified to use the gpu for matrix multiply, the api is exactly the same as the orignal sylvester. Hit execute to benchmark a multiply of two 1024x1024 matrices<br/>
</div>
<input id="execute" type="button" value="execute"><br/><br/>
Open up firebug or the console to test it out <br/>
example code:
<pre>
<code>
var one = $M([[1,2], [1, 2 ]]);
var two= $M([[1,2], [1, 2 ]]);
var result = one.multiply(two)
alert(result.elements);
</code>
</pre>
<input id="executeSample" type="button" value="execute"><br/><br/>
<span><a href="sylvesterTest.html">gpu sylvester</a> <a href="sylvesterTestOriginal.html">original sylvester</a></span>
<br/><br/><br/><span>WebGL is required, below are instructinons to enable WebGL for Safari</span><br/>
<a href='http://webkit.org/blog/603/webgl-now-available-in-webkit-nightlies/'>webkit WebGL instructions</a><br/>
</body>
</html>