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

Function gpuAddAB

test/features/inject-native.js:6–33  ·  view source on GitHub ↗
(mode)

Source from the content-addressed store, hash-verified

4describe('features: inject native');
5
6function gpuAddAB(mode) {
7 const gpu = new GPU({mode});
8 gpu
9 .injectNative(`
10int customAdder(int a, int b) {
11 return a + b;
12}
13`)
14 .addNativeFunction('customAdderLink', `int customAdderLink(int a, int b) {
15 return customAdder(a, b);
16}`);
17 const kernel = gpu.createKernel(function (a, b) {
18 return customAdderLink(a[this.thread.x], b[this.thread.x]);
19 }, {
20 output: [6],
21 returnType: 'Integer'
22 });
23
24 const a = [1, 2, 3, 5, 6, 7];
25 const b = [4, 5, 6, 1, 2, 3];
26
27 const result = kernel(a, b);
28
29 const expected = [5, 7, 9, 6, 8, 10];
30
31 assert.deepEqual(Array.from(result), expected);
32 gpu.destroy();
33}
34
35test('addAB auto', () => {
36 gpuAddAB(null);

Callers 1

inject-native.jsFile · 0.85

Calls 5

injectNativeMethod · 0.95
createKernelMethod · 0.95
destroyMethod · 0.95
kernelFunction · 0.85
addNativeFunctionMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…