Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Investigate WebAssembly integration #102

Closed
mateogianolio opened this issue Jan 21, 2017 · 9 comments
Closed

Investigate WebAssembly integration #102

mateogianolio opened this issue Jan 21, 2017 · 9 comments

Comments

@mateogianolio
Copy link
Owner

WebAssembly has reached Browser Preview and offers high performance typed array manipulation. It also makes it possible run C code in the browser, which might be very interesting for this project. We should investigate in which ways we can interface with WASM once it's released for general users.

@mateogianolio
Copy link
Owner Author

@Khalid-Nowaf
Copy link

I'm using victorious in the browser now, it would be awesome if I could leverage wasm integration and use BLAS in the browser!

@mateogianolio
Copy link
Owner Author

@mateogianolio
Copy link
Owner Author

@metabench
Copy link
Collaborator

To what extent is it worth working on our own lower level implementations, or using existing libraries such as blas and glmw?

AssemblyScript looks very useful. Maybe it would be worth me coding in TypeScript to try it.

Since we already have (or soon will have) Vectorious in TypeScript, AssemblyScript looks like a good route to greater performance. I'm interested in that, as well as porting some JS code to C++ or Rust.

@mateogianolio
Copy link
Owner Author

mateogianolio commented Feb 24, 2019

Check this out. I did a quick test with the the saxpy routine in TypeScript, WASM, C (Node.js addon) and C with system linked BLAS (nblas).

https://github.com/mateogianolio/native-wasm-c

@MaxGraey
Copy link

Unfortunately cost of calls wasm <-> host is pretty significant so using bench tools like benchmark.js is not good choice. See my notes: mateogianolio/native-wasm-c#1 (comment)

@MaxGraey
Copy link

MaxGraey commented Feb 25, 2019

Also pretty interesting results you could got if you slightly modify part of algorithm (and changes this for every versions as well) from:

for (i = m; i < n; i += 4) {
   y[i + 0] += alpha * x[i + 0];
   y[i + 1] += alpha * x[i + 1];
   y[i + 2] += alpha * x[i + 2];
   y[i + 3] += alpha * x[i + 3];
}

to

for (; i < n; i += 4) {
   y[i + 0] += alpha * x[i + 0];
   y[i + 1] += alpha * x[i + 1];
   y[i + 2] += alpha * x[i + 2];
   y[i + 3] += alpha * x[i + 3];
}

Results:

ts x 221,134,839 ops/sec ±0.21% (96 runs sampled)
empty x 57,229,521 ops/sec ±0.42% (92 runs sampled)
wasm x 15.26 ops/sec ±0.72% (42 runs sampled)
c x 85.46 ops/sec ±1.00% (72 runs sampled)
vectorious x 98.55 ops/sec ±2.22% (71 runs sampled)

@mateogianolio
Copy link
Owner Author

Moved to discussions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants