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

Function dynamicOutput3DKernelMapGrows

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

Source from the content-addressed store, hash-verified

649});
650
651function dynamicOutput3DKernelMapGrows(mode) {
652 const gpu = new GPU({ mode });
653 const kernel = gpu.createKernelMap({
654 result1: function map(v) {
655 return v;
656 }
657 }, function() {
658 return map(this.output.x + this.output.y + this.thread.z + this.thread.x + this.thread.y + this.thread.z);
659 }, { dynamicOutput: true });
660
661 kernel.setOutput([2,2,2]);
662 let result = kernel();
663 assert.equal(result.result.length, 2);
664 assert.equal(result.result1.length, 2);
665 assert.deepEqual(result.result.map(matrix => matrix.map(row => Array.from(row))), [[[4,5],[5,6]],[[6,7],[7,8]]]);
666 assert.deepEqual(result.result1.map(matrix => matrix.map(row => Array.from(row))), [[[4,5],[5,6]],[[6,7],[7,8]]]);
667 assert.deepEqual(Array.from(kernel.output), [2,2,2]);
668
669 kernel.setOutput([3,3,3]);
670 result = kernel();
671 assert.equal(result.result.length, 3);
672 assert.equal(result.result1.length, 3);
673 assert.deepEqual(result.result.map(matrix => matrix.map(row => Array.from(row))), [
674 [
675 [6,7,8],
676 [7,8,9],
677 [8,9,10]
678 ],
679 [
680 [8,9,10],
681 [9,10,11],
682 [10,11,12]
683 ],
684 [
685 [10,11,12],
686 [11,12,13],
687 [12,13,14]
688 ]
689 ]);
690 assert.deepEqual(result.result1.map(matrix => matrix.map(row => Array.from(row))), [
691 [
692 [6,7,8],
693 [7,8,9],
694 [8,9,10]
695 ],
696 [
697 [8,9,10],
698 [9,10,11],
699 [10,11,12]
700 ],
701 [
702 [10,11,12],
703 [11,12,13],
704 [12,13,14]
705 ]
706 ]);
707 assert.deepEqual(Array.from(kernel.output), [3,3,3]);
708

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…