JSFiddle - React, Tailwind, and code Playground
HTML
<script src="https://unpkg.com/gpu.js@latest/dist/gpu-browser.min.js"></script>
JavaScript
// GPU is a constructor and namespace for browser
const gpu = new GPU();
const multiplyMatrix = gpu.createKernel(function(a, b) {
let sum = 0;
for (let i = 0; i < 512; i++) {
sum += a[this.thread.y][i] * b[i][this.thread.x];
}
return sum;
}).setOutput([512, 512]);
const c = multiplyMatrix(12, 12);
console.log(c);