Matrix Multiplication

var gpu = new GPU();

// Create the GPU accelerated function
var mat_mult = gpu.createKernel(function(A, B) {
    var sum = 0;
    for (var i=0; i<512; i++) {
        sum += A[this.thread.y][i] * B[i][this.thread.x];
    }
    return sum;
}).dimensions([512, 512]);

// Perform matrix multiplication on 2 matrices of size 512 x 512
var C = mat_mult(A, B);

To be continued

More examples to be added soon.