const gpu = new GPU();
var myFunc = gpu.createKernel(function(a, b) {
return a[this.thread.x] + b[this.thread.x];
}).setOutput([10]);
console.log(myFunc([0,1,2,3,4,5,6,7,8,9], [0,1,2,3,4,5,6,7,8,9]));
Float32Array(10) [0, 1.9999998807907104, 4, 5.999999523162842, 15.999999046325684, 15.999999046325684, 15.999999046325684, 15.999999046325684, 15.999999046325684, 15.999999046325684]
Float32Array(10) [0, 1.9999998807907104, 4, 5.999999523162842, 15.999999046325684, 10, 12, 14, 16, 17.999998092651367]
If use this code with files from
https://github.com/abhisheksoni27/gpu.js-demo(using setDimensions instead setOutput) or inhttp://gpu.rocks/playgroundthe result will bebut also 4 + 4 = 16