Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enable tbb #59

Open
pca006132 opened this issue Nov 27, 2024 · 2 comments
Open

enable tbb #59

pca006132 opened this issue Nov 27, 2024 · 2 comments

Comments

@pca006132
Copy link
Member

Note that manifold can now be compiled with tbb with minimal changes: elalish/manifold#1045

This can probably enable openscad build with tbb as well. I can help if anyone is interested in adding it here.

@ochafik
Copy link
Collaborator

ochafik commented Dec 23, 2024

Hi @pca006132, thanks for the heads up!

We'll need to update https://github.com/openscad/openscad-wasm with the oneTBB dep in our build image (cc/ @DSchroer, @t-paul), but in the meantime it seems to build fine:

./scripts/wasm-base-docker-run.sh /bin/bash -c ' \
    ( test -d oneTBB || git clone https://github.com/uxlfoundation/oneTBB ) && \
    cd oneTBB && \
    rm -fR build && \
    emcmake cmake -B build \
        -DBUILD_SHARED_LIBS=ON \
        -DCMAKE_BUILD_TYPE=Release \
        -DCMAKE_CXX_FLAGS="-Wno-unused-command-line-argument" \
        -DCMAKE_EXE_LINKER_FLAGS="-sMALLOC=emmalloc" \
        -DTBB_DISABLE_HWLOC_AUTOMATIC_SEARCH=ON \
        -DTBB_EXAMPLES=OFF \
        -DTBB_STRICT=OFF \
        -DTBB_TEST=OFF && \
    ( cmake --build build -j || cmake --build build -j2 || cmake --build build ) && \
    cmake --install build && \
    cd .. &&
    emcmake cmake -B build -DCMAKE_BUILD_TYPE=Release -DEXPERIMENTAL=1 && \
    ( cmake --build build -j || cmake --build build -j2 || cmake --build build )'

Then in the playground codebase: mkdir -p libs/openscad-wasm && cp ../path/to/openscad/build/openscad.* libs/openscad-wasm/

Now based on emscripten's docs I guess to get any kind of parallelism we either need to add COOP / COEP headers and build both tbb & openscad with extra -DCMAKE_CXX_FLAGS="-pthread" -DCMAKE_EXE_LINKER_FLAGS="-sPTHREAD_POOL_SIZE=4" flags, or with -DCMAKE_EXE_LINKER_FLAGS="--proxy-to-worker" when headers aren't an option.

It would be nice to test both options with heavy models that leverage parallelism well: suggestions welcome :-)

@pca006132
Copy link
Member Author

Yeah, and we do need mimalloc for performance here (see allocator-performance section).

Do note that we encountered some weird stack corruption that are basically impossible to debug due to the lack of sanitizer support in wasm, not sure if this is fixed in newer versions of emscripten.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants