The Gaudi Framework  master (37c0b60a)
PrecedenceSvc.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIHIVE_PRECEDENCESVC_H_
12 #define GAUDIHIVE_PRECEDENCESVC_H_
13 
14 #include "IPrecedenceSvc.h"
16 
17 // Framework include files
19 #include <GaudiKernel/Service.h>
20 
21 #include <boost/filesystem.hpp>
22 
31 class PrecedenceSvc : public extends<Service, IPrecedenceSvc> {
32 
33 public:
35  PrecedenceSvc( const std::string& name, ISvcLocator* svcLoc ) : base_class( name, svcLoc ) {}
36 
38  StatusCode initialize() override;
39 
41  StatusCode finalize() override;
42 
44  StatusCode iterate( EventSlot&, const Cause& ) override;
45 
47  StatusCode simulate( EventSlot& ) const override;
48 
50  bool CFRulesResolved( EventSlot& ) const override;
51 
53  uint getPriority( const std::string& name ) const override {
54  return (int)m_PRGraph.getAlgorithmNode( name )->getRank();
55  }
56 
58  bool isAsynchronous( const std::string& name ) const override {
60  }
61 
63  void dumpControlFlow() const override;
64  void dumpDataFlow() const override;
65  const std::string printState( EventSlot& ) const override;
66 
69  void dumpPrecedenceRules( const EventSlot& ) override;
72  void dumpPrecedenceTrace( const EventSlot& ) override;
73 
76 
77 private:
78  StatusCode assembleCFRules( Gaudi::Algorithm*, const std::string&, unsigned int recursionDepth = 0 );
79 
80 private:
86  Gaudi::Property<std::string> m_mode{ this, "TaskPriorityRule", "", "Task avalanche induction strategy." };
88  Gaudi::Property<bool> m_ignoreDFRules{ this, "IgnoreDFRules", false, "Ignore the data flow rules." };
91  boost::filesystem::unique_path( boost::filesystem::path( "precedence.analysis.%%%%" ) ) };
92  Gaudi::Property<bool> m_dumpPrecTrace{ this, "DumpPrecedenceTrace", false,
93  "Dump task precedence traces for each event." };
95  this, "PrecedenceTraceFile", "",
96  "Override default name of the GRAPHML trace file. NOTE: if more than "
97  "1 event is processed, the setting forces creation of a single file "
98  "with cumulative precedence trace." };
99  Gaudi::Property<bool> m_dumpPrecRules{ this, "DumpPrecedenceRules", false, "Dump task precedence rules." };
100  Gaudi::Property<std::string> m_dumpPrecRulesFile{ this, "PrecedenceRulesFile", "",
101  "Override default name of the GRAPHML precedence rules file." };
102  Gaudi::Property<bool> m_verifyRules{ this, "VerifyTaskPrecedenceRules", true,
103  "Verify task precedence rules for common errors." };
104  Gaudi::Property<bool> m_showDataFlow{ this, "ShowDataFlow", false,
105  "Show the configuration of DataFlow between Algorithms" };
106 };
107 
108 #endif /* GAUDIHIVE_PRECEDENCESVC_H_ */
PrecedenceSvc
A service to resolve the task execution precedence.
Definition: PrecedenceSvc.h:31
PrecedenceSvc::m_dumpPrecRules
Gaudi::Property< bool > m_dumpPrecRules
Definition: PrecedenceSvc.h:99
PrecedenceSvc::dumpPrecedenceTrace
void dumpPrecedenceTrace(const EventSlot &) override
Dump precedence trace (available only in DEBUG mode, and must be enabled with the corresponding servi...
Definition: PrecedenceSvc.cpp:340
IAlgResourcePool.h
std::string
STL class.
PrecedenceSvc::dumpPrecedenceRules
void dumpPrecedenceRules(const EventSlot &) override
Dump precedence rules (available only in DEBUG mode, and must be enabled with the corresponding servi...
Definition: PrecedenceSvc.cpp:313
PrecedenceSvc::m_PRGraph
concurrency::PrecedenceRulesGraph m_PRGraph
Graph of precedence rules.
Definition: PrecedenceSvc.h:84
AtlasMCRecoFullPrecedenceDump.path
path
Definition: AtlasMCRecoFullPrecedenceDump.py:49
IPrecedenceSvc.h
PrecedenceSvc::m_dumpPrecTraceFile
Gaudi::Property< std::string > m_dumpPrecTraceFile
Definition: PrecedenceSvc.h:94
PrecedenceSvc::PrecedenceSvc
PrecedenceSvc(const std::string &name, ISvcLocator *svcLoc)
Constructor.
Definition: PrecedenceSvc.h:35
PrecedenceSvc::assembleCFRules
StatusCode assembleCFRules(Gaudi::Algorithm *, const std::string &, unsigned int recursionDepth=0)
Definition: PrecedenceSvc.cpp:149
ISvcLocator
Definition: ISvcLocator.h:46
EventSlot
Class representing an event slot.
Definition: EventSlot.h:24
concurrency::PrecedenceRulesGraph
Definition: PrecedenceRulesGraph.h:620
PrecedenceSvc::getRules
const concurrency::PrecedenceRulesGraph * getRules() const
Precedence rules accessor.
Definition: PrecedenceSvc.h:75
PrecedenceSvc::printState
const std::string printState(EventSlot &) const override
Definition: PrecedenceSvc.cpp:305
PrecedenceSvc::initialize
StatusCode initialize() override
Initialize.
Definition: PrecedenceSvc.cpp:31
PrecedenceSvc::m_verifyRules
Gaudi::Property< bool > m_verifyRules
Definition: PrecedenceSvc.h:102
PrecedenceSvc::m_algResourcePool
SmartIF< IAlgResourcePool > m_algResourcePool
A shortcut to the algorithm resource pool.
Definition: PrecedenceSvc.h:82
PrecedenceSvc::simulate
StatusCode simulate(EventSlot &) const override
Simulate execution flow.
Definition: PrecedenceSvc.cpp:243
PrecedenceSvc::dumpDataFlow
void dumpDataFlow() const override
Definition: PrecedenceSvc.cpp:299
Service::name
const std::string & name() const override
Retrieve name of the service
Definition: Service.cpp:332
StatusCode
Definition: StatusCode.h:65
PrecedenceSvc::m_dumpDirName
boost::filesystem::path m_dumpDirName
Precedence analysis facilities.
Definition: PrecedenceSvc.h:90
CommonMessaging
Definition: CommonMessaging.h:66
Gaudi::Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:90
PrecedenceSvc::CFRulesResolved
bool CFRulesResolved(EventSlot &) const override
Check if the root CF decision is resolved.
Definition: PrecedenceSvc.cpp:288
PrecedenceSvc::m_dumpPrecTrace
Gaudi::Property< bool > m_dumpPrecTrace
Definition: PrecedenceSvc.h:92
SmartIF< IAlgResourcePool >
PrecedenceSvc::isAsynchronous
bool isAsynchronous(const std::string &name) const override
Check if a task is asynchronous.
Definition: PrecedenceSvc.h:58
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:20
concurrency::AlgorithmNode::getRank
float getRank() const
Get Algorithm rank.
Definition: PrecedenceRulesGraph.h:515
PrecedenceSvc::iterate
StatusCode iterate(EventSlot &, const Cause &) override
Infer the precedence effect caused by an execution flow event.
Definition: PrecedenceSvc.cpp:219
Service.h
concurrency::PrecedenceRulesGraph::getAlgorithmNode
AlgorithmNode * getAlgorithmNode(const std::string &algoName) const
Get the AlgorithmNode from by algorithm name using graph index.
Definition: PrecedenceRulesGraph.h:651
PrecedenceSvc::m_ignoreDFRules
Gaudi::Property< bool > m_ignoreDFRules
Scheduling strategy.
Definition: PrecedenceSvc.h:88
PrecedenceSvc::m_dumpPrecRulesFile
Gaudi::Property< std::string > m_dumpPrecRulesFile
Definition: PrecedenceSvc.h:100
PrecedenceSvc::dumpControlFlow
void dumpControlFlow() const override
Dump precedence rules.
Definition: PrecedenceSvc.cpp:293
PrecedenceSvc::getPriority
uint getPriority(const std::string &name) const override
Get priority of an algorithm.
Definition: PrecedenceSvc.h:53
PrecedenceSvc::m_showDataFlow
Gaudi::Property< bool > m_showDataFlow
Definition: PrecedenceSvc.h:104
PrecedenceRulesGraph.h
PrecedenceSvc::m_mode
Gaudi::Property< std::string > m_mode
Scheduling strategy.
Definition: PrecedenceSvc.h:86
concurrency::AlgorithmNode::isAsynchronous
bool isAsynchronous() const
Check if algorithm is asynchronous.
Definition: PrecedenceRulesGraph.h:525
Cause
Definition: PrecedenceRulesGraph.h:396
Gaudi::Property< std::string >
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator
Definition: Service.cpp:335
PrecedenceSvc::finalize
StatusCode finalize() override
Finalize.
Definition: PrecedenceSvc.cpp:369