diff --git a/CMakeLists.txt b/CMakeLists.txt index 189d7e53d3..32dcf1e2c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 Intel Corporation +# Copyright (c) 2020-2024 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -194,7 +194,7 @@ endif() # ------------------------------------------------------------------- # Common dependencies #force -pthread during compilation for Emscripten -if (EMSCRIPTEN) +if (EMSCRIPTEN AND NOT EMSCRIPTEN_WITHOUT_PTHREAD) set(THREADS_HAVE_PTHREAD_ARG TRUE) endif() diff --git a/WASM_Support.md b/WASM_Support.md index bf38a91e8e..8c2f6c1af9 100644 --- a/WASM_Support.md +++ b/WASM_Support.md @@ -34,10 +34,12 @@ To build the system, run: ``` mkdir build && cd build emcmake cmake .. -DCMAKE_CXX_COMPILER=em++ -DCMAKE_C_COMPILER=emcc -DTBB_STRICT=OFF -DCMAKE_CXX_FLAGS=-Wno-unused-command-line-argument -DTBB_DISABLE_HWLOC_AUTOMATIC_SEARCH=ON -DBUILD_SHARED_LIBS=ON -DTBB_EXAMPLES=ON -DTBB_TEST=ON +``` +To compile oneTBB without ``pthreads``, set the flag ``-DEMSCRIPTEN_WITHOUT_PTHREAD=true`` in the command above. By default, oneTBB uses the ``pthreads``. +``` cmake --build . cmake --install . ``` - Where: * ``emcmake`` - a tool that sets up the environment for Emscripten*. diff --git a/cmake/compilers/Clang.cmake b/cmake/compilers/Clang.cmake index 330dffa277..e90629b8fe 100644 --- a/cmake/compilers/Clang.cmake +++ b/cmake/compilers/Clang.cmake @@ -1,4 +1,4 @@ -# Copyright (c) 2020-2023 Intel Corporation +# Copyright (c) 2020-2024 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,7 +16,9 @@ if (EMSCRIPTEN) set(TBB_EMSCRIPTEN 1) set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -fexceptions) set(TBB_TEST_LINK_FLAGS ${TBB_COMMON_LINK_FLAGS} -fexceptions -sINITIAL_MEMORY=65536000 -sALLOW_MEMORY_GROWTH=1 -sEXIT_RUNTIME=1) - set_property(TARGET Threads::Threads PROPERTY INTERFACE_LINK_LIBRARIES "-pthread") + if (NOT EMSCRIPTEN_WITHOUT_PTHREAD) + set_property(TARGET Threads::Threads PROPERTY INTERFACE_LINK_LIBRARIES "-pthread") + endif() endif() if (MINGW) diff --git a/src/tbb/tcm_adaptor.cpp b/src/tbb/tcm_adaptor.cpp index 3963ae1329..e20ebb831d 100644 --- a/src/tbb/tcm_adaptor.cpp +++ b/src/tbb/tcm_adaptor.cpp @@ -1,5 +1,5 @@ /* - Copyright (c) 2023 Intel Corporation + Copyright (c) 2023-2024 Intel Corporation Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -137,11 +137,9 @@ class tcm_client : public pm_client { // The permit has changed during the reading, so the callback will be invoked soon one more time and // we can just skip this renegotiation iteration. if (!new_permit.flags.stale) { - __TBB_ASSERT( - new_permit.state != TCM_PERMIT_STATE_INACTIVE || new_concurrency == 0, - "TCM did not nullify resources while deactivating the permit" - ); - delta = update_concurrency(new_concurrency); + // If there is no other demand in TCM, the permit may still have granted concurrency but + // be in the deactivated state thus we enforce 0 allotment to preserve arena invariants. + delta = update_concurrency(new_permit.state != TCM_PERMIT_STATE_INACTIVE ? new_concurrency : 0); } } if (delta) {