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

Function dynamicOutput1DKernelMapShrinks

test/features/dynamic-output.js:151–178  ·  view source on GitHub ↗
(mode)

Source from the content-addressed store, hash-verified

149
150
151function dynamicOutput1DKernelMapShrinks(mode) {
152 const gpu = new GPU({ mode });
153 const kernel = gpu.createKernelMap({
154 result2: function map(v) {
155 return v;
156 }
157 }, function() {
158 return map(this.output.x + this.thread.x);
159 }, { dynamicOutput: true });
160
161 kernel.setOutput([10]);
162 let result = kernel();
163 assert.equal(result.result.length, 10);
164 assert.equal(result.result2.length, 10);
165 assert.deepEqual(Array.from(result.result), [10,11,12,13,14,15,16,17,18,19]);
166 assert.deepEqual(Array.from(result.result2), [10,11,12,13,14,15,16,17,18,19]);
167 assert.deepEqual(Array.from(kernel.output), [10]);
168
169 kernel.setOutput([5]);
170 result = kernel();
171 assert.equal(result.result.length, 5);
172 assert.equal(result.result2.length, 5);
173 assert.deepEqual(Array.from(result.result), [5,6,7,8,9]);
174 assert.deepEqual(Array.from(result.result2), [5,6,7,8,9]);
175 assert.deepEqual(Array.from(kernel.output), [5]);
176
177 gpu.destroy();
178}
179
180test('dynamic output 1d kernel map shrinks auto', () => {
181 dynamicOutput1DKernelMapShrinks();

Callers 1

dynamic-output.jsFile · 0.85

Calls 4

createKernelMapMethod · 0.95
destroyMethod · 0.95
kernelFunction · 0.85
setOutputMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…