From d1c610ef08b121eecb8d4d9d85d5da4930b227b3 Mon Sep 17 00:00:00 2001 From: Philippe Canal Date: Fri, 9 May 2025 13:58:16 -0500 Subject: [PATCH 1/7] core: Add semantic ROOT::EnableImplicitMT Instead of specificy the number of core, the new overload can be specified to select a configuration type. Currently the following 2 configuration are supported: ROOT::EIMTConfig::kWholeMachine ROOT::EIMTConfig::kExistingTBBArena calling ``` ROOT::EnableImplicitMT(ROOT::EIMTConfig::kExistingTBBArena); ``` will attach to an existing TBB Arena instead of creating a new one. This fixes #18301 --- core/base/inc/TROOT.h | 9 ++++++++ core/base/src/TROOT.cxx | 23 +++++++++++++++++++ core/imt/inc/ROOT/RTaskArena.hxx | 10 +++++++-- core/imt/src/ROpaqueTaskArena.hxx | 5 ++++- core/imt/src/RTaskArena.cxx | 37 +++++++++++++++++++++++++++++-- core/imt/src/TImplicitMT.cxx | 16 +++++++++++++ core/imt/test/CMakeLists.txt | 3 ++- core/imt/test/testEnableImt.cxx | 26 ++++++++++++++++++++++ 8 files changed, 123 insertions(+), 6 deletions(-) create mode 100644 core/imt/test/testEnableImt.cxx diff --git a/core/base/inc/TROOT.h b/core/base/inc/TROOT.h index a396aba14c745..6f0334df5374e 100644 --- a/core/base/inc/TROOT.h +++ b/core/base/inc/TROOT.h @@ -80,12 +80,21 @@ namespace Internal { } } // End ROOT::Internal namespace ROOT { + enum class EIMTConfig { + kWholeMachine = 0, ///< Default configuration + kExistingTBBArena = 1, ///< Use the existing TBB arena + kNumConfigs = 2 ///< Number of support IMT semantic configurations + + }; /// \brief Enable support for multi-threading within the ROOT code /// in particular, enables the global mutex to make ROOT thread safe/aware. void EnableThreadSafety(); /// \brief Enable ROOT's implicit multi-threading for all objects and methods that provide an internal /// parallelisation mechanism. void EnableImplicitMT(UInt_t numthreads = 0); + /// \brief Enable ROOT's implicit multi-threading for all objects and methods that provide an internal + /// parallelisation mechanism. + void EnableImplicitMT(ROOT::EIMTConfig config); void DisableImplicitMT(); Bool_t IsImplicitMTEnabled(); UInt_t GetThreadPoolSize(); diff --git a/core/base/src/TROOT.cxx b/core/base/src/TROOT.cxx index 35a35ea468c0d..03a9feb15f97d 100644 --- a/core/base/src/TROOT.cxx +++ b/core/base/src/TROOT.cxx @@ -551,6 +551,29 @@ namespace Internal { #endif } + //////////////////////////////////////////////////////////////////////////////// + /// @param[in] config Configuration to use. The default is kWholeMachine, which + /// will create a thread pool that spans the whole machine. + /// + /// EnableImplicitMT calls in turn EnableThreadSafety. + /// If ImplicitMT is already enabled, this function does nothing. + + + void EnableImplicitMT(ROOT::EIMTConfig config) + { +#ifdef R__USE_IMT + if (ROOT::Internal::IsImplicitMTEnabledImpl()) + return; + EnableThreadSafety(); + static void (*sym)(ROOT::EIMTConfig) = (void(*)(ROOT::EIMTConfig))Internal::GetSymInLibImt("ROOT_TImplicitMT_EnableImplicitMT_Config"); + if (sym) + sym(config); + ROOT::Internal::IsImplicitMTEnabledImpl() = true; +#else + ::Warning("EnableImplicitMT", "Cannot enable implicit multi-threading with %d threads, please build ROOT with -Dimt=ON", numthreads); +#endif + } + //////////////////////////////////////////////////////////////////////////////// /// Disables the implicit multi-threading in ROOT (see EnableImplicitMT). void DisableImplicitMT() diff --git a/core/imt/inc/ROOT/RTaskArena.hxx b/core/imt/inc/ROOT/RTaskArena.hxx index 6de46c4cab2b8..4955eff398797 100644 --- a/core/imt/inc/ROOT/RTaskArena.hxx +++ b/core/imt/inc/ROOT/RTaskArena.hxx @@ -24,6 +24,7 @@ #define ROOT_RTaskArena #include "RConfigure.h" +#include "TROOT.h" // For ROOT::EIMTConfig #include // exclude in case ROOT does not have IMT support @@ -65,9 +66,13 @@ public: ~RTaskArenaWrapper(); // necessary to set size back to zero static unsigned TaskArenaSize(); // A static getter lets us check for RTaskArenaWrapper's existence ROOT::ROpaqueTaskArena &Access(); -private: + struct Attach {}; ///< Marker for attaching to an existing tbb::task_arena + RTaskArenaWrapper(unsigned maxConcurrency = 0); - friend std::shared_ptr GetGlobalTaskArena(unsigned maxConcurrency); + RTaskArenaWrapper(Attach); +private: + + friend std::shared_ptr GetGlobalTaskArena(bool, unsigned, ROOT::EIMTConfig); std::unique_ptr fTBBArena; static unsigned fNWorkers; }; @@ -81,6 +86,7 @@ private: /// references to the previous one are gone and the object destroyed. //////////////////////////////////////////////////////////////////////////////// std::shared_ptr GetGlobalTaskArena(unsigned maxConcurrency = 0); +std::shared_ptr GetGlobalTaskArena(ROOT::EIMTConfig config); } // namespace Internal } // namespace ROOT diff --git a/core/imt/src/ROpaqueTaskArena.hxx b/core/imt/src/ROpaqueTaskArena.hxx index 6da5a5c68da1f..eca082360442f 100644 --- a/core/imt/src/ROpaqueTaskArena.hxx +++ b/core/imt/src/ROpaqueTaskArena.hxx @@ -1,5 +1,8 @@ #include "tbb/task_arena.h" namespace ROOT { -class ROpaqueTaskArena: public tbb::task_arena {}; +class ROpaqueTaskArena: public tbb::task_arena { + public: + using tbb::task_arena::task_arena; +}; } diff --git a/core/imt/src/RTaskArena.cxx b/core/imt/src/RTaskArena.cxx index 9d54d00c3cc4c..748ea84252a57 100644 --- a/core/imt/src/RTaskArena.cxx +++ b/core/imt/src/RTaskArena.cxx @@ -108,6 +108,21 @@ RTaskArenaWrapper::RTaskArenaWrapper(unsigned maxConcurrency) : fTBBArena(new RO ROOT::EnableThreadSafety(); } + +//////////////////////////////////////////////////////////////////////////////// +/// Initializes the tbb::task_arena within RTaskArenaWrapper by attaching to an +/// existing arena. +/// +/// * Can't be reinitialized +//////////////////////////////////////////////////////////////////////////////// +RTaskArenaWrapper::RTaskArenaWrapper(RTaskArenaWrapper::Attach) : + fTBBArena(new ROpaqueTaskArena{tbb::task_arena::attach{}}) +{ + fTBBArena->initialize(tbb::task_arena::attach{}); + fNWorkers = fTBBArena->max_concurrency(); + ROOT::EnableThreadSafety(); +} + RTaskArenaWrapper::~RTaskArenaWrapper() { fNWorkers = 0u; @@ -127,7 +142,7 @@ ROOT::ROpaqueTaskArena &RTaskArenaWrapper::Access() return *fTBBArena; } -std::shared_ptr GetGlobalTaskArena(unsigned maxConcurrency) +std::shared_ptr GetGlobalTaskArena(bool semantic, unsigned maxConcurrency, ROOT::EIMTConfig config) { static std::weak_ptr weak_GTAWrapper; @@ -140,10 +155,28 @@ std::shared_ptr GetGlobalTaskArena(unsigned m } return sp; } - std::shared_ptr sp(new ROOT::Internal::RTaskArenaWrapper(maxConcurrency)); + std::shared_ptr sp; + if (semantic && config == ROOT::EIMTConfig::kExistingTBBArena) { + sp = std::make_shared(ROOT::Internal::RTaskArenaWrapper::Attach{}); + } else { + if (semantic && config != ROOT::EIMTConfig::kWholeMachine) { + maxConcurrency = 0; + } + sp = std::make_shared(maxConcurrency); + } weak_GTAWrapper = sp; return sp; } +std::shared_ptr GetGlobalTaskArena(ROOT::EIMTConfig config) +{ + return GetGlobalTaskArena(true, 0, config); +} + +std::shared_ptr GetGlobalTaskArena(unsigned maxConcurrency) +{ + return GetGlobalTaskArena(false, maxConcurrency, ROOT::EIMTConfig::kNumConfigs); +} + } // namespace Internal } // namespace ROOT diff --git a/core/imt/src/TImplicitMT.cxx b/core/imt/src/TImplicitMT.cxx index 8d92c7fa105aa..708401570d78e 100644 --- a/core/imt/src/TImplicitMT.cxx +++ b/core/imt/src/TImplicitMT.cxx @@ -18,6 +18,7 @@ // // ////////////////////////////////////////////////////////////////////////// +#include "TROOT.h" #include "TError.h" #include "ROOT/RTaskArena.hxx" #include @@ -55,6 +56,21 @@ extern "C" void ROOT_TImplicitMT_EnableImplicitMT(UInt_t numthreads) } }; +extern "C" void ROOT_TImplicitMT_EnableImplicitMT_Config(ROOT::EIMTConfig config) +{ + if (!GetImplicitMTFlag()) { + if (config < ROOT::EIMTConfig::kNumConfigs) { + R__GetTaskArena4IMT() = ROOT::Internal::GetGlobalTaskArena(config); + } else { + ::Warning("ROOT_TImplicitMT_EnableImplicitMT_Config", "Unknown enum value %d defaulting to EIMTCconfig::kWholeMachine", (int)config); + R__GetTaskArena4IMT() = ROOT::Internal::GetGlobalTaskArena(0); + } + GetImplicitMTFlag() = true; + } else { + ::Warning("ROOT_TImplicitMT_EnableImplicitMT_Config", "Implicit multi-threading is already enabled"); + } +}; + extern "C" void ROOT_TImplicitMT_DisableImplicitMT() { if (GetImplicitMTFlag()) { diff --git a/core/imt/test/CMakeLists.txt b/core/imt/test/CMakeLists.txt index 9cfaceffbc1c6..93bacb86ccf2c 100644 --- a/core/imt/test/CMakeLists.txt +++ b/core/imt/test/CMakeLists.txt @@ -5,4 +5,5 @@ # For the list of contributors see $ROOTSYS/README/CREDITS. ROOT_ADD_GTEST(testTaskArena testRTaskArena.cxx LIBRARIES Imt ${TBB_LIBRARIES} FAILREGEX "") -ROOT_ADD_GTEST(testTBBGlobalControl testTBBGlobalControl.cxx LIBRARIES Imt ${TBB_LIBRARIES}) +ROOT_ADD_GTEST(testTBBGlobalControl testTBBGlobalControl.cxx testEnableImt.cxx LIBRARIES Imt ${TBB_LIBRARIES}) +ROOT_ADD_GTEST(testEnable testEnableImt.cxx LIBRARIES Imt ${TBB_LIBRARIES}) diff --git a/core/imt/test/testEnableImt.cxx b/core/imt/test/testEnableImt.cxx new file mode 100644 index 0000000000000..6fce34fc156c9 --- /dev/null +++ b/core/imt/test/testEnableImt.cxx @@ -0,0 +1,26 @@ +#include "TROOT.h" +#include "ROOT/RTaskArena.hxx" + +#include "tbb/task_arena.h" + +#include "ROOT/TestSupport.hxx" +#include "gtest/gtest.h" + +#ifdef R__USE_IMT + +static const unsigned gMaxConcurrency = ROOT::Internal::LogicalCPUBandwidthControl(); + +TEST(EnableImt, TBBAttach) +{ + tbb::task_arena main_arena; + main_arena.initialize(2); + + ROOT::EnableImplicitMT(ROOT::EIMTConfig::kExistingTBBArena); + + auto psize = ROOT::GetThreadPoolSize(); + + EXPECT_TRUE( psize > 1); + EXPECT_EQ( psize, 2); // gMaxConcurrency); +} + +#endif From 90d1cf78d44082695e1c19dd2c355709d367f031 Mon Sep 17 00:00:00 2001 From: Philippe Canal Date: Mon, 12 May 2025 15:31:21 -0500 Subject: [PATCH 2/7] [squash] Call EnableImplicitMT on the TBB thread --- core/imt/test/testEnableImt.cxx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/core/imt/test/testEnableImt.cxx b/core/imt/test/testEnableImt.cxx index 6fce34fc156c9..8c61ccc5e6d9b 100644 --- a/core/imt/test/testEnableImt.cxx +++ b/core/imt/test/testEnableImt.cxx @@ -12,15 +12,17 @@ static const unsigned gMaxConcurrency = ROOT::Internal::LogicalCPUBandwidthContr TEST(EnableImt, TBBAttach) { - tbb::task_arena main_arena; - main_arena.initialize(2); + tbb::task_arena main_arena{2}; - ROOT::EnableImplicitMT(ROOT::EIMTConfig::kExistingTBBArena); + main_arena.execute([&]() { + ROOT::EnableImplicitMT(ROOT::EIMTConfig::kExistingTBBArena); + }); auto psize = ROOT::GetThreadPoolSize(); EXPECT_TRUE( psize > 1); - EXPECT_EQ( psize, 2); // gMaxConcurrency); + EXPECT_EQ( main_arena.max_concurrency(), 2); + EXPECT_EQ( psize, 2); } #endif From 0b55bfbcc612f59ae6800030982e98435356ccfb Mon Sep 17 00:00:00 2001 From: Philippe Canal Date: Tue, 13 May 2025 16:17:50 -0500 Subject: [PATCH 3/7] [squash] Fix ifndef R__USE_IMT branch --- core/base/src/TROOT.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/base/src/TROOT.cxx b/core/base/src/TROOT.cxx index 03a9feb15f97d..ea645dde2c628 100644 --- a/core/base/src/TROOT.cxx +++ b/core/base/src/TROOT.cxx @@ -570,7 +570,7 @@ namespace Internal { sym(config); ROOT::Internal::IsImplicitMTEnabledImpl() = true; #else - ::Warning("EnableImplicitMT", "Cannot enable implicit multi-threading with %d threads, please build ROOT with -Dimt=ON", numthreads); + ::Warning("EnableImplicitMT", "Cannot enable implicit multi-threading with config %d, please build ROOT with -Dimt=ON", static_cast(config)); #endif } From 22a5ed0bb88263f8665d02828e1bb3dedda70c51 Mon Sep 17 00:00:00 2001 From: Philippe Canal Date: Thu, 15 May 2025 07:12:01 -0500 Subject: [PATCH 4/7] [squash][NFC] clang-format --- core/base/inc/TROOT.h | 11 +++++------ core/base/src/TROOT.cxx | 8 +++++--- core/imt/inc/ROOT/RTaskArena.hxx | 2 +- core/imt/src/ROpaqueTaskArena.hxx | 6 +++--- core/imt/src/RTaskArena.cxx | 8 ++++---- core/imt/src/TImplicitMT.cxx | 3 ++- core/imt/test/testEnableImt.cxx | 10 ++++------ 7 files changed, 24 insertions(+), 24 deletions(-) diff --git a/core/base/inc/TROOT.h b/core/base/inc/TROOT.h index 6f0334df5374e..bdeb7f301bb68 100644 --- a/core/base/inc/TROOT.h +++ b/core/base/inc/TROOT.h @@ -80,12 +80,11 @@ namespace Internal { } } // End ROOT::Internal namespace ROOT { - enum class EIMTConfig { - kWholeMachine = 0, ///< Default configuration - kExistingTBBArena = 1, ///< Use the existing TBB arena - kNumConfigs = 2 ///< Number of support IMT semantic configurations - - }; +enum class EIMTConfig { + kWholeMachine = 0, ///< Default configuration + kExistingTBBArena = 1, ///< Use the existing TBB arena + kNumConfigs = 2 ///< Number of support IMT semantic configurations +}; /// \brief Enable support for multi-threading within the ROOT code /// in particular, enables the global mutex to make ROOT thread safe/aware. void EnableThreadSafety(); diff --git a/core/base/src/TROOT.cxx b/core/base/src/TROOT.cxx index ea645dde2c628..851c1ad4eb3d8 100644 --- a/core/base/src/TROOT.cxx +++ b/core/base/src/TROOT.cxx @@ -558,19 +558,21 @@ namespace Internal { /// EnableImplicitMT calls in turn EnableThreadSafety. /// If ImplicitMT is already enabled, this function does nothing. - void EnableImplicitMT(ROOT::EIMTConfig config) { #ifdef R__USE_IMT if (ROOT::Internal::IsImplicitMTEnabledImpl()) return; EnableThreadSafety(); - static void (*sym)(ROOT::EIMTConfig) = (void(*)(ROOT::EIMTConfig))Internal::GetSymInLibImt("ROOT_TImplicitMT_EnableImplicitMT_Config"); + static void (*sym)(ROOT::EIMTConfig) = + (void (*)(ROOT::EIMTConfig))Internal::GetSymInLibImt("ROOT_TImplicitMT_EnableImplicitMT_Config"); if (sym) sym(config); ROOT::Internal::IsImplicitMTEnabledImpl() = true; #else - ::Warning("EnableImplicitMT", "Cannot enable implicit multi-threading with config %d, please build ROOT with -Dimt=ON", static_cast(config)); + ::Warning("EnableImplicitMT", + "Cannot enable implicit multi-threading with config %d, please build ROOT with -Dimt=ON", + static_cast(config)); #endif } diff --git a/core/imt/inc/ROOT/RTaskArena.hxx b/core/imt/inc/ROOT/RTaskArena.hxx index 4955eff398797..a9b68626b63c0 100644 --- a/core/imt/inc/ROOT/RTaskArena.hxx +++ b/core/imt/inc/ROOT/RTaskArena.hxx @@ -70,8 +70,8 @@ public: RTaskArenaWrapper(unsigned maxConcurrency = 0); RTaskArenaWrapper(Attach); -private: +private: friend std::shared_ptr GetGlobalTaskArena(bool, unsigned, ROOT::EIMTConfig); std::unique_ptr fTBBArena; static unsigned fNWorkers; diff --git a/core/imt/src/ROpaqueTaskArena.hxx b/core/imt/src/ROpaqueTaskArena.hxx index eca082360442f..4eacd86d2a183 100644 --- a/core/imt/src/ROpaqueTaskArena.hxx +++ b/core/imt/src/ROpaqueTaskArena.hxx @@ -1,8 +1,8 @@ #include "tbb/task_arena.h" namespace ROOT { -class ROpaqueTaskArena: public tbb::task_arena { - public: - using tbb::task_arena::task_arena; +class ROpaqueTaskArena : public tbb::task_arena { +public: + using tbb::task_arena::task_arena; }; } diff --git a/core/imt/src/RTaskArena.cxx b/core/imt/src/RTaskArena.cxx index 748ea84252a57..d9f51777f0d9d 100644 --- a/core/imt/src/RTaskArena.cxx +++ b/core/imt/src/RTaskArena.cxx @@ -108,15 +108,14 @@ RTaskArenaWrapper::RTaskArenaWrapper(unsigned maxConcurrency) : fTBBArena(new RO ROOT::EnableThreadSafety(); } - //////////////////////////////////////////////////////////////////////////////// /// Initializes the tbb::task_arena within RTaskArenaWrapper by attaching to an /// existing arena. /// /// * Can't be reinitialized //////////////////////////////////////////////////////////////////////////////// -RTaskArenaWrapper::RTaskArenaWrapper(RTaskArenaWrapper::Attach) : - fTBBArena(new ROpaqueTaskArena{tbb::task_arena::attach{}}) +RTaskArenaWrapper::RTaskArenaWrapper(RTaskArenaWrapper::Attach) + : fTBBArena(new ROpaqueTaskArena{tbb::task_arena::attach{}}) { fTBBArena->initialize(tbb::task_arena::attach{}); fNWorkers = fTBBArena->max_concurrency(); @@ -142,7 +141,8 @@ ROOT::ROpaqueTaskArena &RTaskArenaWrapper::Access() return *fTBBArena; } -std::shared_ptr GetGlobalTaskArena(bool semantic, unsigned maxConcurrency, ROOT::EIMTConfig config) +std::shared_ptr +GetGlobalTaskArena(bool semantic, unsigned maxConcurrency, ROOT::EIMTConfig config) { static std::weak_ptr weak_GTAWrapper; diff --git a/core/imt/src/TImplicitMT.cxx b/core/imt/src/TImplicitMT.cxx index 708401570d78e..76ecd9f06a869 100644 --- a/core/imt/src/TImplicitMT.cxx +++ b/core/imt/src/TImplicitMT.cxx @@ -62,7 +62,8 @@ extern "C" void ROOT_TImplicitMT_EnableImplicitMT_Config(ROOT::EIMTConfig config if (config < ROOT::EIMTConfig::kNumConfigs) { R__GetTaskArena4IMT() = ROOT::Internal::GetGlobalTaskArena(config); } else { - ::Warning("ROOT_TImplicitMT_EnableImplicitMT_Config", "Unknown enum value %d defaulting to EIMTCconfig::kWholeMachine", (int)config); + ::Warning("ROOT_TImplicitMT_EnableImplicitMT_Config", + "Unknown enum value %d defaulting to EIMTCconfig::kWholeMachine", (int)config); R__GetTaskArena4IMT() = ROOT::Internal::GetGlobalTaskArena(0); } GetImplicitMTFlag() = true; diff --git a/core/imt/test/testEnableImt.cxx b/core/imt/test/testEnableImt.cxx index 8c61ccc5e6d9b..54052b6eaf2a4 100644 --- a/core/imt/test/testEnableImt.cxx +++ b/core/imt/test/testEnableImt.cxx @@ -14,15 +14,13 @@ TEST(EnableImt, TBBAttach) { tbb::task_arena main_arena{2}; - main_arena.execute([&]() { - ROOT::EnableImplicitMT(ROOT::EIMTConfig::kExistingTBBArena); - }); + main_arena.execute([&]() { ROOT::EnableImplicitMT(ROOT::EIMTConfig::kExistingTBBArena); }); auto psize = ROOT::GetThreadPoolSize(); - EXPECT_TRUE( psize > 1); - EXPECT_EQ( main_arena.max_concurrency(), 2); - EXPECT_EQ( psize, 2); + EXPECT_TRUE(psize > 1); + EXPECT_EQ(main_arena.max_concurrency(), 2); + EXPECT_EQ(psize, 2); } #endif From 02f8367f0a4f7a01d9785c63a87c4b3e17ebb501 Mon Sep 17 00:00:00 2001 From: Philippe Canal Date: Thu, 15 May 2025 07:13:05 -0500 Subject: [PATCH 5/7] [squash][NFC] anti clang-format - follow existing code --- core/base/inc/TROOT.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/core/base/inc/TROOT.h b/core/base/inc/TROOT.h index bdeb7f301bb68..ce906484ed537 100644 --- a/core/base/inc/TROOT.h +++ b/core/base/inc/TROOT.h @@ -80,11 +80,11 @@ namespace Internal { } } // End ROOT::Internal namespace ROOT { -enum class EIMTConfig { - kWholeMachine = 0, ///< Default configuration - kExistingTBBArena = 1, ///< Use the existing TBB arena - kNumConfigs = 2 ///< Number of support IMT semantic configurations -}; + enum class EIMTConfig { + kWholeMachine = 0, ///< Default configuration + kExistingTBBArena = 1, ///< Use the existing TBB arena + kNumConfigs = 2 ///< Number of support IMT semantic configurations + }; /// \brief Enable support for multi-threading within the ROOT code /// in particular, enables the global mutex to make ROOT thread safe/aware. void EnableThreadSafety(); From b7f1274eb09297315c9dd7da58f30fe5093cce11 Mon Sep 17 00:00:00 2001 From: Philippe Canal Date: Thu, 15 May 2025 08:00:30 -0500 Subject: [PATCH 6/7] [squash] Simplify internal routine signature --- core/imt/inc/ROOT/RTaskArena.hxx | 2 +- core/imt/src/RTaskArena.cxx | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/core/imt/inc/ROOT/RTaskArena.hxx b/core/imt/inc/ROOT/RTaskArena.hxx index a9b68626b63c0..7cd871f7eb902 100644 --- a/core/imt/inc/ROOT/RTaskArena.hxx +++ b/core/imt/inc/ROOT/RTaskArena.hxx @@ -72,7 +72,7 @@ public: RTaskArenaWrapper(Attach); private: - friend std::shared_ptr GetGlobalTaskArena(bool, unsigned, ROOT::EIMTConfig); + friend std::shared_ptr GetGlobalTaskArena(unsigned, ROOT::EIMTConfig); std::unique_ptr fTBBArena; static unsigned fNWorkers; }; diff --git a/core/imt/src/RTaskArena.cxx b/core/imt/src/RTaskArena.cxx index d9f51777f0d9d..12f2bbbd65798 100644 --- a/core/imt/src/RTaskArena.cxx +++ b/core/imt/src/RTaskArena.cxx @@ -142,7 +142,7 @@ ROOT::ROpaqueTaskArena &RTaskArenaWrapper::Access() } std::shared_ptr -GetGlobalTaskArena(bool semantic, unsigned maxConcurrency, ROOT::EIMTConfig config) +GetGlobalTaskArena(unsigned maxConcurrency, ROOT::EIMTConfig config) { static std::weak_ptr weak_GTAWrapper; @@ -156,10 +156,10 @@ GetGlobalTaskArena(bool semantic, unsigned maxConcurrency, ROOT::EIMTConfig conf return sp; } std::shared_ptr sp; - if (semantic && config == ROOT::EIMTConfig::kExistingTBBArena) { + if (config == ROOT::EIMTConfig::kExistingTBBArena) { sp = std::make_shared(ROOT::Internal::RTaskArenaWrapper::Attach{}); } else { - if (semantic && config != ROOT::EIMTConfig::kWholeMachine) { + if (config == ROOT::EIMTConfig::kWholeMachine) { maxConcurrency = 0; } sp = std::make_shared(maxConcurrency); @@ -170,12 +170,15 @@ GetGlobalTaskArena(bool semantic, unsigned maxConcurrency, ROOT::EIMTConfig conf std::shared_ptr GetGlobalTaskArena(ROOT::EIMTConfig config) { - return GetGlobalTaskArena(true, 0, config); + if (config >= ROOT::EIMTConfig::kNumConfigs) + ::Fatal("ROOT::Internal::GetGlobalTaskArena", + "Unsupported enum value %d", (int)config); + return GetGlobalTaskArena(0, config); } std::shared_ptr GetGlobalTaskArena(unsigned maxConcurrency) { - return GetGlobalTaskArena(false, maxConcurrency, ROOT::EIMTConfig::kNumConfigs); + return GetGlobalTaskArena(maxConcurrency, ROOT::EIMTConfig::kNumConfigs); } } // namespace Internal From 436a1372b8296a731f8084ab5971f6cfda9d3ab5 Mon Sep 17 00:00:00 2001 From: Philippe Canal Date: Thu, 15 May 2025 08:00:53 -0500 Subject: [PATCH 7/7] [squash] Fix typos in test CMake --- core/imt/test/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/imt/test/CMakeLists.txt b/core/imt/test/CMakeLists.txt index 93bacb86ccf2c..19fd0f3879ddf 100644 --- a/core/imt/test/CMakeLists.txt +++ b/core/imt/test/CMakeLists.txt @@ -5,5 +5,5 @@ # For the list of contributors see $ROOTSYS/README/CREDITS. ROOT_ADD_GTEST(testTaskArena testRTaskArena.cxx LIBRARIES Imt ${TBB_LIBRARIES} FAILREGEX "") -ROOT_ADD_GTEST(testTBBGlobalControl testTBBGlobalControl.cxx testEnableImt.cxx LIBRARIES Imt ${TBB_LIBRARIES}) -ROOT_ADD_GTEST(testEnable testEnableImt.cxx LIBRARIES Imt ${TBB_LIBRARIES}) +ROOT_ADD_GTEST(testTBBGlobalControl testTBBGlobalControl.cxx LIBRARIES Imt ${TBB_LIBRARIES}) +ROOT_ADD_GTEST(testEnableImt testEnableImt.cxx LIBRARIES Imt ${TBB_LIBRARIES})