Running multithreaded Emscripten from D8?

49 views
Skip to first unread message

Keith Teo

unread,
Dec 6, 2024, 12:33:00 AM12/6/24
to emscripten-discuss
Hi, 

I am trying to benchmark the effects of modifications to various parts of the WASM toolchain. But when running multithreaded emscripten output in d8 I get the error:

Aborted(Assertion failed: Pthreads do not work in this environment yet (need Web Workers, or an alternative to them))
test.js:731: RuntimeError: Aborted(Assertion failed: Pthreads do not work in this environment yet (need Web Workers, or an alternative to them))
  throw e;

The error comes from this line:

assert(
  ENVIRONMENT_IS_WEB || ENVIRONMENT_IS_WORKER || ENVIRONMENT_IS_NODE, 'Pthreads do not work in this environment yet (need Web Workers, or an alternative to them)');

Anyone know how to get around this? d8 is capable of running web workers, so there's no technical limitation on it. 

This is how I compiled my cpp code

em++ -sENVIRONMENT=shell,worker -s ASSERTIONS=2 -s PTHREAD_POOL_SIZE=4 -s WASM=1 -pthread test.cpp -o test.js

guest271314

unread,
Dec 10, 2024, 11:41:32 AM12/10/24
to emscripte...@googlegroups.com
I think Worker in d8 is implemented different from Worker in a browser.

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/emscripten-discuss/2e776c13-a1bb-4479-9091-b62ebc49e22bn%40googlegroups.com.

Sam Clegg

unread,
Dec 10, 2024, 11:44:13 AM12/10/24
to emscripte...@googlegroups.com
If you want threads you will need to either run under Node or in the browser.  Emscripten only has support for Node workers and Web workers. 

If you want a version of node that has the very latest version of v8 you can use the node-canary releases: https://nodejs.org/download/v8-canary/

cheers,
sam

Reply all
Reply to author
Forward
0 new messages