oneTBB icon indicating copy to clipboard operation
oneTBB copied to clipboard

Compile to WASM without threads?

Open timmyL17 opened this issue 2 years ago • 5 comments

Is it possible to compile to wasm through emscripten without using pthreads? I have code which uses tbb. With older versions, I was able to compile but just not set the -pthread compile/link flag, and it would run single threaded (I'm assuming tbb has an internal single threaded scheduler if it doesn't find pthreads?). This is useful for running on sites that are not yet setting cross origin headers correctly. Newer versions of tbb force the use of the -pthread flag: https://github.com/oneapi-src/oneTBB/blob/58653a3729f343c48fecb4809a894cd4ba0b8574/CMakeLists.txt#L195C1-L202C31

timmyL17 avatar Dec 07 '23 17:12 timmyL17

Yes, oneTBB can compile without pthreads. You can try removing the line that you mentioned and this. Since, without this flag a few of our tests starts failing, it is difficult for us to comment on the APIs being tested.

JhaShweta1 avatar Dec 08 '23 01:12 JhaShweta1

Thanks, it does seem to work if I make those two changes. Is it possible to make this a cmake option? tbb is included using FetchContent. It would be a few more steps if we need to modify the package directly, instead of just setting a cmake option.

timmyL17 avatar Dec 08 '23 16:12 timmyL17

Yes, we can create a cmake option. I will update this issue with the PR when we are ready with it.

JhaShweta1 avatar Dec 08 '23 18:12 JhaShweta1

Awesome, this will be a big help!

timmyL17 avatar Dec 08 '23 19:12 timmyL17

'EMSCRIPTEN_WITHOUT_PTHREAD=true' should should compile without pthreads.

JhaShweta1 avatar Feb 10 '24 05:02 JhaShweta1

Thank you!

timmyL17 avatar Feb 22 '24 17:02 timmyL17