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
93 lines (72 loc) · 2.05 KB

File metadata and controls

93 lines (72 loc) · 2.05 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
const { assert, skip, test, module: describe, only } = require('qunit');
const { GPU } = require('../../src');
describe('nested function');
function nestedSumABTest(mode) {
const gpu = new GPU({ mode });
const f = gpu.createKernel(function(a, b) {
function custom_adder(a,b) {
return a+b;
}
return custom_adder(a[this.thread.x], b[this.thread.x]);
}, {
output : [6]
});
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];
assert.deepEqual(Array.from(res), exp);
gpu.destroy();
}
test('nested_sum auto', () => {
nestedSumABTest(null);
});
test('nested_sum gpu', () => {
nestedSumABTest('gpu');
});
(GPU.isWebGLSupported ? test : skip)('nested_sum webgl', () => {
nestedSumABTest('webgl');
});
(GPU.isWebGL2Supported ? test : skip)('nested_sum webgl2', () => {
nestedSumABTest('webgl2');
});
(GPU.isHeadlessGLSupported ? test : skip)('nested_sum headlessgl', () => {
nestedSumABTest('headlessgl');
});
test('nested_sum cpu', () => {
nestedSumABTest('cpu');
});
function testNestedInCustomFunction(mode) {
function custom1() {
function nested1() {
return 1;
}
return nested1();
}
const gpu = new GPU({ mode });
gpu.addFunction(custom1);
const kernel = gpu.createKernel(function() {
return custom1();
}, { output: [1] });
assert.deepEqual(kernel(), new Float32Array([1]));
gpu.destroy();
}
test('nested in custom auto', () => {
testNestedInCustomFunction();
});
test('nested in custom gpu', () => {
testNestedInCustomFunction('gpu');
});
(GPU.isWebGLSupported ? test : skip)('nested in custom webgl', () => {
testNestedInCustomFunction('webgl');
});
(GPU.isWebGL2Supported ? test : skip)('nested in custom webgl2', () => {
testNestedInCustomFunction('webgl2');
});
(GPU.isHeadlessGLSupported ? test : skip)('nested in custom headlessgl', () => {
testNestedInCustomFunction('headlessgl');
});
test('nested in custom cpu', () => {
testNestedInCustomFunction('cpu');
});
Morty Proxy This is a proxified and sanitized view of the page, visit original site.