9 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) ) 10 #define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) ) 27 if ( sc.isFailure() ) {
28 fatal() <<
"Base class failed to initialize" <<
endmsg;
36 if ( !boost::filesystem::create_directory(
m_dumpDirName ) ) {
38 "for task precedence tracing" 48 fatal() <<
"Error retrieving AlgoResourcePool" <<
endmsg;
52 info() <<
"Assembling CF and DF task precedence rules" <<
endmsg;
59 auto algorithm =
dynamic_cast<Algorithm*
>( ialgoPtr );
60 if ( !algorithm )
fatal() <<
"Conversion from IAlgorithm to Algorithm failed" <<
endmsg;
62 if ( sc.isFailure() ) {
63 fatal() <<
"Could not assemble the CF precedence realm" <<
endmsg;
69 warning() <<
"Ignoring DF precedence rules, disabling all associated features" <<
endmsg;
75 if ( sc.isFailure() ) {
76 fatal() <<
"Could not assemble the DF precedence realm" <<
endmsg;
84 }
else if (
m_mode ==
"COD" ) {
87 }
else if (
m_mode ==
"E" ) {
90 }
else if (
m_mode ==
"T" ) {
93 }
else if (
m_mode ==
"DRE" ) {
96 }
else if ( !
m_mode.empty() ) {
97 error() <<
"Requested prioritization rule '" <<
m_mode <<
"' is unknown" <<
endmsg;
103 if ( sc.isSuccess() )
info() <<
"PrecedenceSvc initialized successfully" <<
endmsg;
115 bool isGaudiSequencer(
false );
116 bool isAthSequencer(
false );
120 isGaudiSequencer =
true;
122 isAthSequencer =
true;
128 ( subAlgorithms->
empty() && !( isGaudiSequencer || isAthSequencer ) ) ) {
139 bool allPass =
false;
141 bool isSequential =
false;
143 if ( isGaudiSequencer ) {
144 modeOR = ( algo->
getProperty(
"ModeOR" ).toString() ==
"True" ) ?
true :
false;
145 allPass = ( algo->
getProperty(
"IgnoreFilterPassed" ).toString() ==
"True" ) ?
true :
false;
146 isLazy = ( algo->
getProperty(
"ShortCircuit" ).toString() ==
"True" ) ?
true :
false;
147 if ( allPass ) isLazy =
false;
148 isSequential = ( algo->
hasProperty(
"Sequential" ) && ( algo->
getProperty(
"Sequential" ).toString() ==
"True" ) );
149 }
else if ( isAthSequencer ) {
150 modeOR = ( algo->
getProperty(
"ModeOR" ).toString() ==
"True" ) ?
true :
false;
151 allPass = ( algo->
getProperty(
"IgnoreFilterPassed" ).toString() ==
"True" ) ?
true :
false;
152 isLazy = ( algo->
getProperty(
"StopOverride" ).toString() ==
"True" ) ?
false :
true;
153 isSequential = ( algo->
hasProperty(
"Sequential" ) && ( algo->
getProperty(
"Sequential" ).toString() ==
"True" ) );
157 error() <<
"Failed to add DecisionHub " << algo->
name() <<
" to graph of precedence rules" <<
endmsg;
161 for (
Algorithm* subalgo : *subAlgorithms ) {
164 error() <<
"Algorithm " << subalgo->name() <<
" could not be flattened" <<
endmsg;
175 bool ifTrace =
false;
214 int prevAlgosNum = visitor.m_nodesSucceeded;
215 debug() <<
" Proceeding with iteration #" << cntr <<
endmsg;
218 if ( prevNodeDecisions == nodeDecisions ) {
219 error() <<
" No progress on iteration " << cntr <<
" detected, node decisions are:" << nodeDecisions <<
endmsg;
222 info() <<
" Iteration #" << cntr <<
" finished, total algorithms executed: " << visitor.m_nodesSucceeded
226 s << cntr <<
", " << ( visitor.m_nodesSucceeded - prevAlgosNum ) <<
"\n";
233 if ( visitor.m_nodesSucceeded != prevAlgosNum ) counters.
push_back( visitor.m_nodesSucceeded );
236 info() <<
"Asymptotical concurrency speedup depth: " << (float)visitor.m_nodesSucceeded / (
float)counters.
size()
241 nodeDecisions.assign( nodeDecisions.size(), -1 );
280 info() <<
"No temporal and topological aspects of execution flow were traced. " 281 <<
"To get them traced, please set DumpPrecedenceRules " 282 <<
"property to True *and* put the whole application in DEBUG " 283 <<
"logging mode" <<
endmsg;
292 fileName =
"rules.evt-" +
std::to_string( eventID.event_number() ) +
"." +
"run-" +
299 pth.append( fileName );
309 info() <<
"Task precedence was not traced. To get it traced, please set " 310 <<
"DumpPrecedenceTrace property to True *and* put the " 311 <<
"whole application in DEBUG logging mode" <<
endmsg;
320 fileName =
"trace.evt-" +
std::to_string( eventID.event_number() ) +
"." +
"run-" +
327 pth.append( fileName );
StatusCode getProperty(Gaudi::Details::PropertyBase *p) const override
get the property
Gaudi::Property< bool > m_dumpPrecTrace
concurrency::PrecedenceRulesGraph m_PRGraph
Graph of precedence rules.
StatusCode initialize() override
void dumpPrecedenceRules(EventSlot &) override
Dump precedence rules (available only in DEBUG mode, and must be enabled with the corresponding servi...
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
StatusCode addAlgorithmNode(Algorithm *daughterAlgo, const std::string &parentName, bool inverted, bool allPass)
Add algorithm node.
const std::string & name() const override
The identifying name of the algorithm object.
void dumpDataFlow() const override
StatusCode finalize() override
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
AlgsExecutionStates algsStates
Vector of algorithms states.
StatusCode assembleCFRules(Algorithm *, const std::string &, unsigned int recursionDepth=0)
EventContext * eventContext
Cache for the eventContext.
A service to resolve the task execution precedence.
bool hasProperty(const std::string &name) const override
Return true if we have a property with the given name.
void dumpPrecRules(const boost::filesystem::path &, const EventSlot &slot)
dump to file the precedence rules
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
StatusCode addDecisionHubNode(Algorithm *daughterAlgo, const std::string &parentName, bool modeConcurrent, bool modePromptDecision, bool modeOR, bool allPass)
Add a node, which aggregates decisions of direct daughter nodes.
void printState(std::stringstream &output, AlgsExecutionStates &states, const std::vector< int > &node_decisions, const unsigned int &recursionLevel) const
Print a string representing the control flow state.
boost::filesystem::path m_dumpDirName
Precedence analysis facilities.
void addHeadNode(const std::string &headName, bool modeConcurrent, bool modePromptDecision, bool modeOR, bool allPass)
Add a node, which has no parents.
AlgorithmNode * getAlgorithmNode(const std::string &algoName) const
Get the AlgorithmNode from by algorithm name using graph index.
void rankAlgorithms(IGraphVisitor &ranker) const
Rank Algorithm nodes by the number of data outputs.
bool isFailure() const
Test for a status code of FAILURE.
Gaudi::Property< bool > m_ignoreDFRules
Scheduling strategy.
StatusCode iterate(EventSlot &, const Cause &) override
Infer the precedence effect caused by an execution flow event.
Gaudi::Property< std::string > m_dumpPrecRulesFile
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
bool accept(IGraphVisitor &visitor) override
Visitor entry point.
StatusCode initialize()
Initialize graph.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
SmartIF< IAlgResourcePool > m_algResourcePool
A shortcut to the algorithm resource pool.
void dumpPrecTrace(const boost::filesystem::path &)
dump to file the precedence trace
virtual std::list< IAlgorithm * > getTopAlgList()=0
Get top list of algorithms.
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
std::vector< int > controlFlowState
State of the control flow.
StatusCode finalize() override
Finalize.
This class is used for returning status codes from appropriate routines.
std::string dumpDataFlow() const
Print out all data origins and destinations, as reflected in the EF graph.
Gaudi::Property< std::string > m_mode
Scheduling strategy.
#define DECLARE_SERVICE_FACTORY(x)
void dumpPrecedenceTrace(EventSlot &) override
Dump precedence trace (available only in DEBUG mode, and must be enabled with the corresponding servi...
bool CFRulesResolved(EventSlot &) const override
Check if the root CF decision is resolved.
StatusCode simulate(EventSlot &) const override
Simulate execution flow.
const std::vector< Algorithm * > * subAlgorithms() const
List of sub-algorithms. Returns a pointer to a vector of (sub) Algorithms.
Base class from which all concrete algorithm classes should be derived.
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
bool isValid() const
Allow for check if smart pointer is valid.
bool isSequence() const override
Are we a Sequence?
Gaudi::Property< bool > m_dumpPrecRules
Class representing the event slot.
bool accept(IGraphVisitor &visitor) override
Visitor entry point.
Gaudi::Property< std::string > m_dumpPrecTraceFile
const std::string printState(EventSlot &) const override
const EventIDBase & eventID() const
const unsigned int & getNodeIndex() const
Get node index.
MsgStream & fatal() const
shortcut for the method msgStream(MSG::FATAL)
void dumpControlFlow() const override
Dump precedence rules.
std::string dumpControlFlow() const
Print out control flow of Algorithms and Sequences.
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
StatusCode initialize() override
Initialize.
DecisionNode * getHeadNode() const
Get head node.