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

Looks interesting #1

Closed
brunobasto opened this issue May 20, 2020 · 10 comments
Closed

Looks interesting #1

brunobasto opened this issue May 20, 2020 · 10 comments

Comments

@brunobasto
Copy link

I'm following a coursera course about machine learning and was about to write my own library for doing efficient matrix operations in javascript until I found this. Nice work.

One question (I haven't browsed the source code much): In what operations are you leveraging gpu.js? Is it only matrix multiplication for now?

@paolodelia99
Copy link
Owner

Hey Bruno!
First of all thank you for showing interest in my project. Yes, for now only the matrix multyplication is leveraging gpu.js . Now I'm trying to figuring out how to bind LAPACK and BLAS (two low level linear algebra libraries) in my code in order to have really efficent linear-algebra subroutines.

@brunobasto
Copy link
Author

Cool. Have you tried emscritpem with webassembly for nodejs? https://dev.to/azure/experimenting-with-web-assembly-and-nodejs-40f4

@brunobasto
Copy link
Author

Actually, there seems to be a port already: https://github.com/likr/emlapack

@brunobasto
Copy link
Author

By using webassembly instead of directly bind to native libs you'd get the benefit of making your library work on browsers too...

@paolodelia99
Copy link
Owner

Great! Thanks for the advice. Now i'm gonna to take a look to web assembly.

@paolodelia99
Copy link
Owner

But also emlapack seem to be a valide alternative.

@brunobasto
Copy link
Author

So I decided to try something: https://github.com/brunobasto/quick-matrix

From my experiments, doing calculations with WASM is really faster than plain JavaScript or even GPU.js. Actually, I'm finding GPU.js to be really slow. Maybe I'm doing something wrong or my graphics card is just not good. I even tried to memoize the kernels so that the overhead of compiling it would not be a problem but it still seems to be slower than just plain JavaScript..

@paolodelia99
Copy link
Owner

I've also tried WASM in the last couple of days, and I found it really fast! I think that's the way to go to build the low level API. And yes, Gpu.js is slow that plain javascript when dealing with small matrices. I've found it faster when the matrices are bigger than 1024 x 1024.

@paolodelia99
Copy link
Owner

Hey Bruno,
I'm trying to build the wasm api for the most used matrix functions. But I had struggle to wrap up a C struct and use it in js code. Do you think c++ would be better? Since I kinda new to C and C++ would you mind to help me building the WASM api, becuase from what I've seen from your experiment you're more experience c/c++ that me. Thanks.

@brunobasto
Copy link
Author

To be honest, I haven't tried to pass anything other than numbers or arrays from JS to C with emscripten. Maybe this or this can help. I just found out about this bind functionality so probably with c++ it will be easier to do what you want.

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

No branches or pull requests

2 participants