Skip to content
This repository has been archived by the owner on Nov 18, 2023. It is now read-only.

Error when setting number of threads in global thread pool with rayon_wasm #1

Open
mtb0x1 opened this issue Aug 27, 2023 · 2 comments

Comments

@mtb0x1
Copy link
Owner

mtb0x1 commented Aug 27, 2023

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

//@todo ...
//value: ThreadPoolBuildError
//{ kind: IOError(Error { kind: Unsupported, message: "operation not supported on this platform" }) }
/*let cpus_in_use = (cpus as f64*0.75) as usize;
ThreadPoolBuilder::new()
.num_threads(cpus_in_use)
.build_global()
.unwrap();*/
)

Code :

use rayon_wasm::ThreadPoolBuilder;


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

Result :

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

Related : rayon-rs/rayon#1081

@mtb0x1
Copy link
Owner Author

mtb0x1 commented Aug 28, 2023

Switched to wasm-bindgen-rayon as recommended in rayon-rs/rayon#1081

Now facing issue below.


Uncaught (in promise) DOMException: Worker.postMessage: The WebAssembly.Memory object cannot be serialized. The Cross-Origin-Opener-Policy and Cross-Origin-Embedder-Policy HTTP headers can be used to enable this.
    _workers http://localhost:8080/pkg/snippets/wasm-bindgen-rayon-7afa899f36665473/src/workerHelpers.js:98
    startWorkers http://localhost:8080/pkg/snippets/wasm-bindgen-rayon-7afa899f36665473/src/workerHelpers.js:78
    __wbg_startWorkers_6fd3af285ea11136 http://localhost:8080/pkg/port1.js:421
    initThreadPool http://localhost:8080/pkg/port1.js:148
    run http://localhost:8080/:72
    async* http://localhost:8080/:99

@mtb0x1
Copy link
Owner Author

mtb0x1 commented Aug 28, 2023

Using www_server.py and setting required headers results in another issue :

TypeError: error loading dynamically imported module: http://localhost:8080/pkg/
TypeError: error loading dynamically imported module: http://localhost:8080/pkg/

@mtb0x1 mtb0x1 closed this as completed in 92bdbf3 Aug 28, 2023
@mtb0x1 mtb0x1 reopened this Aug 28, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant