From: Anthony Geay Date: Wed, 6 Jan 2016 13:37:48 +0000 (+0100) Subject: Addition of redundant CF links tool for evalyfx. X-Git-Tag: V7_8_0a1~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5b7bfe57f979994570b09bd61fded58c3d1df00b;p=modules%2Fyacs.git Addition of redundant CF links tool for evalyfx. --- diff --git a/src/engine/Bloc.cxx b/src/engine/Bloc.cxx index e7fa7f74c..c91c76172 100644 --- a/src/engine/Bloc.cxx +++ b/src/engine/Bloc.cxx @@ -464,21 +464,20 @@ int Bloc::getMaxLevelOfParallelism() const return ret; } -/*! - * Updates mutable structures _fwLinks and _bwLinks with the result of computation (CPU consuming method). - * _fwLinks is a map with a Node* as key and a set as value. The set gives - * all nodes that are forwardly connected to the key node - * _bwLinks is a map for backward dependencies - * The method is : for all CF link (n1->n2) - * add n2 and _fwLinks[n2] in forward dependencies of n1 and _bwLinks[n1] - * add n1 and _bwLinks[n1] in backward dependencies of n2 and _fwLinks[n2] - * For useless links - * If a node is already in a forward dependency when adding and the direct link - * already exists so it's a useless link (see the code !) - */ -void Bloc::performCFComputations(LinkInfo& info) const +void Bloc::removeRecursivelyRedundantCL() +{ + StaticDefinedComposedNode::removeRecursivelyRedundantCL(); + LinkInfo info(I_CF_USELESS); + initComputation(); + performCFComputationsOnlyOneLevel(info); + std::set< std::pair > linksToKill(info.getInfoUselessLinks()); + for(std::set< std::pair >::const_iterator it=linksToKill.begin();it!=linksToKill.end();it++) + edRemoveCFLink((*it).first,(*it).second); + destructCFComputations(info); +} + +void Bloc::performCFComputationsOnlyOneLevel(LinkInfo& info) const { - StaticDefinedComposedNode::performCFComputations(info); delete _fwLinks;//Normally useless delete _bwLinks;//Normally useless _fwLinks=new map >; @@ -549,6 +548,24 @@ void Bloc::performCFComputations(LinkInfo& info) const } } +/*! + * Updates mutable structures _fwLinks and _bwLinks with the result of computation (CPU consuming method). + * _fwLinks is a map with a Node* as key and a set as value. The set gives + * all nodes that are forwardly connected to the key node + * _bwLinks is a map for backward dependencies + * The method is : for all CF link (n1->n2) + * add n2 and _fwLinks[n2] in forward dependencies of n1 and _bwLinks[n1] + * add n1 and _bwLinks[n1] in backward dependencies of n2 and _fwLinks[n2] + * For useless links + * If a node is already in a forward dependency when adding and the direct link + * already exists so it's a useless link (see the code !) + */ +void Bloc::performCFComputations(LinkInfo& info) const +{ + StaticDefinedComposedNode::performCFComputations(info); + performCFComputationsOnlyOneLevel(info); +} + void Bloc::destructCFComputations(LinkInfo& info) const { StaticDefinedComposedNode::destructCFComputations(info); diff --git a/src/engine/Bloc.hxx b/src/engine/Bloc.hxx index a46ae682c..2e81f0890 100644 --- a/src/engine/Bloc.hxx +++ b/src/engine/Bloc.hxx @@ -61,6 +61,7 @@ namespace YACS void findAllNodesStartingFrom(Node *start, std::set& result, std::map >& accelStr, LinkInfo& info) const; virtual std::string typeName() { return "YACS__ENGINE__Bloc"; } int getMaxLevelOfParallelism() const; + void removeRecursivelyRedundantCL(); protected: bool areAllSubNodesFinished() const; bool areAllSubNodesDone() const; @@ -70,6 +71,7 @@ namespace YACS YACS::Event updateStateOnFinishedEventFrom(Node *node); YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst); void initComputation() const; + void performCFComputationsOnlyOneLevel(LinkInfo& info) const; void performCFComputations(LinkInfo& info) const; void destructCFComputations(LinkInfo& info) const; void checkControlDependancy(OutPort *start, InPort *end, bool cross, diff --git a/src/engine/ComposedNode.cxx b/src/engine/ComposedNode.cxx index 7b846bd57..09134bdb0 100644 --- a/src/engine/ComposedNode.cxx +++ b/src/engine/ComposedNode.cxx @@ -1100,6 +1100,20 @@ std::string ComposedNode::getLowestCommonAncestorStr(const std::string& node1, c return ret; } +/*! + * This method recursively all redundant control links in this. + */ +void ComposedNode::removeRecursivelyRedundantCL() +{ + std::list dd(edGetDirectDescendants()); + for(std::list::const_iterator it=dd.begin();it!=dd.end();it++) + { + ComposedNode *elt(dynamic_cast(*it)); + if(elt) + elt->removeRecursivelyRedundantCL(); + } +} + list ComposedNode::getRecursiveConstituents() const { list ret; diff --git a/src/engine/ComposedNode.hxx b/src/engine/ComposedNode.hxx index 47481334f..b3d8e2e6c 100644 --- a/src/engine/ComposedNode.hxx +++ b/src/engine/ComposedNode.hxx @@ -77,6 +77,7 @@ namespace YACS void edRemoveLink(OutGate *start, InGate *end) throw(Exception); virtual bool isRepeatedUnpredictablySeveralTimes() const { return false; } virtual std::list edGetDirectDescendants() const = 0; + virtual void removeRecursivelyRedundantCL(); std::list getRecursiveConstituents() const; std::list getAllRecursiveNodes(); virtual std::list getAllRecursiveConstituents(); // first implementation diff --git a/src/evalyfx/YACSEvalYFXPattern.cxx b/src/evalyfx/YACSEvalYFXPattern.cxx index 1feacd39c..8e351fed7 100644 --- a/src/evalyfx/YACSEvalYFXPattern.cxx +++ b/src/evalyfx/YACSEvalYFXPattern.cxx @@ -442,6 +442,7 @@ YACSEvalListOfResources *YACSEvalYFXRunOnlyPattern::giveResources() if(!isAlreadyComputedResources()) { YACS::ENGINE::DeploymentTree dt(_runNode->getDeploymentTree()); + _runNode->removeRecursivelyRedundantCL(); YACSEvalListOfResources *res(new YACSEvalListOfResources(_runNode->getMaxLevelOfParallelism(),getCatalogInAppli(),dt)); setResources(res); }