-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
[Taichi.js] JavaScript Backend via Emscripten #394
Comments
I'd be happy to help! |
Good question. I guess one thing to discuss here is "should we do pure JavaScript or leverage WebGL (fragment/compute shaders)?" If we go WebGL, we get higher performance, but the computational pattern also gets restricted to pure array operations (e.g. If we go JavaScript, then it will run slower but we can support much more computational patterns. It's also easier since we can probably directly translate the generated LLVM IR into Javascript. I would suggest starting with this path. |
Let's narrow down the range to generating Javascript via Emscripten until WebGL compute shader is mature. |
It seems that Emscripten itself is switching to the LLVM WASM backend. So one decision to be made: do we directly generate WASM via LLVM or go through Emscripten? The former saves us from adding the dependency on Emscripten. A question to Web experts: how well supported is WASM on current browsers? If everyone's browser already supports WASM (https://caniuse.com/#feat=wasm) then maybe we should directly use the LLVM WASM backend? An old Rust thread on WASM: rust-lang/rust#33205 Inputs are welcome! |
Warning: The issue has been out-of-update for 50 days, marking |
@yuanming-hu |
In comparision to the |
Cool! May I have some insights in terms of the future plan? |
Here's my plan:
|
This is happening under https://github.com/taichi-dev/taichi.js ? |
Yes, except for 1 is actually happening under https://github.com/taichi-dev/taichi.
Oh that would be great! Here's something we could do at this moment:
|
Thanks for all the discussions here! On the compiler side, so far there are two approaches to generate WASM/JS.
On the web development side, a cool thing we can do is host a TaichiHub website, that allows users to share their WASM/JS programs generated by Taichi. Good references are https://allrgb.com/ and https://www.shadertoy.com/ I can help raise some money for hosting the TaichiHub website if that's necessary :-) |
Hi, everyone! Here's my recent progress on TaichiHub: http://142857.red:3389/ |
We can host the web & service on |
Free services are always good :-) We do need to run a Python program on the server and potentially host a database to store the shader data - does |
|
@WenheLI TIL that @yuanming-hu if we go serverless solution instead of containers or hosted service, looks like https://vercel.com/docs/serverless-functions/supported-languages provides services similar to AWS Lambda Functions. (we might deploy the website on it later as well in case we need to speed up the access speed) |
Wow sounds really like a nice fit! They also seem to support Python dependencies: https://vercel.com/docs/runtimes#official-runtimes/python/python-dependencies we can then just add |
It would be nice to have a free server! My concerns are if
If they provide these support, congrats! We can host TaichiHub there. |
@archibate We only need to investigate if And the worse case is we can not host compilation on |
Separating frontend and backend is a nice idea! So here's our workflow:
The backend server could also be equipped with password so that only the We may even make the frontend server non-Python (non-Flask), as its only job is response HTMLs and redirect requests to our backend server, where Emscripten and Taichi are hosted. |
Sounds like a plan, we can definitely do it |
Is your feature request related to a problem? Please describe.
Allowing Taichi to generate JavaScript code will enable many more people to play with state-of-the-art computer graphics in their browsers.
Describe the solution you'd like
More investigation is needed. Emscripten or WASM seem good ways to go.
The kernel code will still be written in Python, yet a
ti.export
function will be added to dump a kernel into compiled JavaScript. Then users can load these js and run it in HTML5.The JavaScript backend does not have to support full Taichi functionality. For example, we can omit some sparse data structure support.
Discussions on/contributions to this are warmly welcome! :-)
The text was updated successfully, but these errors were encountered: