Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
106 lines (89 loc) · 2.18 KB

File metadata and controls

106 lines (89 loc) · 2.18 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
const { assert, skip, test, module: describe, only } = require('qunit');
const { GPU } = require('../../src');
describe('features: basic math');
function sumABTest(mode) {
const gpu = new GPU({ mode });
const f = gpu.createKernel(function(a, b) {
return (a[this.thread.x] + b[this.thread.x]);
}, {
output : [6],
mode : mode,
});
assert.ok( f !== null, 'function generated test');
const a = [1, 2, 3, 5, 6, 7];
const b = [4, 5, 6, 1, 2, 3];
const res = f(a,b);
const exp = [5, 7, 9, 6, 8, 10];
for(let i = 0; i < exp.length; ++i) {
assert.equal(res[i], exp[i], 'Result arr idx: '+i);
}
gpu.destroy();
}
test('sumAB auto', () => {
sumABTest(null);
});
test('sumAB gpu', () => {
sumABTest('gpu');
});
(GPU.isWebGLSupported ? test : skip)('sumAB webgl', () => {
sumABTest('webgl');
});
(GPU.isWebGL2Supported ? test : skip)('sumAB webgl2', () => {
sumABTest('webgl2');
});
(GPU.isHeadlessGLSupported ? test : skip)('sumAB headlessgl', () => {
sumABTest('headlessgl');
});
test('sumAB cpu', () => {
sumABTest('cpu');
});
function multABTest(mode) {
const gpu = new GPU({ mode });
const f = gpu.createKernel(function(a, b) {
let sum = 0;
sum += a[this.thread.y][0] * b[0][this.thread.x];
sum += a[this.thread.y][1] * b[1][this.thread.x];
sum += a[this.thread.y][2] * b[2][this.thread.x];
return sum;
}, {
output : [3, 3]
});
assert.ok(f !== null, 'function generated test');
assert.deepEqual(f(
[
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
],
[
[1, 2, 3],
[4, 5, 6],
[7, 8, 9]
]).map((object) => { return Array.from(object); }),
[
[30, 36, 42],
[66, 81, 96],
[102, 126, 150]
],
'basic mult function test'
);
gpu.destroy();
}
test('multAB auto', () => {
multABTest(null);
});
test('multAB gpu', () => {
multABTest('gpu');
});
(GPU.isWebGLSupported ? test : skip)('multAB webgl', () => {
multABTest('webgl');
});
(GPU.isWebGL2Supported ? test : skip)('multAB webgl2', () => {
multABTest('webgl2');
});
(GPU.isHeadlessGLSupported ? test : skip)('multAB headlessgl', () => {
multABTest('headlessgl');
});
test('multAB cpu', () => {
multABTest('cpu');
});
Morty Proxy This is a proxified and sanitized view of the page, visit original site.