How to Compile VTK-9.0.20210224 with TBB into webassembly

Hi, all
I have compiled VTK-9.0.20210224 as lib and it worked well with my project. Now the question is , how can I use TBB or OpenMP for multithreading in web page ? I have tested on win 10 + VTK+TBB it is all OK.

dir list is :

tbb can be built in /work/wasmtbb/build/linux_wasm32_emscripten_emscripten_wasm32_release/libtbb.a
I tried this :

-G Ninja

cmake worked but errors appearted during make like this :

In file included from …/Common/Core/SMP/TBB/vtkSMPTools.cxx:16:
In file included from …/Common/Core/vtkSMPTools.h:32:
In file included from Common/Core/vtkSMPThreadLocal.h:81:
In file included from /work/wasmtbb/include/tbb/enumerable_thread_specific.h:20:
/work/wasmtbb/include/tbb/atomic.h:195:1: error: use of undeclared identifier ‘__TBB_machine_cmpswp2’
/work/wasmtbb/include/tbb/atomic.h:149:20: note: expanded from macro ‘__TBB_DECL_ATOMIC_PRIMITIVES’
return __TBB_machine_cmpswp##S(location,new_value,comparand);
:29:1: note: expanded from here
fatal error: too many errors emitted, stopping now [-ferror-limit=]

I followed this link boilerplate/ at master · hpcwasm/boilerplate · GitHub
and I have a question , does TBB need boost to work together ?

Any help would be greatly appreciated !

Thanks !


My understanding is that emscripten won’t handle threading properly. CCing Matt M. as he may have more to say on this topic.

Thanks for reply.
I checked emscripten website and there are thread samples Pthreads support — Emscripten 2.0.27 (dev) documentation
But my application is not use multi-thread directly, it run some vtk class which execute in thread like vtkImageGaussianSmooth and vtkImageMarchingCubes. That’s why I need to compile VTK+TBB to speed up .

Thank you again.