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

Function inKernelInstanceSettings

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

Source from the content-addressed store, hash-verified

98});
99
100function inKernelInstanceSettings(mode) {
101 function customAdder(a, b) {
102 return a + b;
103 }
104 const gpu = new GPU({ mode });
105 const kernel = gpu.createKernel(function (a, b) {
106 return customAdder(a[this.thread.x], b[this.thread.x]);
107 }, {
108 output: [6],
109 functions: [
110 customAdder
111 ],
112 });
113
114 const a = [1, 2, 3, 5, 6, 7];
115 const b = [4, 5, 6, 1, 2, 3];
116
117 const result = kernel(a, b);
118
119 const expected = [5, 7, 9, 6, 8, 10];
120
121 assert.deepEqual(Array.from(result), expected);
122 gpu.destroy();
123}
124
125test('in Kernel instance settings auto', () => {
126 inKernelInstanceSettings(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…