ATLAS Offline Software
MonitorThreadOccupancy.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "../counters/CounterThread.h"
7 
10  m_threadToCounterMap(),
11  m_threadCounter(0) {}
12 
13 
15  // Only look at events in the master slot
16  if (not data.isMasterSlot()) {
17  return StatusCode::SUCCESS;
18  }
19 
20  // Check if we ran with EnableMultiSlot=true - in the master slot (online slot) there are algorithms executed on different slot
21  bool isMultiSlot = false;
22  for (const xAOD::TrigComposite* tc : data.costCollection()) {
23  const uint32_t slot = tc->getDetail<uint32_t>("slot");
24  if (slot != data.onlineSlot()){
25  isMultiSlot = true;
26  break;
27  }
28  }
29 
30  if (!isMultiSlot){
31  ATH_MSG_DEBUG("Saving data from multiple slots to master slot was not enabled - ThreadOccupancy Monitoring won't be executed");
32  return StatusCode::SUCCESS;
33  }
34 
35  for (const xAOD::TrigComposite* tc : data.costCollection()) {
36  const uint32_t threadID = tc->getDetail<uint32_t>("thread");
37  if (m_threadToCounterMap.count(threadID) == 0) {
38  std::stringstream threadIDStr;
39  threadIDStr << "Thread_" << std::setfill('0') << std::setw(5) << threadID;
40  m_threadToCounterMap[threadID] = threadIDStr.str();
41  }
42  ATH_CHECK( getCounter(m_threadToCounterMap[threadID])->newEvent(data, tc->index(), weight) );
43  }
44 
46 
47 
48  return StatusCode::SUCCESS;
49 }
50 
51 
54  uint64_t highTimestamp = 0;
55  for (const auto& nameCounterPair : m_counters) {
56  const CounterThread* ptr = dynamic_cast<const CounterThread*>(nameCounterPair.second.get());
57  lowTimestamp = std::min(lowTimestamp, ptr->getLowTimestamp());
58  highTimestamp = std::max(highTimestamp, ptr->getHighTimestamp());
59  }
60  for (auto& nameCounterPair : m_counters) {
61  CounterThread* ptr = dynamic_cast<CounterThread*>(nameCounterPair.second.get());
62  ptr->setAllThreadsTimestamps(lowTimestamp, highTimestamp);
63  ATH_CHECK( ptr->postProcess(weight) );
64  }
65  return StatusCode::SUCCESS;
66 }
67 
68 
69 std::unique_ptr<CounterBase> MonitorThreadOccupancy::newCounter(const std::string& name) {
70  return std::make_unique<CounterThread>(name, this);
71 }
MonitorThreadOccupancy::MonitorThreadOccupancy
MonitorThreadOccupancy()=delete
Forbid default constructor.
data
char data[hepevt_bytes_allocation_ATLAS]
Definition: HepEvt.cxx:11
MonitorThreadOccupancy::newEvent
virtual StatusCode newEvent(const CostData &data, const float weight=1.) override
Concrete dispatch method.
Definition: MonitorThreadOccupancy.cxx:14
MonitorBase::m_counters
std::unordered_map< std::string, std::unique_ptr< CounterBase > > m_counters
Storage of Monitor's collection of Counters.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.h:138
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
min
constexpr double min()
Definition: ap_fixedTest.cxx:26
CounterThread
Concrete implimentation of Counter to monitor all algorithms executing on a single thread.
Definition: CounterThread.h:14
dbg::ptr
void * ptr(T *p)
Definition: SGImplSvc.cxx:74
MonitorThreadOccupancy::m_threadToCounterMap
std::unordered_map< uint32_t, std::string > m_threadToCounterMap
Map thread's hash ID to a counting numeral embedded in a string.
Definition: MonitorThreadOccupancy.h:62
MonitorThreadOccupancy::postProcess
StatusCode postProcess(float weight)
Get the global start and stop timestamps over all threads and sync these to the individual threads.
Definition: MonitorThreadOccupancy.cxx:52
dqt_zlumi_pandas.weight
int weight
Definition: dqt_zlumi_pandas.py:189
MonitorBase::getCounter
CounterBase * getCounter(const std::string &name)
Retrieve counter by name.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.cxx:52
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
test_pyathena.parent
parent
Definition: test_pyathena.py:15
xAOD::uint64_t
uint64_t
Definition: EventInfo_v1.cxx:123
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
xAOD::TrigComposite_v1
Class used to describe composite objects in the HLT.
Definition: TrigComposite_v1.h:52
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
MonitorBase
Forward declare.
Definition: Trigger/TrigCost/TrigCostAnalysis/src/MonitorBase.h:33
MonitoredRange
Container which represents a time range and holds a collection of Monitors which monitor this range.
Definition: MonitoredRange.h:29
MonitorThreadOccupancy.h
MonitorThreadOccupancy::newCounter
virtual std::unique_ptr< CounterBase > newCounter(const std::string &name) override
Concrete counter instantiation.
Definition: MonitorThreadOccupancy.cxx:69
CostData
Caches and propagates event data to be used by monitoring algorithms.
Definition: CostData.h:26