ATLAS Offline Software
Loading...
Searching...
No Matches
HiveExSvc Class Reference

#include <HiveExSvc.h>

Inheritance diagram for HiveExSvc:
Collaboration diagram for HiveExSvc:

Classes

struct  tDat

Public Member Functions

 HiveExSvc (const std::string &name, ISvcLocator *svc)
virtual ~HiveExSvc ()
virtual StatusCode initialize () override
virtual StatusCode finalize () override
virtual void add (const std::string &, const unsigned int &) override

Private Attributes

std::vector< std::list< tDat > > m_times
std::vector< std::unique_ptr< std::mutex > > m_locks

Detailed Description

Definition at line 24 of file HiveExSvc.h.

Constructor & Destructor Documentation

◆ HiveExSvc()

HiveExSvc::HiveExSvc ( const std::string & name,
ISvcLocator * svc )

Definition at line 14 of file HiveExSvc.cxx.

15 : base_class( name, svc ) {}

◆ ~HiveExSvc()

HiveExSvc::~HiveExSvc ( )
virtualdefault

Member Function Documentation

◆ add()

void HiveExSvc::add ( const std::string & algName,
const unsigned int & time )
overridevirtual

Definition at line 77 of file HiveExSvc.cxx.

77 {
78
79 // even though we have separate data structures per concurrent
80 // event (slot), we can't be sure that multiple threads aren't
81 // processing the same slot at the same time, so need to lock the mutex.
82 // this reduces the waiting for a lock, compared with locking the
83 // whole structure, as it's unlikely that we'll have the same Alg in
84 // different concurrent events executing at the same time.
85
86 // for a true lock-free design, we would need a separate container for
87 // each Algorithm in each slot
88
89 EventContext::ContextID_t slot = Gaudi::Hive::currentContextId();
90 std::lock_guard<std::mutex> lock ( *m_locks[slot] );
91 m_times[slot].push_back( tDat(algName, time) );
92}
std::vector< std::unique_ptr< std::mutex > > m_locks
Definition HiveExSvc.h:49
std::vector< std::list< tDat > > m_times
Definition HiveExSvc.h:45

◆ finalize()

StatusCode HiveExSvc::finalize ( )
overridevirtual

Definition at line 46 of file HiveExSvc.cxx.

46 {
47 ATH_MSG_INFO("finalize");
48
49 // calculate the standard deviation of the sleep times
50 std::map<std::string,unsigned int> sum;
51 std::map<std::string,unsigned int> sumSq;
52 std::map<std::string,unsigned int> num;
53
54 for (const auto &ve : m_times) {
55 for (const auto &e : ve) {
56 sum[e.algName] += e.sleep_time;
57 sumSq[e.algName] += e.sleep_time * e.sleep_time;
58 num[e.algName] ++;
59 }
60 }
61
62 info() << "listing timing by alg:";
63 for (const auto &s : sum) {
64 float avg = static_cast<float>(s.second)/num[s.first];
65 float sig = sqrt( ( sumSq[s.first] - 2*s.second*avg + num[s.first]*avg*avg )/(num[s.first]) );
66 info() << "\n " << s.first
67 << " avg: " << avg << " sig: " << sig;
68 }
69 info() << endmsg;
70
71 return StatusCode::SUCCESS;
72}
#define endmsg
#define ATH_MSG_INFO(x)
avg(a, b)
Definition Recovery.py:79

◆ initialize()

StatusCode HiveExSvc::initialize ( )
overridevirtual

Definition at line 24 of file HiveExSvc.cxx.

24 {
25
26 size_t nslots = Gaudi::Concurrency::ConcurrencyFlags::numConcurrentEvents();
27 if (nslots == 0) {
28 nslots = 1;
29 }
30
31 ATH_MSG_INFO("initialize structures of size " << nslots);
32
33 // initialize the structures with the number of concurrent events
34 m_times.resize( nslots );
35 m_locks.resize( nslots );
36 for ( auto & m : m_locks ) {
37 m = std::make_unique<std::mutex>();
38 }
39
40 return StatusCode::SUCCESS;
41}

Member Data Documentation

◆ m_locks

std::vector< std::unique_ptr<std::mutex> > HiveExSvc::m_locks
private

Definition at line 49 of file HiveExSvc.h.

◆ m_times

std::vector< std::list<tDat> > HiveExSvc::m_times
private

Definition at line 45 of file HiveExSvc.h.


The documentation for this class was generated from the following files: