MCPcopy Create free account
hub / github.com/gpujs/gpu.js / inGPUInstanceSettings

Function inGPUInstanceSettings

test/features/add-custom-function.js:6–26  ·  view source on GitHub ↗
(mode)

Source from the content-addressed store, hash-verified

4describe('features: add custom function');
5
6function inGPUInstanceSettings(mode) {
7 function customAdder(a, b) {
8 return a + b;
9 }
10 const gpu = new GPU({mode, functions: [customAdder] });
11 const kernel = gpu.createKernel(function (a, b) {
12 return customAdder(a[this.thread.x], b[this.thread.x]);
13 }, {
14 output: [6]
15 });
16
17 const a = [1, 2, 3, 5, 6, 7];
18 const b = [4, 5, 6, 1, 2, 3];
19
20 const result = kernel(a, b);
21
22 const expected = [5, 7, 9, 6, 8, 10];
23
24 assert.deepEqual(Array.from(result), expected);
25 gpu.destroy();
26}
27
28test('in GPU instance settings auto', () => {
29 inGPUInstanceSettings(null);

Callers 1

Calls 4

createKernelMethod · 0.95
destroyMethod · 0.95
kernelFunction · 0.85
customAdderFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…