forked from fingerecho/gpu.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path300-nested-array-index.js
More file actions
50 lines (43 loc) · 1.51 KB
/
300-nested-array-index.js
File metadata and controls
50 lines (43 loc) · 1.51 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
47
48
49
50
(function() {
var gpu1, gpu2;
// these 2 should be erquivilent
createNestedKernel = function(mode) {
gpu1 = new GPU({ mode });
var broken = gpu1.createKernel(function(input, lookup) {
return lookup[input[this.thread.x]];
}).setOutput([1]);
return broken;
}
createTempVarKernel = function(mode) {
gpu2 = new GPU({ mode });
var working = gpu2.createKernel(function(input, lookup) {
var idx = input[this.thread.x];
return lookup[idx];
}).setOutput([1]);
return working;
}
QUnit.test('Issue #300 nested array index - auto', () => {
QUnit.assert.equal(createNestedKernel()([2], [7, 13, 19, 23])[0], 19);
QUnit.assert.equal(createTempVarKernel()([2], [7, 13, 19, 23])[0], 19);
gpu1.destroy();
gpu2.destroy();
});
QUnit.test('Issue #300 nested array index - gpu', () => {
QUnit.assert.equal(createNestedKernel('gpu')([2], [7, 13, 19, 23])[0], 19);
QUnit.assert.equal(createTempVarKernel('gpu')([2], [7, 13, 19, 23])[0], 19);
gpu1.destroy();
gpu2.destroy();
});
QUnit.test('Issue #300 nested array index - webgl', () => {
QUnit.assert.equal(createNestedKernel('webgl')([2], [7, 13, 19, 23])[0], 19);
QUnit.assert.equal(createTempVarKernel('webgl')([2], [7, 13, 19, 23])[0], 19);
gpu1.destroy();
gpu2.destroy();
});
QUnit.test('Issue #300 nested array index - webgl2', () => {
QUnit.assert.equal(createNestedKernel('webgl2')([2], [7, 13, 19, 23])[0], 19);
QUnit.assert.equal(createTempVarKernel('webgl2')([2], [7, 13, 19, 23])[0], 19);
gpu1.destroy();
gpu2.destroy();
});
})();