X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2Fengine%2FBloc.cxx;h=7d5e7b0450360a06e3ab9b2a15e73dd3ae827418;hb=e66f0810428fc92d9f3e4089e43e068f68c7ed7e;hp=a3dcd389915212047ad09b1ee4d6ed1c4167f13e;hpb=d7fbbabe5e1878abb6d0513ece99a9d94bcd07dc;p=modules%2Fyacs.git diff --git a/src/engine/Bloc.cxx b/src/engine/Bloc.cxx index a3dcd3899..7d5e7b045 100644 --- a/src/engine/Bloc.cxx +++ b/src/engine/Bloc.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2006-2015 CEA/DEN, EDF R&D +// Copyright (C) 2006-2016 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -246,8 +246,8 @@ std::vector< std::list > Bloc::splitIntoIndependantGraph() const ll.push_back(cur); // OutGate *og(cur->getOutGate()); - set og2(og->edSetInGate()); - for(set::const_iterator it2=og2.begin();it2!=og2.end();it2++) + list og2(og->edSetInGate()); + for(list::const_iterator it2=og2.begin();it2!=og2.end();it2++) { Node *cur2((*it2)->getNode()); if(cur2->_colour==White) @@ -319,8 +319,8 @@ bool Bloc::isNameAlreadyUsed(const std::string& name) const bool insertNodeChildrenInSet(Node *node, std::set& nodeSet) { bool verdict=true; - set outNodes=node->getOutNodes(); - for (set::iterator iter=outNodes.begin();iter!=outNodes.end(); iter++) + list outNodes=node->getOutNodes(); + for (list::iterator iter=outNodes.begin();iter!=outNodes.end(); iter++) { verdict=(nodeSet.insert(*iter)).second; if (verdict) verdict = insertNodeChildrenInSet((*iter),nodeSet); @@ -350,8 +350,8 @@ std::vector< std::pair > Bloc::getSetOfInternalCFLinks() co vector< pair > ret; for(list::const_iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++) { - set outCFLinksOfCurNode=(*iter)->_outGate.edSetInGate(); - for(set::iterator iter2=outCFLinksOfCurNode.begin();iter2!=outCFLinksOfCurNode.end();iter2++) + list outCFLinksOfCurNode=(*iter)->_outGate.edSetInGate(); + for(list::iterator iter2=outCFLinksOfCurNode.begin();iter2!=outCFLinksOfCurNode.end();iter2++) ret.push_back(pair(&(*iter)->_outGate,*iter2)); } return ret; @@ -420,26 +420,26 @@ YACS::Event Bloc::updateStateOnFailedEventFrom(Node *node, const Executor *execI void Bloc::writeDot(std::ostream &os) const { - os << " subgraph cluster_" << getId() << " {\n" ; - listnodes=getChildren(); - for(list::const_iterator iter=nodes.begin();iter!=nodes.end();iter++) + os << " subgraph cluster_" << getId() << " {\n" ; + listnodes=getChildren(); + for(list::const_iterator iter=nodes.begin();iter!=nodes.end();iter++) { - (*iter)->writeDot(os); - string p=(*iter)->getId(); - //not connected node - if((*iter)->_inGate._backLinks.size() == 0) os << getId() << " -> " << p << ";\n"; - setoutnodes = (*iter)->getOutNodes(); - for(set::const_iterator itout=outnodes.begin();itout!=outnodes.end();itout++) + (*iter)->writeDot(os); + string p=(*iter)->getId(); + //not connected node + if((*iter)->_inGate._backLinks.size() == 0) os << getId() << " -> " << p << ";\n"; + listoutnodes = (*iter)->getOutNodes(); + for(list::const_iterator itout=outnodes.begin();itout!=outnodes.end();itout++) { - os << p << " -> " << (*itout)->getId() << ";\n"; + os << p << " -> " << (*itout)->getId() << ";\n"; } } - os << "}\n" ; - os << getId() << "[fillcolor=\"" ; - YACS::StatesForNode state=getEffectiveState(); - os << getColorState(state); - os << "\" label=\"" << "Bloc:" ; - os << getQualifiedName() <<"\"];\n"; + os << "}\n" ; + os << getId() << "[fillcolor=\"" ; + YACS::StatesForNode state=getEffectiveState(); + os << getColorState(state); + os << "\" label=\"" << "Bloc:" ; + os << getQualifiedName() <<"\"];\n"; } void Bloc::accept(Visitor* visitor) @@ -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 >; @@ -490,8 +489,8 @@ void Bloc::performCFComputations(LinkInfo& info) const for(list::const_iterator iter=_setOfNode.begin();iter!=_setOfNode.end();iter++) { Node* n1=*iter; - std::set ingates=n1->getOutGate()->edSetInGate(); - for(std::set::const_iterator it2=ingates.begin();it2!=ingates.end();it2++) + std::list ingates=n1->getOutGate()->edSetInGate(); + for(std::list::const_iterator it2=ingates.begin();it2!=ingates.end();it2++) { //CF link : n1 -> (*it2)->getNode() Node* n2=(*it2)->getNode(); @@ -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); @@ -856,9 +873,8 @@ void Bloc::findUselessLinksIn(const std::list< std::vector >& res , Link set searcher(iter2+1,(*whereToPeerAt).end());//to boost research for(;iter2!=((*whereToPeerAt).end()-2);iter2++) { - map::iterator iter4; - map& nexts=(*iter2)->getOutGate()->edMapInGate(); - for(iter4=nexts.begin();iter4!=nexts.end();iter4++) + list< pair >& nexts=(*iter2)->getOutGate()->edMapInGate(); + for(list< pair >::iterator iter4=nexts.begin();iter4!=nexts.end();iter4++) if((*iter4).first->getNode()!=*(iter2+1)) if(searcher.find((*iter4).first->getNode())!=searcher.end()) info.pushUselessCFLink(*iter2,(*iter4).first->getNode());