Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/base/inc/TROOT.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace Internal {
TParBranchProcessingRAII() { EnableParBranchProcessing(); }
~TParBranchProcessingRAII() { DisableParBranchProcessing(); }
};

// Manage parallel tree processing
void EnableParTreeProcessing();
void DisableParTreeProcessing();
Expand All @@ -95,6 +95,7 @@ namespace ROOT {
void DisableImplicitMT();
Bool_t IsImplicitMTEnabled();
UInt_t GetImplicitMTPoolSize();
UInt_t GetAvailableThreads();
}

class TROOT : public TDirectory {
Expand Down
16 changes: 16 additions & 0 deletions core/base/src/TROOT.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,22 @@ namespace Internal {
#endif
}

////////////////////////////////////////////////////////////////////////////////
/// Returns the maximum number of threads the user can instantiate.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment is incorrect (at least for the !IMT case). Could you copy the comment from GetMaxNThreadsAvailable()?

Also this doesn't return the available threads but their number. I'd suggest to use the same name for both the TROOT member and the ROOT::Internal member.

UInt_t GetAvailableThreads()
{
#ifdef R__USE_IMT
static UInt_t (*sym)() = (UInt_t(*)())Internal::GetSymInLibImt("ROOT_TImplicitMT_GetAvailableThreads");
if (sym)
return sym();
else
return 0;
#else
SysInfo_t s;
gSystem->GetSysInfo(&s);
return s.fCpus;
#endif
}
}

TROOT *ROOT::Internal::gROOTLocal = ROOT::GetROOT();
Expand Down
5 changes: 5 additions & 0 deletions core/imt/inc/ROOT/TPoolManager.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,11 @@ namespace ROOT {
/// The number of threads will be able to change calling the factory function again after the last
/// remaining shared_ptr owning the object is destroyed or reasigned, which will trigger the destructor of the manager.
std::shared_ptr<TPoolManager> GetPoolManager(UInt_t nThreads = 0);


/// Get the maximum number of logical CPUs available.
/// In case of having an affinity mask (TBB), return the logical CPU available to the current process in accordance with it.
Int_t GetMaxNThreadsAvailable();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you adjust the function name to the documentation? It does not return the maximum number of threads.

}
}

Expand Down
4 changes: 4 additions & 0 deletions core/imt/src/TImplicitMT.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ extern "C" UInt_t ROOT_TImplicitMT_GetImplicitMTPoolSize()
return ROOT::Internal::TPoolManager::GetPoolSize();
};

extern "C" UInt_t ROOT_TImplicitMT_GetAvailableThreads()
{
return ROOT::Internal::GetMaxNThreadsAvailable();
};

extern "C" void ROOT_TImplicitMT_EnableParBranchProcessing()
{
Expand Down
6 changes: 5 additions & 1 deletion core/imt/src/TPoolManager.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,13 @@ namespace ROOT {
if (GetWP().expired()) {
std::shared_ptr<TPoolManager> shared(new TPoolManager(nThreads));
GetWP() = shared;
return GetWP().lock();
}
return GetWP().lock();
}

Int_t GetMaxNThreadsAvailable()
{
return tbb::task_scheduler_init::default_num_threads();
}
}
}