Skip to content

Commit 1df6d55

Browse files
committed
[CMake] Replace logic that checks removed tbb build option
A long time ago, ROOT had a `tbb` build option, but it was removed in the ROOT 6.08 development cycle in dd899a5 from 2015, by @peremato. However, some build configurations still use it, like CMSSW and Conda: * https://github.com/cms-sw/cmsdist/blob/IB/CMSSW_15_1_X/master/root.spec#L78 * https://github.com/conda-forge/root-feedstock/blob/main/recipe/build_root.sh#L342 That would not be a problem per se, but then, in 2021, @bendavid introduced a new optimization that is enabled only with the long-time removed `tbb` flag (or `builtin_tbb`), in 6c8b77d: * #7260 So we ended up with a secret `tbb=ON` configuration that our CI doesn't test, and a CMake configuration option that has a pretty fundamental effect but is not documented. In the discussions in #19798 with @bendavid, we concluded that it would not be a problem to enable the optimized locks with TBB always when TBB is available during the ROOT build. See: #19798 (comment) Closes #19798.
1 parent 82bc340 commit 1df6d55

File tree

8 files changed

+18
-23
lines changed

8 files changed

+18
-23
lines changed

cmake/modules/RootConfiguration.cmake

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -392,11 +392,6 @@ if(dev)
392392
else()
393393
set(use_less_includes undef)
394394
endif()
395-
if((tbb OR builtin_tbb) AND NOT MSVC)
396-
set(hastbb define)
397-
else()
398-
set(hastbb undef)
399-
endif()
400395
if(root7)
401396
set(hasroot7 define)
402397
else()

config/RConfigure.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@
5151
#@hasdataframe@ R__HAS_DATAFRAME /**/
5252
#@hasroot7@ R__HAS_ROOT7 /**/
5353
#@use_less_includes@ R__LESS_INCLUDES /**/
54-
#@hastbb@ R__HAS_TBB /**/
5554
#define R__HARDWARE_INTERFERENCE_SIZE @hardwareinterferencesize@ /*Determined at CMake configure to be stable across all TUs*/
5655

5756
#if defined(R__HAS_VECCORE) && defined(R__HAS_VC)

core/thread/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,11 @@ target_include_directories(Thread PUBLIC
7777
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/inc>
7878
)
7979

80-
if((tbb OR builtin_tbb) AND NOT MSVC)
80+
if((TBB_FOUND OR builtin_tbb) AND NOT MSVC)
8181
target_include_directories(Thread PRIVATE ${TBB_INCLUDE_DIRS})
8282
target_link_libraries(Thread PRIVATE ${TBB_LIBRARIES})
8383
set_target_properties(Thread PROPERTIES COMPILE_FLAGS "${TBB_CXXFLAGS}")
84+
target_compile_definitions(Thread PUBLIC ROOT_CORE_THREAD_TBB)
8485
endif()
8586

8687
if(WIN32)

core/thread/src/TRWMutexImp.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ template class TRWMutexImp<std::mutex>;
114114
template class TRWMutexImp<TMutex, ROOT::Internal::UniqueLockRecurseCount>;
115115
template class TRWMutexImp<ROOT::TSpinMutex, ROOT::Internal::UniqueLockRecurseCount>;
116116

117-
#ifdef R__HAS_TBB
117+
#ifdef ROOT_CORE_THREAD_TBB
118118
template class TRWMutexImp<std::mutex, ROOT::Internal::RecurseCountsTBB>;
119119
template class TRWMutexImp<std::mutex, ROOT::Internal::RecurseCountsTBBUnique>;
120120
#endif

core/thread/src/TReentrantRWLock.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -414,7 +414,7 @@ template class TReentrantRWLock<ROOT::TSpinMutex, ROOT::Internal::UniqueLockRecu
414414
template class TReentrantRWLock<TMutex, ROOT::Internal::UniqueLockRecurseCount>;
415415
template class TReentrantRWLock<std::mutex, ROOT::Internal::UniqueLockRecurseCount>;
416416

