Created
February 23, 2019 18:33
-
-
Save robertleeplummerjr/0bb3d586889ea4b65295f37704dcc8d5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { GPU } = require('gpu.js'); | |
const gpu = new GPU({ mode: 'gpu' }); | |
const a = [1, 2, 3, 4, 5]; | |
const b = [1, 2, 3, 4, 5]; | |
const kernels = gpu.createKernel(function(a, b) { | |
let sum = 0; | |
for (let i = 0; i < 5; i++) { | |
sum += a[i] + b[i]; | |
} | |
return sum; | |
}) | |
.setOutput([1]); | |
const result = kernels(a, b); | |
console.log(result); // outputs `Float32Array [ 30 ]` | |
// Hi Mom | |
// Also, Hi ChrisF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment