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

general purpose WASM support? #1122

Open
fr-an-k opened this issue Jan 27, 2024 · 1 comment
Open

general purpose WASM support? #1122

fr-an-k opened this issue Jan 27, 2024 · 1 comment

Comments

@fr-an-k
Copy link

fr-an-k commented Jan 27, 2024

I tried to build the example as wasm32-unknown-unknown but it requires the js feature.
There is no browser API or wasm-bindgen in a general purpose WASM module.

It would be nice if this would also be supported, or a mention that it will not be supported and why.

In my case I will probably just use rayon normally for native functions that invoke a WASM function.
So the WASM function just handles one job and returns when done.
The native function is wrapped and threaded by Rayon as usual.
Perhaps that's how it should be done.

For web and native compatibility on the same WASM modules, I would probably have to compile the wasm modules using wasm-bindgen-rayon and not use those exports on a native runtime.

It's difficult to get your head around these things so it would be nice to have this explained or demonstrated for everyone.

This also relates to the issues linked here: #93

@cuviper
Copy link
Member

cuviper commented Jan 27, 2024

Rayon can't fully run in general wasm32-unknown-unknown because there's no threading support. We do at least have a single-threaded fallback, so code written with rayon can still work for the most part, but you don't need to do any special setup for that.

If rayon is running natively, then it's orthogonal that the workload may be a wasm module. Rayon won't know anything about it, but you'll need to load the module to run in whatever wasm runtime you've chosen, just as you would if rayon wasn't involved at all.

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