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
118 lines (106 loc) · 2.81 KB

File metadata and controls

118 lines (106 loc) · 2.81 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
106
107
108
109
110
111
112
113
114
115
116
117
const { assert, skip, test, module: describe, only } = require('qunit');
const { GPU, WebGLFunctionNode, WebGL2FunctionNode } = require('../../src');
describe('internal: loop max');
test('loop max output webgl', () => {
const functionNode = new WebGLFunctionNode((function(a, b) {
let sum = 0;
for (let i = 0; i < a; i++) {
sum += b[this.thread.x][i];
}
return sum;
}).toString(), {
isRootKernel: true,
name: 'kernel',
output: [1],
argumentTypes: ['Number', 'Array'],
lookupFunctionArgumentBitRatio: () => 4,
});
assert.equal(
functionNode.toString(),
'void kernel() {' +
'\nfloat user_sum=0.0;' +
'\nint user_i=0;' +
'\nfor (int safeI=0;safeI<LOOP_MAX;safeI++){' +
'\nif (!(user_i<int(user_a))) break;' +
'\nuser_sum+=get32(user_b, user_bSize, user_bDim, 0, threadId.x, user_i);' +
'\nuser_i++;}' +
'\n' +
'\nkernelResult = user_sum;return;' +
'\n}');
});
test('loop max output webgl2', () => {
const functionNode = new WebGL2FunctionNode((function(a, b) {
let sum = 0;
for (let i = 0; i < a; i++) {
sum += b[this.thread.x][i];
}
return sum;
}).toString(), {
isRootKernel: true,
name: 'kernel',
output: [1],
argumentTypes: ['Number', 'Array'],
lookupFunctionArgumentBitRatio: () => 4,
});
assert.equal(
functionNode.toString(),
'void kernel() {' +
'\nfloat user_sum=0.0;' +
'\nint user_i=0;' +
'\nfor (int safeI=0;safeI<LOOP_MAX;safeI++){' +
'\nif (!(user_i<int(user_a))) break;' +
'\nuser_sum+=get32(user_b, user_bSize, user_bDim, 0, threadId.x, user_i);' +
'\nuser_i++;}' +
'\n' +
'\nkernelResult = user_sum;return;' +
'\n}');
});
(GPU.isWebGLSupported ? test : skip)('loop max webgl', () => {
const gpu = new GPU({mode: 'webgl'});
const add = gpu.createKernel(function(a, b) {
let sum = 0;
for (let i = 0; i < a; i++) {
sum += b[this.thread.x][i];
}
return sum;
}).setOutput([1]);
const output = add(1, [[1]]);
assert.equal(
output[0],
1
);
gpu.destroy();
});
(GPU.isWebGL2Supported ? test : skip)('loop max webgl2', () => {
const gpu = new GPU({mode: 'webgl2'});
const add = gpu.createKernel(function(a, b) {
let sum = 0;
for (let i = 0; i < a; i++) {
sum += b[this.thread.x][i];
}
return sum;
}).setOutput([1]);
const output = add(1, [[1]]);
assert.equal(
output[0],
1
);
gpu.destroy();
});
(GPU.isHeadlessGLSupported ? test : skip)('loop max headlessgl', () => {
const gpu = new GPU({ mode: 'headlessgl' });
const add = gpu.createKernel(function(a, b) {
let sum = 0;
for (let i = 0; i < a; i++) {
sum += b[this.thread.x][i];
}
return sum;
})
.setOutput([1]);
const output = add(1, [[1]]);
assert.equal(
output[0],
1
);
gpu.destroy();
});
Morty Proxy This is a proxified and sanitized view of the page, visit original site.