417-
#ifdef R__HAS_TBB
417+
#ifdef ROOT_CORE_THREAD_TBB
418418
template class TReentrantRWLock<std::mutex, ROOT::Internal::RecurseCountsTBB>;
419419
template class TReentrantRWLock<std::mutex, ROOT::Internal::RecurseCountsTBBUnique>;
420420
#endif

core/thread/src/TReentrantRWLock.hxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <thread>
2323
#include <unordered_map>
2424

25-
#ifdef R__HAS_TBB
25+
#ifdef ROOT_CORE_THREAD_TBB
2626
#include "tbb/enumerable_thread_specific.h"
2727
#endif
2828

@@ -152,7 +152,7 @@ struct RecurseCounts {
152152

153153
};
154154

155-
#ifdef R__HAS_TBB
155+
#ifdef ROOT_CORE_THREAD_TBB
156156
struct RecurseCountsTBB {
157157
using Hint_t = TVirtualRWMutex::Hint_t;
158158

core/thread/src/TThread.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ void TThread::Init()
346346
if (!ROOT::gCoreMutex) {
347347
// To avoid dead locks, caused by shared library opening and/or static initialization
348348
// taking the same lock as 'tls_get_addr_tail', we can not use UniqueLockRecurseCount.
349-
#ifdef R__HAS_TBB
349+
#ifdef ROOT_CORE_THREAD_TBB
350350
ROOT::gCoreMutex = new ROOT::TRWMutexImp<std::mutex, ROOT::Internal::RecurseCountsTBBUnique>();
351351
#else
352352
ROOT::gCoreMutex = new ROOT::TRWMutexImp<std::mutex, ROOT::Internal::RecurseCounts>();

core/thread/test/testRWLock.cxx

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,14 @@ auto gMutex = new TMutex(kTRUE);
250250
auto gRWMutex = new TRWMutexImp<TMutex>();
251251
auto gRWMutexSpin = new TRWMutexImp<ROOT::TSpinMutex>();
252252
auto gRWMutexStd = new TRWMutexImp<std::mutex>();
253-
#ifdef R__HAS_TBB
253+
#ifdef ROOT_CORE_THREAD_TBB
254254
auto gRWMutexStdTBB = new TRWMutexImp<std::mutex, ROOT::Internal::RecurseCountsTBB>();
255255
auto gRWMutexStdTBBUnique = new TRWMutexImp<std::mutex, ROOT::Internal::RecurseCountsTBBUnique>();
256256
#endif
257257
auto gReentrantRWMutex = new ROOT::TReentrantRWLock<TMutex>();
258258
auto gReentrantRWMutexSM = new ROOT::TReentrantRWLock<ROOT::TSpinMutex>();
259259
auto gReentrantRWMutexStd = new ROOT::TReentrantRWLock<std::mutex>();
260-
#ifdef R__HAS_TBB
260+
#ifdef ROOT_CORE_THREAD_TBB
261261
auto gReentrantRWMutexStdTBB = new ROOT::TReentrantRWLock<std::mutex, ROOT::Internal::RecurseCountsTBB>();
262262
auto gReentrantRWMutexStdTBBUnique = new ROOT::TReentrantRWLock<std::mutex, ROOT::Internal::RecurseCountsTBBUnique>();
263263
#endif
@@ -335,7 +335,7 @@ TEST(RWLock, WriteStdDirectUnLock)
335335
testWriteUnLock(gReentrantRWMutexStd, gRepetition, gWriteHint);
336336
}
337337

338-
#ifdef R__HAS_TBB
338+
#ifdef ROOT_CORE_THREAD_TBB
339339
TEST(RWLock, WriteStdTBBDirectLock)
340340
{
341341
gWriteHint = testWriteLock(gReentrantRWMutexStdTBB, gRepetition);
@@ -387,7 +387,7 @@ TEST(RWLock, ReadUnLockStdDirect)
387387
testReadUnLock(gReentrantRWMutexStd, gRepetition, gReadHint);
388388
}
389389

390-
#ifdef R__HAS_TBB
390+
#ifdef ROOT_CORE_THREAD_TBB
391391
TEST(RWLock, ReadLockStdTBBDirect)
392392
{
393393
gReadHint = testReadLock(gReentrantRWMutexStdTBB, gRepetition);
@@ -494,7 +494,7 @@ TEST(RWLock, ReentrantStd)
494494
Reentrant(*gReentrantRWMutexStd);
495495
}
496496

497-
#ifdef R__HAS_TBB
497+
#ifdef ROOT_CORE_THREAD_TBB
498498
TEST(RWLock, ReentrantStdTBB)
499499
{
500500
Reentrant(*gReentrantRWMutexStdTBB);
@@ -531,7 +531,7 @@ TEST(RWLock, ResetRestoreStd)
531531
ResetRestore(*gReentrantRWMutexStd);
532532
}
533533

534-
#ifdef R__HAS_TBB
534+
#ifdef ROOT_CORE_THREAD_TBB
535535
TEST(RWLock, ResetRestoreStdTBB)
536536
{
537537
ResetRestore(*gReentrantRWMutexStdTBB);
@@ -579,7 +579,7 @@ TEST(RWLock, concurrentResetRestoreStd)
579579
concurrentResetRestore(gRWMutexStd, 2, gRepetition / 10000);
580580
}
581581

582-
#ifdef R__HAS_TBB
582+
#ifdef ROOT_CORE_THREAD_TBB
583583
TEST(RWLock, concurrentResetRestoreStdTBB)
584584
{
585585
concurrentResetRestore(gRWMutexStdTBB, 2, gRepetition / 10000);
@@ -629,7 +629,7 @@ TEST(RWLock, concurrentReadsAndWritesStd)
629629
concurrentReadsAndWrites(gRWMutexStd, 1, 2, gRepetition / 10000);
630630
}
631631

632-
#ifdef R__HAS_TBB
632+
#ifdef ROOT_CORE_THREAD_TBB
633633
TEST(RWLock, concurrentReadsAndWritesStdTBB)
634634
{
635635
concurrentReadsAndWrites(gRWMutexStdTBB, 1, 2, gRepetition / 10000);
@@ -651,7 +651,7 @@ TEST(RWLock, LargeconcurrentReadsAndWritesStd)
651651
concurrentReadsAndWrites(gRWMutex, 10, 20, gRepetition / 10000);
652652
}
653653

654-
#ifdef R__HAS_TBB
654+
#ifdef ROOT_CORE_THREAD_TBB
655655
TEST(RWLock, LargeconcurrentReadsAndWritesStdTBB)
656656
{
657657
concurrentReadsAndWrites(gRWMutexStdTBB, 10, 20, gRepetition / 10000);
@@ -678,7 +678,7 @@ TEST(RWLock, VeryLargeconcurrentReadsAndWritesStd)
678678
concurrentReadsAndWrites(gRWMutexStd, 10, 200, gRepetition / 10000);
679679
}
680680

681-
#ifdef R__HAS_TBB
681+
#ifdef ROOT_CORE_THREAD_TBB
682682
TEST(RWLock, VeryLargeconcurrentReadsAndWritesStdTBB)
683683
{
684684
concurrentReadsAndWrites(gRWMutexStdTBB, 10, 200, gRepetition / 10000);
@@ -706,7 +706,7 @@ TEST(RWLock, VeryLargeconcurrentReadsStd)
706706
concurrentReadsAndWrites(gRWMutexStd, 0, 200, gRepetition / 10000);
707707
}
708708

709-
#ifdef R__HAS_TBB
709+
#ifdef ROOT_CORE_THREAD_TBB
710710
TEST(RWLock, VeryLargeconcurrentReadsStdTBB)
711711
{
712712
concurrentReadsAndWrites(gRWMutexStdTBB, 0, 200, gRepetition / 10000);

0 commit comments

Comments
 (0)