9 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) ) 10 #define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) ) 28 if ( sc.isFailure() ) {
29 fatal() <<
"Base class failed to initialize" <<
endmsg;
35 if ( !boost::filesystem::create_directory(
m_dumpDirName ) ) {
37 "for task precedence tracing" 48 fatal() <<
"Error retrieving AlgoResourcePool" <<
endmsg;
52 info() <<
"Assembling CF and DF task precedence rules" <<
endmsg;
60 auto algorithm =
dynamic_cast<Algorithm*
>( ialgoPtr );
61 if ( !algorithm )
fatal() <<
"Conversion from IAlgorithm to Algorithm failed" <<
endmsg;
63 if ( sc.isFailure() ) {
64 fatal() <<
"Could not assemble the CF precedence realm" <<
endmsg;
70 warning() <<
"Ignoring DF precedence rules, disabling all associated features" <<
endmsg;
76 if ( sc.isFailure() ) {
77 fatal() <<
"Could not assemble the DF precedence realm" <<
endmsg;
85 }
else if (
m_mode ==
"COD" ) {
88 }
else if (
m_mode ==
"E" ) {
91 }
else if (
m_mode ==
"T" ) {
94 }
else if (
m_mode ==
"DRE" ) {
97 }
else if ( !
m_mode.empty() ) {
98 error() <<
"Requested prioritization rule '" <<
m_mode <<
"' is unknown" <<
endmsg;
104 if ( sc.isSuccess() )
info() <<
"PrecedenceSvc initialized successfully" <<
endmsg;
118 bool isGaudiSequencer(
false );
119 bool isAthSequencer(
false );
123 isGaudiSequencer =
true;
125 isAthSequencer =
true;
131 ( subAlgorithms->
empty() && !( isGaudiSequencer || isAthSequencer ) ) ) {
142 bool allPass =
false;
143 bool promptDecision =
false;
144 bool isSequential =
false;
145 bool isInverted =
false;
147 if ( isGaudiSequencer ) {
148 modeOr = ( algo->
getProperty(
"ModeOR" ).toString() ==
"True" );
149 allPass = ( algo->
getProperty(
"IgnoreFilterPassed" ).toString() ==
"True" );
150 promptDecision = ( algo->
getProperty(
"ShortCircuit" ).toString() ==
"True" );
151 isInverted = ( algo->
getProperty(
"Invert" ).toString() ==
"True" );
152 if ( allPass ) promptDecision =
false;
153 isSequential = ( algo->
hasProperty(
"Sequential" ) && ( algo->
getProperty(
"Sequential" ).toString() ==
"True" ) );
154 }
else if ( isAthSequencer ) {
155 modeOr = ( algo->
getProperty(
"ModeOR" ).toString() ==
"True" );
156 allPass = ( algo->
getProperty(
"IgnoreFilterPassed" ).toString() ==
"True" );
157 promptDecision = ( algo->
getProperty(
"StopOverride" ).toString() ==
"False" );
158 isSequential = ( algo->
hasProperty(
"Sequential" ) && ( algo->
getProperty(
"Sequential" ).toString() ==
"True" ) );
163 error() <<
"Failed to add DecisionHub " << algo->
name() <<
" to graph of precedence rules" <<
endmsg;
167 for (
Algorithm* subalgo : *subAlgorithms ) {
170 error() <<
"Algorithm " << subalgo->name() <<
" could not be flattened" <<
endmsg;
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";
229 myfile.
open(
"RunSimulation.csv", std::ios::app );
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 warning() <<
"No temporal and topological aspects of execution flow were traced. " 281 <<
"To get them traced, please set DumpPrecedenceRules " 282 <<
"property to True " <<
endmsg;
291 fileName =
"rules.evt-" +
std::to_string( eventID.event_number() ) +
"." +
"run-" +
298 pth.append( fileName );
308 warning() <<
"Task precedence was not traced. To get it traced, please set " 309 <<
"DumpPrecedenceTrace property to True " <<
endmsg;
318 fileName =
"trace.evt-" +
std::to_string( eventID.event_number() ) +
"." +
"run-" +
325 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)
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.
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::tagged_bool< class ModeOr_tag > ModeOr
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.
Gaudi::tagged_bool< class Inverted_tag > Inverted
void enableAnalysis()
BGL-based facilities.
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.
Gaudi::tagged_bool< class Concurrent_tag > Concurrent
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.
Gaudi::tagged_bool< class PromptDecision_tag > PromptDecision
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
StatusCode addDecisionHubNode(Algorithm *daughterAlgo, const std::string &parentName, concurrency::Concurrent, concurrency::PromptDecision, concurrency::ModeOr, concurrency::AllPass, concurrency::Inverted)
Add a node, which aggregates decisions of direct daughter nodes.
Class representing the event slot.
Gaudi::tagged_bool< class AllPass_tag > AllPass
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.
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.
void addHeadNode(const std::string &headName, concurrency::Concurrent, concurrency::PromptDecision, concurrency::ModeOr, concurrency::AllPass, concurrency::Inverted)
Add a node, which has no parents.
DecisionNode * getHeadNode() const
Get head node.