Salome HOME
Addition of redundant CF links tool for evalyfx.
authorAnthony Geay <anthony.geay@edf.fr>
Wed, 6 Jan 2016 13:37:48 +0000 (14:37 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Wed, 6 Jan 2016 13:37:48 +0000 (14:37 +0100)
src/engine/Bloc.cxx
src/engine/Bloc.hxx
src/engine/ComposedNode.cxx
src/engine/ComposedNode.hxx
src/evalyfx/YACSEvalYFXPattern.cxx

index e7fa7f74cb26696ff6ec0f535eb9ca069f5cfe27..c91c7617295b77577717288021043a6942ba4824 100644 (file)
@@ -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<Node*> 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<Node *, Node *> > linksToKill(info.getInfoUselessLinks());
+  for(std::set< std::pair<Node *, Node *> >::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<Node *,set<Node *> >;
@@ -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<Node*> 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);
index a46ae682c6da7946c83c3f3a59fac6aaa2e6e57b..2e81f089097c3a204371dc76479c99b568cbc528 100644 (file)
@@ -61,6 +61,7 @@ namespace YACS
       void findAllNodesStartingFrom(Node *start, std::set<Node *>& result, std::map<Node *, std::set<Node *> >& 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,
index 7b846bd578f4fc1f18fe50962a11af7cc28d56db..09134bdb0f2d0717cef4876ede700147b9ee0cd9 100644 (file)
@@ -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<Node *> dd(edGetDirectDescendants());
+  for(std::list<Node *>::const_iterator it=dd.begin();it!=dd.end();it++)
+    {
+      ComposedNode *elt(dynamic_cast<ComposedNode *>(*it));
+      if(elt)
+        elt->removeRecursivelyRedundantCL();
+    }
+}
+
 list<ElementaryNode *> ComposedNode::getRecursiveConstituents() const
 {
   list<ElementaryNode *> ret;
index 47481334f65e9a193c67d3fe825982e1fb575d13..b3d8e2e6c9007ed4b728d4b4f3468d293cade571 100644 (file)
@@ -77,6 +77,7 @@ namespace YACS
       void edRemoveLink(OutGate *start, InGate *end) throw(Exception);
       virtual bool isRepeatedUnpredictablySeveralTimes() const { return false; }
       virtual std::list<Node *> edGetDirectDescendants() const =  0;
+      virtual void removeRecursivelyRedundantCL();
       std::list<ElementaryNode *> getRecursiveConstituents() const;
       std::list<Node *> getAllRecursiveNodes();
       virtual std::list<Node *> getAllRecursiveConstituents(); // first implementation
index 1feacd39c947341bf59309a20ef94ec95ffdb97a..8e351fed7538636f08c4496550d9ed25630903a4 100644 (file)
@@ -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);
     }