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 :
/work/vtk/build
/work/wasmtbb/

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

cmake
-G Ninja
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DBUILD_SHARED_LIBS:BOOL=OFF
-DCMAKE_BUILD_TYPE:STRING=Release
-DVTK_ENABLE_LOGGING:BOOL=OFF
-DVTK_ENABLE_WRAPPING:BOOL=OFF
-DVTK_LEGACY_REMOVE:BOOL=ON
-DVTK_OPENGL_USE_GLES:BOOL=ON
-DVTK_USE_SDL2:BOOL=ON
-DVTK_NO_PLATFORM_SOCKETS:BOOL=ON
-DVTK_MODULE_ENABLE_VTK_hdf5:STRING=NO
-DVTK_SMP_IMPLEMENTATION_TYPE:STRING=TBB
-DTBB_INCLUDE_DIR:STRING=/work/wasmtbb/include
-DTBB_LIBRARY_RELEASE:STRING=/work/wasmtbb/build/linux_wasm32_emscripten_emscripten_wasm32_release/libtbb.a

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’
__TBB_DECL_ATOMIC_PRIMITIVES(2)
^
/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
__TBB_machine_cmpswp2
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]

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

Any help would be greatly appreciated !

Thanks !

William

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

Will,
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.