Skip to content

Commit 9afd759

Browse files
committed
Commit oneTBB source code 627cac6
1 parent bc3abe7 commit 9afd759

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020-2023 Intel Corporation
1+
# Copyright (c) 2020-2024 Intel Corporation
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -194,7 +194,7 @@ endif()
194194
# -------------------------------------------------------------------
195195
# Common dependencies
196196
#force -pthread during compilation for Emscripten
197-
if (EMSCRIPTEN)
197+
if (EMSCRIPTEN AND NOT EMSCRIPTEN_WITHOUT_PTHREAD)
198198
set(THREADS_HAVE_PTHREAD_ARG TRUE)
199199
endif()
200200

WASM_Support.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,12 @@ To build the system, run:
3434
```
3535
mkdir build && cd build
3636
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
37+
```
38+
To compile oneTBB without ``pthreads``, set the flag ``-DEMSCRIPTEN_WITHOUT_PTHREAD=true`` in the command above. By default, oneTBB uses the ``pthreads``.
39+
```
3740
cmake --build . <options>
3841
cmake --install . <options>
3942
```
40-
4143
Where:
4244

4345
* ``emcmake`` - a tool that sets up the environment for Emscripten*.

cmake/compilers/Clang.cmake

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2020-2023 Intel Corporation
1+
# Copyright (c) 2020-2024 Intel Corporation
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -16,7 +16,9 @@ if (EMSCRIPTEN)
1616
set(TBB_EMSCRIPTEN 1)
1717
set(TBB_COMMON_COMPILE_FLAGS ${TBB_COMMON_COMPILE_FLAGS} -fexceptions)
1818
set(TBB_TEST_LINK_FLAGS ${TBB_COMMON_LINK_FLAGS} -fexceptions -sINITIAL_MEMORY=65536000 -sALLOW_MEMORY_GROWTH=1 -sEXIT_RUNTIME=1)
19-
set_property(TARGET Threads::Threads PROPERTY INTERFACE_LINK_LIBRARIES "-pthread")
19+
if (NOT EMSCRIPTEN_WITHOUT_PTHREAD)
20+
set_property(TARGET Threads::Threads PROPERTY INTERFACE_LINK_LIBRARIES "-pthread")
21+
endif()
2022
endif()
2123

2224
if (MINGW)

src/tbb/tcm_adaptor.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2023 Intel Corporation
2+
Copyright (c) 2023-2024 Intel Corporation
33
44
Licensed under the Apache License, Version 2.0 (the "License");
55
you may not use this file except in compliance with the License.
@@ -137,11 +137,9 @@ class tcm_client : public pm_client {
137137
// The permit has changed during the reading, so the callback will be invoked soon one more time and
138138
// we can just skip this renegotiation iteration.
139139
if (!new_permit.flags.stale) {
140-
__TBB_ASSERT(
141-
new_permit.state != TCM_PERMIT_STATE_INACTIVE || new_concurrency == 0,
142-
"TCM did not nullify resources while deactivating the permit"
143-
);
144-
delta = update_concurrency(new_concurrency);
140+
// If there is no other demand in TCM, the permit may still have granted concurrency but
141+
// be in the deactivated state thus we enforce 0 allotment to preserve arena invariants.
142+
delta = update_concurrency(new_permit.state != TCM_PERMIT_STATE_INACTIVE ? new_concurrency : 0);
145143
}
146144
}
147145
if (delta) {

0 commit comments

Comments
 (0)