forked from fingerecho/gpu.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path207-same-function-reuse.js
More file actions
46 lines (38 loc) · 1.09 KB
/
207-same-function-reuse.js
File metadata and controls
46 lines (38 loc) · 1.09 KB
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
(function() {
function reuse(mode) {
var gpu = new GPU({ mode: mode });
var f = gpu.createKernel(function(a, b) {
function custom_adder(a, b) {
return a + b;
}
function some_fun_1(a, b) {
return custom_adder(a, b);
}
function some_fun_2(a, b) {
return custom_adder(a, b);
}
return some_fun_1(1,2) + some_fun_2(a[this.thread.x], b[this.thread.x]);
})
.setOutput([6]);
var a = [1, 2, 3, 5, 6, 7];
var b = [4, 5, 6, 1, 2, 3];
var result = f(a,b);
QUnit.assert.deepEqual(QUnit.extend([], result), [8,10,12,9,11,13]);
gpu.destroy();
}
QUnit.test('Issue #207 - same function reuse (cpu)', function() {
reuse('cpu');
});
QUnit.test('Issue #207 - same function reuse (auto)', function() {
reuse(null);
});
QUnit.test('Issue #207 - same function reuse (gpu)', function() {
reuse('gpu');
});
QUnit.test('Issue #207 - same function reuse (webgl)', function() {
reuse('webgl');
});
QUnit.test('Issue #207 - same function reuse (webgl2)', function() {
reuse('webgl2');
});
})();