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

rayon_wasm : "Operation not supported on this platform" when setting number of global threads to be used #1081

Closed
mtb0x1 opened this issue Aug 27, 2023 · 1 comment

Comments

@mtb0x1
Copy link

mtb0x1 commented Aug 27, 2023

(rayon_wasm v1.6.2).

Running the code below in browser after compiling it to wasm, results in an error.

use rayon_wasm::ThreadPoolBuilder;


let cpus_in_use =5;
ThreadPoolBuilder::new()
.num_threads(cpus_in_use)
.build_global()
.unwrap();

Error :

value: ThreadPoolBuildError { kind: IOError(Error { kind: Unsupported, message: "operation not supported on this platform"})}

is this an expected behavior ? if yes what are the alternatives if there are any ?

Thanks.

@cuviper
Copy link
Member

cuviper commented Aug 27, 2023

rayon-wasm is an unofficial forked publication, as noted here: #1019 (comment). Please use rayon 1.7.0.

That wasm support is just a fallback that lets rayon work single-threaded, but that's only applied when you leave num_threads unspecified. The target does not support threads, so std::thread::spawn is returning Unsupported.

With Rust nightly, you can build a version of the target with atomics, and threading may work. See the documentation here: https://github.com/GoogleChromeLabs/wasm-bindgen-rayon

There are also proposals in motion to add real supported WASI threading: rust-lang/compiler-team#574, rust-lang/compiler-team#607, rust-lang/compiler-team#661.

@mtb0x1 mtb0x1 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 27, 2023
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