Skip to content

Commit 3cf24fa

Browse files
committed
Update README.md
1 parent 967476e commit 3cf24fa

1 file changed

Lines changed: 31 additions & 5 deletions

File tree

README.md

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,32 @@
11
[![Logo](http://gpu.rocks/img/ogimage.png)](http://gpu.rocks/)
22

3-
gpu.js is a single-file JavaScript library for GPGPU using WebGL. There is graceful fallback to JavaScript if WebGL is not available.
3+
gpu.js is a single-file JavaScript library for GPGPU in the browser. gpu.js will automatically compile specially written JavaScript functions into shader language and run it on the GPU using the WebGL API. There is graceful fallback to JavaScript if WebGL is not available.
4+
5+
# Example
6+
7+
Matrix multiplication written in gpu.js:
8+
9+
```js
10+
var gpu = new GPU();
11+
12+
// Create the GPU accelerated function from a kernel
13+
// function that computes a single element in the
14+
// 512 x 512 matrix (2D array). The kernel function
15+
// is run in a parallel manner in the GPU resulting
16+
// in very fast computations! (...sometimes)
17+
var mat_mult = gpu.createKernel(function(A, B) {
18+
var sum = 0;
19+
for (var i=0; i<512; i++) {
20+
sum += A[this.thread.y][i] * B[i][this.thread.x];
21+
}
22+
return sum;
23+
}).dimensions([512, 512]);
24+
25+
// Perform matrix multiplication on 2 matrices of size 512 x 512
26+
var C = mat_mult(A, B);
27+
```
28+
29+
You can run a benchmark of this [here](http://gpu.rocks). Typically, it will run at 1-15x speedup depending on your hardware.
430

531
# Getting Started
632

@@ -21,10 +47,10 @@ var gpu = new GPU();
2147
Depnding on your output type, specify the intended dimensions of your output. You cannot have a accelerated function that does not specify any dimensions.
2248

2349
Dimensions of Output | How to specify dimensions
24-
--- | ---
25-
1D | `[length]`
26-
2D | `[width, height]`
27-
3D | `[width, height, depth]`
50+
----------------------- |-------------------------------
51+
1D | `[length]`
52+
2D | `[width, height]`
53+
3D | `[width, height, depth]`
2854

2955
```js
3056
var opt = {

0 commit comments

Comments
 (0)