-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkernel-template.js
More file actions
44 lines (38 loc) · 894 Bytes
/
kernel-template.js
File metadata and controls
44 lines (38 loc) · 894 Bytes
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
// Kernel template
// Author: Peter Jensen
(function () {
// Kernel configuration
var kernelConfig = {
kernelName: "Test",
kernelInit: init,
kernelSimd: simd,
kernelNonSimd: nonSimd,
kernelIterations: 100000000
};
// Hook up to the harness
benchmarks.add (new Benchmark (kernelConfig));
// Kernel Initializer
function init () {
// Do sanity checking. Check that simd and nonSimd results are the same.
// returns:
// true: OK to run the test
// false: Not OK to run the test
return simd (1) === nonSimd (1);
}
// SIMD version of the kernel
function simd (n) {
var s = 0;
for (var i = 0; i < n; ++i) {
s += i;
}
return s;
}
// Non SIMD version of the kernel
function nonSimd (n) {
var s = 0;
for (var i = 0; i < n; ++i) {
s += i;
}
return s;
}
} ());