39 const char DynParaLoop::NAME_OF_SPLITTED_SEQ_OUT[] =
"evalSamples";
40 const char DynParaLoop::OLD_NAME_OF_SPLITTED_SEQ_OUT[] =
"SmplPrt";
42 DynParaLoop::DynParaLoop(
const std::string& name,
TypeCode *typeOfDataSplitted, std::unique_ptr<NbBranchesAbstract>&& branchManager)
43 :
ComposedNode(name),_node(0),_initNode(0),_finalizeNode(0),_nbOfEltConsumed(0),
44 _nbOfBranches(std::move(branchManager)),
45 _splittedPort(NAME_OF_SPLITTED_SEQ_OUT,this,typeOfDataSplitted),_initializingCounter(0),_unfinishedCounter(0),_failedCounter(0),_weight(), _loopWeight(0)
58 :
ComposedNode(other,father),_nbOfBranches(other._nbOfBranches->copy(this)),
59 _splittedPort(other._splittedPort,this), _node(0), _initNode(0), _finalizeNode(0),
60 _nbOfEltConsumed(0),_initializingCounter(0),_unfinishedCounter(0),_failedCounter(0),_weight(other._weight), _loopWeight(other._loopWeight)
69 set<InPort *> endsOfLinksToReproduce=startOfLinksToReproduce.
edSetInPort();
70 for(set<InPort *>::iterator iter=endsOfLinksToReproduce.begin();iter!=endsOfLinksToReproduce.end();iter++)
82 if (node == NULL || nodeToReplace == node)
85 throw Exception(
string(
"Can't set node: node ") + node->
getName() +
" is not orphan.");
88 " has the same name than exec node already in " +
_name +
".");
91 " has the same name than init node already in " +
_name +
".");
94 " has the same name than finalize node already in " +
_name +
".");
97 Node * ret = nodeToReplace;
110 string what(
"DynParaLoop::init : no node specified for ForEachLoop with name "); what +=
_name;
229 Node * ret = nodeToRemove;
266 ret.push_back(
_node);
302 throw Exception(
"ForEachLoop::getNumberOfBranches : No branches created dynamically ! - ForEachLoop needs to run or to be runned to call getNumberOfBranches");
315 std::string what(
"node "); what+= name ; what+=
" is not a child of DynParaLoop node "; what +=
getName();
322 throw Exception(
"ForEachLoop::getChildByNameExec : invalid id - too large compared with dynamically created branches.");
329 std::string what(
"node "); what+= name ; what+=
" is not a child of DynParaLoop node "; what +=
getName();
335 vector<Node *>::iterator iter;
357 for(list<InPort *>::iterator iter2=temp.begin();iter2!=temp.end();iter2++)
359 if ((*iter2)->edSetOutPort().size() == 1 && *(*iter2)->edSetOutPort().begin() == NULL)
361 portsToSetVals.insert(*iter2);
367 for(list<InputPort *>::iterator iter = localPorts.begin() ; iter != localPorts.end() ; iter++)
368 portsToSetVals.erase(*iter);
369 for(set< InPort * >::iterator iter=portsToSetVals.begin();iter!=portsToSetVals.end();iter++)
372 void *val=curPortCasted->
get();
376 portToSet->
put((
const void *)val);
386 bool isDispatched =
false;
388 for(set<InPort *>::iterator iter=inPrtLkdWthSplttdPrt.begin();iter!=inPrtLkdWthSplttdPrt.end();iter++)
393 if(portOnGivenBranch)
399 traducer->
put((
const void *)val);
401 if(traducer!=portOnGivenBranch)
415 vector<Node *>::iterator iter;
428 throw Exception(
"DynParaLoop::getIdentityOfNotifyerNode: unrecognized node !");
434 throw Exception(
"DynParaLoop::setWeight : invalid input value !");
459 throw Exception(
"DynParaLoop::buildDelegateOf : A link with datastream end inside DynParaLoop is not possible");
464 std::string linkName(
"(");
465 linkName += port.first->getName()+
" to "+finalTarget->
getName()+
")";
468 throw Exception(std::string(
"Illegal link within a parallel loop: \
469 a link starting from the init node can't leave the scope of the loop.")
474 throw Exception(std::string(
"Illegal link within a parallel loop: \
475 an output port of the finalize node can't be linked.")
479 throw Exception(std::string(
"Illegal link within a parallel loop: \
480 the 'evalSamples' port must be linked within the scope of the loop.")
486 const char what[]=
"DynParaLoop::checkCFLinks : internal error.";
497 else if(alreadyFed==
FED_ST)
515 std::vector<OutPort *>& fwCross,
523 InPort *end,
const std::list<ComposedNode *>& pointsOfViewEnd)
528 std::string linkName(
"(");
532 throw Exception(std::string(
"Illegal link within a parallel loop: \
533 the 'evalSamples' port can only be connected to the working node of the loop.")
537 throw Exception(std::string(
"Illegal link within a parallel loop: \
538 the finalize node can't be the origin of a link.")
542 throw Exception(std::string(
"Illegal link within a parallel loop: \
543 can't make a link from the working node to the init node.")
547 throw Exception(std::string(
"Illegal link within a parallel loop: \
548 can't make a link from the working node to the finalize node.")
561 string portName, nodeName;
568 return _execNodes[branchNb]->getInputPort(portName);
581 DEBTRACE(
"DynParaLoop::checkBasicConsistency");
584 throw Exception(
"For a dynamic loop, internal node is mandatory");
595 std::string report=
"<error node= " +
getName();
596 switch(effectiveState)
599 report=report+
" state= INVALID";
602 report=report+
" state= ERROR";
605 report=report+
" state= FAILED";
610 report=report +
">\n" ;
618 for(list<Node *>::iterator iter=constituents.begin(); iter!=constituents.end(); iter++)
620 std::string rep=(*iter)->getErrorReport();
623 report=report+rep+
"\n";
632 std::string rep=(*iter)->getErrorReport();
635 report=report+rep+
"\n";
642 std::string rep=(*iter)->getErrorReport();
645 report=report+rep+
"\n";
651 std::string rep=(*iter)->getErrorReport();
654 report=report+rep+
"\n";
659 report=report+
"</error>";
666 Node * origNode = NULL;
694 if (compNode && compNodeExe)
697 list<Node *>::iterator iter=aChldn.begin();
698 for(;iter!=aChldn.end();iter++)
701 node->
setState((*iter)->getState());
716 DEBTRACE(
"DynParaLoop::updateStateOnFailedEventFrom " << node->
getName());
746 DEBTRACE(
"Begin cloneAndPlaceNodesCoherently")
747 vector<Node *> clones;
749 vector<list<ElementaryNode *> > origElemNodeList;
750 for (
int i=0 ;
i<origNodes.size() ;
i++)
753 if (origNodes[
i] == NULL)
755 DEBTRACE(
"Cloning node " <<
i <<
", NULL" )
756 clones.push_back(NULL);
757 origElemNodeList.push_back(list<ElementaryNode *>());
762 clones.push_back(origNodes[
i]->
simpleClone(
this,
false));
763 list<ElementaryNode *> tasks = origNodes[
i]->getRecursiveConstituents();
764 origElemNodeList.push_back(tasks);
765 for (list< ElementaryNode *>::iterator iter=tasks.begin() ; iter!=tasks.end() ; iter++)
766 treeToDup.
appendTask(*iter, (*iter)->getDynClonerIfExists(
this));
775 std::vector< std::pair<OutPort *, InPort *> >::const_iterator it;
776 for(it=outLinks.begin(); it!=outLinks.end(); it++)
778 OutPort *startPort = it->first;
779 InPort *endPort = it->second;
781 if(destNode ==
_node)
783 clones[1]->getInPort(endPort->
getName()));
786 clones[2]->getInPort(endPort->
getName()));
794 for(vector<Container *>::iterator iterCt=conts.begin();iterCt!=conts.end();iterCt++)
796 DEBTRACE(
"Container " << ((*iterCt)?(*iterCt)->getName():
"NULL"))
800 contCloned=(*iterCt)->
clone();
803 for(vector<ComponentInstance *>::iterator iterCp=comps.begin();iterCp!=comps.end();iterCp++)
805 DEBTRACE(
"Component " << (*iterCp)->getCompoName())
808 DEBTRACE(
"Assign container " << (*iterCp)->getCompoName())
810 for(vector<Task *>::iterator iterT=tasks.begin();iterT!=tasks.end();iterT++)
815 for (
i=0 ;
i<origNodes.size() ;
i++)
816 if (origNodes[
i] != NULL)
818 DEBTRACE(
"Looking in original node " <<
i)
819 list<ElementaryNode *>::iterator res=find(origElemNodeList[
i].begin(),
820 origElemNodeList[
i].end(),
822 if (res != origElemNodeList[
i].end()) {
831 if (origNodes[
i] == origElemNode)
835 string childName = ((
ComposedNode *)origNodes[
i])->getChildName(origElemNode);
838 DEBTRACE(
"Assign component: " << (*iterCp)->getCompoName() <<
"," << nodeC->
getName())
846 for(vector<Task *>::iterator iterT=tasks.begin();iterT!=tasks.end();iterT++)
851 for (
i=0 ;
i<origNodes.size() ;
i++)
852 if (origNodes[
i] != NULL)
854 DEBTRACE(
"Looking in original node " <<
i)
855 list<ElementaryNode *>::iterator res=find(origElemNodeList[
i].begin(),
856 origElemNodeList[
i].end(),
858 if (res != origElemNodeList[
i].end())
867 if (origNodes[
i] == origElemNode)
873 string childName = ((
ComposedNode *)origNodes[
i])->getChildName(origElemNode);
885 DEBTRACE(
"End cloneAndPlaceNodesCoherently")
927 std::vector<Node *>::iterator iter;
929 (*iter)->shutdown(level);
931 (*iter)->shutdown(level);
933 (*iter)->shutdown(level);
#define YASSERT(val)
YASSERT macro is always defined, used like assert, but throw a YACS::Exception instead of abort.
virtual void setValue(Any *data)
store the current dispatched value
: Interface for management of storage of data formated dynamically in its TypeCode....
virtual Any * clone() const =0
void setLoopWeight(double loopWeight, int nbCoresByIteration)
Base class for all component instances.
virtual bool setContainer(Container *cont)
virtual ComponentInstance * clone() const =0
Base class for all composed nodes.
std::string getChildName(const Node *node) const
Node * getChildByName(const std::string &name) const
static const unsigned char FREE_ST
std::list< InputPort * > getSetOfInputPort() const
std::list< OutputPort * > getLocalOutputPorts() const
redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself
OutPort * getOutPort(const std::string &name) const
void checkNoCrossHierachyWith(Node *node) const
std::string getName() const
void solveObviousOrDelegateCFLinks(const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
OutputPort * getOutputPort(const std::string &name) const
Get an output port given its name.
InputPort * getInputPort(const std::string &name) const
Get an input port given its name.
virtual std::list< Node * > getAllRecursiveConstituents()
Idem getAllRecursiveNodes, but this node is NOT included.
std::list< OutputPort * > getSetOfOutputPort() const
std::list< InputPort * > getLocalInputPorts() const
redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself
virtual void edRemoveChild(Node *node)
Remove a child node.
virtual void checkBasicConsistency() const
int getNumberOfOutputPorts() const
std::string getPortName(const PORT *port) const
static bool splitNamesBySep(const std::string &globalName, const char separator[], std::string &firstPart, std::string &lastPart, bool priority)
Splits name globalName in 2 parts using separator.
static const unsigned char FED_ST
std::string getInPortName(const InPort *) const
Get the input port name.
std::set< InPort * > getAllInPortsComingFromOutsideOfCurrentScope() const
List all input ports that are linked to out of scope ports.
void init(bool start=true)
int getNumberOfInputPorts() const
bool edAddLink(OutPort *start, InPort *end)
Add a dataflow link between two data ports.
Node * isInMyDescendance(Node *nodeToTest) const
Returns the parent of a node that is the direct child of this node.
virtual void checkLinkPossibility(OutPort *start, const std::list< ComposedNode * > &pointsOfViewStart, InPort *end, const std::list< ComposedNode * > &pointsOfViewEnd)
virtual Container * clone() const =0
WARNING ! clone behaviour MUST be in coherence with what is returned by isAttachedOnCloning() method
virtual std::string getName() const
std::string getNameOfTypeOfCurrentInstance() const
TypeCode * edGetType() const
std::string getName() const
std::vector< Task * > getTasksLinkedToComponent(ComponentInstance *comp) const
std::vector< ComponentInstance * > getComponentsLinkedToContainer(Container *cont) const
std::vector< Task * > getTasksLinkedToContainer(Container *cont) const
unsigned char appendTask(Task *task, Scheduler *cloner)
std::vector< Container * > getAllContainers() const
Base class for dynamically (fully or semifully) built graphs.
Node * getChildByShortName(const std::string &name) const
Node * getChildByNameExec(const std::string &name, unsigned id) const
InputPort * getInputPort(const std::string &name) const
Get an input port given its name.
std::list< OutputPort * > getLocalOutputPorts() const
redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself
int getNumberOfInputPorts() const
virtual bool edAddChild(Node *DISOWNnode)
virtual void checkLinkPossibility(OutPort *start, const std::list< ComposedNode * > &pointsOfViewStart, InPort *end, const std::list< ComposedNode * > &pointsOfViewEnd)
Node * removeNode(Node *&nodeToRemove)
This method is used to factorize methods edRemoveNode, edRemoveInitNode and edRemoveFinalizeNode.
std::unique_ptr< NbBranchesAbstract > _nbOfBranches
static const char OLD_NAME_OF_SPLITTED_SEQ_OUT[]
bool isMultiplicitySpecified(unsigned &value) const
virtual bool edAddDFLink(OutPort *start, InPort *end)
Connect an OutPort to an InPort and add control link if necessary.
std::list< OutputPort * > getSetOfOutputPort() const
std::vector< Node * > _execNodes
Node * edRemoveFinalizeNode()
static const char NAME_OF_SPLITTED_SEQ_OUT[]
std::vector< Node * > cloneAndPlaceNodesCoherently(const std::vector< Node * > &origNodes)
Clone nodes and make their placement consistent with the placement of the original ones.
void setWeight(double loopWeight)
void buildDelegateOf(InPort *&port, OutPort *initialStart, const std::list< ComposedNode * > &pointsOfView)
OutputPort * getOutputPort(const std::string &name) const
Get an output port given its name.
unsigned _nbOfEltConsumed
unsigned getNumberOfBranchesCreatedDyn() const
OutPort * getOutPort(const std::string &name) const
bool isPlacementPredictableB4Run() const
For the moment false is returned : impovement about it coming soon.
void checkControlDependancy(OutPort *start, InPort *end, bool cross, std::map< ComposedNode *, std::list< OutPort * >, SortHierarc > &fw, std::vector< OutPort * > &fwCross, std::map< ComposedNode *, std::list< OutPort * >, SortHierarc > &bw, LinkInfo &info) const
std::list< Node * > edGetDirectDescendants() const
virtual std::string getErrorReport()
returns a string that contains an error report if the node is in error
virtual YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst)
Method used to notify the node that a child node has failed.
int getBranchIDOfNode(Node *node) const
std::list< InputPort * > getLocalInputPorts() const
redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself
void init(bool start=true)
void edRemoveChild(Node *node)
Remove a child node.
Node * edSetFinalizeNode(Node *DISOWNnode)
ComplexWeight * getWeight()
std::vector< Node * > _execFinalizeNodes
virtual void shutdown(int level)
Stop all pending activities of the composed node.
Node * edSetNode(Node *DISOWNnode)
int getNumberOfOutputPorts() const
void prepareInputsFromOutOfScope(int branchNb)
int getMaxLevelOfParallelism() const
virtual void cleanDynGraph()
void checkCFLinks(const std::list< OutPort * > &starts, InputPort *end, unsigned char &alreadyFed, bool direction, LinkInfo &info) const
check control flow links
Node * checkConsistencyAndSetNode(Node *&nodeToReplace, Node *DISOWNnode)
This method is used to factorize methods edSetNode, edSetInitNode and edSetFinalizeNode.
Node * edRemoveInitNode()
virtual void forwardExecStateToOriginalBody(Node *execNode)
Node * edSetInitNode(Node *DISOWNnode)
void putValueOnBranch(Any *val, unsigned branchId, bool first)
AnyOutputPort _splittedPort
std::vector< Node * > _execInitNodes
void accept(Visitor *visitor)
void forceMultiplicity(unsigned value)
std::list< InputPort * > getSetOfInputPort() const
InputPort * getDynInputPortByAbsName(int branchNb, const std::string &name, bool initNodeAdmitted)
void partitionRegardingDPL(const PartDefinition *pd, std::map< ComposedNode *, YACS::BASES::AutoRefCnt< PartDefinition > > &zeMap)
TypeOfNode getIdentityOfNotifyerNode(const Node *node, unsigned &id)
virtual void checkBasicConsistency() const
Base class for all calculation nodes.
virtual void edNotifyReferencedBy(OutPort *fromPort, bool isLoopProof=true)
Class for calculation node (function) inlined (and executed) in the schema.
virtual void setContainer(Container *container)
Class that deal with list of semantics links for high level analysis.
void pushInfoLink(OutPort *semStart, InPort *end, InfoReason reason)
Base class for all nodes.
virtual Node * simpleClone(ComposedNode *father, bool editionOnly=true) const =0
virtual int getMaxLevelOfParallelism() const =0
virtual void setErrorDetails(const std::string &error)
virtual void modified()
Sets Node in modified state and its father if it exists.
Node * clone(ComposedNode *father, bool editionOnly=true) const
This method MUST NEVER BE VIRTUAL
virtual void init(bool start=true)
std::list< InPort * > getSetOfInPort() const
void setState(YACS::StatesForNode theState)
Sets the given state for node.
virtual std::string getErrorDetails() const
virtual YACS::StatesForNode getState() const
static const char SEP_CHAR_IN_PORT[]
InPort * getInPort(const std::string &name) const
virtual std::vector< std::pair< OutPort *, InPort * > > getSetOfLinksLeavingCurrentScope() const =0
const std::string & getName() const
std::string _errorDetails
virtual YACS::StatesForNode getEffectiveState() const
Return the node state in the context of its father.
YACS::StatesForNode _state
virtual void partitionRegardingDPL(const PartDefinition *pd, std::map< ComposedNode *, YACS::BASES::AutoRefCnt< PartDefinition > > &zeMap)=0
std::set< InPort * > edSetInPort() const
virtual PartDefinition * copy() const =0
static const char RUNTIME_ENGINE_INTERACTION_IMPL_NAME[]
virtual InputPort * adapt(InputPort *source, const std::string &impl, TypeCode *type, bool init=false)=0
Class for calculation node associated with a component service.
virtual void setComponent(ComponentInstance *compo)
Associate an existing component instance to this service node AND check the consistency regarding the...
Base class for all type objects.
virtual void visitDynParaLoop(DynParaLoop *node)=0
YACSLIBENGINE_EXPORT Runtime * getRuntime()
def distance(node, new_node)