MCPcopy Index your code
hub / github.com/gpujs/gpu.js / nestedSumABTest

Function nestedSumABTest

test/features/nested-function.js:6–28  ·  view source on GitHub ↗
(mode)

Source from the content-addressed store, hash-verified

4describe('nested function');
5
6function nestedSumABTest(mode) {
7 const gpu = new GPU({ mode });
8 const f = gpu.createKernel(function(a, b) {
9 function custom_adder(a,b) {
10 return a+b;
11 }
12
13 return custom_adder(a[this.thread.x], b[this.thread.x]);
14 }, {
15 output : [6]
16 });
17
18 assert.ok(f !== null, 'function generated test');
19
20 const a = [1, 2, 3, 5, 6, 7];
21 const b = [4, 5, 6, 1, 2, 3];
22
23 const res = f(a,b);
24 const exp = [5, 7, 9, 6, 8, 10];
25
26 assert.deepEqual(Array.from(res), exp);
27 gpu.destroy();
28}
29
30test('nested_sum auto', () => {
31 nestedSumABTest(null);

Callers 1

nested-function.jsFile · 0.85

Calls 3

createKernelMethod · 0.95
destroyMethod · 0.95
custom_adderFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…