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

Exploring wasm options #15

Open
VarLad opened this issue Nov 2, 2023 · 4 comments
Open

Exploring wasm options #15

VarLad opened this issue Nov 2, 2023 · 4 comments

Comments

@VarLad
Copy link
Member

VarLad commented Nov 2, 2023

Posting some links here to look into them later. (and for others if interested)
Wasm + Julia have come a far way.
It would be ideal to have the JuliaWGPU stack on wasm (as the goal is to be able to run everything on the web to begin with)

@arhik
Copy link
Member

arhik commented Nov 4, 2023

I completely agree. WebAssemblyCompiler looks promising. While WebAssemblyCompiler is using SSA based approach with binaryen, I will be open to any library that can do this compilation. I tried LLVM based approach here https://github.com/arhik/WASMCompiler.jl. it works. I was able to compile julia functions with LLVM tools (look into target.jl for hints) and do basic calculations on browser. And also, some arrays processing. I couldn't trigger console log and print strings though. I also had difficulties with 64-bit pointers and 32-bit pointer conversions. If WebAssemblyCompiler.jl can do those seamlessly we can ditch LLVM based approach. WASM now has garbage collection feature added. Not sure what it means for us but all this hints us it is good time to work on basic examples for JuliaWGPU on browser.

@tshort
Copy link

tshort commented Nov 12, 2023

Having JuliaWGPU would be awesome. If Makie could be tied in, that'd be even better. Let me know if you run into issues with WebAssemblyCompiler.

@VarLad
Copy link
Member Author

VarLad commented Nov 12, 2023

@tshort Thanks for commenting here!
What would be needed to support:

  • Pointers
  • Union Types
  • Integer types
  • C deps

in WebAssemblyCompiler.jl ?
Also, Memory type PR has been merged.

@tshort
Copy link

tshort commented Nov 12, 2023

  • Pointers--This isn't possible currently. Maybe some sort of PseudoPtr would work, depending on specific needs. Future additions to WASM-GC may cover more use cases.
  • Union Types--The easiest way is probably to create a type that can hold all possibilities along with a type flag. That's not very memory efficient, but I'm not sure WASM-GC can handle more complicated reinterpretation.
  • Integer types--Int128 and similar is probably the main need. That's best to emulate on the Julia side and swap in where needed.
  • C deps--This should work now. Compile a library to WebAssembly with Emscripten. ccall should just work. Either link the wasm files, or pull them in separately. I don't think that Emscripten/LLVM can handle GC'd arrays and objects, though, so common things like OpenBLAS won't work (unless you copy the GC'd array to wasm's linear memory).

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

3 participants