https://github.com/mil-tokyo/sushi2
Matrix Library for JavaScript
https://github.com/mil-tokyo/sushi2
gpu-computing javascript matrix-library webcl
Last synced: about 1 year ago
JSON representation
Matrix Library for JavaScript
- Host: GitHub
- URL: https://github.com/mil-tokyo/sushi2
- Owner: mil-tokyo
- License: other
- Archived: true
- Created: 2016-11-04T01:52:38.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2017-01-17T06:47:21.000Z (over 9 years ago)
- Last Synced: 2024-05-14T02:41:20.674Z (about 2 years ago)
- Topics: gpu-computing, javascript, matrix-library, webcl
- Language: JavaScript
- Size: 771 KB
- Stars: 60
- Watchers: 21
- Forks: 4
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Sushi2 library
Matrix Library for JavaScript
This library is intended to be the fastest matrix library for JavaScript, with the power of GPU computing.
To gain best performance, [WebCL](https://en.wikipedia.org/wiki/WebCL) technology is used to access GPU from JavaScript.
[Interactive getting started on the browser](https://mil-tokyo.github.io/sushilab/?loadurl=notebooks/gettingstarted.json)
[Documents (work in progress)](https://mil-tokyo.github.io/sushi2/)
# Build for use in node.js
Since this project is written in TypeScript, transpiling to JavaScript is necessary.
Package from npm repository contains transplied JavaScript, so simply installing them is enough.
```bash
npm install milsushi2
```
If you intend to modify code, download and build.
```bash
git clone https://github.com/mil-tokyo/sushi2
cd sushi2
npm install
npm run build
```
Sushi2 depends on [node-opencl](https://github.com/mikeseven/node-opencl) for GPU computing which allows dramatically faster computation.
This dependency is optional, so even the installation of node-opencl fails, Sushi2 can work without it.
In my environment (Ubuntu 14.04 + NVIDIA CUDA 7.5), installation with node-opencl requires additional environment variables.
```bash
CPLUS_INCLUDE_PATH=/usr/local/cuda/include LIBRARY_PATH=/usr/local/cuda/lib64 npm install milsushi2
```
# Build for use in web browser
For simply using the library, download the js file from [releases page](https://github.com/mil-tokyo/sushi2/releases).
To make single JavaScript file for web browsers, type the following commands:
```bash
git clone https://github.com/mil-tokyo/sushi2
cd sushi2
npm install
npm run build
npm run browserify
```
This will generate `browser/milsushi2.js` (without WebCL support), and `browser/milsushi2_cl.js` (WebCL support version).
# Usage in node.js
You can import the module by `require('milsushi2')`.
Hello world in node shell
```javascript
var $M = require('milsushi2');
$M.initcl();//OpenCL initialization, true if succeeds
var x = $M.jsa2mat([[1,2],[3,4]]);
var y = $M.jsa2mat([[0.1,0.5],[0.7,0.0]]);
$M.plus(x, y);
```
# Usage in web browser
By loading them from html page (``), `milsushi2` global object is generated.
Hello world in html
```html
var $M = milsushi2;
var x = $M.jsa2mat([[1,2],[3,4]]);
var y = $M.jsa2mat([[0.1,0.5],[0.7,0.0]]);
alert($M.plus(x, y));
```
To use WebCL for GPU computing, use `milsushi2_cl.js` instead of `milsushi2`.
Unfortunately, currently a plugin is needed to enable WebCL. We tested on [webcl-firefox](https://github.com/toaarnio/webcl-firefox) plugin with [Firefox 32](https://ftp.mozilla.org/pub/firefox/releases/32.0/).
Compiled version of webcl-firefox plugin for Linux is [here](https://drive.google.com/file/d/0BxKvBdxU_LchMWVVUWFGVS1NcE0/view?usp=sharing) (Ubuntu 14.04 + CUDA 7.5, commit d87447f, License: MPL 2.0).
If WebCL is enabled, `$M.initcl()` should return true.
# License
MIT