# List of targets in this project we want to make visible to the rest of the world.
# They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup"
SET(_${PROJECT_NAME}_exposed_targets
- YACSBases YACSlibEngine
+ YACSBases YACSlibEngine YACSlibWorkloadmanager
)
IF(SALOME_YACS_USE_KERNEL)
inline Echo_i() {}
virtual ~Echo_i() {}
virtual char* echoString(const char* mesg);
- CORBA::Long echoLong(CORBA::Long i) throw(eo::SALOME_Exception);
+ CORBA::Long echoLong(CORBA::Long i);
void echoDouble(CORBA::Double i,CORBA::Double& j) ;
void echoDoubleVec(const eo::DoubleVec& i,eo::DoubleVec_out j) ;
void echoDoubleVecVec(const eo::DoubleVecVec&, eo::DoubleVecVec_out);
out=new eo::DoubleVecVec(in);
}
-CORBA::Long Echo_i::echoLong(CORBA::Long i ) throw(eo::SALOME_Exception)
+CORBA::Long Echo_i::echoLong(CORBA::Long i )
{
DEBTRACE("Echo_i::echoLong " << i);
CORBA::Long j=i;
# Common packages
##
SET(SUBDIRS_COMMON
- bases engine wrappergen yacsorb salomeloader
+ bases engine wrappergen yacsorb salomeloader workloadmanager
pmml
)
yacsloader
yacsloader_swig
py2yacs
+ workloadmanager
)
return new AtomAny(val,type);
}
-AnyPtr AtomAny::operator[](int i) const throw(YACS::Exception)
+AnyPtr AtomAny::operator[](int i) const
{
throw InvalidExtractionException(_type->kind(),Sequence);
}
-AnyPtr AtomAny::operator[](const char *key) const throw(YACS::Exception)
+AnyPtr AtomAny::operator[](const char *key) const
{
throw Exception("AtomAny::operator[] : try to get a part of a partitionned data whereas atomical.");
}
return false;
}
-int AtomAny::getIntValue() const throw(YACS::Exception)
+int AtomAny::getIntValue() const
{
if(_type->isA(Runtime::_tc_int))
return _value._i;
throw Exception("Value is not an int");
}
-bool AtomAny::getBoolValue() const throw(YACS::Exception)
+bool AtomAny::getBoolValue() const
{
if(_type->isA(Runtime::_tc_bool))
return _value._b;
throw Exception("Value is not a bool");
}
-double AtomAny::getDoubleValue() const throw(YACS::Exception)
+double AtomAny::getDoubleValue() const
{
if(_type->isA(Runtime::_tc_double))
return _value._d;
throw Exception("Value is not a double");
}
-std::string AtomAny::getStringValue() const throw(YACS::Exception)
+std::string AtomAny::getStringValue() const
{
if(_type->isA(Runtime::_tc_string) || _type->kind()==YACS::ENGINE::Objref)
{
_type->decrRef();
}
-AnyPtr ComposedAny::operator[](const char *key) const throw(YACS::Exception)
+AnyPtr ComposedAny::operator[](const char *key) const
{
throw Exception("AtomAny::operator[] : try to get a part of a partitionned data not localizable by a string.");
}
-void ComposedAny::checkTypeOf(const Any *elem) const throw(YACS::Exception)
+void ComposedAny::checkTypeOf(const Any *elem) const
{
if(!elem->getType()->isA(_type->contentType()))
throw Exception("ComposedAny::checkTypeOf : invalid type.");
}
-int ComposedAny::getIntValue() const throw(YACS::Exception)
+int ComposedAny::getIntValue() const
{
throw InvalidExtractionException(_type->kind(),Runtime::_tc_int->kind());
}
-bool ComposedAny::getBoolValue() const throw(YACS::Exception)
+bool ComposedAny::getBoolValue() const
{
throw InvalidExtractionException(_type->kind(),Runtime::_tc_bool->kind());
}
-double ComposedAny::getDoubleValue() const throw(YACS::Exception)
+double ComposedAny::getDoubleValue() const
{
throw InvalidExtractionException(_type->kind(),Runtime::_tc_double->kind());
}
-std::string ComposedAny::getStringValue() const throw(YACS::Exception)
+std::string ComposedAny::getStringValue() const
{
throw InvalidExtractionException(_type->kind(),Runtime::_tc_string->kind());
}
return true;
}
-void SequenceAny::setEltAtRank(int i, const Any *elem) throw(YACS::Exception)
+void SequenceAny::setEltAtRank(int i, const Any *elem)
{
checkTypeOf(elem);
_alloc.destroy(_alloc._start+i*_alloc._sizeOf1Elm,_type->contentType());
_alloc.construct(_alloc._start+i*_alloc._sizeOf1Elm,elem);
}
-AnyPtr SequenceAny::operator[](int i) const throw(YACS::Exception)
+AnyPtr SequenceAny::operator[](int i) const
{
return _type->contentType()->getOrBuildAnyFromZippedData(_alloc._start+i*_alloc._sizeOf1Elm);
}
}
}
-void ArrayAny::setEltAtRank(int i, const Any *elem) throw(YACS::Exception)
+void ArrayAny::setEltAtRank(int i, const Any *elem)
{
checkTypeOf(elem);
const TypeCode *subType=_type->contentType();
return true;
}
-AnyPtr ArrayAny::operator[](int i) const throw(YACS::Exception)
+AnyPtr ArrayAny::operator[](int i) const
{
const TypeCode *subType=_type->contentType();
unsigned sizePerContent=subType->getSizeInByteOfAnyReprInSeq();
return true;
}
-AnyPtr StructAny::operator[](int i) const throw(YACS::Exception)
+AnyPtr StructAny::operator[](int i) const
{
const char what[]="StructAny::operator[](int i) : Struct key are strings not integers.";
throw Exception(what);
}
-AnyPtr StructAny::operator[](const char *key) const throw(YACS::Exception)
+AnyPtr StructAny::operator[](const char *key) const
{
const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
char *whereToGet=_data;
return (*iter).second->getOrBuildAnyFromZippedData(whereToGet);
}
-void StructAny::setEltAtRank(int i, const Any *elem) throw(YACS::Exception)
+void StructAny::setEltAtRank(int i, const Any *elem)
{
const char what[]="Struct key are strings not integers.";
throw Exception(what);
}
-void StructAny::setEltAtRank(const char *key, const Any *elem) throw(YACS::Exception)
+void StructAny::setEltAtRank(const char *key, const Any *elem)
{
const TypeCodeStruct *typeC=(const TypeCodeStruct *)_type;
unsigned offset;
const TypeCode *getType() const { return _type; }
//for convenience methods
virtual Any *clone() const = 0;
- virtual AnyPtr operator[](int i) const throw(Exception) = 0;
- virtual AnyPtr operator[](const char *key) const throw(Exception) = 0;
+ virtual AnyPtr operator[](int i) const = 0;
+ virtual AnyPtr operator[](const char *key) const = 0;
virtual bool operator ==(const Any& other) const = 0;
- virtual int getIntValue() const throw(Exception) = 0;
- virtual bool getBoolValue() const throw(Exception) = 0;
- virtual double getDoubleValue() const throw(Exception) = 0;
- virtual std::string getStringValue() const throw(Exception) = 0;
+ virtual int getIntValue() const = 0;
+ virtual bool getBoolValue() const = 0;
+ virtual double getDoubleValue() const = 0;
+ virtual std::string getStringValue() const = 0;
//
protected:
#ifndef SWIG
static AtomAny *New(T val) { return new AtomAny(val); }
static AtomAny *New(char *val, Deallocator dealloc);
static AtomAny *New(const std::string& val, TypeCode *type);
- AnyPtr operator[](int i) const throw(Exception);
- AnyPtr operator[](const char *key) const throw(Exception);
+ AnyPtr operator[](int i) const;
+ AnyPtr operator[](const char *key) const;
bool operator ==(const Any& other) const;
- int getIntValue() const throw(Exception);
- bool getBoolValue() const throw(Exception);
- double getDoubleValue() const throw(Exception);
- std::string getStringValue() const throw(Exception);
+ int getIntValue() const;
+ bool getBoolValue() const;
+ double getDoubleValue() const;
+ std::string getStringValue() const;
const char *getBytesValue(std::size_t& len) const;
protected:
void putMyReprAtPlace(char *data) const;
class YACSLIBENGINE_EXPORT ComposedAny : public Any
{
public:
- virtual void setEltAtRank(int i, const Any *elem) throw(Exception) = 0;
- AnyPtr operator[](const char *key) const throw(Exception);
+ virtual void setEltAtRank(int i, const Any *elem) = 0;
+ AnyPtr operator[](const char *key) const;
protected:
ComposedAny(const ComposedAny& other);
ComposedAny(TypeCode* type, bool isNew=true);
protected:
- void checkTypeOf(const Any *elem) const throw(Exception);
+ void checkTypeOf(const Any *elem) const;
private://error methods called during incorrect runtime extraction
- int getIntValue() const throw(Exception);
- bool getBoolValue() const throw(Exception);
- double getDoubleValue() const throw(Exception);
- std::string getStringValue() const throw(Exception);
+ int getIntValue() const;
+ bool getBoolValue() const;
+ double getDoubleValue() const;
+ std::string getStringValue() const;
};
typedef SharedPtr<SequenceAny> SequenceAnyPtr;
unsigned int size() const { return _alloc.size(); }
void pushBack(const Any *elem);
bool operator ==(const Any& other) const;
- void setEltAtRank(int i, const Any *elem) throw(Exception);
- AnyPtr operator[](int i) const throw(Exception);
+ void setEltAtRank(int i, const Any *elem);
+ AnyPtr operator[](int i) const;
Any *clone() const;
template<class T>
static SequenceAny *New(const std::vector<T>& vec);
{
friend class TypeCodeArray;
public:
- void setEltAtRank(int i, const Any *elem) throw(Exception);
+ void setEltAtRank(int i, const Any *elem);
bool operator ==(const Any& other) const;
- AnyPtr operator[](int i) const throw(Exception);
+ AnyPtr operator[](int i) const;
unsigned int size() const;
Any *clone() const;
template<class T>
Any *clone() const;
bool operator ==(const Any& other) const;
static StructAny *New(TypeCodeStruct *type);
- AnyPtr operator[](int i) const throw(Exception);
- AnyPtr operator[](const char *key) const throw(Exception);
- void setEltAtRank(int i, const Any *elem) throw(Exception);
- void setEltAtRank(const char *key, const Any *elem) throw(Exception);
+ AnyPtr operator[](int i) const;
+ AnyPtr operator[](const char *key) const;
+ void setEltAtRank(int i, const Any *elem);
+ void setEltAtRank(const char *key, const Any *elem);
protected:
void putMyReprAtPlace(char *data) const;
static void putReprAtPlace(char *data, const char *src, const TypeCodeStruct *type, bool deepCpy);
return getRuntime()->convertNeutralAsString(edGetType(),_value);
}
-void AnyInputPort::put(const void *data) throw(ConversionException)
+void AnyInputPort::put(const void *data)
{
put((Any *)data);
}
void *get() const;
virtual std::string getAsString();
virtual bool isEmpty();
- void put(const void *data) throw(ConversionException);
+ void put(const void *data);
InputPort *clone(Node *newHelder) const;
std::string dump();
virtual std::string typeName() {return "YACS__ENGINE__AnyInputPort";}
return new AnyOutputPort(*this,newHelder);
}
-void AnyOutputPort::put(const void *data) throw(ConversionException)
+void AnyOutputPort::put(const void *data)
{
put((YACS::ENGINE::Any *)data);
}
-void AnyOutputPort::put(YACS::ENGINE::Any *data) throw(ConversionException)
+void AnyOutputPort::put(YACS::ENGINE::Any *data)
{
setValue(data);
OutputPort::put(data);
AnyOutputPort(const AnyOutputPort& other, Node *newHelder);
virtual ~AnyOutputPort();
virtual void setValue(Any *data);
- virtual void put(const void *data) throw(ConversionException);
- void put(Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(Any *data);
//! get the current dispatched value for update port value
Any* getValue() const { return _data; }
virtual std::string getAsString();
* If node name already used in bloc, throw exception.
* Publish inputPorts in current bloc and ancestors.
*/
-bool Bloc::edAddChild(Node *node) throw(YACS::Exception)
+bool Bloc::edAddChild(Node *node)
{
if(isNodeAlreadyAggregated(node))
{
* @exception If 'node' is NOT the son of 'this'.
*/
-void Bloc::edRemoveChild(Node *node) throw(YACS::Exception)
+void Bloc::edRemoveChild(Node *node)
{
StaticDefinedComposedNode::edRemoveChild(node);
list<Node *>::iterator iter=find(_setOfNode.begin(),_setOfNode.end(),node);
return ret;
}
-Node *Bloc::getChildByShortName(const std::string& name) const throw(YACS::Exception)
+Node *Bloc::getChildByShortName(const std::string& name) const
{
for (list<Node *>::const_iterator iter = _setOfNode.begin(); iter != _setOfNode.end(); iter++)
if ((*iter)->getName() == name)
* \b WARNING : When using this method 'node' has to be checked in order to be part of direct children of 'this'.
*
*/
-void Bloc::checkNoCyclePassingThrough(Node *node) throw(YACS::Exception)
+void Bloc::checkNoCyclePassingThrough(Node *node)
{
set<Node *> currentNodesToTest;
//don't insert node to test in set.
void getReadyTasks(std::vector<Task *>& tasks);
void exUpdateState();
//Node* DISOWNnode is a SWIG notation to indicate that the ownership of the node is transfered to C++
- bool edAddChild(Node *DISOWNnode) throw(Exception);
- void edRemoveChild(Node *node) throw(Exception);
+ bool edAddChild(Node *DISOWNnode) ;
+ void edRemoveChild(Node *node) ;
std::list<Node *> getChildren() const { return _setOfNode; }
std::list<Node *> edGetDirectDescendants() const { return _setOfNode; }
std::vector< std::list<Node *> > splitIntoIndependantGraph() const;
- Node *getChildByShortName(const std::string& name) const throw(Exception);
+ Node *getChildByShortName(const std::string& name) const ;
virtual void writeDot(std::ostream &os) const;
void accept(Visitor *visitor);
template<bool direction>
void removeRecursivelyRedundantCL();
void partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap);
void fitToPlayGround(const PlayGround *pg);
+ void propagePlayGround(const PlayGround *pg);
protected:
bool areAllSubNodesFinished() const;
bool areAllSubNodesDone() const;
bool isNameAlreadyUsed(const std::string& name) const;
- void checkNoCyclePassingThrough(Node *node) throw(Exception);
+ void checkNoCyclePassingThrough(Node *node) ;
std::vector< std::pair<OutGate *, InGate *> > getSetOfInternalCFLinks() const;
YACS::Event updateStateOnFinishedEventFrom(Node *node);
YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst);
#include "Visitor.hxx"
#include "ForEachLoop.hxx"
#include "InlineNode.hxx"
+#include "ServiceNode.hxx"
+#include "ServerNode.hxx"
#include "HomogeneousPoolContainer.hxx"
using namespace YACS::ENGINE;
if(_lev==0)
_max_lev=0;
}
+ void visitForEachLoopDyn(ForEachLoopDyn *node) { throw YACS::Exception(MSG); }
void visitOptimizerLoop(OptimizerLoop *node) { throw YACS::Exception(MSG); }
void visitDynParaLoop(DynParaLoop *node) { throw YACS::Exception(MSG); }
void visitForLoop(ForLoop *node) { throw YACS::Exception(MSG); }
if(!cont2)
return ;
_cont.push_back(cont2);
- HomogeneousPoolContainer *cont3(cont2->getDirectFather());
- if(cont3)
- _cont2.insert(cont3);
+ _cont2.insert(cont2);
}
void visitInlineFuncNode(InlineFuncNode *node) { throw YACS::Exception(MSG); }
void visitLoop(Loop *node) { throw YACS::Exception(MSG); }
}
for(std::set< HomogeneousPoolContainer * >::const_iterator it=vis._cont2.begin();it!=vis._cont2.end();it++)
(*it)->setSizeOfPool(pg->getNumberOfWorkers((*it)->getNumberOfCoresPerWorker()));
- for(std::list< HomogeneousPoolContainer *>::const_iterator it=vis._cont.begin();it!=vis._cont.end();it++)
- (*it)->prepareMaskForExecution();
+ //FIXME
}
+
+constexpr char MSG[]="Bloc::propagePlayGround : Not implemented yet for this type of node !";
+class MyVisitorPropagate : public Visitor
+ {
+ public:
+ MyVisitorPropagate(ComposedNode *root):Visitor(root) { }
+ void visitBloc(Bloc *node) { node->ComposedNode::accept(this); }
+ void visitElementaryNode(ElementaryNode *node) { }
+ void visitForEachLoop(ForEachLoop *node) { node->ComposedNode::accept(this); }
+ void visitForEachLoopDyn(ForEachLoopDyn *node) { node->ComposedNode::accept(this); }
+ void visitOptimizerLoop(OptimizerLoop *node) { throw YACS::Exception(MSG); }
+ void visitDynParaLoop(DynParaLoop *node) { throw YACS::Exception(MSG); }
+ void visitForLoop(ForLoop *node) { throw YACS::Exception(MSG); }
+ template<class NodeClass>
+ void visitNodeWithContainer(NodeClass *node)
+ {
+ Container *cont(node->getContainer());
+ HomogeneousPoolContainer *cont2(dynamic_cast<HomogeneousPoolContainer *>(cont));
+ if(!cont2)
+ return ;
+ _cont2.insert(cont2);
+ }
+ void visitInlineNode(InlineNode *node) { this->visitNodeWithContainer<InlineNode>(node); }
+ void visitInlineFuncNode(InlineFuncNode *node) { visitInlineNode(node); }
+ void visitLoop(Loop *node) { throw YACS::Exception(MSG); }
+ void visitProc(Proc *node) { node->ComposedNode::accept(this); }
+ void visitServiceNode(ServiceNode *node) { this->visitNodeWithContainer<ServiceNode>(node); }
+ void visitServerNode(ServerNode *node) { visitInlineNode(node); }
+ void visitServiceInlineNode(ServiceInlineNode *node) { throw YACS::Exception(MSG); }
+ void visitSwitch(Switch *node) { throw YACS::Exception(MSG); }
+ void visitWhileLoop(WhileLoop *node) { throw YACS::Exception(MSG); }
+ void visitPresetNode(DataNode *node) { throw YACS::Exception(MSG); }
+ void visitOutNode(DataNode *node) { throw YACS::Exception(MSG); }
+ void visitStudyInNode(DataNode *node) { throw YACS::Exception(MSG); }
+ void visitStudyOutNode(DataNode *node) { throw YACS::Exception(MSG); }
+ public:
+ std::set< HomogeneousPoolContainer * > _cont2;
+};
+
+void Bloc::propagePlayGround(const PlayGround *pg)
+{
+ MyVisitorPropagate vis(this);
+ this->accept(&vis);
+ for(auto cont : vis._cont2)
+ cont->assignPG(pg);
+}
\ No newline at end of file
INCLUDE_DIRECTORIES(
${PTHREAD_INCLUDE_DIR}
${PROJECT_SOURCE_DIR}/src/bases
+ ${PROJECT_SOURCE_DIR}/src
)
# libraries to link to
SET(_link_LIBRARIES
${PTHREAD_LIBRARIES}
YACSBases
+ YACSlibWorkloadmanager
)
# --- headers ---
SetOfPoints.hxx
PlayGround.hxx
ObserverAsPlugin.hxx
+ NbBranches.hxx
+ WlmTask.hxx
)
# --- sources ---
WhileLoop.cxx
Switch.cxx
DynParaLoop.cxx
+ NbBranches.cxx
ForEachLoop.cxx
OptimizerAlg.cxx
OptimizerLoop.cxx
PlayGround.cxx
ComplexWeight.cxx
ObserverAsPlugin.cxx
+ WlmTask.cxx
)
SET(YACSlibEngine_HEADERS ${YACSlibEngine_HEADERS} PARENT_SCOPE) # Make it visible to src/engine_swig to handle dependencies
/*!
* \param deep if \b true a deep check is perfomed. Typically has to be called by an executor before any attempt to launch an execution.
*/
-DeploymentTree ComposedNode::checkDeploymentTree(bool deep) const throw(YACS::Exception)
+DeploymentTree ComposedNode::checkDeploymentTree(bool deep) const
{
DeploymentTree ret;
list< ElementaryNode * > tasks=getRecursiveConstituents();
* \return true if a new link has been created, false otherwise.
*/
-bool ComposedNode::edAddLink(OutPort *start, InPort *end) throw(YACS::Exception)
+bool ComposedNode::edAddLink(OutPort *start, InPort *end)
{
DEBTRACE("ComposedNode::edAddLink");
set<OutPort *> represented;
* \param end : the InPort to connect
* \return true if a new link has been created, false otherwise.
*/
-bool ComposedNode::edAddDFLink(OutPort *start, InPort *end) throw(YACS::Exception)
+bool ComposedNode::edAddDFLink(OutPort *start, InPort *end)
{
Node* n1=start->getNode();
Node* n2=end->getNode();
* supporting it.
* \return true if a new link has been created, false otherwise.
*/
-bool ComposedNode::edAddLink(OutGate *start, InGate *end) throw(YACS::Exception)
+bool ComposedNode::edAddLink(OutGate *start, InGate *end)
{
Node* n1=start->getNode();
Node* n2=end->getNode();
/*!
* Add a controlflow link between two nodes by calling edAddLink on their control ports
*/
-bool ComposedNode::edAddCFLink(Node *nodeS, Node *nodeE) throw(YACS::Exception)
+bool ComposedNode::edAddCFLink(Node *nodeS, Node *nodeE)
{
return edAddLink(nodeS->getOutGate(),nodeE->getInGate());
}
//! Remove a controlflow link.
-void ComposedNode::edRemoveCFLink(Node *nodeS, Node *nodeE) throw(YACS::Exception)
+void ComposedNode::edRemoveCFLink(Node *nodeS, Node *nodeE)
{
edRemoveLink(nodeS->getOutGate(),nodeE->getInGate());
}
* implies DF/DS gateway.
*/
-void ComposedNode::edRemoveLink(OutPort *start, InPort *end) throw(YACS::Exception)
+void ComposedNode::edRemoveLink(OutPort *start, InPort *end)
{
if(!start->isAlreadyLinkedWith(end))
throw Exception("ComposedNode::edRemoveLink : unexisting link");
}
//! Remove a controlflow link.
-void ComposedNode::edRemoveLink(OutGate *start, InGate *end) throw(YACS::Exception)
+void ComposedNode::edRemoveLink(OutGate *start, InGate *end)
{
ComposedNode* father=checkHavingCommonFather(start->getNode(),end->getNode());
if(father!=this)
start->edRemoveInGate(end);
}
-bool ComposedNode::edAddChild(Node *DISOWNnode) throw(YACS::Exception)
+bool ComposedNode::edAddChild(Node *DISOWNnode)
{
return false; // --- reimplemented in derived classes
}
//! Remove a child node.
-void ComposedNode::edRemoveChild(Node *node) throw(YACS::Exception)
+void ComposedNode::edRemoveChild(Node *node)
{
if(!node)
return;
* separator was not found).
*/
bool ComposedNode::splitNamesBySep(const std::string& globalName, const char separator[],
- std::string& firstPart, std::string& lastPart, bool priority) throw(YACS::Exception)
+ std::string& firstPart, std::string& lastPart, bool priority)
{
const string delims(separator);
string portName, nodeName;
return ret;
}
-void ComposedNode::checkConsistency(LinkInfo& info) const throw(YACS::Exception)
+void ComposedNode::checkConsistency(LinkInfo& info) const
{
info.clearAll();
info.setPointOfView((ComposedNode *)this);
* This method check that G1 <- G2 <- G3 <- G1 does not happened.
* Typically called by methods that set a hierarchy (Bloc::edAddChild, Loop::edSetNode, ...).
*/
-void ComposedNode::checkNoCrossHierachyWith(Node *node) const throw(YACS::Exception)
+void ComposedNode::checkNoCrossHierachyWith(Node *node) const
{
ComposedNode *nodeC=dynamic_cast<ComposedNode *>(node);
if(!nodeC)
/*!
* call it only for 'starts' to 'end' links \b DEALED by 'this'.
*/
-void ComposedNode::checkLinksCoherenceRegardingControl(const std::vector<OutPort *>& starts, InputPort *end, LinkInfo& info) const throw(YACS::Exception)
+void ComposedNode::checkLinksCoherenceRegardingControl(const std::vector<OutPort *>& starts, InputPort *end, LinkInfo& info) const
{
map < ComposedNode *, list<OutPort *>, SortHierarc > outputs;//forward link classical
vector<OutPort *> outputsCross;//forward link cross
}
}
-ComposedNode *ComposedNode::getRootNode() const throw(YACS::Exception)
+ComposedNode *ComposedNode::getRootNode() const
{
if(!_father)
return (ComposedNode *)this;
return 0;
}
-string ComposedNode::getChildName(const Node* node) const throw(YACS::Exception)
+string ComposedNode::getChildName(const Node* node) const
{
string nodeName=node->getQualifiedName();
if (!isNodeAlreadyAggregated(node))
return directSon->getName();
}
-Node *ComposedNode::getChildByName(const std::string& name) const throw(YACS::Exception)
+Node *ComposedNode::getChildByName(const std::string& name) const
{
string potentiallyDirectSonName, remainsPath;
bool forwardNeeded=ComposedNode::splitNamesBySep(name, SEP_CHAR_BTW_LEVEL,
* \exception Exception : If 'nodeToTest' is NOT in descendance of 'this' AND not equal to 'this'
* \param nodeToTest : the node to check
*/
-void ComposedNode::checkInMyDescendance(Node *nodeToTest) const throw(YACS::Exception)
+void ComposedNode::checkInMyDescendance(Node *nodeToTest) const
{
const char whatC[]=" is not the descendance of node ";
if(nodeToTest==0)
* \return The lowest common ancestor if it exists.
*
*/
-ComposedNode *ComposedNode::getLowestCommonAncestor(Node *node1, Node *node2) throw(YACS::Exception)
+ComposedNode *ComposedNode::getLowestCommonAncestor(Node *node1, Node *node2)
{
const char what[]="The two nodes do not share the same genealogy";
if(node1==0 || node2==0)
* get the input port name used by the current node, recursively built with children names.
*/
-string ComposedNode::getInPortName(const InPort * inPort) const throw(YACS::Exception)
+string ComposedNode::getInPortName(const InPort * inPort) const
{
return getPortName<InPort>(inPort);
}
-string ComposedNode::getOutPortName(const OutPort *outPort) const throw(YACS::Exception)
+string ComposedNode::getOutPortName(const OutPort *outPort) const
{
return getPortName<OutPort>(outPort);
}
return ret;
}
-OutPort *ComposedNode::getOutPort(const std::string& name) const throw(YACS::Exception)
+OutPort *ComposedNode::getOutPort(const std::string& name) const
{
string portName, nodeName;
if(splitNamesBySep(name,Node::SEP_CHAR_IN_PORT,nodeName,portName,false))
* and so the leaf of type ElementaryNode aggregating
* this InputPort is directly invoked.
*/
-InputPort * ComposedNode::getInputPort(const std::string& name) const throw(YACS::Exception)
+InputPort * ComposedNode::getInputPort(const std::string& name) const
{
try {
return Node::getInputPort(name);
* Contrary to YACS::ENGINE::ComposedNode::getInputPort, this method is recursive and go
* down hierarchy step by step to complete its work.
*/
-OutputPort * ComposedNode::getOutputPort(const std::string& name) const throw(YACS::Exception)
+OutputPort * ComposedNode::getOutputPort(const std::string& name) const
{
string portName, nodeName;
if(splitNamesBySep(name,Node::SEP_CHAR_IN_PORT,nodeName,portName,false))
}
}
-InputDataStreamPort *ComposedNode::getInputDataStreamPort(const std::string& name) const throw(YACS::Exception)
+InputDataStreamPort *ComposedNode::getInputDataStreamPort(const std::string& name) const
{
string portName, nodeName;
if(splitNamesBySep(name,Node::SEP_CHAR_IN_PORT,nodeName,portName,true))
}
}
-OutputDataStreamPort *ComposedNode::getOutputDataStreamPort(const std::string& name) const throw(YACS::Exception)
+OutputDataStreamPort *ComposedNode::getOutputDataStreamPort(const std::string& name) const
{
string portName, nodeName;
if(splitNamesBySep(name,Node::SEP_CHAR_IN_PORT,nodeName,portName,true))
}
void ComposedNode::checkLinkPossibility(OutPort *start, const std::list<ComposedNode *>& pointsOfViewStart,
- InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) throw(YACS::Exception)
+ InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd)
{
if((dynamic_cast<DataFlowPort *>(start) || dynamic_cast<DataFlowPort *>(end))
&& (dynamic_cast<DataStreamPort *>(start) || dynamic_cast<DataStreamPort *>(end)))
{
}
-void ComposedNode::getDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView) throw(YACS::Exception)
+void ComposedNode::getDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView)
{
}
-void ComposedNode::getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(YACS::Exception)
+void ComposedNode::getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView)
{
}
-void ComposedNode::releaseDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView) throw(YACS::Exception)
+void ComposedNode::releaseDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView)
{
}
-void ComposedNode::releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(YACS::Exception)
+void ComposedNode::releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView)
{
}
}
}
+void ComposedNode::setProperty(const std::string& name,const std::string& value)
+{
+ Node::setProperty(name, value);
+}
+
+std::string ComposedNode::getProperty(const std::string& name)
+{
+ return Node::getProperty(name);
+}
+
+
//! redefined on derived class of ComposedNode. by default a ComposedNode has no port by itself
std::list<InputPort *> ComposedNode::getLocalInputPorts() const
{
-void ComposedNode::checkBasicConsistency() const throw(YACS::Exception)
+void ComposedNode::checkBasicConsistency() const
{
DEBTRACE("ComposedNode::checkBasicConsistency");
std::list<InputPort *>::const_iterator iter;
std::string getName() const;
std::string getTaskName(Task *task) const;
DeploymentTree getDeploymentTree() const;
- DeploymentTree checkDeploymentTree(bool deep) const throw(Exception);
+ DeploymentTree checkDeploymentTree(bool deep) const ;
std::vector<Task *> getNextTasks(bool& isMore);
virtual bool isPlacementPredictableB4Run() const = 0;
void notifyFrom(const Task *sender, YACS::Event event, const Executor *execInst);
- bool edAddLink(OutPort *start, InPort *end) throw(Exception);
- virtual bool edAddDFLink(OutPort *start, InPort *end) throw(Exception);
+ bool edAddLink(OutPort *start, InPort *end) ;
+ virtual bool edAddDFLink(OutPort *start, InPort *end) ;
//Node* DISOWNnode is a SWIG notation to indicate that the ownership of the node is transfered to C++
- virtual bool edAddChild(Node *DISOWNnode) throw(Exception);
- virtual void edRemoveChild(Node *node) throw(Exception);
- bool edAddLink(OutGate *start, InGate *end) throw(Exception);
- bool edAddCFLink(Node *nodeS, Node *nodeE) throw(Exception);
- void edRemoveCFLink(Node *nodeS, Node *nodeE) throw(Exception);
- void edRemoveLink(OutPort *start, InPort *end) throw(Exception);
- void edRemoveLink(OutGate *start, InGate *end) throw(Exception);
+ virtual bool edAddChild(Node *DISOWNnode) ;
+ virtual void edRemoveChild(Node *node) ;
+ bool edAddLink(OutGate *start, InGate *end) ;
+ bool edAddCFLink(Node *nodeS, Node *nodeE) ;
+ void edRemoveCFLink(Node *nodeS, Node *nodeE) ;
+ void edRemoveLink(OutPort *start, InPort *end) ;
+ void edRemoveLink(OutGate *start, InGate *end) ;
virtual bool isRepeatedUnpredictablySeveralTimes() const { return false; }
virtual bool isLoop() const { return false; }
virtual std::list<Node *> edGetDirectDescendants() const = 0;
std::list<Node *> getAllRecursiveNodes();
virtual std::list<Node *> getAllRecursiveConstituents(); // first implementation
std::list<ProgressWeight> getProgressWeight() const;
- std::string getInPortName(const InPort *) const throw (Exception);
- std::string getOutPortName(const OutPort *) const throw (Exception);
+ std::string getInPortName(const InPort *) const ;
+ std::string getOutPortName(const OutPort *) const ;
//
int getNumberOfInputPorts() const;
int getNumberOfOutputPorts() const;
std::set<InPort *> getAllInPortsComingFromOutsideOfCurrentScope() const;
std::list<InputDataStreamPort *> getSetOfInputDataStreamPort() const;
std::list<OutputDataStreamPort *> getSetOfOutputDataStreamPort() const;
- OutPort *getOutPort(const std::string& name) const throw(Exception);
- InputPort *getInputPort(const std::string& name) const throw(Exception);
- OutputPort *getOutputPort(const std::string& name) const throw(Exception);
- InputDataStreamPort *getInputDataStreamPort(const std::string& name) const throw(Exception);
- OutputDataStreamPort *getOutputDataStreamPort(const std::string& name) const throw(Exception);
+ OutPort *getOutPort(const std::string& name) const ;
+ InputPort *getInputPort(const std::string& name) const ;
+ OutputPort *getOutputPort(const std::string& name) const ;
+ InputDataStreamPort *getInputDataStreamPort(const std::string& name) const ;
+ OutputDataStreamPort *getOutputDataStreamPort(const std::string& name) const ;
std::vector< std::pair<OutPort *, InPort *> > getSetOfInternalLinks() const;
virtual std::vector< std::pair<OutPort *, InPort *> > getSetOfLinksLeavingCurrentScope() const;
- void checkConsistency(LinkInfo& info) const throw(Exception);
+ void checkConsistency(LinkInfo& info) const ;
virtual std::vector< std::pair<InPort *, OutPort *> > getSetOfLinksComingInCurrentScope() const;
virtual std::string typeName() {return "YACS__ENGINE__ComposedNode";}
virtual void edUpdateState();
- virtual void checkBasicConsistency() const throw(Exception);
+ virtual void checkBasicConsistency() const ;
virtual std::string getErrorReport();
//
- ComposedNode *getRootNode() const throw(Exception);
+ ComposedNode *getRootNode() const ;
bool isNodeAlreadyAggregated(const Node *node) const;
virtual bool isNameAlreadyUsed(const std::string& name) const;
Node *isInMyDescendance(Node *nodeToTest) const;
- std::string getChildName(const Node* node) const throw(Exception);
+ std::string getChildName(const Node* node) const ;
virtual std::string getMyQualifiedName(const Node *directSon) const;
- Node *getChildByName(const std::string& name) const throw(Exception);
- static ComposedNode *getLowestCommonAncestor(Node *node1, Node *node2) throw(Exception);
+ Node *getChildByName(const std::string& name) const ;
+ static ComposedNode *getLowestCommonAncestor(Node *node1, Node *node2) ;
static std::string getLowestCommonAncestorStr(const std::string& node1, const std::string& node2);
void loaded();
void connected();
void accept(Visitor *visitor);
virtual void cleanNodes();
virtual std::string getProgress() const { return "0"; }
+ void setProperty(const std::string& name,const std::string& value)override;
+ std::string getProperty(const std::string& name)override;
protected:
struct SortHierarc
{
protected:
void edDisconnectAllLinksWithMe();
static bool splitNamesBySep(const std::string& globalName, const char separator[],
- std::string& firstPart, std::string& lastPart, bool priority) throw(Exception);
- virtual Node *getChildByShortName(const std::string& name) const throw(Exception) = 0;
+ std::string& firstPart, std::string& lastPart, bool priority) ;
+ virtual Node *getChildByShortName(const std::string& name) const = 0;
YACS::Event updateStateFrom(Node *node, YACS::Event event, const Executor *execInst);//update the state of this. Precondition : node->_father == this
virtual YACS::Event updateStateOnStartEventFrom(Node *node);//transition 3 doc P.R
virtual YACS::Event updateStateOnFinishedEventFrom(Node *node) = 0;//transition 9 doc P.R.
virtual YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst);//transition 9 doc P.R.
virtual void checkLinkPossibility(OutPort *start, const std::list<ComposedNode *>& pointsOfViewStart,
- InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) throw(Exception);
+ InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) ;
virtual void buildDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView);
virtual void buildDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView);
- virtual void getDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView) throw(Exception);
- virtual void getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(Exception);
- virtual void releaseDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView) throw(Exception);
- virtual void releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(Exception);
- virtual void checkNoCyclePassingThrough(Node *node) throw(Exception) = 0;
- void checkInMyDescendance(Node *nodeToTest) const throw(Exception);
+ virtual void getDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView) ;
+ virtual void getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) ;
+ virtual void releaseDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView) ;
+ virtual void releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) ;
+ virtual void checkNoCyclePassingThrough(Node *node) = 0;
+ void checkInMyDescendance(Node *nodeToTest) const ;
template <class PORT>
- std::string getPortName(const PORT * port) const throw (Exception);
+ std::string getPortName(const PORT * port) const ;
//For CF Computations
- void checkNoCrossHierachyWith(Node *node) const throw (Exception);
+ void checkNoCrossHierachyWith(Node *node) const ;
virtual void performCFComputations(LinkInfo& info) const;
virtual void destructCFComputations(LinkInfo& info) const;
Node *getLowestNodeDealingAll(const std::list<OutPort *>& ports) const;
void checkLinksCoherenceRegardingControl(const std::vector<OutPort *>& starts,
- InputPort *end, LinkInfo& info) const throw(Exception);
+ InputPort *end, LinkInfo& info) const ;
virtual void checkControlDependancy(OutPort *start, InPort *end, bool cross,
std::map < ComposedNode *, std::list < OutPort * >, SortHierarc >& fw,
std::vector<OutPort *>& fwCross,
};
template <class PORT>
- std::string ComposedNode::getPortName(const PORT * port) const throw (Exception)
+ std::string ComposedNode::getPortName(const PORT * port) const
{
Node *node = port->getNode();
std::string portName = port->getName();
return (void *)_value;
}
-void ConditionInputPort::put(const void *data) throw(ConversionException)
+void ConditionInputPort::put(const void *data)
{
put((Any*)data);
}
_value=nullptr;
}
-void ConditionInputPort::put(Any *data) throw(ConversionException)
+void ConditionInputPort::put(Any *data)
{
ConditionInputPort::releaseData();
_value=data;
void edNotifyReferencedBy(OutPort *fromPort, bool isLoopProof) override;
void edNotifyDereferencedBy(OutPort *fromPort);
void *get() const;
- virtual void put(const void *data) throw(ConversionException);
- void put(Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(Any *data);
void releaseData() override;
std::string dump();
virtual std::string getAsString();
const char Container::AOC_ENTRY[]="attached_on_cloning";
+const char Container::USE_PYCACHE_PROPERTY[]="use_py_cache";
+
Container::Container():_isAttachedOnCloning(false),_proc(0)
{
}
return oss.str();
}
+void Container::start(const Task *askingNode,
+ const std::string& resource_name,
+ const std::string& container_name)
+{
+ return start(askingNode);
+}
+
+bool Container::canAcceptImposedResource()
+{
+ return false;
+}
+
/*!
* If \a val is equal to true the current container 'this' is not destined to be deeply copied on clone call.
* If \a val is equal to false the current container 'this' is destined to be deeply copied on clone call.
setProperty((*it).first,(*it).second);
}
+bool Container::isUsingPythonCache()
+{
+ bool found = false;
+ std::string str_value;
+ str_value = getProperty(USE_PYCACHE_PROPERTY);
+ const char* yes_values[] = {"YES", "Yes", "yes", "TRUE", "True", "true", "1",
+ "ON", "on", "On"};
+ for(const char* v : yes_values)
+ if(str_value == v)
+ {
+ found = true;
+ break;
+ }
+ return found;
+}
+
+void Container::usePythonCache(bool v)
+{
+ if(v)
+ setProperty(USE_PYCACHE_PROPERTY, "1");
+ else
+ setProperty(USE_PYCACHE_PROPERTY, "0");
+}
+
//Execution only methods
virtual std::string getDiscreminantStrOfThis(const Task *askingNode) const;
virtual bool isAlreadyStarted(const Task *askingNode) const = 0;
- virtual void start(const Task *askingNode) throw(Exception) = 0;
+ virtual void start(const Task *askingNode) = 0;
+ virtual void start(const Task *askingNode,
+ const std::string& resource_name,
+ const std::string& container_name);
+ virtual bool canAcceptImposedResource();
+ virtual bool isUsingPythonCache();
+ virtual void usePythonCache(bool v);
virtual std::string getPlacementId(const Task *askingNode) const = 0;
virtual std::string getFullPlacementId(const Task *askingNode) const = 0;
//Edition only methods
virtual Container *clone() const = 0;
virtual Container *cloneAlways() const = 0;
virtual bool isSupportingRTODefNbOfComp() const;
- virtual void checkCapabilityToDealWith(const ComponentInstance *inst) const throw(Exception) = 0;
+ virtual void checkCapabilityToDealWith(const ComponentInstance *inst) const = 0;
virtual void setProperty(const std::string& name,const std::string& value) = 0;
virtual std::string getProperty(const std::string& name) const = 0;
virtual void clearProperties() = 0;
virtual void shutdown(int level) = 0;
static const char KIND_ENTRY[];
static const char AOC_ENTRY[];
+ static const char USE_PYCACHE_PROPERTY[];
protected:
std::string _name;
mutable bool _isAttachedOnCloning;
//! returns type of channel the port will use for data exchange on runtime : DATAFLOW or DATASTREAM.
virtual TypeOfChannel getTypeOfChannel() const = 0;
bool isDifferentTypeOf(const DataPort *other) const;
- virtual void edRemoveAllLinksLinkedWithMe() throw(Exception) = 0;
+ virtual void edRemoveAllLinksLinkedWithMe() = 0;
virtual std::string typeName() {return "YACS__ENGINE__DataPort";}
virtual std::string getAsString();
public:
const char DynParaLoop::NAME_OF_SPLITTED_SEQ_OUT[] = "evalSamples";
const char DynParaLoop::OLD_NAME_OF_SPLITTED_SEQ_OUT[] = "SmplPrt"; // For backward compatibility with 5.1.4
-const char DynParaLoop::NAME_OF_NUMBER_OF_BRANCHES[]="nbBranches";
-
-DynParaLoop::DynParaLoop(const std::string& name, TypeCode *typeOfDataSplitted)
+DynParaLoop::DynParaLoop(const std::string& name, TypeCode *typeOfDataSplitted, std::unique_ptr<NbBranchesAbstract>&& branchManager)
: ComposedNode(name),_node(0),_initNode(0),_finalizeNode(0),_nbOfEltConsumed(0),
- _nbOfBranches(NAME_OF_NUMBER_OF_BRANCHES,this,Runtime::_tc_int),
+ _nbOfBranches(std::move(branchManager)),
_splittedPort(NAME_OF_SPLITTED_SEQ_OUT,this,typeOfDataSplitted),_initializingCounter(0),_unfinishedCounter(0),_failedCounter(0),_weight(), _loopWeight(0)
{
_weight.setDefaultLoop();
}
DynParaLoop::DynParaLoop(const DynParaLoop& other, ComposedNode *father, bool editionOnly)
- : ComposedNode(other,father), _nbOfBranches(other._nbOfBranches,this),
+ : ComposedNode(other,father),_nbOfBranches(other._nbOfBranches->copy(this)),
_splittedPort(other._splittedPort,this), _node(0), _initNode(0), _finalizeNode(0),
_nbOfEltConsumed(0),_initializingCounter(0),_unfinishedCounter(0),_failedCounter(0),_weight(other._weight), _loopWeight(other._loopWeight)
{
_node->init(start);
if (_initNode) _initNode->init(start);
if (_finalizeNode) _finalizeNode->init(start);
- _nbOfBranches.exInit(start);
+ _nbOfBranches->exInit(start);
_splittedPort.exInit();
_nbOfEltConsumed=0;
_failedCounter=0;
* \param end : the InPort to connect
* \return true if a new link has been created, false otherwise.
*/
-bool DynParaLoop::edAddDFLink(OutPort *start, InPort *end) throw(YACS::Exception)
+bool DynParaLoop::edAddDFLink(OutPort *start, InPort *end)
{
return edAddLink(start,end);
}
return ret;
}
-OutPort *DynParaLoop::getOutPort(const std::string& name) const throw(YACS::Exception)
+OutPort *DynParaLoop::getOutPort(const std::string& name) const
{
if (name == NAME_OF_SPLITTED_SEQ_OUT || name == OLD_NAME_OF_SPLITTED_SEQ_OUT)
return (OutPort *)&_splittedPort;
}
-OutputPort *DynParaLoop::getOutputPort(const std::string& name) const throw(YACS::Exception)
+OutputPort *DynParaLoop::getOutputPort(const std::string& name) const
{
if (name == NAME_OF_SPLITTED_SEQ_OUT || name == OLD_NAME_OF_SPLITTED_SEQ_OUT)
return (OutputPort *)&_splittedPort;
return removeNode(_finalizeNode);
}
-void DynParaLoop::edRemoveChild(Node *node) throw(YACS::Exception)
+void DynParaLoop::edRemoveChild(Node *node)
{
ComposedNode::edRemoveChild(node);
if(node==_node)
modified();
}
-bool DynParaLoop::edAddChild(Node *DISOWNnode) throw(YACS::Exception)
+bool DynParaLoop::edAddChild(Node *DISOWNnode)
{
return edSetNode(DISOWNnode);
}
std::list<InputPort *> DynParaLoop::getSetOfInputPort() const
{
list<InputPort *> ret=ComposedNode::getSetOfInputPort();
- ret.push_back((InputPort *)&_nbOfBranches);
+ InputPort *port(_nbOfBranches->getPort());
+ if(port)
+ ret.push_back(port);
return ret;
}
-InputPort *DynParaLoop::getInputPort(const std::string& name) const throw(YACS::Exception)
+InputPort *DynParaLoop::getInputPort(const std::string& name) const
{
- if(name==NAME_OF_NUMBER_OF_BRANCHES)
- return (InputPort *)&_nbOfBranches;
+ if(_nbOfBranches->isMyName(name))
+ return _nbOfBranches->getPort();
return ComposedNode::getInputPort(name);
}
std::list<InputPort *> DynParaLoop::getLocalInputPorts() const
{
list<InputPort *> ret=ComposedNode::getLocalInputPorts();
- ret.push_back((InputPort *)&_nbOfBranches);
+ InputPort *port(_nbOfBranches->getPort());
+ if(port)
+ ret.push_back(port);
return ret;
}
-unsigned DynParaLoop::getNumberOfBranchesCreatedDyn() const throw(YACS::Exception)
+unsigned DynParaLoop::getNumberOfBranchesCreatedDyn() const
{
if(_execNodes.empty())
throw Exception("ForEachLoop::getNumberOfBranches : No branches created dynamically ! - ForEachLoop needs to run or to be runned to call getNumberOfBranches");
return _execNodes.size();
}
-Node *DynParaLoop::getChildByShortName(const std::string& name) const throw(YACS::Exception)
+Node *DynParaLoop::getChildByShortName(const std::string& name) const
{
if (_node && name == _node->getName())
return _node;
throw Exception(what);
}
-Node *DynParaLoop::getChildByNameExec(const std::string& name, unsigned id) const throw(YACS::Exception)
+Node *DynParaLoop::getChildByNameExec(const std::string& name, unsigned id) const
{
if(id>=getNumberOfBranchesCreatedDyn())
throw Exception("ForEachLoop::getChildByNameExec : invalid id - too large compared with dynamically created branches.");
bool DynParaLoop::isMultiplicitySpecified(unsigned& value) const
{
- if(_nbOfBranches.edIsManuallyInitialized())
- if(_nbOfBranches.edGetNumberOfLinks()==0)
- {
- value=_nbOfBranches.getIntValue();
- return true;
- }
- return false;
+ return _nbOfBranches->isMultiplicitySpecified(value);
}
void DynParaLoop::forceMultiplicity(unsigned value)
{
- _nbOfBranches.edRemoveAllLinksLinkedWithMe();
- _nbOfBranches.edInit((int)value);
+ _nbOfBranches->forceMultiplicity(value);
}
void DynParaLoop::buildDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView)
}
void DynParaLoop::checkLinkPossibility(OutPort *start, const std::list<ComposedNode *>& pointsOfViewStart,
- InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) throw(YACS::Exception)
+ InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd)
{
ComposedNode::checkLinkPossibility(start, pointsOfViewStart, end, pointsOfViewEnd);
Node * startNode = isInMyDescendance(start->getNode());
return 0;
}
-void DynParaLoop::checkBasicConsistency() const throw(YACS::Exception)
+void DynParaLoop::checkBasicConsistency() const
{
DEBTRACE("DynParaLoop::checkBasicConsistency");
ComposedNode::checkBasicConsistency();
int DynParaLoop::getMaxLevelOfParallelism() const
{
- return _nbOfBranches.getIntValue() * _node->getMaxLevelOfParallelism();
+ return _nbOfBranches->getIntValue() * _node->getMaxLevelOfParallelism();
}
void DynParaLoop::partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap)
#include "AnyInputPort.hxx"
#include "AnyOutputPort.hxx"
#include "OutputPort.hxx"
+#include "NbBranches.hxx"
+
+#include <memory>
namespace YACS
{
Node *_finalizeNode;
unsigned _nbOfEltConsumed;
std::vector<int> _execIds;
- AnyInputPort _nbOfBranches;
+ //NbBranches _nbOfBranches2;
+ std::unique_ptr<NbBranchesAbstract> _nbOfBranches;
AnyOutputPort _splittedPort;
std::vector<Node *> _execNodes;
std::vector<Node *> _execInitNodes;
protected:
static const char NAME_OF_SPLITTED_SEQ_OUT[];
static const char OLD_NAME_OF_SPLITTED_SEQ_OUT[];
- static const char NAME_OF_NUMBER_OF_BRANCHES[];
protected:
- DynParaLoop(const std::string& name, TypeCode *typeOfDataSplitted);
+ DynParaLoop(const std::string& name, TypeCode *typeOfDataSplitted, std::unique_ptr<NbBranchesAbstract>&& branchManager);
virtual ~DynParaLoop();
DynParaLoop(const DynParaLoop& other, ComposedNode *father, bool editionOnly);
public:
Node *edSetNode(Node *DISOWNnode);
Node *edSetInitNode(Node *DISOWNnode);
Node *edSetFinalizeNode(Node *DISOWNnode);
- virtual bool edAddDFLink(OutPort *start, InPort *end) throw(Exception);
+ virtual bool edAddDFLink(OutPort *start, InPort *end) ;
void init(bool start=true);
- InputPort *edGetNbOfBranchesPort() { return &_nbOfBranches; }
+ InputPort *edGetNbOfBranchesPort() { return _nbOfBranches->getPort(); }
int getNumberOfInputPorts() const;
int getNumberOfOutputPorts() const;
unsigned getNumberOfEltsConsumed() const { return _nbOfEltConsumed; }
std::list<OutputPort *> getSetOfOutputPort() const;
std::list<OutputPort *> getLocalOutputPorts() const;
OutputPort *edGetSamplePort() { return &_splittedPort; }
- OutPort *getOutPort(const std::string& name) const throw(Exception);
- InputPort *getInputPort(const std::string& name) const throw(Exception);
- OutputPort *getOutputPort(const std::string& name) const throw(Exception);
+ OutPort *getOutPort(const std::string& name) const ;
+ InputPort *getInputPort(const std::string& name) const ;
+ OutputPort *getOutputPort(const std::string& name) const ;
//! For the moment false is returned : impovement about it coming soon.
bool isPlacementPredictableB4Run() const;
- void edRemoveChild(Node *node) throw(Exception);
+ void edRemoveChild(Node *node) ;
bool isLoop() const override { return true; }
- virtual bool edAddChild(Node *DISOWNnode) throw(Exception);
+ virtual bool edAddChild(Node *DISOWNnode) ;
std::list<Node *> edGetDirectDescendants() const;
std::list<InputPort *> getSetOfInputPort() const;
std::list<InputPort *> getLocalInputPorts() const;
- unsigned getNumberOfBranchesCreatedDyn() const throw(Exception);
- Node *getChildByShortName(const std::string& name) const throw(Exception);
- Node *getChildByNameExec(const std::string& name, unsigned id) const throw(Exception);
+ unsigned getNumberOfBranchesCreatedDyn() const ;
+ Node *getChildByShortName(const std::string& name) const ;
+ Node *getChildByNameExec(const std::string& name, unsigned id) const ;
std::vector<Node *> getNodes() const { return _execNodes; } // need to use in GUI part for adding observers for clone nodes
ComplexWeight * getWeight();
void setWeight(double loopWeight);
void getWeightRegardingDPL(ComplexWeight *weight) {weight->addWeight(getWeight());}
bool isMultiplicitySpecified(unsigned& value) const;
void forceMultiplicity(unsigned value);
- virtual void checkBasicConsistency() const throw(Exception);
+ virtual void checkBasicConsistency() const ;
virtual std::string getErrorReport();
void accept(Visitor *visitor);
Node * getInitNode();
std::map< ComposedNode *, std::list < OutPort *>, SortHierarc >& bw,
LinkInfo& info) const;
virtual void checkLinkPossibility(OutPort *start, const std::list<ComposedNode *>& pointsOfViewStart,
- InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) throw(Exception);
+ InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) ;
protected:
void prepareInputsFromOutOfScope(int branchNb);
void putValueOnBranch(Any *val, unsigned branchId, bool first);
return _setOfOutputPort.size();
}
-InputPort *ElementaryNode::getInputPort(const std::string& name) const throw(YACS::Exception)
+InputPort *ElementaryNode::getInputPort(const std::string& name) const
{
try {
return Node::getInputPort(name);
return getPort<InputPort>(name,_setOfInputPort);
}
-OutputPort *ElementaryNode::getOutputPort(const std::string& name) const throw(YACS::Exception)
+OutputPort *ElementaryNode::getOutputPort(const std::string& name) const
{
return getPort<OutputPort>(name,_setOfOutputPort);
}
return ret;
}
-InputDataStreamPort *ElementaryNode::getInputDataStreamPort(const std::string& name) const throw(YACS::Exception)
+InputDataStreamPort *ElementaryNode::getInputDataStreamPort(const std::string& name) const
{
return getPort<InputDataStreamPort>(name,_setOfInputDataStreamPort);
}
-OutputDataStreamPort *ElementaryNode::getOutputDataStreamPort(const std::string& name) const throw(YACS::Exception)
+OutputDataStreamPort *ElementaryNode::getOutputDataStreamPort(const std::string& name) const
{
return getPort<OutputDataStreamPort>(name,_setOfOutputDataStreamPort);
}
* remove port from node at edition. Ports are typed.
*/
-void ElementaryNode::edRemovePort(Port *port) throw(YACS::Exception)
+void ElementaryNode::edRemovePort(Port *port)
{
DEBTRACE("ElementaryNode::edRemovePort ");
if(port->getNode()!=this)
return ret;
}
-Node *ElementaryNode::getChildByName(const std::string& name) const throw(YACS::Exception)
+Node *ElementaryNode::getChildByName(const std::string& name) const
{
string what("ElementaryNode does not agregate any nodes particullary node with name "); what+=name;
throw Exception(what);
}
-void ElementaryNode::checkBasicConsistency() const throw(YACS::Exception)
+void ElementaryNode::checkBasicConsistency() const
{
DEBTRACE("ElementaryNode::checkBasicConsistency");
list<InputPort *>::const_iterator iter;
* WARNING: CHECK CASE OF BLOC: ONLY INPUT PORTS NOT INTERNALLY CONNECTED MUST BE VISIBLE.
*/
-InputPort *ElementaryNode::edAddInputPort(const std::string& inputPortName, TypeCode* type) throw(YACS::Exception)
+InputPort *ElementaryNode::edAddInputPort(const std::string& inputPortName, TypeCode* type)
{
// Cannot create an InputPort defined with InPropertyPort name.
* for now, publication is done the same way as input ports
*/
-OutputPort *ElementaryNode::edAddOutputPort(const std::string& outputPortName, TypeCode* type) throw(YACS::Exception)
+OutputPort *ElementaryNode::edAddOutputPort(const std::string& outputPortName, TypeCode* type)
{
OutputPort *ret =0;
if (edCheckAddPort<OutputPort, TypeCode*>(outputPortName,_setOfOutputPort,type))
return getRuntime()->createInputDataStreamPort(inputPortDSName, this, type);
}
-InputDataStreamPort *ElementaryNode::edAddInputDataStreamPort(const std::string& inputPortDSName, TypeCode* type) throw(YACS::Exception)
+InputDataStreamPort *ElementaryNode::edAddInputDataStreamPort(const std::string& inputPortDSName, TypeCode* type)
{
InputDataStreamPort *ret = 0;
if (edCheckAddPort<InputDataStreamPort, TypeCode*>(inputPortDSName,_setOfInputDataStreamPort,type))
return getRuntime()->createOutputDataStreamPort(outputPortDSName, this, type);
}
-OutputDataStreamPort *ElementaryNode::edAddOutputDataStreamPort(const std::string& outputPortDSName, TypeCode* type) throw(YACS::Exception)
+OutputDataStreamPort *ElementaryNode::edAddOutputDataStreamPort(const std::string& outputPortDSName, TypeCode* type)
{
OutputDataStreamPort *ret = 0;
if (edCheckAddPort<OutputDataStreamPort, TypeCode*>(outputPortDSName,_setOfOutputDataStreamPort,type))
* get the input port name used by the current node (see composed nodes)
*/
-string ElementaryNode::getInPortName(const InPort * inPort) const throw(YACS::Exception)
+string ElementaryNode::getInPortName(const InPort * inPort) const
{
Node *node = inPort->getNode();
if ( node != this )
return inPort->getName();
}
-string ElementaryNode::getOutPortName(const OutPort *outPort) const throw(YACS::Exception)
+string ElementaryNode::getOutPortName(const OutPort *outPort) const
{
Node *node = outPort->getNode();
if ( node != this )
Container *getContainer();
YACS::StatesForNode getState() const;
void getReadyTasks(std::vector<Task *>& tasks);
- void edRemovePort(Port *port) throw(Exception);
+ void edRemovePort(Port *port) ;
std::list<ElementaryNode *> getRecursiveConstituents() const;
std::list<ProgressWeight> getProgressWeight() const;
- Node *getChildByName(const std::string& name) const throw(Exception);
- virtual void checkBasicConsistency() const throw(Exception);
+ Node *getChildByName(const std::string& name) const ;
+ virtual void checkBasicConsistency() const ;
ComposedNode *getDynClonerIfExists(const ComposedNode *levelToStop) const;
int getNumberOfInputPorts() const;
int getNumberOfOutputPorts() const;
- std::string getInPortName(const InPort *) const throw (Exception);
- std::string getOutPortName(const OutPort *) const throw (Exception);
- InputPort *getInputPort(const std::string& name) const throw(Exception);
- OutputPort *getOutputPort(const std::string& name) const throw(Exception);
+ std::string getInPortName(const InPort *) const ;
+ std::string getOutPortName(const OutPort *) const ;
+ InputPort *getInputPort(const std::string& name) const ;
+ OutputPort *getOutputPort(const std::string& name) const ;
std::list<InputPort *> getSetOfInputPort() const { return _setOfInputPort; }
std::list<OutputPort *> getSetOfOutputPort() const { return _setOfOutputPort; }
std::list<InputPort *> getLocalInputPorts() const { return _setOfInputPort; }
virtual std::vector< std::pair<InPort *, OutPort *> > getSetOfLinksComingInCurrentScope() const;
std::list<InputDataStreamPort *> getSetOfInputDataStreamPort() const { return _setOfInputDataStreamPort; }
std::list<OutputDataStreamPort *> getSetOfOutputDataStreamPort() const { return _setOfOutputDataStreamPort; }
- InputDataStreamPort *getInputDataStreamPort(const std::string& name) const throw(Exception);
- OutputDataStreamPort *getOutputDataStreamPort(const std::string& name) const throw(Exception);
+ InputDataStreamPort *getInputDataStreamPort(const std::string& name) const ;
+ OutputDataStreamPort *getOutputDataStreamPort(const std::string& name) const ;
virtual InputPort *createInputPort(const std::string& inputPortName, TypeCode* type);
virtual OutputPort *createOutputPort(const std::string& outputPortName, TypeCode* type);
virtual InputDataStreamPort *createInputDataStreamPort(const std::string& inputPortDSName, TypeCode* type);
virtual OutputDataStreamPort *createOutputDataStreamPort(const std::string& outputPortDSName, TypeCode* type);
- virtual InputPort *edAddInputPort(const std::string& inputPortName, TypeCode* type) throw(Exception);
- virtual OutputPort *edAddOutputPort(const std::string& outputPortName, TypeCode* type) throw(Exception);
- virtual InputDataStreamPort *edAddInputDataStreamPort(const std::string& inputPortDSName, TypeCode* type) throw(Exception);
- virtual OutputDataStreamPort *edAddOutputDataStreamPort(const std::string& outputPortDSName, TypeCode* type) throw(Exception);
+ virtual InputPort *edAddInputPort(const std::string& inputPortName, TypeCode* type) ;
+ virtual OutputPort *edAddOutputPort(const std::string& outputPortName, TypeCode* type) ;
+ virtual InputDataStreamPort *edAddInputDataStreamPort(const std::string& inputPortDSName, TypeCode* type) ;
+ virtual OutputDataStreamPort *edAddOutputDataStreamPort(const std::string& outputPortDSName, TypeCode* type) ;
virtual void edOrderInputPorts(const std::list<InputPort*>& ports);
virtual void edOrderOutputPorts(const std::list<OutputPort*>& ports);
void edDisconnectAllLinksWithMe();
bool areAllInputPortsValid() const;
template<class PORT>
- PORT *getPort(const std::string& name, const std::list<PORT *>& setOfPorts) const throw(Exception);
+ PORT *getPort(const std::string& name, const std::list<PORT *>& setOfPorts) const ;
template<class PORT, class ENUMTYPE>
- PORT *edAddPort(const std::string& portName, std::list<PORT *>& setOfPorts, ENUMTYPE type) throw(Exception);
+ PORT *edAddPort(const std::string& portName, std::list<PORT *>& setOfPorts, ENUMTYPE type) ;
template<class PORT, class ENUMTYPE>
- bool edCheckAddPort(const std::string& portName, std::list<PORT *>& setOfPorts, ENUMTYPE type) throw(Exception);
+ bool edCheckAddPort(const std::string& portName, std::list<PORT *>& setOfPorts, ENUMTYPE type) ;
template<class PORT>
- static void edRemovePortTypedFromSet(PORT *port, std::list<PORT *>& setOfPorts) throw(Exception);
+ static void edRemovePortTypedFromSet(PORT *port, std::list<PORT *>& setOfPorts) ;
template<class PORT>
static bool isPortNameAlreadyExist(const std::string& portName, const std::list<PORT *>& setOfPorts);
};
*/
template<class PORT>
- PORT *ElementaryNode::getPort(const std::string& name, const std::list<PORT *>& setOfPorts) const throw(Exception)
+ PORT *ElementaryNode::getPort(const std::string& name, const std::list<PORT *>& setOfPorts) const
{
for(typename std::list<PORT *>::const_iterator iter=setOfPorts.begin();iter!=setOfPorts.end();iter++)
{
*/
template<class PORT, class ENUMTYPE>
- PORT *ElementaryNode::edAddPort(const std::string& portName, std::list<PORT *>& setOfPorts, ENUMTYPE type) throw(Exception)
+ PORT *ElementaryNode::edAddPort(const std::string& portName, std::list<PORT *>& setOfPorts, ENUMTYPE type)
{
checkValidityOfPortName(portName);
if(isPortNameAlreadyExist<PORT>(portName, setOfPorts))
}
template<class PORT, class ENUMTYPE>
- bool ElementaryNode::edCheckAddPort(const std::string& portName, std::list<PORT *>& setOfPorts, ENUMTYPE type) throw(Exception)
+ bool ElementaryNode::edCheckAddPort(const std::string& portName, std::list<PORT *>& setOfPorts, ENUMTYPE type)
{
checkValidityOfPortName(portName);
if(isPortNameAlreadyExist<PORT>(portName, setOfPorts))
*/
template<class PORT>
- void ElementaryNode::edRemovePortTypedFromSet(PORT *port, std::list<PORT *>& setOfPorts) throw(Exception)
+ void ElementaryNode::edRemovePortTypedFromSet(PORT *port, std::list<PORT *>& setOfPorts)
{
if(!isPortNameAlreadyExist<PORT>(port->getName(), setOfPorts))
throw Exception("Port is not part of the list : unable to remove it");
#include "ServiceNode.hxx"
#include "ComposedNode.hxx"
+#include "WlmTask.hxx"
+#include "workloadmanager/WorkloadManager.hxx"
+#include "workloadmanager/DefaultAlgorithm.hxx"
+
#include <iostream>
#include <fstream>
#include <sys/stat.h>
string tracefile = "traceExec_";
tracefile += _mainSched->getName();
_trace.open(tracefile.c_str());
-#ifdef WIN32
- _start = timeGetTime();
-#else
- gettimeofday(&_start, NULL);
-#endif
-
+ _start = std::chrono::steady_clock::now();
} // --- End of critical section
if (debug > 1) _displayDot(graph);
if (checkBreakPoints()) break; // end of thread requested, OK to exit at once;
if (debug > 0) _displayDot(graph);
DEBTRACE("---");
- //loadTasks(_tasks);
loadParallelTasks(_tasks,this);
if (debug > 1) _displayDot(graph);
DEBTRACE("---");
Executor *execInst;
};
-void Executor::loadTasks(const std::vector<Task *>& tasks, const Executor *execInst)
-{
- for(std::vector<Task *>::const_iterator iter = _tasks.begin(); iter != _tasks.end(); iter++)
- loadTask(*iter,execInst);
-}
-
void Executor::loadParallelTasks(const std::vector<Task *>& tasks, const Executor *execInst)
{
std::vector<Thread> ths(tasks.size());
HomogeneousPoolContainer *contC(dynamic_cast<HomogeneousPoolContainer *>(task->getContainer()));
if(contC)
{
- YACS::BASES::AutoLocker<Container> alckCont(contC);
+ std::lock_guard<std::mutex> alckCont(contC->getLocker());
contC->release(task);
}
if (cont)
containerName = cont->getName();
-#ifdef WIN32
- DWORD now = timeGetTime();
- double elapse = (now - _start)/1000.0;
-#else
- timeval now;
- gettimeofday(&now, NULL);
- double elapse = (now.tv_sec - _start.tv_sec) + double(now.tv_usec - _start.tv_usec)/1000000.0;
-#endif
+ std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
+ std::chrono::milliseconds millisec;
+ millisec = std::chrono::duration_cast<std::chrono::milliseconds>(now -_start);
+ double elapse = double(millisec.count()) / 1000.0;
{
YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForTrace);
_trace << elapse << " " << containerName << " " << placement << " " << nodeName << " " << message << endl;
disp->dispatch(_root,event);
}
+struct HPCCompare
+{
+ bool operator()(HomogeneousPoolContainer * lhs, HomogeneousPoolContainer * rhs) const
+ {
+ if(!lhs && !rhs)
+ return false;
+ if(!lhs)
+ return true;
+ if(!rhs)
+ return false;
+ return lhs->getNumberOfCoresPerWorker() < rhs->getNumberOfCoresPerWorker();
+ }
+};
+
/*!
* This method takes in input a list of tasks and selects from that lists a part of it considering only the containers.
* If tasks have no container instance subclass of HomogeneousPoolContainer this method will let the \a tsks untouched.
*/
void Executor::FilterTasksConsideringContainers(std::vector<Task *>& tsks)
{
- std::map<HomogeneousPoolContainer *, std::vector<Task *> > m;
- for(std::vector<Task *>::const_iterator it=tsks.begin();it!=tsks.end();it++)
+ std::map<HomogeneousPoolContainer *, std::vector<Task *>, HPCCompare > m;
+ for(auto cur : tsks)
{
- Task *cur(*it);
if(!cur)
continue;
Container *cont(cur->getContainer());
if(!cont)
{
- m[(HomogeneousPoolContainer *)NULL].push_back(cur);
+ m[nullptr].push_back(cur);
continue;
}
HomogeneousPoolContainer *contC(dynamic_cast<HomogeneousPoolContainer *>(cont));
if(!contC)
{
- m[(HomogeneousPoolContainer *)NULL].push_back(cur);
+ m[nullptr].push_back(cur);
continue;
}
m[contC].push_back(cur);
}
//
std::vector<Task *> ret;
- for(std::map<HomogeneousPoolContainer *, std::vector<Task *> >::const_iterator it=m.begin();it!=m.end();it++)
+ for(auto it : m)
{
- HomogeneousPoolContainer *curhpc((*it).first);
- const std::vector<Task *>& curtsks((*it).second);
+ HomogeneousPoolContainer *curhpc(it.first);
+ const std::vector<Task *>& curtsks(it.second);
if(!curhpc)
{
ret.insert(ret.end(),curtsks.begin(),curtsks.end());
else
{
// start of critical section for container curhpc
- YACS::BASES::AutoLocker<Container> alckForCont(curhpc);
+ std::lock_guard<std::mutex> alckCont(curhpc->getLocker());
std::vector<const Task *> vecOfTaskSharingSameHPContToBeRunSimutaneously;
std::size_t sz(curhpc->getNumberOfFreePlace());
std::vector<Task *>::const_iterator it2(curtsks.begin());
placement=zeTask->getContainer()->getFullPlacementId(zeTask);
return placement;
}
+
+///////// NEW EXECUTOR ////////////////////////////////
+void Executor::loadTask(Task *task, const WorkloadManager::RunInfo& runInfo)
+{
+ if(task->getState() != YACS::TOLOAD)
+ return;
+ traceExec(task, "state:TOLOAD", ComputePlacement(task));
+ {//Critical section
+ YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForSchedulerUpdate);
+ _mainSched->notifyFrom(task,YACS::START,this);
+ }//End of critical section
+ try
+ {
+ std::ostringstream container_name;
+ container_name << runInfo.type.name << "-" << runInfo.index;
+ task->imposeResource(runInfo.resource.name, container_name.str());
+ traceExec(task, "load", ComputePlacement(task));
+ task->load();
+ traceExec(task, "initService", ComputePlacement(task));
+ task->initService();
+ }
+ catch(Exception& ex)
+ {
+ std::cerr << ex.what() << std::endl;
+ {//Critical section
+ YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForSchedulerUpdate);
+ task->aborted();
+ _mainSched->notifyFrom(task,YACS::ABORT, this);
+ traceExec(task, "state:"+Node::getStateName(task->getState()), ComputePlacement(task));
+ }//End of critical section
+ }
+ catch(...)
+ {
+ std::cerr << "Load failed" << std::endl;
+ {//Critical section
+ YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForSchedulerUpdate);
+ task->aborted();
+ _mainSched->notifyFrom(task,YACS::ABORT, this);
+ traceExec(task, "state:"+Node::getStateName(task->getState()), ComputePlacement(task));
+ }//End of critical section
+ }
+}
+
+void Executor::beginTask(Task *task)
+{
+ // --- Critical section
+ YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForSchedulerUpdate);
+ _numberOfRunningTasks++;
+ _runningTasks.insert(task);
+ // --- End of critical section
+}
+
+void Executor::endTask(Task *task, YACS::Event ev)
+{
+ YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForSchedulerUpdate);
+ try
+ {
+ if (ev == YACS::FINISH) task->finished();
+ if (ev == YACS::ABORT)
+ {
+ _errorDetected = true;
+ if (_stopOnErrorRequested)
+ {
+ _execMode = YACS::STEPBYSTEP;
+ _isOKToEnd = true;
+ }
+ task->aborted();
+ }
+ //traceExec(task, "state:"+Node::getStateName(task->getState()),placement);
+ _mainSched->notifyFrom(task,ev,this);
+ }
+ catch(Exception& ex)
+ {
+ //notify has failed : it is supposed to have set state
+ //so no need to do anything
+ std::cerr << "Error during notification" << std::endl;
+ std::cerr << ex.what() << std::endl;
+ }
+ catch(...)
+ {
+ //notify has failed : it is supposed to have set state
+ //so no need to do anything
+ std::cerr << "Notification failed" << std::endl;
+ }
+ _numberOfRunningTasks--;
+ _runningTasks.erase(task);
+ if ((_numberOfRunningTasks == 0) && (_execMode != YACS::CONTINUE)) // no more running tasks
+ {
+ if (_executorState == YACS::WAITINGTASKS)
+ {
+ _executorState = YACS::PAUSED;
+ sendEvent("executor");
+ _condForPilot.notify_all();
+ if (_errorDetected &&
+ _stopOnErrorRequested &&
+ !_isRunningunderExternalControl)
+ _condForStepByStep.notify_all(); // exec thread may be on waitResume
+ }
+ }
+ if (_executorState != YACS::PAUSED)
+ wakeUp();
+}
+
+YACS::Event Executor::runTask(Task *task)
+{
+ { // --- Critical section
+ YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForSchedulerUpdate);
+ task->begin(); //change state to ACTIVATED
+ }
+ traceExec(task, "state:"+Node::getStateName(task->getState()),ComputePlacement(task));
+
+ if(getDPLScopeSensitive())
+ {
+ Node *node(dynamic_cast<Node *>(task));
+ ComposedNode *gfn(dynamic_cast<ComposedNode *>(_mainSched));
+ if(node!=0 && gfn!=0)
+ node->applyDPLScope(gfn);
+ }
+
+ YACS::Event ev=YACS::FINISH;
+ try
+ {
+ traceExec(task, "start execution",ComputePlacement(task));
+ task->execute();
+ traceExec(task, "end execution OK",ComputePlacement(task));
+ }
+ catch(Exception& ex)
+ {
+ std::cerr << "YACS Exception during execute" << std::endl;
+ std::cerr << ex.what() << std::endl;
+ ev=YACS::ABORT;
+ string message = "end execution ABORT, ";
+ message += ex.what();
+ traceExec(task, message,ComputePlacement(task));
+ }
+ catch(...)
+ {
+ // Execution has failed
+ std::cerr << "Execution has failed: unknown reason" << std::endl;
+ ev=YACS::ABORT;
+ traceExec(task, "end execution ABORT, unknown reason",ComputePlacement(task));
+ }
+
+ // Disconnect task
+ try
+ {
+ DEBTRACE("task->disconnectService()");
+ task->disconnectService();
+ traceExec(task, "disconnectService",ComputePlacement(task));
+ }
+ catch(...)
+ {
+ // Disconnect has failed
+ std::cerr << "disconnect has failed" << std::endl;
+ ev=YACS::ABORT;
+ traceExec(task, "disconnectService failed, ABORT",ComputePlacement(task));
+ }
+ //
+
+ std::string placement(ComputePlacement(task));
+
+ // container management for HomogeneousPoolOfContainer
+
+ HomogeneousPoolContainer *contC(dynamic_cast<HomogeneousPoolContainer *>(task->getContainer()));
+ if(contC)
+ {
+ std::lock_guard<std::mutex> alckCont(contC->getLocker());
+ contC->release(task);
+ }
+
+ return ev;
+}
+
+void Executor::makeDatastreamConnections(Task *task)
+{
+ YACS::StatesForNode state=task->getState();
+ if(state != YACS::TOLOAD && state != YACS::TORECONNECT)
+ return;
+ try
+ {
+ task->connectService();
+ traceExec(task, "connectService",ComputePlacement(task));
+ {//Critical section
+ YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForSchedulerUpdate);
+ task->connected();
+ }//End of critical section
+ }
+ catch(Exception& ex)
+ {
+ std::cerr << ex.what() << std::endl;
+ try
+ {
+ (task)->disconnectService();
+ traceExec(task, "disconnectService",ComputePlacement(task));
+ }
+ catch(...)
+ {
+ // Disconnect has failed
+ traceExec(task, "disconnectService failed, ABORT",ComputePlacement(task));
+ }
+ {//Critical section
+ YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForSchedulerUpdate);
+ task->aborted();
+ _mainSched->notifyFrom(task,YACS::ABORT,this);
+ }//End of critical section
+ }
+ catch(...)
+ {
+ std::cerr << "Problem in connectService" << std::endl;
+ try
+ {
+ (task)->disconnectService();
+ traceExec(task, "disconnectService",ComputePlacement(task));
+ }
+ catch(...)
+ {
+ // Disconnect has failed
+ traceExec(task, "disconnectService failed, ABORT",ComputePlacement(task));
+ }
+ {//Critical section
+ YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForSchedulerUpdate);
+ task->aborted();
+ _mainSched->notifyFrom(task,YACS::ABORT,this);
+ }//End of critical section
+ }
+ if(task->getState() == YACS::ERROR)
+ {
+ //try to put all coupled tasks in error
+ std::set<Task*> coupledSet;
+ task->getCoupledTasks(coupledSet);
+ for (std::set<Task*>::iterator it = coupledSet.begin(); it != coupledSet.end(); ++it)
+ {
+ Task* t=*it;
+ if(t == task)continue;
+ if(t->getState() == YACS::ERROR)continue;
+ try
+ {
+ t->disconnectService();
+ traceExec(t, "disconnectService",ComputePlacement(task));
+ }
+ catch(...)
+ {
+ // Disconnect has failed
+ traceExec(t, "disconnectService failed, ABORT",ComputePlacement(task));
+ }
+ {//Critical section
+ YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForSchedulerUpdate);
+ t->aborted();
+ _mainSched->notifyFrom(t,YACS::ABORT,this);
+ }//End of critical section
+ traceExec(t, "state:"+Node::getStateName(t->getState()),ComputePlacement(task));
+ }
+ }
+ traceExec(task, "state:"+Node::getStateName(task->getState()),ComputePlacement(task));
+}
+
+void Executor::runWlm(Scheduler *graph,int debug, bool fromScratch)
+{
+ DEBTRACE("Executor::runWlm debug: "<< graph->getName() <<" "<< debug<<" fromScratch: "<<fromScratch);
+ { // --- Critical section
+ YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForSchedulerUpdate);
+ _mainSched = graph;
+ _root = dynamic_cast<ComposedNode *>(_mainSched);
+ if (!_root) throw Exception("Executor::Run, Internal Error!");
+ _executorState = YACS::NOTYETINITIALIZED;
+ sendEvent("executor");
+ _toContinue=true;
+ _isOKToEnd = false;
+ _errorDetected = false;
+ _isWaitingEventsFromRunningTasks = false;
+ _numberOfRunningTasks = 0;
+ _runningTasks.clear();
+ _numberOfEndedTasks = 0;
+ string tracefile = "traceExec_";
+ tracefile += _mainSched->getName();
+ _trace.open(tracefile.c_str());
+ _start = std::chrono::steady_clock::now();
+ } // --- End of critical section
+
+ if (debug > 1) _displayDot(graph);
+
+ if (fromScratch)
+ {
+ try
+ {
+ graph->init();
+ graph->exUpdateState();
+ }
+ catch(Exception& ex)
+ {
+ DEBTRACE("exception: "<< (ex.what()));
+ _executorState = YACS::FINISHED;
+ sendEvent("executor");
+ throw;
+ }
+ }
+ _executorState = YACS::INITIALISED;
+ sendEvent("executor");
+
+ if (debug > 1) _displayDot(graph);
+
+ bool isMore;
+ int problemCount=0;
+ int numberAllTasks;
+
+ _executorState = YACS::RUNNING;
+ sendEvent("executor");
+
+ WorkloadManager::DefaultAlgorithm algo;
+ WorkloadManager::WorkloadManager wlm(algo);
+ WlmTask::loadResources(wlm);
+ wlm.start();
+
+ while (_toContinue)
+ {
+ DEBTRACE("--- executor main loop");
+ sleepWhileNoEventsFromAnyRunningTask();
+ DEBTRACE("--- events...");
+ if (debug > 2) _displayDot(graph);
+ { // --- Critical section
+ YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForSchedulerUpdate);
+ std::vector<Task *> readyTasks=graph->getNextTasks(isMore);
+ graph->selectRunnableTasks(readyTasks);
+ _tasks.clear();
+ for(Task * t : readyTasks)
+ if(_runningTasks.find(t) == _runningTasks.end())
+ _tasks.push_back(t);
+ // TODO: to be removed
+ FilterTasksConsideringContainers(_tasks);
+ numberAllTasks=_numberOfRunningTasks+_tasks.size();
+ } // --- End of critical section
+ if (debug > 2) _displayDot(graph);
+ DEBTRACE("--- events...");
+ if (_executorState == YACS::RUNNING)
+ {
+ if (checkBreakPoints()) break; // end of thread requested, OK to exit at once;
+ for(Task * task : _tasks)
+ {
+ beginTask(task);
+ WlmTask* newTask = new WlmTask(*this, task);
+ wlm.addTask(newTask);
+ }
+ }
+ if (debug > 1) _displayDot(graph);
+ { // --- Critical section
+ DEBTRACE("---");
+ YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForSchedulerUpdate);
+ //It is possible that the graph is finished but it remains running tasks (it's an error but we must take it into account)
+ _toContinue = !graph->isFinished();
+
+ DEBTRACE("_numberOfRunningTasks: " << _numberOfRunningTasks);
+ DEBTRACE("_numberOfEndedTasks: " << _numberOfEndedTasks);
+ DEBTRACE("_toContinue: " << _toContinue);
+ if(_toContinue && numberAllTasks==0)
+ {
+ //Problem : no running tasks and no task to launch ??
+ problemCount++;
+ std::cerr << "Problem in Executor : no running tasks and no task to launch ?? problemCount=" << problemCount << std::endl;
+ //Pause to give a chance to interrupt
+ usleep(1000);
+ if(problemCount > 25)
+ {
+ // Too much problems encountered : stop execution
+ _toContinue=false;
+ }
+ }
+
+ if (! _toContinue)
+ {
+ _executorState = YACS::FINISHED;
+ sendEvent("executor");
+ _condForPilot.notify_all();
+ }
+ } // --- End of critical section
+ if (debug > 0) _displayDot(graph);
+ DEBTRACE("_toContinue: " << _toContinue);
+ }
+
+ wlm.stop();
+ DEBTRACE("End of main Loop");
+
+ { // --- Critical section
+ YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForSchedulerUpdate);
+ if ( _toContinue) // --- break while(): request to stop detected on checkBreakPoints()
+ {
+ DEBTRACE("stop requested: End soon");
+ _executorState = YACS::STOPPED;
+ _toContinue = false;
+ sendEvent("executor");
+ }
+ } // --- End of critical section
+ if ( _dumpOnErrorRequested && _errorDetected)
+ {
+ saveState(_dumpErrorFile);
+ }
+ {
+ YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&_mutexForTrace);
+ _trace.close();
+ }
+}
+
+void Executor::RunW(Scheduler *graph,int debug, bool fromScratch)
+{
+ std::string str_value = graph->getProperty("executor");
+ if(str_value == "WorkloadManager"
+ || str_value == "WORKLOADMANAGER"
+ || str_value == "workloadmanager"
+ || str_value == "WorkLoadManager")
+ runWlm(graph, debug, fromScratch);
+ else
+ RunB(graph, debug, fromScratch);
+}
#include <string>
#include <fstream>
#include <ctime>
+#include <chrono>
+
+namespace WorkloadManager
+{
+ struct RunInfo;
+}
namespace YACS
{
bool _keepGoingOnFail;
//! specifies if scope DynParaLoop is active or not. False by default.
bool _DPLScopeSensitive;
-#ifdef WIN32
- DWORD _start;
-#else
- timeval _start;
-#endif
+ std::chrono::steady_clock::time_point _start;
public:
Executor();
virtual ~Executor();
void RunA(Scheduler *graph,int debug=0, bool fromScratch=true);
- void RunW(Scheduler *graph,int debug=0, bool fromScratch=true) { RunB(graph, debug, fromScratch); }
+ void RunW(Scheduler *graph,int debug=0, bool fromScratch=true);
void RunB(Scheduler *graph,int debug=0, bool fromScratch=true);
+ void runWlm(Scheduler *graph,int debug=0, bool fromScratch=true);
void setKeepGoingProperty(bool newVal) { _keepGoingOnFail=newVal; }
bool getKeepGoingProperty() const { return _keepGoingOnFail; }
void setDPLScopeSensitive(bool newVal) { _DPLScopeSensitive=newVal; }
static int _maxThreads;
static size_t _threadStackSize;
YACS::BASES::Mutex& getTheMutexForSchedulerUpdate() { return _mutexForSchedulerUpdate; }
+ ///// new executor !!!!!
+ void loadTask(Task *task, const WorkloadManager::RunInfo& runInfo);
+ YACS::Event runTask(Task *task);
+ void makeDatastreamConnections(Task *task);
+ void beginTask(Task *task);
+ void endTask(Task *task, YACS::Event ev);
+ ////////////
protected:
bool checkBreakPoints();
void waitResume();
void loadTask(Task *task, const Executor *execInst);
- void loadTasks(const std::vector<Task *>& tasks, const Executor *execInst);
void loadParallelTasks(const std::vector<Task *>& tasks, const Executor *execInst);
void launchTasks(const std::vector<Task*>& tasks);
void launchTask(Task *task);
const char SplitterNode::NAME_OF_SEQUENCE_INPUT[]="SmplsCollection";
-const char ForEachLoop::NAME_OF_SPLITTERNODE[]="splitter";
+const char ForEachLoopGen::NAME_OF_SPLITTERNODE[]="splitter";
-const int ForEachLoop::NOT_RUNNING_BRANCH_ID=-1;
+const int ForEachLoopGen::NOT_RUNNING_BRANCH_ID=-1;
-const char ForEachLoop::INTERCEPTOR_STR[]="_interceptor";
+const char ForEachLoopGen::INTERCEPTOR_STR[]="_interceptor";
InterceptorInputPort::InterceptorInputPort(const std::string& name, Node *node, TypeCode* type):AnyInputPort(name,node,type),
DataPort(name,node,type),Port(node),
{
}
-bool AnySplitOutputPort::addInPort(InPort *inPort) throw(YACS::Exception)
+bool AnySplitOutputPort::addInPort(InPort *inPort)
{
bool ret=OutputPort::addInPort(inPort);
if(_repr)
_repr->getAllRepresented(represented);
}
-int AnySplitOutputPort::removeInPort(InPort *inPort, bool forward) throw(YACS::Exception)
+int AnySplitOutputPort::removeInPort(InPort *inPort, bool forward)
{
bool ret=OutputPort::removeInPort(inPort,forward);
if(_repr)
}
SplitterNode::SplitterNode(const std::string& name, TypeCode *typeOfData,
- ForEachLoop *father):ElementaryNode(name),
+ ForEachLoopGen *father):ElementaryNode(name),
_dataPortToDispatch(NAME_OF_SEQUENCE_INPUT,
this,(TypeCodeSeq *)TypeCode::sequenceTc("","",typeOfData))
{
_father=father;
}
-SplitterNode::SplitterNode(const SplitterNode& other, ForEachLoop *father):ElementaryNode(other,father),
+SplitterNode::SplitterNode(const SplitterNode& other, ForEachLoopGen *father):ElementaryNode(other,father),
_dataPortToDispatch(other._dataPortToDispatch,this)
{
}
-InputPort *SplitterNode::getInputPort(const std::string& name) const throw(YACS::Exception)
+InputPort *SplitterNode::getInputPort(const std::string& name) const
{
if(name==NAME_OF_SEQUENCE_INPUT)
return (InputPort *)&_dataPortToDispatch;
Node *SplitterNode::simpleClone(ComposedNode *father, bool editionOnly) const
{
- return new SplitterNode(*this,(ForEachLoop *)father);
+ return new SplitterNode(*this,(ForEachLoopGen *)father);
}
unsigned SplitterNode::getNumberOfElements() const
void SplitterNode::putSplittedValueOnRankTo(int rankInSeq, int branch, bool first)
{
Any *valueToDispatch=_dataPortToDispatch.getValueAtRank(rankInSeq);
- ForEachLoop *fatherTyped=(ForEachLoop *)_father;
+ ForEachLoopGen *fatherTyped=(ForEachLoopGen *)_father;
fatherTyped->putValueOnBranch(valueToDispatch,branch,first);
valueToDispatch->decrRef();
}
-FakeNodeForForEachLoop::FakeNodeForForEachLoop(ForEachLoop *loop, bool normalFinish):ElementaryNode(NAME),
- _loop(loop),
- _normalFinish(normalFinish)
+FakeNodeForForEachLoop::FakeNodeForForEachLoop(ForEachLoopGen *loop, bool normalFinish):ElementaryNode(NAME),
+ _loop(loop),
+ _normalFinish(normalFinish)
{
_state=YACS::TOACTIVATE;
_father=_loop->getFather();
}
}
-ForEachLoop::ForEachLoop(const std::string& name, TypeCode *typeOfDataSplitted):DynParaLoop(name,typeOfDataSplitted),
- _splitterNode(NAME_OF_SPLITTERNODE,typeOfDataSplitted,this),
- _execCurrentId(0),_nodeForSpecialCases(0),_currentIndex(0),_passedData(0)
+ForEachLoopGen::ForEachLoopGen(const std::string& name, TypeCode *typeOfDataSplitted, std::unique_ptr<NbBranchesAbstract>&& branchManager):
+ DynParaLoop(name,typeOfDataSplitted,std::move(branchManager)),
+ _splitterNode(NAME_OF_SPLITTERNODE,typeOfDataSplitted,this),
+ _execCurrentId(0),_nodeForSpecialCases(0),_currentIndex(0),_passedData(0)
{
}
-ForEachLoop::ForEachLoop(const ForEachLoop& other, ComposedNode *father, bool editionOnly):DynParaLoop(other,father,editionOnly),
- _splitterNode(other._splitterNode,this),
- _execCurrentId(0),_nodeForSpecialCases(0),_currentIndex(0),_passedData(0)
+ForEachLoopGen::ForEachLoopGen(const ForEachLoopGen& other, ComposedNode *father, bool editionOnly):DynParaLoop(other,father,editionOnly),
+ _splitterNode(other._splitterNode,this),
+ _execCurrentId(0),_nodeForSpecialCases(0),_currentIndex(0),_passedData(0)
{
int i=0;
if(!editionOnly)
}
}
-Node *ForEachLoop::simpleClone(ComposedNode *father, bool editionOnly) const
-{
- return new ForEachLoop(*this,father,editionOnly);
-}
-
-ForEachLoop::~ForEachLoop()
+ForEachLoopGen::~ForEachLoopGen()
{
cleanDynGraph();
for(vector<AnySplitOutputPort *>::iterator iter=_outGoingPorts.begin();iter!=_outGoingPorts.end();iter++)
delete _passedData;
}
-void ForEachLoop::init(bool start)
+void ForEachLoopGen::init(bool start)
{
DynParaLoop::init(start);
_splitterNode.init(start);
_passedData->init();
}
-void ForEachLoop::exUpdateState()
+void ForEachLoopGen::exUpdateState()
{
- DEBTRACE("ForEachLoop::exUpdateState");
+ DEBTRACE("ForEachLoopGen::exUpdateState");
if(_state == YACS::DISABLED)
return;
if(_state == YACS::DONE)
{
//internal graph update
int i;
- int nbOfBr(_nbOfBranches.getIntValue()),nbOfElts(_splitterNode.getNumberOfElements()),nbOfEltsDone(0);
+ int nbOfElts(_splitterNode.getNumberOfElements()),nbOfEltsDone(0);
+ int nbOfBr(_nbOfBranches->getNumberOfBranches(nbOfElts));
if(_passedData)
{
_passedData->checkCompatibilyWithNb(nbOfElts);
set< InPort * > portsToSetVals=getAllInPortsComingFromOutsideOfCurrentScope();
for(auto iter : portsToSetVals)
{
- InputPort *curPortCasted=(InputPort *) iter;//Cast granted by ForEachLoop::buildDelegateOf(InPort)
+ InputPort *curPortCasted=(InputPort *) iter;//Cast granted by ForEachLoopGen::buildDelegateOf(InPort)
if(!curPortCasted->canSafelySqueezeMemory())// this can appear strange ! if not safelySqueeze -> release. Nevertheless it is true.
curPortCasted->releaseData(); // these input ports have been incremented with InputPort::put into DynParaLoop::prepareInputsFromOutOfScope. So they can be released now.
}
catch(YACS::Exception& ex)
{
//ForEachLoop must be put in error and the exception rethrown to notify the caller
- DEBTRACE( "ForEachLoop::exUpdateState: " << ex.what() );
+ DEBTRACE( "ForEachLoopGen::exUpdateState: " << ex.what() );
setState(YACS::ERROR);
setErrorDetails(ex.what());
exForwardFailed();
}
}
-void ForEachLoop::exUpdateProgress()
+void ForEachLoopGen::exUpdateProgress()
{
// emit notification to all observers registered with the dispatcher on any change of the node's state
sendEvent("progress");
}
-void ForEachLoop::getReadyTasks(std::vector<Task *>& tasks)
+void ForEachLoopGen::getReadyTasks(std::vector<Task *>& tasks)
{
if(!_node)
return;
}
}
-int ForEachLoop::getNumberOfInputPorts() const
+int ForEachLoopGen::getNumberOfInputPorts() const
{
return DynParaLoop::getNumberOfInputPorts()+1;
}
-void ForEachLoop::checkNoCyclePassingThrough(Node *node) throw(YACS::Exception)
+void ForEachLoopGen::checkNoCyclePassingThrough(Node *node)
{
//TO DO
}
-void ForEachLoop::selectRunnableTasks(std::vector<Task *>& tasks)
+void ForEachLoopGen::selectRunnableTasks(std::vector<Task *>& tasks)
{
}
-std::list<InputPort *> ForEachLoop::getSetOfInputPort() const
+std::list<InputPort *> ForEachLoopGen::getSetOfInputPort() const
{
list<InputPort *> ret=DynParaLoop::getSetOfInputPort();
ret.push_back((InputPort *)&_splitterNode._dataPortToDispatch);
return ret;
}
-std::list<InputPort *> ForEachLoop::getLocalInputPorts() const
+std::list<InputPort *> ForEachLoopGen::getLocalInputPorts() const
{
list<InputPort *> ret=DynParaLoop::getLocalInputPorts();
ret.push_back((InputPort *)&_splitterNode._dataPortToDispatch);
return ret;
}
-InputPort *ForEachLoop::getInputPort(const std::string& name) const throw(YACS::Exception)
+InputPort *ForEachLoopGen::getInputPort(const std::string& name) const
{
if(name==SplitterNode::NAME_OF_SEQUENCE_INPUT)
return (InputPort *)&_splitterNode._dataPortToDispatch;
return DynParaLoop::getInputPort(name);
}
-OutputPort *ForEachLoop::getOutputPort(const std::string& name) const throw(YACS::Exception)
+OutputPort *ForEachLoopGen::getOutputPort(const std::string& name) const
{
for(vector<AnySplitOutputPort *>::const_iterator iter=_outGoingPorts.begin();iter!=_outGoingPorts.end();iter++)
{
return DynParaLoop::getOutputPort(name);
}
-OutPort *ForEachLoop::getOutPort(const std::string& name) const throw(YACS::Exception)
+OutPort *ForEachLoopGen::getOutPort(const std::string& name) const
{
for(vector<AnySplitOutputPort *>::const_iterator iter=_outGoingPorts.begin();iter!=_outGoingPorts.end();iter++)
{
return DynParaLoop::getOutPort(name);
}
-Node *ForEachLoop::getChildByShortName(const std::string& name) const throw(YACS::Exception)
+Node *ForEachLoopGen::getChildByShortName(const std::string& name) const
{
if(name==NAME_OF_SPLITTERNODE)
return (Node *)&_splitterNode;
* \param node : the child node that has finished
* \return the state change
*/
-YACS::Event ForEachLoop::updateStateOnFinishedEventFrom(Node *node)
+YACS::Event ForEachLoopGen::updateStateOnFinishedEventFrom(Node *node)
{
DEBTRACE("updateStateOnFinishedEventFrom " << node->getName() << " " << node->getState());
unsigned int id;
return YACS::NOEVENT;
}
-YACS::Event ForEachLoop::updateStateForInitNodeOnFinishedEventFrom(Node *node, unsigned int id)
+YACS::Event ForEachLoopGen::updateStateForInitNodeOnFinishedEventFrom(Node *node, unsigned int id)
{
_execNodes[id]->exUpdateState();
_nbOfEltConsumed++;
/*!
* \param [in] isNormalFinish - if true
*/
-YACS::Event ForEachLoop::updateStateForWorkNodeOnFinishedEventFrom(Node *node, unsigned int id, bool isNormalFinish)
+YACS::Event ForEachLoopGen::updateStateForWorkNodeOnFinishedEventFrom(Node *node, unsigned int id, bool isNormalFinish)
{
_currentIndex++;
exUpdateProgress();
if(_failedCounter!=0)
{// case of keepgoing mode + a failed
std::ostringstream oss; oss << "Keep Going mode activated and some errors (" << _failedCounter << ")reported !";
- DEBTRACE("ForEachLoop::updateStateOnFinishedEventFrom : "<< oss.str());
+ DEBTRACE("ForEachLoopGen::updateStateOnFinishedEventFrom : "<< oss.str());
setState(YACS::FAILED);
return YACS::ABORT;
}
}
catch(YACS::Exception& ex)
{
- DEBTRACE("ForEachLoop::updateStateOnFinishedEventFrom: "<<ex.what());
+ DEBTRACE("ForEachLoopGen::updateStateOnFinishedEventFrom: "<<ex.what());
//no way to push results : put following nodes in FAILED state
//TODO could be more fine grain : put only concerned nodes in FAILED state
exForwardFailed();
return YACS::NOEVENT;
}
-YACS::Event ForEachLoop::updateStateForFinalizeNodeOnFinishedEventFrom(Node *node, unsigned int id)
+YACS::Event ForEachLoopGen::updateStateForFinalizeNodeOnFinishedEventFrom(Node *node, unsigned int id)
{
DEBTRACE("Finalize node finished on branch " << id);
_unfinishedCounter--;
return YACS::NOEVENT;
}
-YACS::Event ForEachLoop::updateStateOnFailedEventFrom(Node *node, const Executor *execInst)
+YACS::Event ForEachLoopGen::updateStateOnFailedEventFrom(Node *node, const Executor *execInst)
{
unsigned int id;
DynParaLoop::TypeOfNode ton(getIdentityOfNotifyerNode(node,id));
}
}
-void ForEachLoop::InterceptorizeNameOfPort(std::string& portName)
+void ForEachLoopGen::InterceptorizeNameOfPort(std::string& portName)
{
std::replace_if(portName.begin(), portName.end(), std::bind1st(std::equal_to<char>(), '.'), '_');
portName += INTERCEPTOR_STR;
}
-void ForEachLoop::buildDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView)
+void ForEachLoopGen::buildDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView)
{
DynParaLoop::buildDelegateOf(port,finalTarget,pointsOfView);
string typeOfPortInstance=(port.first)->getNameOfTypeOfCurrentInstance();
}
}
else
- throw Exception("ForEachLoop::buildDelegateOf : not implemented for DS because not specified");
+ throw Exception("ForEachLoopGen::buildDelegateOf : not implemented for DS because not specified");
}
-void ForEachLoop::getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(YACS::Exception)
+void ForEachLoopGen::getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView)
{
string typeOfPortInstance=(port.first)->getNameOfTypeOfCurrentInstance();
if(typeOfPortInstance==OutputPort::NAME)
break;
if(iter==_outGoingPorts.end())
{
- string what("ForEachLoop::getDelegateOf : Port with name "); what+=port.first->getName(); what+=" not exported by ForEachLoop "; what+=_name;
+ string what("ForEachLoopGen::getDelegateOf : Port with name "); what+=port.first->getName(); what+=" not exported by ForEachLoop "; what+=_name;
throw Exception(what);
}
else
port.first=(*iter);
}
else
- throw Exception("ForEachLoop::getDelegateOf : not implemented because not specified");
+ throw Exception("ForEachLoopGen::getDelegateOf : not implemented because not specified");
}
-void ForEachLoop::releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(YACS::Exception)
+void ForEachLoopGen::releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView)
{
string typeOfPortInstance=portDwn->getNameOfTypeOfCurrentInstance();
if(typeOfPortInstance==OutputPort::NAME)
}
}
-OutPort *ForEachLoop::getDynOutPortByAbsName(int branchNb, const std::string& name)
+OutPort *ForEachLoopGen::getDynOutPortByAbsName(int branchNb, const std::string& name)
{
string portName, nodeName;
splitNamesBySep(name,Node::SEP_CHAR_IN_PORT,nodeName,portName,false);
Node *staticChild = getChildByName(nodeName);
- return _execNodes[branchNb]->getOutPort(portName);//It's impossible(garanteed by YACS::ENGINE::ForEachLoop::buildDelegateOf)
+ return _execNodes[branchNb]->getOutPort(portName);//It's impossible(garanteed by YACS::ENGINE::ForEachLoopGen::buildDelegateOf)
//that a link starting from _initNode goes out of scope of 'this'.
}
-void ForEachLoop::cleanDynGraph()
+void ForEachLoopGen::cleanDynGraph()
{
DynParaLoop::cleanDynGraph();
for(vector< SequenceAny *>::iterator iter3=_execVals.begin();iter3!=_execVals.end();iter3++)
_execOutGoingPorts.clear();
}
-void ForEachLoop::storeOutValsInSeqForOutOfScopeUse(int rank, int branchNb)
+void ForEachLoopGen::storeOutValsInSeqForOutOfScopeUse(int rank, int branchNb)
{
vector<AnyInputPort *>::iterator iter;
int i=0;
}
}
-int ForEachLoop::getFinishedId()
+int ForEachLoopGen::getFinishedId()
{
if(!_passedData)
return _splitterNode.getNumberOfElements();
return _passedData->getNumberOfElementsToDo();
}
-void ForEachLoop::prepareSequenceValues(int sizeOfSamples)
+void ForEachLoopGen::prepareSequenceValues(int sizeOfSamples)
{
_execVals.resize(_outGoingPorts.size());
vector<AnySplitOutputPort *>::iterator iter=_outGoingPorts.begin();
_execVals[i]=SequenceAny::New((*iter)->edGetType()->contentType(),sizeOfSamples);
}
-void ForEachLoop::pushAllSequenceValues()
+void ForEachLoopGen::pushAllSequenceValues()
{
vector<AnySplitOutputPort *>::iterator iter=_outGoingPorts.begin();
int i=0;
(*iter)->put((const void *)_execVals[i]);
}
-void ForEachLoop::createOutputOutOfScopeInterceptors(int branchNb)
+void ForEachLoopGen::createOutputOutOfScopeInterceptors(int branchNb)
{
vector<AnySplitOutputPort *>::iterator iter=_outGoingPorts.begin();
int i=0;
}
}
-void ForEachLoop::checkLinkPossibility(OutPort *start, const std::list<ComposedNode *>& pointsOfViewStart,
- InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) throw(YACS::Exception)
+void ForEachLoopGen::checkLinkPossibility(OutPort *start, const std::list<ComposedNode *>& pointsOfViewStart,
+ InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd)
{
DynParaLoop::checkLinkPossibility(start, pointsOfViewStart, end, pointsOfViewEnd);
if(end->getNode() == &_splitterNode)
throw Exception("Illegal link within a foreach loop: \
the 'SmplsCollection' port cannot be linked within the scope of the loop.");
- if(end == &_nbOfBranches)
+ if(end == _nbOfBranches->getPort())
throw Exception("Illegal link within a foreach loop: \
the 'nbBranches' port cannot be linked within the scope of the loop.");
}
-std::list<OutputPort *> ForEachLoop::getLocalOutputPorts() const
+std::list<OutputPort *> ForEachLoopGen::getLocalOutputPorts() const
{
list<OutputPort *> ret;
ret.push_back(getOutputPort(NAME_OF_SPLITTED_SEQ_OUT));
return ret;
}
-void ForEachLoop::accept(Visitor *visitor)
-{
- visitor->visitForEachLoop(this);
-}
-
//! Dump the node state to a stream
/*!
* \param os : the output stream
*/
-void ForEachLoop::writeDot(std::ostream &os) const
+void ForEachLoopGen::writeDot(std::ostream &os) const
{
os << " subgraph cluster_" << getId() << " {\n" ;
//only one node in a loop
}
//! Reset the state of the node and its children depending on the parameter level
-void ForEachLoop::resetState(int level)
+void ForEachLoopGen::resetState(int level)
{
if(level==0)return;
DynParaLoop::resetState(level);
cleanDynGraph();
}
-std::string ForEachLoop::getProgress() const
+std::string ForEachLoopGen::getProgress() const
{
int nbElems(getNbOfElementsToBeProcessed());
std::stringstream aProgress;
* Only elementary nodes have weight. For each node in the loop, the weight done is multiplied
* by the number of elements done and the weight total by the number total of elements
*/
-list<ProgressWeight> ForEachLoop::getProgressWeight() const
+list<ProgressWeight> ForEachLoopGen::getProgressWeight() const
{
list<ProgressWeight> ret;
list<Node *> setOfNode=edGetDirectDescendants();
return ret;
}
-int ForEachLoop::getNbOfElementsToBeProcessed() const
+int ForEachLoopGen::getNbOfElementsToBeProcessed() const
{
- int nbBranches = _nbOfBranches.getIntValue();
- return _splitterNode.getNumberOfElements()
+ int nbOfElems(_splitterNode.getNumberOfElements());
+ int nbBranches = _nbOfBranches->getNumberOfBranches(nbOfElems);
+ return nbOfElems
+ (_initNode ? nbBranches:0)
+ (_finalizeNode ? nbBranches:0) ;
}
*
* \sa edGetSeqOfSamplesPort
*/
-std::vector<unsigned int> ForEachLoop::getPassedResults(Executor *execut, std::vector<SequenceAny *>& outputs, std::vector<std::string>& nameOfOutputs) const
+std::vector<unsigned int> ForEachLoopGen::getPassedResults(Executor *execut, std::vector<SequenceAny *>& outputs, std::vector<std::string>& nameOfOutputs) const
{
YACS::BASES::AutoLocker<YACS::BASES::Mutex> alck(&(execut->getTheMutexForSchedulerUpdate()));
if(_execVals.empty())
* This method is typically useful for post-mortem relaunch to avoid to recompute already passed cases. This method takes in input exactly the parameters retrieved by
* getPassedResults method.
*/
-void ForEachLoop::assignPassedResults(const std::vector<unsigned int>& passedIds, const std::vector<SequenceAny *>& passedOutputs, const std::vector<std::string>& nameOfOutputs)
+void ForEachLoopGen::assignPassedResults(const std::vector<unsigned int>& passedIds, const std::vector<SequenceAny *>& passedOutputs, const std::vector<std::string>& nameOfOutputs)
{
delete _passedData;
_failedCounter=0;
_passedData=new ForEachLoopPassedData(passedIds,passedOutputs,nameOfOutputs);
}
-int ForEachLoop::getFEDeltaBetween(OutPort *start, InPort *end)
+int ForEachLoopGen::getFEDeltaBetween(OutPort *start, InPort *end)
{
Node *ns(start->getNode()),*ne(end->getNode());
ComposedNode *co(getLowestCommonAncestor(ns,ne));
Node *work(ns);
while(work!=co)
{
- ForEachLoop *isFE(dynamic_cast<ForEachLoop *>(work));
+ ForEachLoopGen *isFE(dynamic_cast<ForEachLoopGen *>(work));
if(isFE)
ret++;
work=work->getFather();
* This method is used to obtain the values already processed by the ForEachLoop.
* A new ForEachLoopPassedData object is returned. You have to delete it.
*/
-ForEachLoopPassedData* ForEachLoop::getProcessedData()const
+ForEachLoopPassedData* ForEachLoopGen::getProcessedData()const
{
std::vector<SequenceAny *> outputs;
std::vector<std::string> nameOfOutputs;
return new ForEachLoopPassedData(_execVals[0]->getSetItems(), outputs, nameOfOutputs);
}
-void ForEachLoop::setProcessedData(ForEachLoopPassedData* processedData)
+void ForEachLoopGen::setProcessedData(ForEachLoopPassedData* processedData)
{
if(_passedData)
delete _passedData;
/*!
* \param portName : "interceptorized" name of port.
*/
-const YACS::ENGINE::TypeCode* ForEachLoop::getOutputPortType(const std::string& portName)const
+const YACS::ENGINE::TypeCode* ForEachLoopGen::getOutputPortType(const std::string& portName)const
{
const YACS::ENGINE::TypeCode* ret=NULL;
vector<AnySplitOutputPort *>::const_iterator it;
{
std::string originalPortName(getPortName(*it));
//InterceptorizeNameOfPort(originalPortName);
- DEBTRACE("ForEachLoop::getOutputPortType compare " << portName << " == " << originalPortName);
+ DEBTRACE("ForEachLoopGen::getOutputPortType compare " << portName << " == " << originalPortName);
if(originalPortName == portName)
{
ret = (*it)->edGetType()->contentType();
}
return ret;
}
+
+Node *ForEachLoop::simpleClone(ComposedNode *father, bool editionOnly) const
+{
+ return new ForEachLoop(*this,father,editionOnly);
+}
+
+void ForEachLoop::accept(Visitor *visitor)
+{
+ visitor->visitForEachLoop(this);
+}
+
+void ForEachLoopDyn::accept(Visitor *visitor)
+{
+ visitor->visitForEachLoopDyn(this);
+}
+
+Node *ForEachLoopDyn::simpleClone(ComposedNode *father, bool editionOnly) const
+{
+ return new ForEachLoopDyn(*this,father,editionOnly);
+}
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#ifndef __FOREACHLOOP_HXX__
-#define __FOREACHLOOP_HXX__
+#pragma once
#include "YACSlibEngineExport.hxx"
#include "ElementaryNode.hxx"
namespace ENGINE
{
class ForEachLoop;
+ class ForEachLoopGen;
class SplitterNode;
class AnySplitOutputPort;
class TypeCode;
class InterceptorInputPort : public AnyInputPort
{
- friend class ForEachLoop;
+ friend class ForEachLoopGen;
friend class SplitterNode;
private:
AnySplitOutputPort *_repr;
class AnySplitOutputPort : public OutputPort
{
- friend class ForEachLoop;
+ friend class ForEachLoopGen;
friend class SplitterNode;
private:
OutPort *_repr;
void incrRef() const;
AnySplitOutputPort(const std::string& name, Node *node, TypeCode *type);
AnySplitOutputPort(const AnySplitOutputPort& other, Node *newHelder);
- bool addInPort(InPort *inPort) throw(Exception);
+ bool addInPort(InPort *inPort) ;
void getAllRepresented(std::set<OutPort *>& represented) const;
- int removeInPort(InPort *inPort, bool forward) throw(Exception);
+ int removeInPort(InPort *inPort, bool forward) ;
void addRepr(OutPort *repr, InterceptorInputPort *intercptr);
OutPort *getRepr() const { return _repr; }
OutputPort *clone(Node *newHelder) const;
class YACSLIBENGINE_EXPORT SeqAnyInputPort : public AnyInputPort
{
- friend class ForEachLoop;
+ friend class ForEachLoopGen;
friend class SplitterNode;
public:
unsigned getNumberOfElements() const;
class SplitterNode : public ElementaryNode
{
- friend class ForEachLoop;
+ friend class ForEachLoopGen;
private:
static const char NAME_OF_SEQUENCE_INPUT[];
private:
- SplitterNode(const std::string& name, TypeCode *typeOfData, ForEachLoop *father);
- SplitterNode(const SplitterNode& other, ForEachLoop *father);
- InputPort *getInputPort(const std::string& name) const throw(Exception);
+ SplitterNode(const std::string& name, TypeCode *typeOfData, ForEachLoopGen *father);
+ SplitterNode(const SplitterNode& other, ForEachLoopGen *father);
+ InputPort *getInputPort(const std::string& name) const ;
Node *simpleClone(ComposedNode *father, bool editionOnly) const;
unsigned getNumberOfElements() const;
void execute();
class FakeNodeForForEachLoop : public ElementaryNode
{
- friend class ForEachLoop;
+ friend class ForEachLoopGen;
private:
- ForEachLoop *_loop;
+ ForEachLoopGen *_loop;
bool _normalFinish;
private:
- FakeNodeForForEachLoop(ForEachLoop *loop, bool normalFinish);
+ FakeNodeForForEachLoop(ForEachLoopGen *loop, bool normalFinish);
FakeNodeForForEachLoop(const FakeNodeForForEachLoop& other);
Node *simpleClone(ComposedNode *father, bool editionOnly) const;
void exForwardFailed();
class Executor;
- class YACSLIBENGINE_EXPORT ForEachLoop : public DynParaLoop
+ class YACSLIBENGINE_EXPORT ForEachLoopGen : public DynParaLoop
{
friend class SplitterNode;
friend class FakeNodeForForEachLoop;
std::vector< std::vector<AnyInputPort *> > _execOutGoingPorts;
ForEachLoopPassedData *_passedData;
public:
- ForEachLoop(const std::string& name, TypeCode *typeOfDataSplitted);
- ForEachLoop(const ForEachLoop& other, ComposedNode *father, bool editionOnly);
- ~ForEachLoop();
+ ForEachLoopGen(const std::string& name, TypeCode *typeOfDataSplitted, std::unique_ptr<NbBranchesAbstract>&& branchManager);
+ ForEachLoopGen(const ForEachLoopGen& other, ComposedNode *father, bool editionOnly);
+ ~ForEachLoopGen();
void init(bool start=true);
void exUpdateState();
void exUpdateProgress();
void getReadyTasks(std::vector<Task *>& tasks);
int getNumberOfInputPorts() const;
//
- void checkNoCyclePassingThrough(Node *node) throw(Exception);
+ void checkNoCyclePassingThrough(Node *node) ;
void selectRunnableTasks(std::vector<Task *>& tasks);
//
unsigned getExecCurrentId() const { return _execCurrentId; } // for update progress bar on GUI part
std::list<InputPort *> getSetOfInputPort() const;
std::list<InputPort *> getLocalInputPorts() const;
InputPort *edGetSeqOfSamplesPort() { return &_splitterNode._dataPortToDispatch; }
- InputPort *getInputPort(const std::string& name) const throw(Exception);
- OutPort *getOutPort(const std::string& name) const throw(Exception);
- OutputPort *getOutputPort(const std::string& name) const throw(Exception);
- Node *getChildByShortName(const std::string& name) const throw(Exception);
+ InputPort *getInputPort(const std::string& name) const ;
+ OutPort *getOutPort(const std::string& name) const ;
+ OutputPort *getOutputPort(const std::string& name) const ;
+ Node *getChildByShortName(const std::string& name) const ;
std::list<OutputPort *> getLocalOutputPorts() const;
- void accept(Visitor *visitor);
void writeDot(std::ostream &os) const;
virtual std::string typeName() {return "YACS__ENGINE__ForEachLoop";}
virtual void resetState(int level);
const TypeCode* getOutputPortType(const std::string& portName)const;
void cleanDynGraph() override;
protected:
- Node *simpleClone(ComposedNode *father, bool editionOnly=true) const;
void checkLinkPossibility(OutPort *start, const std::list<ComposedNode *>& pointsOfViewStart,
- InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) throw(Exception);
+ InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) ;
YACS::Event updateStateOnFinishedEventFrom(Node *node);
YACS::Event updateStateForInitNodeOnFinishedEventFrom(Node *node, unsigned int id);
YACS::Event updateStateForWorkNodeOnFinishedEventFrom(Node *node, unsigned int id, bool isNormalFinish);
YACS::Event updateStateForFinalizeNodeOnFinishedEventFrom(Node *node, unsigned int id);
YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst);
void buildDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView);
- void getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(Exception);
- void releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(Exception);
+ void getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) ;
+ void releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) ;
protected:
void pushAllSequenceValues();
void createOutputOutOfScopeInterceptors(int branchNb);
static void InterceptorizeNameOfPort(std::string& portName);
static const char INTERCEPTOR_STR[];
};
+
+ class YACSLIBENGINE_EXPORT ForEachLoop : public ForEachLoopGen
+ {
+ public:
+ ForEachLoop(const std::string& name, TypeCode *typeOfDataSplitted):ForEachLoopGen(name,typeOfDataSplitted,std::unique_ptr<NbBranchesAbstract>(new NbBranches(this))) { }
+ ForEachLoop(const ForEachLoop& other, ComposedNode *father, bool editionOnly):ForEachLoopGen(other,father,editionOnly) { }
+ ~ForEachLoop() { }
+ void accept(Visitor *visitor);
+ protected:
+ Node *simpleClone(ComposedNode *father, bool editionOnly=true) const;
+ };
+
+ class YACSLIBENGINE_EXPORT ForEachLoopDyn : public ForEachLoopGen
+ {
+ public:
+ ForEachLoopDyn(const std::string& name, TypeCode *typeOfDataSplitted):ForEachLoopGen(name,typeOfDataSplitted,std::unique_ptr<NbBranchesAbstract>(new NoNbBranches)) { }
+ ForEachLoopDyn(const ForEachLoopDyn& other, ComposedNode *father, bool editionOnly):ForEachLoopGen(other,father,editionOnly) { }
+ ~ForEachLoopDyn() { }
+ void accept(Visitor *visitor);
+ protected:
+ Node *simpleClone(ComposedNode *father, bool editionOnly=true) const;
+ };
}
}
-#endif
return new ForLoop(*this,father,editionOnly);
}
-InputPort* ForLoop::getInputPort(const std::string& name) const throw(YACS::Exception)
+InputPort* ForLoop::getInputPort(const std::string& name) const
{
if(name == NAME_OF_NSTEPS_NUMBER)return (InputPort*)&_nbOfTimesPort;
return Loop::getInputPort(name);
return ret;
}
-OutPort *ForLoop::getOutPort(const std::string& name) const throw(YACS::Exception)
+OutPort *ForLoop::getOutPort(const std::string& name) const
{
if(name==NAME_OF_INDEX)
return (OutPort *)&_indexPort;
return Loop::getOutPort(name);
}
-OutputPort *ForLoop::getOutputPort(const std::string& name) const throw(YACS::Exception)
+OutputPort *ForLoop::getOutputPort(const std::string& name) const
{
if(name==NAME_OF_INDEX)
return (OutputPort *)&_indexPort;
void init(bool start=true);
InputPort *edGetNbOfTimesInputPort() { return &_nbOfTimesPort; }
Node *simpleClone(ComposedNode *father, bool editionOnly=true) const;
- InputPort* getInputPort(const std::string& name) const throw(Exception);
- OutPort *getOutPort(const std::string& name) const throw(Exception);
- OutputPort *getOutputPort(const std::string& name) const throw(Exception);
+ InputPort* getInputPort(const std::string& name) const ;
+ OutPort *getOutPort(const std::string& name) const ;
+ OutputPort *getOutputPort(const std::string& name) const ;
std::list<InputPort *> getLocalInputPorts() const;
std::list<OutputPort *> getLocalOutputPorts() const;
std::list<OutputPort *> getSetOfOutputPort() const;
throw Exception("An HomogeneousPoolContainer cannot be detached on cloning #2 !");
}
+void HomogeneousPoolContainer::assignPG(const PlayGround *pg)
+{
+ _pg.takeRef(pg);
+}
+
void HomogeneousPoolContainer::dettachOnCloning() const
{
_isAttachedOnCloning=true;
HomogeneousPoolContainer::~HomogeneousPoolContainer()
{
}
+
+const PlayGround *HomogeneousPoolContainer::getPG() const
+{
+ if(_pg.isNull())
+ throw Exception("HomogeneousPoolContainer::getPG : PlayGround is nullptr !");
+ return _pg;
+}
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#ifndef __HOMOGENEOUSPOOLCONTAINER_HXX__
-#define __HOMOGENEOUSPOOLCONTAINER_HXX__
+#pragma once
#include "YACSlibEngineExport.hxx"
#include "Exception.hxx"
void dettachOnCloning() const;
bool isAttachedOnCloning() const;
void setAttachOnCloningStatus(bool val) const;
+ virtual void assignPG(const PlayGround *pg);
+ std::mutex &getLocker() const { return this->getPG()->getLocker(); }
//
virtual void setSizeOfPool(int sz) = 0;
virtual int getSizeOfPool() const = 0;
virtual std::size_t getNumberOfFreePlace() const = 0;
virtual void allocateFor(const std::vector<const Task *>& nodes) = 0;
virtual void release(const Task *node) = 0;
- virtual YACS::BASES::AutoRefCnt<HomogeneousPoolContainer> decorate(YACS::BASES::AutoConstRefCnt<PartDefinition> pd) = 0;
- virtual HomogeneousPoolContainer *getDirectFather() = 0;
- virtual const HomogeneousPoolContainer *getDirectFather() const = 0;
virtual int getNumberOfCoresPerWorker() const = 0;
- virtual void prepareMaskForExecution() const = 0;
- virtual void forYourTestsOnly(ForTestOmlyHPContCls *data) const = 0;
static const char SIZE_OF_POOL_KEY[];
static const char INITIALIZE_SCRIPT_KEY[];
protected:
#ifndef SWIG
virtual ~HomogeneousPoolContainer();
#endif
+ protected:
+ const PlayGround *getPG() const;
+ private:
+ YACS::BASES::AutoConstRefCnt<PlayGround> _pg;
};
}
}
-#endif
return _backLinks.size();
}
-void InPort::edRemoveAllLinksLinkedWithMe() throw(YACS::Exception)
+void InPort::edRemoveAllLinksLinkedWithMe()
{
set< std::pair<OutPort *,bool> > temp(_backLinks);//edRemoveLink called after causes invalidation of set iterator.
for(auto iter : temp)
friend class SplitterNode;
friend class ComposedNode;
friend class OptimizerLoop;
+ friend class NbBranches;
friend class ElementaryNode; //for removeAllLinksWithMe
friend class CollectorSwOutPort;
friend class OutputDataStreamPort;
protected:
InPort(const InPort& other, Node *newHelder);
InPort(const std::string& name, Node *node, TypeCode* type);
- void edRemoveAllLinksLinkedWithMe() throw(Exception);
+ void edRemoveAllLinksLinkedWithMe() ;
virtual void edNotifyReferencedBy(OutPort *fromPort, bool isLoopProof = true);
virtual void edNotifyDereferencedBy(OutPort *fromPort);
virtual void getAllRepresentants(std::set<InPort *>& repr) const;
}
void
-InPropertyPort::put(const void *data) throw(ConversionException)
+InPropertyPort::put(const void *data)
{
put((YACS::ENGINE::Any *)data);
}
virtual void exRestoreInit();
virtual InPropertyPort *clone(Node *newHelder) const;
virtual void *get() const;
- virtual void put(const void *data) throw(ConversionException);
+ virtual void put(const void *data);
virtual void put(YACS::ENGINE::Any *data);
void releaseData() override;
protected:
#include "InlineNode.hxx"
#include "Visitor.hxx"
#include "Container.hxx"
-#include "HomogeneousPoolContainer.hxx"
#include <iostream>
#define _DEVDEBUG_
modified();
}
-void InlineFuncNode::checkBasicConsistency() const throw(YACS::Exception)
+void InlineFuncNode::checkBasicConsistency() const
{
InlineNode::checkBasicConsistency();
if(_fname.empty() )
int ret(1); iss >> ret;
return ret;
}
-
-void InlineNode::partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap)
-{
- if(!isDeployable())
- return ;
- if(!_container)
- return ;
- HomogeneousPoolContainer *contC(dynamic_cast<HomogeneousPoolContainer *>(_container));
- if(!contC)
- return ;
- YACS::BASES::AutoConstRefCnt<PartDefinition> zePd;
- zePd.takeRef(pd);
- YACS::BASES::AutoRefCnt<HomogeneousPoolContainer> zeCont(contC->decorate(zePd));
- setContainer(zeCont);
-}
void performShallowDuplicationOfPlacement(const Node& other);
bool isDeployable() const;
int getMaxLevelOfParallelism() const;
- void partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap);
public:
static const char LOCAL_STR[];
static const char REMOTE_STR[];
void accept(Visitor *visitor);
virtual ~InlineFuncNode();
virtual std::string typeName() { return "YACS__ENGINE__InlineFuncNode"; }
- virtual void checkBasicConsistency() const throw(Exception);
+ virtual void checkBasicConsistency() const ;
protected:
std::string _fname;
};
}
//! Check basically that this port has one chance to be specified on time. It's a necessary condition \b not \b sufficient at all.
-void InputPort::checkBasicConsistency() const throw(YACS::Exception)
+void InputPort::checkBasicConsistency() const
{
if(!_canBeNull && !edIsManuallyInitialized() && _backLinks.size()==0 )
{
*/
}
-void ProxyPort::edRemoveAllLinksLinkedWithMe() throw(YACS::Exception)
+void ProxyPort::edRemoveAllLinksLinkedWithMe()
{
_port->edRemoveAllLinksLinkedWithMe();
}
_port->releaseData();
}
-void ProxyPort::put(const void *data) throw(ConversionException)
+void ProxyPort::put(const void *data)
{
_port->put(data);
}
void edInit(Any *value);
void edInit(const std::string& impl,const void* value);
virtual void edRemoveManInit();
- virtual void checkBasicConsistency() const throw(Exception);
+ virtual void checkBasicConsistency() const ;
virtual void exInit(bool start);
virtual void exSaveInit() = 0;
virtual void exRestoreInit() = 0;
virtual void *get() const = 0;
virtual void releaseData() = 0;
- virtual void put(const void *data) throw(ConversionException) = 0;
+ virtual void put(const void *data) = 0;
virtual std::string dump();
virtual std::string getHumanRepr();
virtual void setStringRef(std::string strRef);
ProxyPort(InputPort* p);
~ProxyPort();
- void edRemoveAllLinksLinkedWithMe() throw(Exception);
+ void edRemoveAllLinksLinkedWithMe() ;
InputPort *clone(Node *newHelder) const;
void edNotifyReferencedBy(OutPort *fromPort, bool isLoopProof = true) override;
void edNotifyDereferencedBy(OutPort *fromPort);
InputPort *getPublicRepresentant();
#endif
void *get() const;
- virtual void put(const void *data) throw(ConversionException) ;
+ virtual void put(const void *data) ;
void releaseData() override;
int edGetNumberOfLinks() const;
bool isIntermediate() const { return true; }
_level++;
}
-void LinkInfo::endCollapseTransac() throw(YACS::Exception)
+void LinkInfo::endCollapseTransac()
{
if(--_level==0)
{
_collapse[reason].back().push_back(pair<OutPort *,InPort *>(semStart,end));
}
-void LinkInfo::pushErrLink(OutPort *semStart, InPort *end, ErrReason reason) throw(YACS::Exception)
+void LinkInfo::pushErrLink(OutPort *semStart, InPort *end, ErrReason reason)
{
if(reason==E_NEVER_SET_INPUTPORT)
_unsetInPort.push_back(end);
throw Exception(getErrRepr());
}
-void LinkInfo::pushErrSwitch(CollectorSwOutPort *collector) throw(YACS::Exception)
+void LinkInfo::pushErrSwitch(CollectorSwOutPort *collector)
{
_errorsOnSwitchCases.push_back(collector);
if(_level==0)
_uselessLinks.insert(pair<Node *,Node *>(start,end));
}
-void LinkInfo::takeDecision() const throw(YACS::Exception)
+void LinkInfo::takeDecision() const
{
if(!_errors.empty())
throw Exception(getErrRepr());
LinkInfo(unsigned char level);
void clearAll();
void startCollapseTransac();
- void endCollapseTransac() throw(Exception);
+ void endCollapseTransac();
void setPointOfView(ComposedNode *pov);
void pushInfoLink(OutPort *semStart, InPort *end, InfoReason reason);
void pushWarnLink(OutPort *semStart, InPort *end, WarnReason reason);
- void pushErrLink(OutPort *semStart, InPort *end, ErrReason reason) throw(Exception);
- void pushErrSwitch(CollectorSwOutPort *collector) throw(Exception);
+ void pushErrLink(OutPort *semStart, InPort *end, ErrReason reason);
+ void pushErrSwitch(CollectorSwOutPort *collector);
void pushUselessCFLink(Node *start, Node *end);
- void takeDecision() const throw(Exception);
+ void takeDecision() const;
//Typically methods for high level use.
std::string getGlobalRepr() const;
std::string getInfoRepr() const;
repr.insert(s.begin(),s.end());
}
-void *InputPort4DF2DS::get() const throw(YACS::Exception)
+void *InputPort4DF2DS::get() const
{
if(!_data)
{
_initValue->incrRef();
}
-void InputPort4DF2DS::put(const void *data) throw(ConversionException)
+void InputPort4DF2DS::put(const void *data)
{
put((Any *)data);
}
{
}
-InputPort *DFToDSForLoop::getInputPort(const std::string& name) const throw(YACS::Exception)
+InputPort *DFToDSForLoop::getInputPort(const std::string& name) const
{
try {
return Node::getInputPort(name);
return (*it);
}
-OutputDataStreamPort *DFToDSForLoop::getOutputDataStreamPort(const std::string& name) const throw(YACS::Exception)
+OutputDataStreamPort *DFToDSForLoop::getOutputDataStreamPort(const std::string& name) const
{
list<OutputDataStreamPort *>::const_iterator it =_setOfOutputDataStreamPort.begin();
return (*it);
(*iter)->getAllRepresented(represented);
}
-void OutputPort4DS2DF::put(const void *data) throw(ConversionException)
+void OutputPort4DS2DF::put(const void *data)
{
put((Any *)data);
OutputPort::put(data);
{
}
-OutputPort *DSToDFForLoop::getOutputPort(const std::string& name) const throw(YACS::Exception)
+OutputPort *DSToDFForLoop::getOutputPort(const std::string& name) const
{
list<OutputPort *>::const_iterator it = _setOfOutputPort.begin();
return (*it);
}
-InputDataStreamPort *DSToDFForLoop::getInputDataStreamPort(const std::string& name) const throw(YACS::Exception)
+InputDataStreamPort *DSToDFForLoop::getInputDataStreamPort(const std::string& name) const
{
list<InputDataStreamPort *>::const_iterator it = _setOfInputDataStreamPort.begin();
return (*it);
return ret;
}
-bool Loop::edAddChild(Node *node) throw(YACS::Exception)
+bool Loop::edAddChild(Node *node)
{
return edSetNode(node);
}
}
}
-void Loop::edRemoveChild(Node *node) throw(YACS::Exception)
+void Loop::edRemoveChild(Node *node)
{
StaticDefinedComposedNode::edRemoveChild(node);
if(_node==node)
_node->partitionRegardingDPL(pd,zeMap);
}
-Node *Loop::getChildByShortName(const std::string& name) const throw(YACS::Exception)
+Node *Loop::getChildByShortName(const std::string& name) const
{
if (_node)
if(name==_node->getName())
throw Exception(what);
}
-TypeCode* Loop::MappingDF2DS(TypeCode* type) throw(YACS::Exception)
+TypeCode* Loop::MappingDF2DS(TypeCode* type)
{
return type;
}
-TypeCode* Loop::MappingDS2DF(TypeCode* type) throw(YACS::Exception)
+TypeCode* Loop::MappingDS2DF(TypeCode* type)
{
return type;
}
port.first=(*iter)->getOutputDataStreamPort("");
}
-void Loop::getDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView) throw(YACS::Exception)
+void Loop::getDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView)
{
string typeOfPortInstance=port->getNameOfTypeOfCurrentInstance();
if(typeOfPortInstance!=InputPort::NAME ||
}
void Loop::getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget,
- const std::list<ComposedNode *>& pointsOfView) throw(YACS::Exception)
+ const std::list<ComposedNode *>& pointsOfView)
{
string typeOfPortInstance=(port.first)->getNameOfTypeOfCurrentInstance();
if(typeOfPortInstance!=OutputPort::NAME ||
port.first=(*iter)->getOutputDataStreamPort("");
}
-void Loop::releaseDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView) throw(YACS::Exception)
+void Loop::releaseDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView)
{
string typeOfPortInstance=port->getNameOfTypeOfCurrentInstance();
if(typeOfPortInstance!=InputPort::NAME ||
}
}
-void Loop::releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(YACS::Exception)
+void Loop::releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView)
{
if(portDwn==portUp)
return ;
}
}
-void Loop::checkNoCyclePassingThrough(Node *node) throw(YACS::Exception)
+void Loop::checkNoCyclePassingThrough(Node *node)
{
//throw Exception("Loop::checkNoCyclePassingThrough : Internal error occured");
}
* \param end : the InPort to connect
* \return true if a new link has been created, false otherwise.
*/
-bool Loop::edAddDFLink(OutPort *start, InPort *end) throw(YACS::Exception)
+bool Loop::edAddDFLink(OutPort *start, InPort *end)
{
return edAddLink(start,end);
}
fw[(ComposedNode *)this].push_back(start);
}
-void Loop::checkBasicConsistency() const throw(YACS::Exception)
+void Loop::checkBasicConsistency() const
{
DEBTRACE("Loop::checkBasicConsistency");
ComposedNode::checkBasicConsistency();
InputPort4DF2DS(DFToDSForLoop *node, TypeCode* type);
void getAllRepresentants(std::set<InPort *>& repr) const;
void releaseData() override;
- void put(const void *data) throw(ConversionException);
+ void put(const void *data);
InputPort *clone(Node *newHelder) const;
- void *get() const throw(Exception);
+ void *get() const ;
void exRestoreInit();
void exSaveInit();
void put(Any *data);
void loopHasOneMoreRef() { _nbOfTimeUsed++; }
bool loopHasOneLessRef() { return --_nbOfTimeUsed==0; }
void getReadyTasks(std::vector<Task *>& tasks);
- InputPort *getInputPort(const std::string& name) const throw(Exception);
- OutputDataStreamPort *getOutputDataStreamPort(const std::string& name) const throw(Exception);
+ InputPort *getInputPort(const std::string& name) const ;
+ OutputDataStreamPort *getOutputDataStreamPort(const std::string& name) const ;
Node *simpleClone(ComposedNode *father, bool editionOnly=true) const;
//run part
void execute();
public:
OutputPort4DS2DF(DSToDFForLoop *node, TypeCode *type);
void getAllRepresented(std::set<OutPort *>& represented) const;
- void put(const void *data) throw(ConversionException);
+ void put(const void *data);
OutputPort *clone(Node *newHelder) const;
void put(Any *data);
~OutputPort4DS2DF();
void loopHasOneMoreRef() { _nbOfTimeUsed++; }
bool loopHasOneLessRef() { return --_nbOfTimeUsed==0; }
void getReadyTasks(std::vector<Task *>& tasks);
- OutputPort *getOutputPort(const std::string& name) const throw(Exception);
- InputDataStreamPort *getInputDataStreamPort(const std::string& name) const throw(Exception);
+ OutputPort *getOutputPort(const std::string& name) const ;
+ InputDataStreamPort *getInputDataStreamPort(const std::string& name) const ;
//run part
void execute();
void load();
int getNbOfTurns() const { return _nbOfTurns; }
//Node* DISOWNnode is a SWIG notation to indicate that the ownership of the node is transfered to C++
Node *edSetNode(Node *DISOWNnode);
- virtual bool edAddChild(Node *DISOWNnode) throw(Exception);
+ virtual bool edAddChild(Node *DISOWNnode) ;
bool isLoop() const override { return true; }
Node *edRemoveNode();
- virtual void checkBasicConsistency() const throw(Exception);
+ virtual void checkBasicConsistency() const ;
//! Returns the port which value is used to take decision about the continuation of the loop.
virtual InputPort *getDecisionPort() const = 0;
void getReadyTasks(std::vector<Task *>& tasks);
- void edRemoveChild(Node *node) throw(Exception);
+ void edRemoveChild(Node *node) ;
bool isRepeatedUnpredictablySeveralTimes() const { return true; }
std::list<Node *> edGetDirectDescendants() const;
std::list<InputPort *> getSetOfInputPort() const;
int getMaxLevelOfParallelism() const;
void getWeightRegardingDPL(ComplexWeight *weight);
void partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap);
- Node *getChildByShortName(const std::string& name) const throw(Exception);
- static TypeCode* MappingDF2DS(TypeCode* type) throw(Exception);
- static TypeCode* MappingDS2DF(TypeCode* type) throw(Exception);
- virtual bool edAddDFLink(OutPort *start, InPort *end) throw(Exception);
+ Node *getChildByShortName(const std::string& name) const ;
+ static TypeCode* MappingDF2DS(TypeCode* type) ;
+ static TypeCode* MappingDS2DF(TypeCode* type) ;
+ virtual bool edAddDFLink(OutPort *start, InPort *end) ;
void writeDot(std::ostream &os) const;
virtual void accept(Visitor *visitor);
virtual std::string typeName() {return "YACS__ENGINE__Loop";}
protected:
void buildDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView);
void buildDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView);
- void getDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView) throw(Exception);
- void getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(Exception);
- void releaseDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView) throw(Exception);
- void releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(Exception);
- void checkNoCyclePassingThrough(Node *node) throw(Exception);
+ void getDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView) ;
+ void getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) ;
+ void releaseDelegateOf(InPort * & port, OutPort *initialStart, const std::list<ComposedNode *>& pointsOfView) ;
+ void releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) ;
+ void checkNoCyclePassingThrough(Node *node) ;
void checkControlDependancy(OutPort *start, InPort *end, bool cross,
std::map < ComposedNode *, std::list < OutPort * >, SortHierarc >& fw,
std::vector<OutPort *>& fwCross,
--- /dev/null
+// Copyright (C) 2006-2020 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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "NbBranches.hxx"
+
+using namespace YACS::ENGINE;
+
+const char NbBranchesAbstract::NAME_OF_NUMBER_OF_BRANCHES[]="nbBranches";
+
+bool NbBranchesAbstract::IsBranchPortName(const std::string& name)
+{
+ return name == NAME_OF_NUMBER_OF_BRANCHES;
+}
+
+std::unique_ptr<NbBranchesAbstract> NbBranches::copy(Node *node) const
+{
+ return std::unique_ptr<NbBranchesAbstract>(new NbBranches(*this,node));
+}
+
+int NbBranches::getNumberOfBranches(int) const
+{
+ return this->getIntValue();
+}
+
+bool NbBranches::isMyName(const std::string& name) const
+{
+ return NbBranchesAbstract::IsBranchPortName(name);
+}
+
+void NbBranches::exInit(bool start)
+{
+ _nbOfBranches.exInit(start);
+}
+
+InputPort *NbBranches::getPort() const
+{
+ return const_cast<AnyInputPort *>(&_nbOfBranches);
+}
+
+bool NbBranches::isMultiplicitySpecified(unsigned& value) const
+{
+ if(_nbOfBranches.edIsManuallyInitialized())
+ if(_nbOfBranches.edGetNumberOfLinks()==0)
+ {
+ value=_nbOfBranches.getIntValue();
+ return true;
+ }
+ return false;
+}
+
+void NbBranches::forceMultiplicity(unsigned value)
+{
+ _nbOfBranches.edRemoveAllLinksLinkedWithMe();
+ _nbOfBranches.edInit((int)value);
+}
+
+std::unique_ptr<NbBranchesAbstract> NoNbBranches::copy(Node *) const
+{
+ return std::unique_ptr<NbBranchesAbstract>(new NoNbBranches);
+}
+
+int NoNbBranches::getNumberOfBranches(int nbOfElems) const
+{
+ return nbOfElems;
+}
+
+void NoNbBranches::exInit(bool start)
+{
+}
+
+InputPort *NoNbBranches::getPort() const
+{
+ return nullptr;
+}
+
+bool NoNbBranches::isMultiplicitySpecified(unsigned& value) const
+{
+ return false;
+}
+
+void NoNbBranches::forceMultiplicity(unsigned value)
+{
+ throw Exception("NoNbBranches::forceMultiplicity : impossible to be forced !");
+}
+
+int NoNbBranches::getIntValue() const
+{
+ throw Exception("NoNbBranches::getIntValue : no value stored !");
+}
--- /dev/null
+// Copyright (C) 2006-2020 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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#pragma once
+
+#include "YACSlibEngineExport.hxx"
+#include "AnyInputPort.hxx"
+
+#include <memory>
+
+namespace YACS
+{
+ namespace ENGINE
+ {
+ class Node;
+ class YACSLIBENGINE_EXPORT NbBranchesAbstract
+ {
+ public:
+ virtual std::unique_ptr<NbBranchesAbstract> copy(Node *node) const = 0;
+ virtual int getNumberOfBranches(int nbOfElems) const = 0;
+ virtual bool isMyName(const std::string& name) const = 0;
+ virtual void exInit(bool start) = 0;
+ virtual InputPort *getPort() const = 0;
+ virtual bool isMultiplicitySpecified(unsigned& value) const = 0;
+ virtual void forceMultiplicity(unsigned value) = 0;
+ virtual int getIntValue() const = 0;
+ static bool IsBranchPortName(const std::string& name);
+ protected:
+ static const char NAME_OF_NUMBER_OF_BRANCHES[];
+ };
+
+ class YACSLIBENGINE_EXPORT NbBranches : public NbBranchesAbstract
+ {
+ public:
+ NbBranches(Node *node):_nbOfBranches(NAME_OF_NUMBER_OF_BRANCHES,node,Runtime::_tc_int) { }
+ NbBranches(const NbBranches& other, Node *node):_nbOfBranches(other._nbOfBranches,node) { }
+ bool isMyName(const std::string& name) const override;
+ std::unique_ptr<NbBranchesAbstract> copy(Node *node) const override;
+ int getNumberOfBranches(int nbOfElems) const override;
+ void exInit(bool start) override;
+ InputPort *getPort() const override;
+ bool isMultiplicitySpecified(unsigned& value) const override;
+ void forceMultiplicity(unsigned value) override;
+ int getIntValue() const override { return _nbOfBranches.getIntValue(); }
+ private:
+ AnyInputPort _nbOfBranches;
+ };
+
+ class YACSLIBENGINE_EXPORT NoNbBranches : public NbBranchesAbstract
+ {
+ public:
+ NoNbBranches() = default;
+ std::unique_ptr<NbBranchesAbstract> copy(Node *node) const override;
+ int getNumberOfBranches(int nbOfElems) const override;
+ bool isMyName(const std::string& name) const override { return false; }
+ void exInit(bool start) override;
+ InputPort *getPort() const override;
+ bool isMultiplicitySpecified(unsigned& value) const override;
+ void forceMultiplicity(unsigned value) override;
+ int getIntValue() const override;
+ };
+ }
+}
_outGate.exNotifyDisabled();
}
-InPort *Node::getInPort(const std::string& name) const throw(YACS::Exception)
+InPort *Node::getInPort(const std::string& name) const
{
InPort *ret;
try
}
InPropertyPort *
-Node::getInPropertyPort() const throw(YACS::Exception)
+Node::getInPropertyPort() const
{
return _inPropertyPort;
}
InputPort *
-Node::getInputPort(const std::string& name) const throw(YACS::Exception)
+Node::getInputPort(const std::string& name) const
{
if (name == "__InPropertyPort__Node__YACS_")
return _inPropertyPort;
* \note: Contrary to getOutputPort method, this method returns the output port at highest level, possible.
* That is to say in some ComposedNode, like ForEachLoop or Switch, an outport inside 'this' is seen differently than the true outport.
*/
-OutPort *Node::getOutPort(const std::string& name) const throw(YACS::Exception)
+OutPort *Node::getOutPort(const std::string& name) const
{
OutPort *ret;
try
return NULL;
}
-ComposedNode *Node::getRootNode() const throw(YACS::Exception)
+ComposedNode *Node::getRootNode() const
{
if(!_father)
throw Exception("No root node");
* USAGE NOT CLEAR, not used so far, when are those characters set ?
*/
-void Node::checkValidityOfPortName(const std::string& name) throw(YACS::Exception)
+void Node::checkValidityOfPortName(const std::string& name)
{
if(name.find(SEP_CHAR_IN_PORT, 0 )!=string::npos)
{
* @note : Check that 'node1' and 'node2' have exactly the same father
* @exception : If 'node1' and 'node2' have NOT exactly the same father
*/
-ComposedNode *Node::checkHavingCommonFather(Node *node1, Node *node2) throw(YACS::Exception)
+ComposedNode *Node::checkHavingCommonFather(Node *node1, Node *node2)
{
if(node1!=0 && node2!=0)
{
virtual std::list<OutputPort *> getLocalOutputPorts() const = 0;
virtual std::set<InputPort *> edGetSetOfUnitializedInputPort() const;
virtual bool edAreAllInputPortInitialized() const;
- virtual std::string getInPortName(const InPort *) const throw (Exception) = 0;
- virtual std::string getOutPortName(const OutPort *) const throw (Exception) = 0;
+ virtual std::string getInPortName(const InPort *) const = 0;
+ virtual std::string getOutPortName(const OutPort *) const = 0;
virtual std::list<InputDataStreamPort *> getSetOfInputDataStreamPort() const = 0;
virtual std::list<OutputDataStreamPort *> getSetOfOutputDataStreamPort() const = 0;
- InPort *getInPort(const std::string& name) const throw(Exception);
- InPropertyPort *getInPropertyPort() const throw(Exception);
- virtual OutPort *getOutPort(const std::string& name) const throw(Exception);
+ InPort *getInPort(const std::string& name) const;
+ InPropertyPort *getInPropertyPort() const;
+ virtual OutPort *getOutPort(const std::string& name) const;
virtual std::set<OutPort *> getAllOutPortsLeavingCurrentScope() const = 0;
virtual std::set<InPort *> getAllInPortsComingFromOutsideOfCurrentScope() const = 0;
virtual std::vector< std::pair<OutPort *, InPort *> > getSetOfLinksLeavingCurrentScope() const = 0;
virtual std::vector< std::pair<InPort *, OutPort *> > getSetOfLinksComingInCurrentScope() const =0;
- virtual InputPort *getInputPort(const std::string& name) const throw(Exception);
- virtual OutputPort *getOutputPort(const std::string& name) const throw(Exception) = 0;
- virtual InputDataStreamPort *getInputDataStreamPort(const std::string& name) const throw(Exception) = 0;
- virtual OutputDataStreamPort *getOutputDataStreamPort(const std::string& name) const throw(Exception) = 0;
+ virtual InputPort *getInputPort(const std::string& name) const;
+ virtual OutputPort *getOutputPort(const std::string& name) const = 0;
+ virtual InputDataStreamPort *getInputDataStreamPort(const std::string& name) const = 0;
+ virtual OutputDataStreamPort *getOutputDataStreamPort(const std::string& name) const = 0;
std::list<ComposedNode *> getAllAscendanceOf(ComposedNode *levelToStop = 0) const;
bool operator>(const Node& other) const;
bool operator<(const Node& other) const;
std::string getImplementation() const;
DynParaLoop *getClosestDPLAmongAncestors() const;
- virtual ComposedNode *getRootNode() const throw(Exception);
+ virtual ComposedNode *getRootNode() const;
virtual void setProperty(const std::string& name,const std::string& value);
virtual std::string getProperty(const std::string& name);
std::map<std::string,std::string> getProperties() ;
std::map<std::string,std::string> getPropertyMap() { return _propertyMap; }
virtual void setProperties(std::map<std::string,std::string> properties);
- virtual Node *getChildByName(const std::string& name) const throw(Exception) = 0;
+ virtual Node *getChildByName(const std::string& name) const = 0;
virtual Proc *getProc();
virtual const Proc *getProc() const;
virtual void accept(Visitor *visitor) = 0;
virtual void exForwardFailed();
virtual void exForwardFinished();
virtual void edDisconnectAllLinksWithMe();
- static void checkValidityOfPortName(const std::string& name) throw(Exception);
- static ComposedNode *checkHavingCommonFather(Node *node1, Node *node2) throw(Exception);
+ static void checkValidityOfPortName(const std::string& name);
+ static ComposedNode *checkHavingCommonFather(Node *node1, Node *node2);
public:
static void checkValidityOfNodeName(const std::string& name);
};
{
}
-void OptimizerAlgBase::initialize(const Any *input) throw (YACS::Exception)
+void OptimizerAlgBase::initialize(const Any *input)
{
}
return getTCForAlgoResult();
}
-void OptimizerAlgBase::initializeProxy(const Any *input) throw (YACS::Exception)
+void OptimizerAlgBase::initializeProxy(const Any *input)
{
initialize(input);
}
virtual TypeCode *getTCForAlgoInit() const;
//! returns typecode of type expected as algo result. OwnerShip of returned pointer is held by this.
virtual TypeCode *getTCForAlgoResult() const;
- virtual void initialize(const Any *input) throw (Exception);
+ virtual void initialize(const Any *input) ;
virtual void start() = 0;//! Update _pool attribute before performing anything.
virtual void takeDecision() = 0;//! _pool->getCurrentId gives the \b id at the origin of this call.
//! Perform the job of analysing to know what new jobs to do (_pool->pushInSample)
virtual TypeCode *getTCForOutProxy() const;
virtual TypeCode *getTCForAlgoInitProxy() const;
virtual TypeCode *getTCForAlgoResultProxy() const;
- virtual void initializeProxy(const Any *input) throw (Exception);
+ virtual void initializeProxy(const Any *input) ;
virtual void startProxy();
virtual void takeDecisionProxy();
virtual void finishProxy();
OptimizerLoop::OptimizerLoop(const std::string& name, const std::string& algLibWthOutExt,
const std::string& symbolNameToOptimizerAlgBaseInstanceFactory,
bool algInitOnFile,bool initAlgo, Proc * procForTypes):
- DynParaLoop(name,Runtime::_tc_string),_algInitOnFile(algInitOnFile),_alglib(algLibWthOutExt),
+ DynParaLoop(name,Runtime::_tc_string,std::unique_ptr<NbBranchesAbstract>(new NbBranches(this))),_algInitOnFile(algInitOnFile),_alglib(algLibWthOutExt),
_algoInitPort(NAME_OF_ALGO_INIT_PORT, this, Runtime::_tc_string, true),
_loader(NULL),_alg(0),_convergenceReachedWithOtherCalc(false),
_retPortForOutPool(NAME_OF_OUT_POOL_INPUT,this,Runtime::_tc_string),
//internal graph update
int i;
- int nbOfBr=_nbOfBranches.getIntValue();
+ int nbOfBr=_nbOfBranches->getIntValue();
_alg->setNbOfBranches(nbOfBr);
_alg->startProxy();
return DynParaLoop::getNumberOfInputPorts()+2;
}
-InputPort *OptimizerLoop::getInputPort(const std::string& name) const throw(YACS::Exception)
+InputPort *OptimizerLoop::getInputPort(const std::string& name) const
{
if (name == NAME_OF_ALGO_INIT_PORT)
return (InputPort *)&_algoInitPort;
{
// Run the finalize nodes, the OptimizerLoop will be done only when they all finish
_unfinishedCounter = 0; // This counter indicates how many branches are not finished
- for (int i=0 ; i<_nbOfBranches.getIntValue() ; i++)
+ for (int i=0 ; i<_nbOfBranches->getIntValue() ; i++)
if (_execIds[i] == NOT_RUNNING_BRANCH_ID)
{
DEBTRACE("Launching finalize node for branch " << i)
return DynParaLoop::updateStateOnFailedEventFrom(node,execInst);
}
-void OptimizerLoop::checkNoCyclePassingThrough(Node *node) throw(YACS::Exception)
+void OptimizerLoop::checkNoCyclePassingThrough(Node *node)
{
}
}
void OptimizerLoop::checkLinkPossibility(OutPort *start, const std::list<ComposedNode *>& pointsOfViewStart,
- InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) throw(YACS::Exception)
+ InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd)
{
DynParaLoop::checkLinkPossibility(start, pointsOfViewStart, end, pointsOfViewEnd);
std::string linkName("(");
linkName += start->getName()+" to "+end->getName()+")";
// Yes, it should be possible to link back the result port to any input port of the loop.
- if(end == &_nbOfBranches || end == &_algoInitPort)
+ if(end == _nbOfBranches->getPort() || end == &_algoInitPort)
if(start != &_algoResultPort)
throw Exception(std::string("Illegal OptimizerLoop link.") + linkName);
else
/*!
* Throw an exception if the node is not valid
*/
-void OptimizerLoop::checkBasicConsistency() const throw(YACS::Exception)
+void OptimizerLoop::checkBasicConsistency() const
{
DEBTRACE("OptimizerLoop::checkBasicConsistency");
if (_alglib == "")
return ret;
}
-OutPort * OptimizerLoop::getOutPort(const std::string& name) const throw(YACS::Exception)
+OutPort * OptimizerLoop::getOutPort(const std::string& name) const
{
return (name == NAME_OF_ALGO_RESULT_PORT) ? (OutPort *)&_algoResultPort :
DynParaLoop::getOutPort(name);
}
-OutputPort * OptimizerLoop::getOutputPort(const std::string& name) const throw(YACS::Exception)
+OutputPort * OptimizerLoop::getOutputPort(const std::string& name) const
{
return (name == NAME_OF_ALGO_RESULT_PORT) ? (OutputPort *)&_algoResultPort :
DynParaLoop::getOutputPort(name);
InputPort *edGetPortForOutPool() { return &_retPortForOutPool; }
InputPort *edGetAlgoInitPort() { return &_algoInitPort; }
OutputPort *edGetAlgoResultPort() { return &_algoResultPort; }
- InputPort *getInputPort(const std::string& name) const throw(Exception);
+ InputPort *getInputPort(const std::string& name) const ;
std::list<InputPort *> getSetOfInputPort() const;
std::list<InputPort *> getLocalInputPorts() const;
void selectRunnableTasks(std::vector<Task *>& tasks);
void getReadyTasks(std::vector<Task *>& tasks);
YACS::Event updateStateOnFinishedEventFrom(Node *node);
- void checkNoCyclePassingThrough(Node *node) throw(Exception);
+ void checkNoCyclePassingThrough(Node *node) ;
virtual void accept(Visitor *visitor);
virtual std::string getSymbol() const { return _symbol; }
virtual std::string getAlgLib() const ;
virtual void setAlgorithm(const std::string& alglib,const std::string& symbol,
bool checkLinks=true, Proc * procForTypes = NULL);
- virtual void checkBasicConsistency() const throw(Exception);
+ virtual void checkBasicConsistency() const ;
virtual std::string typeName() {return "YACS__ENGINE__OptimizerLoop";}
int getNumberOfOutputPorts() const;
std::list<OutputPort *> getSetOfOutputPort() const;
std::list<OutputPort *> getLocalOutputPorts() const;
- OutPort *getOutPort(const std::string& name) const throw(Exception);
- OutputPort *getOutputPort(const std::string& name) const throw(Exception);
+ OutPort *getOutPort(const std::string& name) const ;
+ OutputPort *getOutputPort(const std::string& name) const ;
YACS::Event finalize();
protected:
virtual YACS::Event updateStateOnFailedEventFrom(Node *node, const Executor *execInst);
LinkInfo& info) const;
void checkCFLinks(const std::list<OutPort *>& starts, InputPort *end, unsigned char& alreadyFed, bool direction, LinkInfo& info) const;
void checkLinkPossibility(OutPort *start, const std::list<ComposedNode *>& pointsOfViewStart,
- InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) throw(Exception);
+ InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) ;
protected:
void cleanInterceptors();
void launchMaxOfSamples(bool first);
return ret;
}
-void OutGate::edRemoveInGate(InGate *inGate, bool coherenceWithInGate) throw(YACS::Exception)
+void OutGate::edRemoveInGate(InGate *inGate, bool coherenceWithInGate)
{
std::list< pair<InGate* , bool> >::iterator iter(std::find_if(_setOfInGate.begin(),_setOfInGate.end(),ItemCmp(inGate)));
if(iter==_setOfInGate.end())
bool edAddInGate(InGate *inGate);
std::list< std::pair< InGate *, bool> >& edMapInGate() { return _setOfInGate; }
std::list<InGate *> edSetInGate() const;
- void edRemoveInGate(InGate *inGate, bool coherenceWithInGate=true) throw(Exception);
+ void edRemoveInGate(InGate *inGate, bool coherenceWithInGate=true);
int getNbOfInGatesConnected() const;
bool isAlreadyInSet(InGate *inGate) const;
virtual std::string typeName() {return "YACS__ENGINE__OutGate";}
virtual std::set<InPort *> edSetInPort() const = 0;
virtual bool isAlreadyLinkedWith(InPort *withp) const = 0;
virtual void getAllRepresented(std::set<OutPort *>& represented) const;
- virtual bool addInPort(InPort *inPort) throw(Exception) = 0;
- virtual int removeInPort(InPort *inPort, bool forward) throw(Exception) = 0;
+ virtual bool addInPort(InPort *inPort) = 0;
+ virtual int removeInPort(InPort *inPort, bool forward) = 0;
virtual ~OutPort();
std::vector<DataPort *> calculateHistoryOfLinkWith(InPort *end);
virtual std::string typeName() {return "YACS__ENGINE__OutPort";}
}
bool OutputDataStreamPort::edAddInputDataStreamPort(InputDataStreamPort *port)
- throw(ConversionException)
{
DEBTRACE("OutputDataStreamPort::edAddInputDataStreamPort");
if(!isAlreadyInSet(port))
return false;
}
-int OutputDataStreamPort::edRemoveInputDataStreamPort(InputDataStreamPort *inPort, bool forward) throw(YACS::Exception)
+int OutputDataStreamPort::edRemoveInputDataStreamPort(InputDataStreamPort *inPort, bool forward)
{
if(forward)
{
}
}
-bool OutputDataStreamPort::addInPort(InPort *inPort) throw(YACS::Exception)
+bool OutputDataStreamPort::addInPort(InPort *inPort)
{
DEBTRACE("OutputDataStreamPort::addInPort");
if(inPort->getNameOfTypeOfCurrentInstance()!=InputDataStreamPort::NAME)
return edAddInputDataStreamPort(static_cast<InputDataStreamPort*>(inPort));
}
-void OutputDataStreamPort::edRemoveAllLinksLinkedWithMe() throw(YACS::Exception)
+void OutputDataStreamPort::edRemoveAllLinksLinkedWithMe()
{
set<InputDataStreamPort *>::iterator iter;
set<InputDataStreamPort *> vec(_setOfInputDataStreamPort);
_setOfInputDataStreamPort.clear();
}
-int OutputDataStreamPort::removeInPort(InPort *inPort, bool forward) throw(YACS::Exception)
+int OutputDataStreamPort::removeInPort(InPort *inPort, bool forward)
{
DEBTRACE("OutputDataStreamPort::removeInPort");
if(inPort->getNameOfTypeOfCurrentInstance()!=InputDataStreamPort::NAME && !forward)
std::set<InPort *> edSetInPort() const;
bool isAlreadyLinkedWith(InPort *withp) const;
virtual std::string getNameOfTypeOfCurrentInstance() const;
- virtual bool addInPort(InPort *inPort) throw(Exception);
- virtual bool edAddInputDataStreamPort(InputDataStreamPort *port) throw(ConversionException);
- int edRemoveInputDataStreamPort(InputDataStreamPort *inPort, bool forward) throw(Exception);
- void edRemoveAllLinksLinkedWithMe() throw(Exception);
- int removeInPort(InPort *inPort, bool forward) throw(Exception);
+ virtual bool addInPort(InPort *inPort) ;
+ virtual bool edAddInputDataStreamPort(InputDataStreamPort *port);
+ int edRemoveInputDataStreamPort(InputDataStreamPort *inPort, bool forward) ;
+ void edRemoveAllLinksLinkedWithMe() ;
+ int removeInPort(InPort *inPort, bool forward) ;
virtual std::string typeName() {return "YACS__ENGINE__OutputDataStreamPort";}
private:
bool isAlreadyInSet(InputDataStreamPort *inPort) const;
return NAME;
}
-void OutputPort::edRemoveAllLinksLinkedWithMe() throw(YACS::Exception)
+void OutputPort::edRemoveAllLinksLinkedWithMe()
{
set<InputPort *>::iterator iter;
set<InputPort *> vec(_setOfInputPort);
{
}
-void OutputPort::put(const void *data) throw(ConversionException)
+void OutputPort::put(const void *data)
{
for(set<InputPort *>::iterator iter = _setOfInputPort.begin(); iter != _setOfInputPort.end(); iter++)
(*iter)->put(data);
/**
* check if output type is an input type and if a data converter exists before link
*/
-bool OutputPort::edAddInputPort(InputPort *phyPort) throw(YACS::Exception)
+bool OutputPort::edAddInputPort(InputPort *phyPort)
{
DEBTRACE("OutputPort::edAddInputPort");
if(!isAlreadyInSet(phyPort))
return false;
}
-bool OutputPort::edAddInPropertyPort(InPropertyPort *phyPort) throw(YACS::Exception)
+bool OutputPort::edAddInPropertyPort(InPropertyPort *phyPort)
{
DEBTRACE("OutputPort::edAddInPropertyPort");
if(!isAlreadyInSet(phyPort))
* If 'forward' == true the forward deletion
* If 'forward' == false no forward deletion performed, oneway deletion without update 'inputPort' side.
*/
-int OutputPort::edRemoveInputPort(InputPort *inputPort, bool forward) throw(YACS::Exception)
+int OutputPort::edRemoveInputPort(InputPort *inputPort, bool forward)
{
if(forward)
{
/**
* check compatibility of port class ( an inputPort ) before trying to create the link.
*/
-bool OutputPort::addInPort(InPort *inPort) throw(YACS::Exception)
+bool OutputPort::addInPort(InPort *inPort)
{
DEBTRACE("OutputPort::addInPort");
if(inPort->getNameOfTypeOfCurrentInstance()!=InputPort::NAME &&
/**
* check compatibility of port class ( an inputPort ) before trying to remove link WITHOUT forward.
*/
-int OutputPort::removeInPort(InPort *inPort, bool forward) throw(YACS::Exception)
+int OutputPort::removeInPort(InPort *inPort, bool forward)
{
if(inPort->getNameOfTypeOfCurrentInstance()!=InputPort::NAME && !forward)
{
}
//! Check validity of output port. Nothing on base class
-void OutputPort::checkBasicConsistency() const throw(YACS::Exception)
+void OutputPort::checkBasicConsistency() const
{
}
bool isAlreadyInSet(InputPort *inputPort) const;
bool isConnected() const;
std::string getNameOfTypeOfCurrentInstance() const;
- int removeInPort(InPort *inPort, bool forward) throw(Exception);
- virtual bool edAddInputPort(InputPort *phyPort) throw(Exception);
- virtual bool edAddInPropertyPort(InPropertyPort *phyPort) throw(Exception);
- virtual int edRemoveInputPort(InputPort *inputPort, bool forward) throw(Exception);
- bool addInPort(InPort *inPort) throw(Exception);
- void edRemoveAllLinksLinkedWithMe() throw(Exception);//entry point for forward port deletion
+ int removeInPort(InPort *inPort, bool forward) ;
+ virtual bool edAddInputPort(InputPort *phyPort) ;
+ virtual bool edAddInPropertyPort(InPropertyPort *phyPort) ;
+ virtual int edRemoveInputPort(InputPort *inputPort, bool forward) ;
+ bool addInPort(InPort *inPort) ;
+ void edRemoveAllLinksLinkedWithMe() ;//entry point for forward port deletion
virtual void exInit();
- virtual void checkBasicConsistency() const throw(Exception);
+ virtual void checkBasicConsistency() const ;
virtual OutputPort *clone(Node *newHelder) const = 0;
virtual std::string dump();
- virtual void put(const void *data) throw(ConversionException);
+ virtual void put(const void *data);
virtual std::string typeName() {return "YACS__ENGINE__OutputPort";}
protected:
#include <sstream>
#include <iomanip>
#include <numeric>
+#include <iostream>
#include <algorithm>
using namespace YACS::ENGINE;
+std::size_t Resource::getNumberOfFreePlace(int nbCoresPerCont) const
+{
+ std::size_t ret(0),pos(0);
+ while( pos < _occupied.size() )
+ {
+ bool isChunckFree(true);
+ int posInChunck(0);
+ for( ; ( posInChunck < nbCoresPerCont ) && ( pos < _occupied.size() ) ; ++posInChunck, ++pos)
+ if(_occupied[pos])
+ isChunckFree = false;
+ if( isChunckFree && (posInChunck == nbCoresPerCont) )
+ ret++;
+ }
+ return ret;
+}
+
+std::vector<std::size_t> Resource::allocateFor(std::size_t& nbOfPlacesToTake, int nbCoresPerCont) const
+{
+ std::vector<std::size_t> ret;
+ std::size_t pos(0),curWorkerId(0);
+ while( ( pos < _occupied.size() ) && ( nbOfPlacesToTake > 0 ) )
+ {
+ bool isChunckFree(true);
+ int posInChunck(0);
+ for( ; ( posInChunck < nbCoresPerCont ) && ( pos < _occupied.size() ) ; ++posInChunck, ++pos)
+ if(_occupied[pos])
+ isChunckFree = false;
+ if( isChunckFree && (posInChunck == nbCoresPerCont) )
+ {
+ for(int i = 0 ; i < nbCoresPerCont ; ++i)
+ _occupied[pos-nbCoresPerCont+i] = true;
+ ret.push_back(curWorkerId);
+ --nbOfPlacesToTake;
+ }
+ ++curWorkerId;
+ }
+ return ret;
+}
+
+void Resource::release(std::size_t workerId, int nbCoresPerCont) const
+{
+ if(workerId >= this->getNumberOfWorkers(nbCoresPerCont))
+ throw Exception("Resource::release : invalid worker id !");
+ std::size_t pos(workerId*static_cast<std::size_t>(nbCoresPerCont));
+ for(int i = 0 ; i < nbCoresPerCont ; ++i)
+ {
+ if(!_occupied[pos + static_cast<std::size_t>(i)])
+ throw Exception("Resource::release : internal error ! A core is expected to be occupied !");
+ _occupied[pos + static_cast<std::size_t>(i)] = false;
+ }
+}
+
+std::size_t Resource::getNumberOfWorkers(int nbCoresPerCont) const
+{
+ return static_cast<std::size_t>(this->nbCores())/static_cast<std::size_t>(nbCoresPerCont);
+}
+
+void Resource::printSelf(std::ostream& oss) const
+{
+ oss << this->name() << " (" << this->nbCores() << ") : ";
+ for(auto it : this->_occupied)
+ {
+ if(it)
+ oss << "1";
+ else
+ oss << "0";
+ }
+}
std::string PlayGround::printSelf() const
{
std::ostringstream oss;
std::size_t sz(0);
- for(std::vector< std::pair<std::string,int> >::const_iterator it=_data.begin();it!=_data.end();it++)
- sz=std::max(sz,(*it).first.length());
- for(std::vector< std::pair<std::string,int> >::const_iterator it=_data.begin();it!=_data.end();it++)
+ for(auto it : _data)
+ sz=std::max(sz,it.name().length());
+ for(auto it : _data)
{
- oss << " - " << std::setw(10) << (*it).first << " : " << (*it).second << std::endl;
+ oss << " - " << std::setw(10) << it.name() << " : " << it.nbCores() << std::endl;
}
return oss.str();
}
void PlayGround::setData(const std::vector< std::pair<std::string,int> >& defOfRes)
{
- _data=defOfRes;
+ _data=std::vector<Resource>(defOfRes.begin(),defOfRes.end());
checkCoherentInfo();
}
int PlayGround::getNumberOfCoresAvailable() const
{
int ret(0);
- for(std::vector< std::pair<std::string,int> >::const_iterator it=_data.begin();it!=_data.end();it++)
- ret+=(*it).second;
+ for(auto it : _data)
+ ret+=it.nbCores();
return ret;
}
if(nbCoresPerCont<1)
throw Exception("PlayGround::getMaxNumberOfContainersCanBeHostedWithoutOverlap : invalid nbCoresPerCont. Must be >=1 !");
int ret(0);
- for(std::vector< std::pair<std::string,int> >::const_iterator it=_data.begin();it!=_data.end();it++)
- ret+=(*it).second/nbCoresPerCont;
+ for(auto it : _data)
+ ret+=it.nbCores()/nbCoresPerCont;
return ret;
}
{
std::size_t sz(_data.size()),i(0);
std::vector<int> ret(sz+1); ret[0]=0;
- for(std::vector< std::pair<std::string,int> >::const_iterator it=_data.begin();it!=_data.end();it++,i++)
- ret[i+1]=ret[i]+(*it).second;
+ for(auto it=_data.begin();it!=_data.end();it++,i++)
+ ret[i+1]=ret[i]+it->nbCores();
return ret;
}
void PlayGround::checkCoherentInfo() const
{
std::set<std::string> s;
- for(std::vector< std::pair<std::string,int> >::const_iterator it=_data.begin();it!=_data.end();it++)
+ for(auto it : _data)
{
- s.insert((*it).first);
- if((*it).second<0)
+ s.insert(it.name());
+ if(it.nbCores()<0)
throw Exception("Presence of negative int value !");
}
if(s.size()!=_data.size())
return ret;
}
+std::size_t PlayGround::getNumberOfFreePlace(int nbCoresPerCont) const
+{
+ std::size_t ret(0);
+ for(auto res : _data)
+ {
+ ret += res.getNumberOfFreePlace(nbCoresPerCont);
+ }
+ return ret;
+}
+
+std::vector<std::size_t> PlayGround::allocateFor(std::size_t nbOfPlacesToTake, int nbCoresPerCont) const
+{
+ std::vector<std::size_t> ret;
+ std::size_t nbOfPlacesToTakeCpy(nbOfPlacesToTake),offset(0);
+ for(const auto& res : _data)
+ {
+ std::vector<std::size_t> contIdsInRes(res.allocateFor(nbOfPlacesToTakeCpy,nbCoresPerCont));
+ std::for_each(contIdsInRes.begin(),contIdsInRes.end(),[offset](std::size_t& val) { val += offset; });
+ ret.insert(ret.end(),contIdsInRes.begin(),contIdsInRes.end());
+ offset += static_cast<std::size_t>(res.nbCores()/nbCoresPerCont);
+ }
+ if( ( nbOfPlacesToTakeCpy!=0 ) || ( ret.size()!=nbOfPlacesToTake ) )
+ throw Exception("PlayGround::allocateFor : internal error ! Promised place is not existing !");
+ return ret;
+}
+
+void PlayGround::release(std::size_t workerId, int nbCoresPerCont) const
+{
+ std::size_t offset(0);
+ for(const auto& res : _data)
+ {
+ std::size_t nbOfWorker(static_cast<std::size_t>(res.nbCores()/nbCoresPerCont));
+ std::size_t minId(offset),maxId(offset+nbOfWorker);
+ if(workerId>=minId && workerId<maxId)
+ {
+ res.release(workerId-minId,nbCoresPerCont);
+ break;
+ }
+ }
+}
+
+void PlayGround::printMe() const
+{
+ for(auto it : _data)
+ {
+ it.printSelf(std::cout);
+ std::cout << std::endl;
+ }
+}
+
std::vector<int> PlayGround::BuildVectOfIdsFromVecBool(const std::vector<bool>& v)
{
std::size_t sz(std::count(v.begin(),v.end(),true)),i(0);
{
std::size_t posBg(0),posWorker(0);
std::vector<std::size_t> ret;
- for(std::vector< std::pair<std::string,int> >::const_iterator it=_data.begin();it!=_data.end();it++)
+ for(auto it : _data)
{
- int nbWorker((*it).second/nbCoresPerComp);
+ int nbWorker(it.nbCores()/nbCoresPerComp);
for(int j=0;j<nbWorker;j++,posWorker++)
{
std::vector<bool>::const_iterator it2(std::find(coreFlags.begin()+posBg+j*nbCoresPerComp,coreFlags.begin()+posBg+(j+1)*nbCoresPerComp,false));
if(it2==coreFlags.begin()+posBg+(j+1)*nbCoresPerComp)
ret.push_back(posWorker);
}
- posBg+=(*it).second;
+ posBg+=it.nbCores();
}
return ret;
}
std::size_t sz2(_data.size());
std::vector<int> deltas(sz2+1); deltas[0]=0;
for(std::size_t i=0;i<sz2;i++)
- deltas[i+1]=deltas[i]+(_data[i].second)/nbProcPerNode;
+ deltas[i+1]=deltas[i]+(_data[i].nbCores())/nbProcPerNode;
int zePos(0);
while(zePos<sz2 && (workerId<deltas[zePos] || workerId>=deltas[zePos+1]))
zePos++;
std::string PlayGround::deduceMachineFrom(int workerId, int nbProcPerNode) const
{
int zePos(fromWorkerIdToResId(workerId,nbProcPerNode));
- return _data[zePos].first;
+ return _data[zePos].name();
}
/*!
#include <vector>
#include <string>
+#include <mutex>
#include <map>
namespace YACS
{
namespace ENGINE
{
- class PartDefinition;
+ class PartDefinition;
+
+ class YACSLIBENGINE_EXPORT Resource
+ {
+ public:
+ Resource(const std::string& name, int nbCores):_name(name),_nbCores(nbCores),_occupied(_nbCores,false) { }
+ Resource(const std::pair<std::string,int>& p):_name(p.first),_nbCores(p.second),_occupied(_nbCores,false) { }
+ std::pair<std::string,int> toPair() const { return {_name,_nbCores}; }
+ int nbCores() const { return _nbCores; }
+ std::string name() const { return _name; }
+ std::size_t getNumberOfFreePlace(int nbCoresPerCont) const;
+ std::vector<std::size_t> allocateFor(std::size_t& nbOfPlacesToTake, int nbCoresPerCont) const;
+ void release(std::size_t workerId, int nbCoresPerCont) const;
+ std::size_t getNumberOfWorkers(int nbCoresPerCont) const;
+ void printSelf(std::ostream& oss) const;
+ private:
+ std::string _name;
+ int _nbCores;
+ mutable std::vector<bool> _occupied;
+ };
+
+
+ class ResourceIterator : public std::iterator<
+ std::input_iterator_tag, // iterator_category
+ Resource, // value_type
+ long, // difference_type
+ const Resource*, // pointer
+ std::pair<std::string,int> > // reference
+ {
+ const std::vector< Resource > *_vec;
+ std::size_t _num;
+ public:
+ explicit ResourceIterator(const std::vector< Resource > *vec, const std::size_t num) : _vec(vec),_num(num) { }
+ ResourceIterator& operator++() { _num++; return *this; }
+ bool operator==(ResourceIterator other) const { return _num == other._num; }
+ bool operator!=(ResourceIterator other) const { return !(*this == other); }
+ reference operator*() const { return (*_vec)[_num].toPair(); }
+ };
class YACSLIBENGINE_EXPORT PlayGround : public RefCounter
{
public:
- PlayGround(const std::vector< std::pair<std::string,int> >& defOfRes):_data(defOfRes) { checkCoherentInfo(); }
+ PlayGround(const std::vector< std::pair<std::string,int> >& defOfRes):_data(defOfRes.begin(),defOfRes.end()) { checkCoherentInfo(); }
PlayGround() { }
std::string printSelf() const;
void loadFromKernelCatalog();
- std::vector< std::pair<std::string,int> > getData() const { return _data; }
+ std::vector< std::pair<std::string,int> > getData() const { return std::vector< std::pair<std::string,int> >(ResourceIterator(&_data,0),ResourceIterator(&_data,_data.size())); }
void setData(const std::vector< std::pair<std::string,int> >& defOfRes);
int getNumberOfCoresAvailable() const;
int getMaxNumberOfContainersCanBeHostedWithoutOverlap(int nbCoresPerCont) const;
std::vector<std::size_t> getWorkerIdsFullyFetchedBy(int nbCoresPerComp, const std::vector<bool>& coreFlags) const;
static std::vector<int> BuildVectOfIdsFromVecBool(const std::vector<bool>& v);
static std::vector<int> GetIdsMatching(const std::vector<bool>& bigArr, const std::vector<bool>& pat);
+ public:// critical section part
+ std::size_t getNumberOfFreePlace(int nbCoresPerCont) const;
+ std::vector<std::size_t> allocateFor(std::size_t nbOfPlacesToTake, int nbCoresPerCont) const;
+ void release(std::size_t workerId, int nbCoresPerCont) const;
+ std::mutex& getLocker() const { return _locker; }
+ void printMe() const;
private:
std::vector< std::pair <const ComplexWeight *, int> > bigToTiny(const std::vector< std::pair <const ComplexWeight *, int> > &weights, std::map<int,int> &saveOrder) const;
std::vector< std::vector<int> > backToOriginalOrder(const std::vector< std::vector<int> > &disorderVec, const std::map<int,int> &saveOrder) const;
private:
~PlayGround();
private:
- std::vector< std::pair<std::string,int> > _data;
+ mutable std::mutex _locker;
+ std::vector< Resource > _data;
};
class YACSLIBENGINE_EXPORT PartDefinition : public RefCounter
rien = solv->next();
}
-void PluginSimplex::initialize(const Any *input) throw(YACS::Exception)
+void PluginSimplex::initialize(const Any *input)
{
}
void parseFileToInit(const std::string& fileName);
void start();
void takeDecision();
- void initialize(const Any *input) throw(Exception);
+ void initialize(const Any *input) ;
void finish();
};
}
* corrupted 'this'.
*
*/
-void Pool::checkConsistency() throw(YACS::Exception)
+void Pool::checkConsistency()
{
// First check unicity of ids.
std::set<int> ids;
/*!
* \throw See the \b throw case of pushOutSampleAt method.
*/
-void Pool::setCurrentId(int id) throw(YACS::Exception)
+void Pool::setCurrentId(int id)
{
std::list< std::pair<int, ExpData> >::iterator iter;
for(iter=_container.begin();iter!=_container.end();iter++)
* has destroyed a case id different from its id.
*
*/
-void Pool::putOutSampleAt(int id, Any *outValue) throw(YACS::Exception)
+void Pool::putOutSampleAt(int id, Any *outValue)
{
std::list< std::pair<int, ExpData> >::iterator iter;
for(iter=_container.begin();iter!=_container.end();iter++)
private:
//For OptimizerNode use
void destroyCurrentCase();
- void checkConsistency() throw(Exception);
- void setCurrentId(int id) throw(Exception);
- void putOutSampleAt(int id, Any *outValue) throw(Exception);
+ void checkConsistency() ;
+ void setCurrentId(int id) ;
+ void putOutSampleAt(int id, Any *outValue) ;
Any *getNextSampleWithHighestPriority(int& id, unsigned char& priority) const;
void markIdAsInUse(int id);
bool empty() const;
// singleton creation must be done before by a derived class
-Runtime* YACS::ENGINE::getRuntime() throw(Exception)
+Runtime* YACS::ENGINE::getRuntime()
{
if ( ! Runtime::_singleton )
throw Exception("Runtime is not yet initialized");
return ret;
}
+ForEachLoopDyn* Runtime::createForEachLoopDyn(const std::string& name,TypeCode * type)
+{
+ return new ForEachLoopDyn(name,type);
+}
+
OptimizerLoop* Runtime::createOptimizerLoop(const std::string& name,const std::string& algLib,const std::string& factoryName,bool algInitOnFile,
const std::string& kind, Proc * procForTypes)
{
namespace ENGINE
{
class Runtime;
- YACSLIBENGINE_EXPORT Runtime* getRuntime() throw(Exception);
+ YACSLIBENGINE_EXPORT Runtime* getRuntime() ;
class Any;
class InputPort;
class InPropertyPort;
class ForLoop;
class ForEachLoop;
+ class ForEachLoopDyn;
class OptimizerLoop;
class WhileLoop;
class Switch;
class YACSLIBENGINE_EXPORT Runtime
{
- friend Runtime* getRuntime() throw(Exception);
+ friend Runtime* getRuntime() ;
public:
virtual void init() { }
virtual void fini() { }
virtual WhileLoop* createWhileLoop(const std::string& name);
virtual ForLoop* createForLoop(const std::string& name);
virtual ForEachLoop* createForEachLoop(const std::string& name,TypeCode * type);
+ virtual ForEachLoopDyn* createForEachLoopDyn(const std::string& name,TypeCode * type);
virtual OptimizerLoop* createOptimizerLoop(const std::string& name,const std::string& algLib,
const std::string& factoryName,bool algInitOnFile,
const std::string& kind="", Proc * procForTypes = NULL);
TypeCode * type);
virtual InputPort* adapt(InputPort* source, const std::string& impl, TypeCode * type,
- bool init=false) throw (ConversionException) = 0;
+ bool init=false) = 0;
virtual InputPort* adapt(InPropertyPort* source,
const std::string& impl,
TypeCode * type,
- bool init=false) throw (ConversionException) = 0;
+ bool init=false) = 0;
virtual void* convertNeutral(TypeCode * type, Any *data);
virtual std::string convertNeutralAsString(TypeCode * type, Any *data);
virtual bool isPlacementPredictableB4Run() const = 0;
virtual bool isMultiplicitySpecified(unsigned& value) const = 0;
virtual void forceMultiplicity(unsigned value) = 0;
+ virtual void setProperty(const std::string& name,const std::string& value)=0;
+ virtual std::string getProperty(const std::string& name)=0;
virtual ~Scheduler();
};
}
}
//! Associate an existing component instance to this service node \b AND check the consistency regarding the deployment from root node point of view.
-void ServiceNode::setComponent(ComponentInstance* compo) throw(YACS::Exception)
+void ServiceNode::setComponent(ComponentInstance* compo)
{
DEBTRACE("ServiceNode::setComponent " << compo);
if(compo)
public:
virtual void load();
virtual bool isDeployable() const;
- virtual void setComponent(ComponentInstance* compo) throw(Exception);
+ virtual void setComponent(ComponentInstance* compo) ;
virtual ComponentInstance *getComponent();
virtual const ComponentInstance *getComponent() const;
virtual Container *getContainer();
return _className;
}
-void CollectorSwOutPort::edRemoveAllLinksLinkedWithMe() throw(YACS::Exception)
+void CollectorSwOutPort::edRemoveAllLinksLinkedWithMe()
{
map<int, OutPort *>::iterator pt;
if(_consumer)
((*pt).second)->getAllRepresented(represented);
}
-bool CollectorSwOutPort::addInPort(InPort *inPort) throw(YACS::Exception)
+bool CollectorSwOutPort::addInPort(InPort *inPort)
{
if(_currentProducer)
{//a specific link is beeing done
(*iter).second->addInPort(inPort);
}
-int CollectorSwOutPort::removeInPort(InPort *inPort, bool forward) throw(YACS::Exception)
+int CollectorSwOutPort::removeInPort(InPort *inPort, bool forward)
{
if(_currentProducer)
{
return _potentialProducers.empty();
}
-bool CollectorSwOutPort::checkManagementOfPort(OutPort *port) throw(YACS::Exception)
+bool CollectorSwOutPort::checkManagementOfPort(OutPort *port)
{
for(map<int, OutPort *>::iterator iter=_potentialProducers.begin();iter!=_potentialProducers.end();iter++)
if((*iter).second==port)
(*it).second->partitionRegardingDPL(pd,zeMap);
}
-void Switch::edRemoveChild(Node *node) throw(YACS::Exception)
+void Switch::edRemoveChild(Node *node)
{
map< int , Node * >::iterator iter=_mapOfNode.begin();
for(;iter!=_mapOfNode.end();iter++)
ret.push_back((InputPort *)&_condition);
return ret;
}
-OutPort *Switch::getOutPort(const std::string& name) const throw(YACS::Exception)
+OutPort *Switch::getOutPort(const std::string& name) const
{
for(map<InPort *, CollectorSwOutPort * >::const_iterator iter=_outPortsCollector.begin();iter!=_outPortsCollector.end();iter++)
if(name==(*iter).second->getName())
return StaticDefinedComposedNode::getOutPort(name);
}
-InputPort *Switch::getInputPort(const std::string& name) const throw(YACS::Exception)
+InputPort *Switch::getInputPort(const std::string& name) const
{
if(name==SELECTOR_INPUTPORT_NAME)
return (InputPort *)&_condition;
return StaticDefinedComposedNode::getInputPort(name);
}
-Node *Switch::getChildByShortName(const std::string& name) const throw(YACS::Exception)
+Node *Switch::getChildByShortName(const std::string& name) const
{
if(name==DEFAULT_NODE_NAME)
{
return edSetNode(ID_FOR_DEFAULT_NODE,node);
}
-Node *Switch::edReleaseDefaultNode() throw(YACS::Exception)
+Node *Switch::edReleaseDefaultNode()
{
return edReleaseCase(ID_FOR_DEFAULT_NODE);
}
-Node *Switch::edReleaseCase(int caseId) throw(YACS::Exception)
+Node *Switch::edReleaseCase(int caseId)
{
map< int , Node * >::iterator iter=_mapOfNode.find(caseId);
if(iter==_mapOfNode.end())
* 0 is returned if caseId is a new ID.
* \b WARNING : 'node' is held by 'this' after call, whereas returned node is no more held.
*/
-Node *Switch::edSetNode(int caseId, Node *node) throw(YACS::Exception)
+Node *Switch::edSetNode(int caseId, Node *node)
{
if(!node)
throw Exception("Switch::edSetNode : null node cannot be set as a case in switch node");
return ret;
}
-bool Switch::edAddChild(Node *node) throw(YACS::Exception)
+bool Switch::edAddChild(Node *node)
{
int aCase = getMaxCase() + 1;
DEBTRACE(aCase);
throw Exception("Switch::checkControlDependancy : a link was dectected between 2 cases of a switch. Impossible !");
}
-void Switch::checkNoCyclePassingThrough(Node *node) throw(YACS::Exception)
+void Switch::checkNoCyclePassingThrough(Node *node)
{
throw Exception("Switch::checkNoCyclePassingThrough : uncorrect control flow link relative to switch");
}
void Switch::checkLinkPossibility(OutPort *start, const std::list<ComposedNode *>& pointsOfViewStart,
- InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) throw(YACS::Exception)
+ InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd)
{
throw Exception("Switch::checkLinkPossibility : A link between 2 different cases of a same Switch requested -> Impossible");
}
port.first=newCollector;
}
-void Switch::getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(YACS::Exception)
+void Switch::getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView)
{
map<InPort *, CollectorSwOutPort * >::iterator iter=_outPortsCollector.find(finalTarget);
if(iter==_outPortsCollector.end())
port.first=(*iter).second;
}
-void Switch::releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(YACS::Exception)
+void Switch::releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView)
{
set<OutPort *> repr;
portDwn->getAllRepresented(repr);
return id;
}
-std::string Switch::getCaseId(const Node *node) const throw(YACS::Exception)
+std::string Switch::getCaseId(const Node *node) const
{
const char sep='_';
map<int, Node*>::const_iterator iter;
std::set<InPort *> edSetInPort() const;
bool isAlreadyLinkedWith(InPort *withp) const;
std::string getNameOfTypeOfCurrentInstance() const;
- void edRemoveAllLinksLinkedWithMe() throw(Exception);
+ void edRemoveAllLinksLinkedWithMe() ;
TypeOfChannel getTypeOfChannel() const;
void getAllRepresented(std::set<OutPort *>& represented) const;
- bool addInPort(InPort *inPort) throw(Exception);
- int removeInPort(InPort *inPort, bool forward) throw(Exception);
+ bool addInPort(InPort *inPort) ;
+ int removeInPort(InPort *inPort, bool forward) ;
public:
void getHumanReprOfIncompleteCases(std::ostream& stream) const;
private://Specific part
CollectorSwOutPort(Switch *master, InPort *port);
CollectorSwOutPort(const CollectorSwOutPort& other, Switch *master);
void addPotentialProducerForMaster(OutPort *port);
- bool checkManagementOfPort(OutPort *port) throw(Exception);
+ bool checkManagementOfPort(OutPort *port) ;
private:
InPort *_consumer;
std::string _className;
void init(bool start=true);
//Node* DISOWNnode is a SWIG notation to indicate that the ownership of the node is transfered to C++
Node *edSetDefaultNode(Node *DISOWNnode);
- Node *edReleaseDefaultNode() throw(Exception);
- Node *edReleaseCase(int caseId) throw(Exception);
+ Node *edReleaseDefaultNode() ;
+ Node *edReleaseCase(int caseId) ;
Node *edGetNode(int caseId);
- Node *edSetNode(int caseId, Node *DISOWNnode) throw(Exception);
+ Node *edSetNode(int caseId, Node *DISOWNnode) ;
void edChangeCase(int oldCase, int newCase);
- virtual bool edAddChild(Node *DISOWNnode) throw(Exception);
+ virtual bool edAddChild(Node *DISOWNnode) ;
int getMaxCase();
void getReadyTasks(std::vector<Task *>& tasks);
std::list<Node *> edGetDirectDescendants() const;
int getMaxLevelOfParallelism() const;
void getWeightRegardingDPL(ComplexWeight *weight);
void partitionRegardingDPL(const PartDefinition *pd, std::map<ComposedNode *, YACS::BASES::AutoRefCnt<PartDefinition> >& zeMap);
- void edRemoveChild(Node *node) throw(Exception);
+ void edRemoveChild(Node *node) ;
std::list<InputPort *> getSetOfInputPort() const;
std::list<InputPort *> getLocalInputPorts() const;
YACS::StatesForNode getEffectiveState() const;
YACS::StatesForNode getEffectiveState(const Node* node) const;
- OutPort *getOutPort(const std::string& name) const throw(Exception);
- InputPort* getInputPort(const std::string& name) const throw(Exception);
- Node *getChildByShortName(const std::string& name) const throw(Exception);
+ OutPort *getOutPort(const std::string& name) const ;
+ InputPort* getInputPort(const std::string& name) const ;
+ Node *getChildByShortName(const std::string& name) const ;
std::string getMyQualifiedName(const Node *directSon) const;
- std::string getCaseId(const Node *node) const throw(Exception);
+ std::string getCaseId(const Node *node) const ;
virtual void accept(Visitor *visitor);
int getRankOfNode(Node *node) const;
virtual std::string typeName() {return "YACS__ENGINE__Switch";}
Node *simpleClone(ComposedNode *father, bool editionOnly=true) const;
std::set<InPort *> getAllInPortsComingFromOutsideOfCurrentScope() const;
void checkLinkPossibility(OutPort *start, const std::list<ComposedNode *>& pointsOfViewStart,
- InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) throw(Exception);
+ InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) ;
void buildDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView);
- void getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(Exception);
- void releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) throw(Exception);
+ void getDelegateOf(std::pair<OutPort *, OutPort *>& port, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) ;
+ void releaseDelegateOf(OutPort *portDwn, OutPort *portUp, InPort *finalTarget, const std::list<ComposedNode *>& pointsOfView) ;
void checkCFLinks(const std::list<OutPort *>& starts, InputPort *end, unsigned char& alreadyFed, bool direction, LinkInfo& info) const;
void checkControlDependancy(OutPort *start, InPort *end, bool cross,
std::map < ComposedNode *, std::list < OutPort * > >& fw,
std::vector<OutPort *>& fwCross,
std::map< ComposedNode *, std::list < OutPort *> >& bw,
LinkInfo& info) const;
- void checkNoCyclePassingThrough(Node *node) throw(Exception);
+ void checkNoCyclePassingThrough(Node *node) ;
private:
int getNbOfCases() const;
static std::string getRepresentationOfCase(int i);
#include "YACSlibEngineExport.hxx"
#include "define.hxx"
#include <set>
+#include <string>
namespace YACS
{
virtual YACS::StatesForNode getState() const = 0;
virtual void finished() = 0;
virtual void aborted() = 0;
+ virtual void imposeResource(const std::string& resource_name,
+ const std::string& container_name) {}
+ virtual bool canAcceptImposedResource() { return false;}
+ virtual bool hasImposedResource()const { return false;}
virtual ~Task();
};
}
return _alreadyStarted;
}
-void ContainerTest::start(const Task *askingNode) throw(YACS::Exception)
+void ContainerTest::start(const Task *askingNode)
{
if(_alreadyStarted)
throw Exception("ContainerTest already started !!!!");
return new ContainerTest;
}
-void ContainerTest::checkCapabilityToDealWith(const ComponentInstance *inst) const throw(YACS::Exception)
+void ContainerTest::checkCapabilityToDealWith(const ComponentInstance *inst) const
{
if(inst->getKind()!=SUPPORTED_COMP_KIND)
throw Exception("ContainerTest not compatible with this type of instance.");
return _alreadyStarted;
}
-void ContainerTest2::start(const Task *askingNode) throw(YACS::Exception)
+void ContainerTest2::start(const Task *askingNode)
{
if(_alreadyStarted)
throw Exception("ContainerTest already started !!!!");
_counter=0;
}
-void ContainerTest2::checkCapabilityToDealWith(const ComponentInstance *inst) const throw(YACS::Exception)
+void ContainerTest2::checkCapabilityToDealWith(const ComponentInstance *inst) const
{
if(inst->getKind()!=SUPPORTED_COMP_KIND)
throw Exception("ContainerTest not compatible with this type of instance.");
std::string getPlacementInfo() const;
// implementation of compulsary methods
bool isAlreadyStarted(const Task *askingNode) const;
- void start(const Task *askingNode) throw(Exception);
+ void start(const Task *askingNode) ;
Container *clone() const;
Container *cloneAlways() const;
//
std::string getFullPlacementId(const Task *askingNode) const { return ""; }
static void initAllContainers();
protected:
- void checkCapabilityToDealWith(const ComponentInstance *inst) const throw(Exception);
+ void checkCapabilityToDealWith(const ComponentInstance *inst) const ;
protected:
bool _alreadyStarted;
unsigned _myCounter;
std::string getKind() const;
// implementation of compulsary methods
bool isAlreadyStarted(const Task *askingNode) const;
- void start(const Task *askingNode) throw(Exception);
+ void start(const Task *askingNode) ;
Container *clone() const;
Container *cloneAlways() const;
//
std::string getFullPlacementId(const Task *askingNode) const { return ""; }
static void initAllContainers();
protected:
- void checkCapabilityToDealWith(const ComponentInstance *inst) const throw(Exception);
+ void checkCapabilityToDealWith(const ComponentInstance *inst) const ;
protected:
bool _alreadyStarted;
unsigned _myCounter;
_idTest++;
}
-void PluginOptEvTest1::initialize(const Any *input) throw(YACS::Exception)
+void PluginOptEvTest1::initialize(const Any *input)
{
}
void parseFileToInit(const std::string& fileName);
void start();
void takeDecision();
- void initialize(const Any *input) throw(Exception);
+ void initialize(const Any *input) ;
void finish();
};
}
std::vector< std::pair<std::string,int> > RuntimeForEngineIntegrationTest::getCatalogOfComputeNodes() const
{
- throw Exception("RuntimeForEngineIntegrationTest not implemented !");
+ return std::vector< std::pair<std::string,int> >();
}
-ElementaryNode* RuntimeForEngineIntegrationTest::createNode(const std::string& implementation, const std::string& name) throw (YACS::Exception)
+ElementaryNode* RuntimeForEngineIntegrationTest::createNode(const std::string& implementation, const std::string& name)
{
if (implementation == ToyNode::MY_IMPL_NAME)
return new ToyNode(name);
throw Exception(msg.str());
}
-InputPort* RuntimeForEngineIntegrationTest::adapt(InputPort* source, const std::string& impl,TypeCode * type,bool init) throw (ConversionException)
+InputPort* RuntimeForEngineIntegrationTest::adapt(InputPort* source, const std::string& impl,TypeCode * type,bool init)
{
return new ProxyPort(source);
}
-InputPort* RuntimeForEngineIntegrationTest::adapt(InPropertyPort* source, const std::string& impl, TypeCode * type, bool init) throw (ConversionException)
+InputPort* RuntimeForEngineIntegrationTest::adapt(InPropertyPort* source, const std::string& impl, TypeCode * type, bool init)
{
return adapt((InputPort *)source, impl, type, init);
}
public:
static void setRuntime();
std::vector< std::pair<std::string,int> > getCatalogOfComputeNodes() const;
- ElementaryNode* createNode(const std::string& implementation, const std::string& name) throw(Exception);
+ ElementaryNode* createNode(const std::string& implementation, const std::string& name) ;
InputPort* createInputPort(const std::string& name, const std::string& impl, Node * node, TypeCode * type);
OutputPort* createOutputPort(const std::string& name, const std::string& impl, Node * node, TypeCode * type);
- InputPort* adapt(InputPort* source, const std::string& impl,TypeCode * type,bool init) throw (ConversionException);
- InputPort* adapt(InPropertyPort* source, const std::string& impl, TypeCode * type,bool init) throw (ConversionException);
+ InputPort* adapt(InputPort* source, const std::string& impl,TypeCode * type,bool init);
+ InputPort* adapt(InPropertyPort* source, const std::string& impl, TypeCode * type,bool init);
ComponentInstance* createComponentInstance(const std::string& name, const std::string& kind="");
};
}
throw Exception(msg.str());
}
-void TestElemInputPort::put(const void *data) throw(ConversionException)
+void TestElemInputPort::put(const void *data)
{
cerr << _name << endl;
stringstream msg;
return new TestElemInputPort(*this,newHelder);
}
-void *TestElemInputPort::get() const throw(YACS::Exception)
+void *TestElemInputPort::get() const
{
stringstream msg;
msg << "Not implemented (" << __FILE__ << ":" << __LINE__ << ")";
return new TestElemOutputPort(*this,newHelder);
}
-void TestElemOutputPort::put(const void *data) throw(ConversionException)
+void TestElemOutputPort::put(const void *data)
{
cerr << _name << endl;
stringstream msg;
std::vector< std::pair<std::string,int> > RuntimeForEngineTest::getCatalogOfComputeNodes() const
{
- throw Exception("RuntimeForEngineTest::getCatalogOfComputeNodes : not implemented !");
+ return std::vector< std::pair<std::string,int> >();
}
-ElementaryNode* RuntimeForEngineTest::createNode(const string& implementation, const string& name) throw(YACS::Exception)
+ElementaryNode* RuntimeForEngineTest::createNode(const string& implementation, const string& name)
{
return new TestElemNode(name);
}
return new TestElemOutputPort(name, node, type);
}
-InputPort* RuntimeForEngineTest::adapt(InputPort* source, const string& impl,TypeCode * type,bool init) throw (ConversionException)
+InputPort* RuntimeForEngineTest::adapt(InputPort* source, const string& impl,TypeCode * type,bool init)
{
return new ProxyPort(source);
}
-InputPort* RuntimeForEngineTest::adapt(InPropertyPort* source, const std::string& impl, TypeCode * type, bool init) throw (ConversionException)
+InputPort* RuntimeForEngineTest::adapt(InPropertyPort* source, const std::string& impl, TypeCode * type, bool init)
{
return adapt((InputPort *)source,impl,type,init);
}
TestElemInputPort(const std::string& name, Node *node, TypeCode* type);
TestElemInputPort(const TestElemInputPort& other, Node *newHelder);
void releaseData() override;
- void put(const void *data) throw(ConversionException);
+ void put(const void *data);
InputPort *clone(Node *newHelder) const;
- void *get() const throw(Exception);
+ void *get() const ;
void exRestoreInit();
void exSaveInit();
protected:
public:
TestElemOutputPort(const std::string& name, Node *node, TypeCode* type);
TestElemOutputPort(const TestElemOutputPort& other, Node *newHelder);
- void put(const void *data) throw(ConversionException);
+ void put(const void *data);
OutputPort *clone(Node *newHelder) const;
};
public:
static void setRuntime();
std::vector< std::pair<std::string,int> > getCatalogOfComputeNodes() const;
- ElementaryNode* createNode(const std::string& implementation, const std::string& name) throw(Exception);
+ ElementaryNode* createNode(const std::string& implementation, const std::string& name) ;
InputPort* createInputPort(const std::string& name, const std::string& impl, Node * node, TypeCode * type);
OutputPort* createOutputPort(const std::string& name, const std::string& impl, Node * node, TypeCode * type);
- InputPort* adapt(InputPort* source, const std::string& impl, TypeCode * type,bool init) throw (ConversionException);
- InputPort* adapt(InPropertyPort* source, const std::string& impl, TypeCode * type,bool init) throw (ConversionException);
+ InputPort* adapt(InputPort* source, const std::string& impl, TypeCode * type,bool init);
+ InputPort* adapt(InPropertyPort* source, const std::string& impl, TypeCode * type,bool init);
};
}
}
{
}
-void InputToyPort::put(const void *data) throw(ConversionException)
+void InputToyPort::put(const void *data)
{
put((Any *)data);
}
return _initData!=0;
}
-void *InputToyPort::get() const throw(YACS::Exception)
+void *InputToyPort::get() const
{
return (void *)_data;
}
_data=other._data->clone();
}
-void OutputToyPort::put(const void *data) throw(ConversionException)
+void OutputToyPort::put(const void *data)
{
put((Any *)data);
OutputPort::put(data);
return ElementaryNode::getNumberOfInputPorts()+1;
}
-OutputPort *ToyNode::getOutputPort(const std::string& name) const throw(YACS::Exception)
+OutputPort *ToyNode::getOutputPort(const std::string& name) const
{
if(name==NAME_FOR_NB)
return (OutputPort *)&_nbOfInputsPort;
return ret;
}
-InputPort *SeqToyNode::getInputPort(const std::string& name) const throw(YACS::Exception)
+InputPort *SeqToyNode::getInputPort(const std::string& name) const
{
if(name==NAME_NBOFELTS_INSEQ_INPRT)
return (InputPort *)&_inIntValue;
return ret;
}
-OutputPort *SeqToyNode::getOutputPort(const std::string& name) const throw(YACS::Exception)
+OutputPort *SeqToyNode::getOutputPort(const std::string& name) const
{
if(name==NAME_SEQ_OUTPRT)
return (OutputPort *)&_seqOut;
return ret;
}
-InputPort *Seq2ToyNode::getInputPort(const std::string& name) const throw(YACS::Exception)
+InputPort *Seq2ToyNode::getInputPort(const std::string& name) const
{
if(name==NAME_SEQ_INPRT1)
return (InputPort *)&_inValue1;
return ret;
}
-OutputPort *Seq2ToyNode::getOutputPort(const std::string& name) const throw(YACS::Exception)
+OutputPort *Seq2ToyNode::getOutputPort(const std::string& name) const
{
if(name==NAME_SEQ_OUTPRT)
return (OutputPort *)&_seqOut;
return ret;
}
-InputPort *Seq3ToyNode::getInputPort(const std::string& name) const throw(YACS::Exception)
+InputPort *Seq3ToyNode::getInputPort(const std::string& name) const
{
if(name==NAME_SEQ_INPRT1)
return (InputPort *)&_inValue1;
return ret;
}
-OutputPort *Seq3ToyNode::getOutputPort(const std::string& name) const throw(YACS::Exception)
+OutputPort *Seq3ToyNode::getOutputPort(const std::string& name) const
{
if(name==NAME_SEQ_OUTPRT)
return (OutputPort *)&_seqOut;
{
}
-void InputLimitPort::put(const void *data) throw(ConversionException)
+void InputLimitPort::put(const void *data)
{
put((Any *)data);
}
return _initData!=0;
}
-void *InputLimitPort::get() const throw(YACS::Exception)
+void *InputLimitPort::get() const
{
if(!_data)
{
{
}
-void OutputLimitPort::put(const void *data) throw(ConversionException)
+void OutputLimitPort::put(const void *data)
{
put((Any *)data);
OutputPort::put(data);
return ret;
}
-InputPort *LimitNode::getInputPort(const std::string& name) const throw(YACS::Exception)
+InputPort *LimitNode::getInputPort(const std::string& name) const
{
if(name==NAME_FOR_SWPORT)
return (InputPort *)&_entry;
return ElementaryNode::getInputPort(name);
}
-OutputPort *LimitNode::getOutputPort(const std::string& name) const throw(YACS::Exception)
+OutputPort *LimitNode::getOutputPort(const std::string& name) const
{
if(name==NAME_FOR_SWPORT)
return (OutputPort *)&_switchPort;
InputToyPort(const InputToyPort& other, Node *newHelder);
InputToyPort(const std::string& name, Node *node);
void releaseData() override;
- void put(const void *data) throw(ConversionException);
+ void put(const void *data);
InputPort *clone(Node *newHelder) const;
bool edIsManuallyInitialized() const;
- void *get() const throw(Exception);
+ void *get() const ;
void edRemoveManInit();
void put(Any *data);
~InputToyPort();
public:
OutputToyPort(const std::string& name, Node *node, TypeCode *type);
OutputToyPort(const OutputToyPort& other, Node *newHelder);
- void put(const void *data) throw(ConversionException);
+ void put(const void *data);
OutputPort *clone(Node *newHelder) const;
void put(Any *data);
~OutputToyPort();
OutputPort *edGetNbOfInputsOutputPort() { return &_nbOfInputsPort; }
std::list<OutputPort *> getSetOfOutputPort() const;
int getNumberOfOutputPorts()const;
- OutputPort *getOutputPort(const std::string& name) const throw(Exception);
+ OutputPort *getOutputPort(const std::string& name) const ;
protected:
Node *simpleClone(ComposedNode *father, bool editionOnly) const;
public:
InputPort *edGetInIntValue() const { return (InputPort *)&_inIntValue; }
int getNumberOfInputPorts() const;
std::list<InputPort *> getSetOfInputPort() const;
- InputPort *getInputPort(const std::string& name) const throw(Exception);
+ InputPort *getInputPort(const std::string& name) const ;
int getNumberOfOutputPorts() const;
std::list<OutputPort *> getSetOfOutputPort() const;
- OutputPort *getOutputPort(const std::string& name) const throw(Exception);
+ OutputPort *getOutputPort(const std::string& name) const ;
protected:
Node *simpleClone(ComposedNode *father, bool editionOnly) const;
public:
InputPort *edGetInValue2() const { return (InputPort *)&_inValue2; }
int getNumberOfInputPorts() const;
std::list<InputPort *> getSetOfInputPort() const;
- InputPort *getInputPort(const std::string& name) const throw(Exception);
+ InputPort *getInputPort(const std::string& name) const ;
int getNumberOfOutputPorts() const;
std::list<OutputPort *> getSetOfOutputPort() const;
- OutputPort *getOutputPort(const std::string& name) const throw(Exception);
+ OutputPort *getOutputPort(const std::string& name) const ;
protected:
Node *simpleClone(ComposedNode *father, bool editionOnly) const;
public:
InputPort *edGetInValue2() const { return (InputPort *)&_inValue2; }
int getNumberOfInputPorts() const;
std::list<InputPort *> getSetOfInputPort() const;
- InputPort *getInputPort(const std::string& name) const throw(Exception);
+ InputPort *getInputPort(const std::string& name) const ;
int getNumberOfOutputPorts() const;
std::list<OutputPort *> getSetOfOutputPort() const;
- OutputPort *getOutputPort(const std::string& name) const throw(Exception);
+ OutputPort *getOutputPort(const std::string& name) const ;
protected:
Node *simpleClone(ComposedNode *father, bool editionOnly) const;
public:
{
friend class LimitNode;
public:
- void put(const void *data) throw(ConversionException);
+ void put(const void *data);
InputPort *clone(Node *newHelder) const;
bool edIsManuallyInitialized() const;
- void *get() const throw(Exception);
+ void *get() const ;
void edRemoveManInit();
void releaseData() override;
void put(Any *data);
{
friend class LimitNode;
public:
- void put(const void *data) throw(ConversionException);
+ void put(const void *data);
OutputPort *clone(Node *newHelder) const;
void put(Any *data);
~OutputLimitPort();
OutputPort *getCounterPort() { return &_counterPort; }
std::list<InputPort *> getSetOfInputPort() const;
std::list<OutputPort *> getSetOfOutputPort() const;
- InputPort *getInputPort(const std::string& name) const throw(Exception);
- OutputPort *getOutputPort(const std::string& name) const throw(Exception);
+ InputPort *getInputPort(const std::string& name) const ;
+ OutputPort *getOutputPort(const std::string& name) const ;
LimitNode(const LimitNode& other, ComposedNode *father);
LimitNode(const std::string& name);
protected:
return AtomAny::getOrBuildFromData(data,this);
}
-const char * TypeCode::name() const throw(YACS::Exception)
+const char * TypeCode::name() const
{
return id();
}
return id();
}
-const char * TypeCode::id() const throw(YACS::Exception)
+const char * TypeCode::id() const
{
switch(_kind)
{
}
}
-int TypeCode::isA(const char* id) const throw(YACS::Exception)
+int TypeCode::isA(const char* id) const
{
throw Exception("Not implemented for this type");
}
}
}
-const TypeCode * TypeCode::contentType() const throw(YACS::Exception)
+const TypeCode * TypeCode::contentType() const
{
throw Exception("No content type");
};
return AtomAny::getOrBuildFromData(data,this);
}
-const char * TypeCodeObjref::id() const throw(YACS::Exception)
+const char * TypeCodeObjref::id() const
{
return _repoId.c_str();
};
-const char * TypeCodeObjref::name() const throw(YACS::Exception)
+const char * TypeCodeObjref::name() const
{
return _name.c_str();
}
* \param id : a given id
* \return 1 if true, 0 if false
*/
-int TypeCodeObjref::isA(const char* id) const throw(YACS::Exception)
+int TypeCodeObjref::isA(const char* id) const
{
if(_repoId == id)return 1;
list<TypeCodeObjref *>::const_iterator iter;
return SequenceAny::getOrBuildFromData(data,this);
}
-const char * TypeCodeSeq::id() const throw(YACS::Exception)
+const char * TypeCodeSeq::id() const
{
return _repoId.c_str();
}
-const char * TypeCodeSeq::name() const throw(YACS::Exception)
+const char * TypeCodeSeq::name() const
{
return _name.c_str();
}
return oss.str();
}
-const TypeCode * TypeCodeSeq::contentType() const throw(YACS::Exception)
+const TypeCode * TypeCodeSeq::contentType() const
{
return _content;
}
return ArrayAny::getOrBuildFromData(data,this);
}
-const char * TypeCodeArray::id() const throw(YACS::Exception)
+const char * TypeCodeArray::id() const
{
return _repoId.c_str();
}
-const char * TypeCodeArray::name() const throw(YACS::Exception)
+const char * TypeCodeArray::name() const
{
return _name.c_str();
}
return _staticLgth;
}
-const TypeCode * TypeCodeArray::contentType() const throw(YACS::Exception)
+const TypeCode * TypeCodeArray::contentType() const
{
return _content;
}
return StructAny::getOrBuildFromData(data,this);
}
-const char * TypeCodeStruct::id() const throw(YACS::Exception)
+const char * TypeCodeStruct::id() const
{
return _repoId.c_str();
};
-const char * TypeCodeStruct::name() const throw(YACS::Exception)
+const char * TypeCodeStruct::name() const
{
return _name.c_str();
}
return ret;
}
-const TypeCode *TypeCodeStruct::contentType() const throw(YACS::Exception)
+const TypeCode *TypeCodeStruct::contentType() const
{
const char what[]="Content type is specified by giving a key.";
throw Exception(what);
* \param id : a given id
* \return 1 if true, 0 if false
*/
-int TypeCodeStruct::isA(const char* id) const throw(YACS::Exception)
+int TypeCodeStruct::isA(const char* id) const
{
if(_repoId == id)return 1;
return 0;
virtual void putReprAtPlace(char *pt, const char *val, bool deepCpy) const;
virtual void destroyZippedAny(char *data) const;
virtual AnyPtr getOrBuildAnyFromZippedData(char *data) const;
- virtual const char * name() const throw(Exception);
+ virtual const char * name() const;
virtual const char * shortName() const;
- virtual const char * id() const throw(Exception);
- virtual const TypeCode * contentType() const throw(Exception);
- virtual int isA(const char* repositoryId) const throw(Exception);
+ virtual const char * id() const;
+ virtual const TypeCode * contentType() const;
+ virtual int isA(const char* repositoryId) const;
virtual int isA(const TypeCode* tc) const ;
virtual int isAdaptable(const TypeCode* tc) const;
virtual int isEquivalent(const TypeCode* tc) const;
void putReprAtPlace(char *pt, const char *val, bool deepCpy) const;
void destroyZippedAny(char *data) const;
AnyPtr getOrBuildAnyFromZippedData(char *data) const;
- const char * id() const throw(Exception);
- const char * name() const throw(Exception);
+ const char * id() const;
+ const char * name() const;
const char * shortName() const;
- int isA(const char* repositoryId) const throw(Exception);
+ int isA(const char* repositoryId) const;
virtual int isA(const TypeCode* tc) const ;
virtual int isAdaptable(const TypeCode* tc) const;
virtual int isEquivalent(const TypeCode* tc) const;
void destroyZippedAny(char *data) const;
virtual unsigned getSizeInByteOfAnyReprInSeq() const;
AnyPtr getOrBuildAnyFromZippedData(char *data) const;
- const char * id() const throw(Exception);
- const char * name() const throw(Exception);
+ const char * id() const;
+ const char * name() const;
const char * shortName() const;
virtual std::string getPrintStr() const;
- virtual const TypeCode * contentType() const throw(Exception);
+ virtual const TypeCode * contentType() const;
virtual int isA(const TypeCode* tc) const ;
virtual int isAdaptable(const TypeCode* tc) const;
virtual int isEquivalent(const TypeCode* tc) const;
void putReprAtPlace(char *pt, const char *val, bool deepCpy) const;
void destroyZippedAny(char *data) const;
AnyPtr getOrBuildAnyFromZippedData(char *data) const;
- const char * id() const throw(Exception);
- const char * name() const throw(Exception);
+ const char * id() const;
+ const char * name() const;
const char * shortName() const;
unsigned getStaticLgth() const;
- virtual const TypeCode * contentType() const throw(Exception);
+ virtual const TypeCode * contentType() const;
virtual int isA(const TypeCode* tc) const ;
virtual int isAdaptable(const TypeCode* tc) const;
virtual int isEquivalent(const TypeCode* tc) const;
void putReprAtPlace(char *pt, const char *val, bool deepCpy) const;
void destroyZippedAny(char *data) const;
AnyPtr getOrBuildAnyFromZippedData(char *data) const;
- const char * id() const throw(Exception);
- const char * name() const throw(Exception);
+ const char * id() const;
+ const char * name() const;
const char * shortName() const;
virtual unsigned getSizeInByteOfAnyReprInSeq() const;
- const TypeCode * contentType() const throw(Exception);
- virtual int isA(const char* repositoryId) const throw(Exception);
+ const TypeCode * contentType() const;
+ virtual int isA(const char* repositoryId) const;
virtual int isA(const TypeCode* tc) const ;
virtual int isAdaptable(const TypeCode* tc) const;
virtual int isEquivalent(const TypeCode* tc) const;
class ElementaryNode;
class ComposedNode;
class ForEachLoop;
+ class ForEachLoopDyn;
class OptimizerLoop;
class DynParaLoop;
class InlineNode;
virtual void visitBloc(Bloc *node) = 0;
virtual void visitElementaryNode(ElementaryNode *node) = 0;
virtual void visitForEachLoop(ForEachLoop *node) = 0;
+ virtual void visitForEachLoopDyn(ForEachLoopDyn *node) = 0;
virtual void visitOptimizerLoop(OptimizerLoop *node) = 0;
virtual void visitDynParaLoop(DynParaLoop *node) = 0;
virtual void visitForLoop(ForLoop *node) = 0;
}
}
-void VisitorSaveSchema::openFileSchema(std::string xmlSchema) throw(YACS::Exception)
+void VisitorSaveSchema::openFileSchema(std::string xmlSchema)
{
_out.open(xmlSchema.c_str(), ios::out);
if (!_out)
DEBTRACE("END visitForEachLoop " << _root->getChildName(node));
}
+void VisitorSaveSchema::visitForEachLoopDyn(ForEachLoopDyn *node)
+{
+ DEBTRACE("START visitForEachLoopDyn " << _root->getChildName(node));
+ beginCase(node);
+ int depth = depthNode(node);
+
+ _out << indent(depth) << "<foreachdyn name=\"" << node->getName() << "\"";
+ if (node->getState() == YACS::DISABLED)
+ _out << " state=\"disabled\"";
+ _out << " loopWeight=\"" << node->getWeight()->getSimpleLoopWeight() << "\"";
+ if (node->edGetSamplePort())
+ _out << " type=\"" << node->edGetSamplePort()->edGetType()->name() << "\"";
+ _out << ">" << endl;
+
+ writeProperties(node);
+ node->DynParaLoop::accept(this);
+ writeSimpleDataLinks(node);
+ writeSimpleStreamLinks(node);
+ _out << indent(depth) << "</foreachdyn>" << endl;
+ endCase(node);
+ DEBTRACE("END visitForEachLoopDyn " << _root->getChildName(node));
+}
+
void VisitorSaveSchema::visitOptimizerLoop(OptimizerLoop *node)
{
DEBTRACE("START visitOptimizerLoop " << _root->getChildName(node));
for (list<Node*>::iterator ic = setOfChildren.begin(); ic != setOfChildren.end(); ++ic)
// add "splitter" node of ForEachLoop nodes to the set of children
- if ( dynamic_cast<ForEachLoop*>( *ic ) )
+ if ( dynamic_cast<ForEachLoopGen*>( *ic ) )
{
Node *nodeToInsert=(*ic)->getChildByName(ForEachLoop::NAME_OF_SPLITTERNODE);
if(find(setOfChildrenPlusSplitters.begin(),setOfChildrenPlusSplitters.end(),nodeToInsert)==setOfChildrenPlusSplitters.end())
DEBTRACE( "BINGO!" );
string fromName;
- if ( dynamic_cast<SplitterNode*>(from) && dynamic_cast<ForEachLoop*>(from->getFather()) )
+ if ( dynamic_cast<SplitterNode*>(from) && dynamic_cast<ForEachLoopGen*>(from->getFather()) )
fromName = from->getFather()->getName();
else
fromName = node->getChildName(from);
string childName;
- if ( dynamic_cast<SplitterNode*>(to) && dynamic_cast<ForEachLoop*>(to->getFather()) )
+ if ( dynamic_cast<SplitterNode*>(to) && dynamic_cast<ForEachLoopGen*>(to->getFather()) )
childName = node->getChildName(to->getFather());
else
childName = node->getChildName(to);
public:
VisitorSaveSchema(ComposedNode *root);
virtual ~VisitorSaveSchema();
- void openFileSchema(std::string xmlDump) throw(Exception);
+ void openFileSchema(std::string xmlDump) ;
void closeFileSchema();
virtual void visitBloc(Bloc *node);
virtual void visitElementaryNode(ElementaryNode *node);
- virtual void visitForEachLoop(ForEachLoop *node);
+ void visitForEachLoop(ForEachLoop *node) override;
+ void visitForEachLoopDyn(ForEachLoopDyn *node) override;
virtual void visitOptimizerLoop(OptimizerLoop *node);
virtual void visitDynParaLoop(DynParaLoop *node);
virtual void visitForLoop(ForLoop *node);
}
}
-void VisitorSaveState::openFileDump(const std::string& xmlDump) throw(YACS::Exception)
+void VisitorSaveState::openFileDump(const std::string& xmlDump)
{
_out.open(xmlDump.c_str(), ios::out);
if (!_out)
_out << " </node>" << endl;
}
+void VisitorSaveState::visitForEachLoopDyn(ForEachLoopDyn *node)
+{
+ node->ComposedNode::accept(this);
+ if (!_out) throw Exception("No file open for dump state");
+ string name = _root->getName();
+ if (static_cast<ComposedNode*>(node) != _root) name = _root->getChildName(node);
+ DEBTRACE("VisitorSaveState::visitForEachLoopDyn ------ " << name);
+ _out << " <node type='forEachLoopDyn'>" << endl;
+ _out << " <name>" << name << "</name>" << endl;
+ _out << " <state>" << _nodeStateName[node->getState()] << "</state>" << endl;
+ _out << " </node>" << endl;
+}
+
void VisitorSaveState::visitOptimizerLoop(OptimizerLoop *node)
{
node->ComposedNode::accept(this);
public:
VisitorSaveState(ComposedNode *root);
virtual ~VisitorSaveState();
- void openFileDump(const std::string& xmlDump) throw(Exception);
+ void openFileDump(const std::string& xmlDump) ;
void closeFileDump();
virtual void visitBloc(Bloc *node);
virtual void visitElementaryNode(ElementaryNode *node);
- virtual void visitForEachLoop(ForEachLoop *node);
+ void visitForEachLoop(ForEachLoop *node) override;
+ void visitForEachLoopDyn(ForEachLoopDyn *node) override;
virtual void visitOptimizerLoop(OptimizerLoop *node);
virtual void visitDynParaLoop(DynParaLoop *node);
virtual void visitForLoop(ForLoop *node);
return new WhileLoop(*this,father,editionOnly);
}
-InputPort *WhileLoop::getInputPort(const std::string& name) const throw(YACS::Exception)
+InputPort *WhileLoop::getInputPort(const std::string& name) const
{
if(name==NAME_OF_INPUT_CONDITION)
return (InputPort*)&_conditionPort;
void WhileLoop::checkLinkPossibility(OutPort *start,
const std::list<ComposedNode *>& pointsOfViewStart,
InPort *end,
- const std::list<ComposedNode *>& pointsOfViewEnd) throw(YACS::Exception)
+ const std::list<ComposedNode *>& pointsOfViewEnd)
{
DEBTRACE("WhileLoop::checkLinkPossibility");
}
void exUpdateState();
void init(bool start=true);
InputPort *edGetConditionPort() { return &_conditionPort; }
- InputPort* getInputPort(const std::string& name) const throw(Exception);
+ InputPort* getInputPort(const std::string& name) const ;
std::list<InputPort *> getLocalInputPorts() const;
virtual void accept(Visitor *visitor);
InputPort *getDecisionPort() const { return (InputPort *)&_conditionPort; }
protected:
Node *simpleClone(ComposedNode *father, bool editionOnly=true) const;
void checkLinkPossibility(OutPort *start, const std::list<ComposedNode *>& pointsOfViewStart,
- InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) throw(Exception);
+ InPort *end, const std::list<ComposedNode *>& pointsOfViewEnd) ;
YACS::Event updateStateOnFinishedEventFrom(Node *node);
};
}
--- /dev/null
+// Copyright (C) 2006-2020 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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "WlmTask.hxx"
+#include "Runtime.hxx"
+#include "Container.hxx"
+
+namespace YACS
+{
+namespace ENGINE
+{
+WlmTask::WlmTask(Executor& executor, YACS::ENGINE::Task* yacsTask)
+: _type()
+, _executor(executor)
+, _yacsTask(yacsTask)
+{
+ Container * yacsContainer = yacsTask->getContainer();
+ if(yacsContainer != nullptr && yacsTask->canAcceptImposedResource())
+ {
+ _type.ignoreResources = false;
+ _type.name = yacsContainer->getName();
+ std::string nb_procs_str = yacsContainer->getProperty("nb_parallel_procs");
+ float needed_cores = 0.0;
+ if(!nb_procs_str.empty())
+ needed_cores = std::stof(nb_procs_str);
+ _type.neededCores = needed_cores;
+ }
+ else
+ {
+ _type.ignoreResources = true;
+ _type.name = "test";
+ _type.neededCores = 0;
+ }
+ _type.id = 0;
+}
+
+const WorkloadManager::ContainerType& WlmTask::type()const
+{
+ return _type;
+}
+
+void WlmTask::run(const WorkloadManager::RunInfo& runInfo)
+{
+ _executor.loadTask(_yacsTask, runInfo);
+ _executor.makeDatastreamConnections(_yacsTask);
+ YACS::Event ev = _executor.runTask(_yacsTask);
+ _executor.endTask(_yacsTask, ev);
+ delete this; // provisoire
+}
+
+bool WlmTask::isAccepted(const WorkloadManager::Resource& r)
+{
+ Container * yacsContainer = _yacsTask->getContainer();
+ std::string hostname = yacsContainer->getProperty("hostname");
+ bool accept = true;
+ if(!hostname.empty())
+ accept = (hostname == r.name);
+ return accept;
+}
+
+void WlmTask::loadResources(WorkloadManager::WorkloadManager& wm)
+{
+ Runtime *r(getRuntime());
+ if(!r)
+ throw YACS::Exception("loadResources : no runtime !");
+ std::vector< std::pair<std::string,int> > data(r->getCatalogOfComputeNodes());
+ int id = 0;
+ for(const std::pair<std::string,int>& res : data)
+ {
+ WorkloadManager::Resource newResource;
+ newResource.name = res.first;
+ newResource.id = id;
+ id++;
+ newResource.nbCores = res.second;
+ wm.addResource(newResource);
+ }
+}
+
+}
+}
--- /dev/null
+// Copyright (C) 2006-2020 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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef __WLM_TASK_HXX__
+#define __WLM_TASK_HXX__
+#include "Executor.hxx"
+#include "Task.hxx"
+#include "workloadmanager/WorkloadManager.hxx"
+
+namespace YACS
+{
+namespace ENGINE
+{
+class YACSLIBENGINE_EXPORT WlmTask : public WorkloadManager::Task
+{
+public:
+ WlmTask(Executor& executor, YACS::ENGINE::Task* yacsTask);
+ const WorkloadManager::ContainerType& type()const override;
+ void run(const WorkloadManager::RunInfo& runInfo)override;
+ bool isAccepted(const WorkloadManager::Resource& r)override;
+
+ static void loadResources(WorkloadManager::WorkloadManager& wm);
+private:
+ WorkloadManager::ContainerType _type;
+ Executor& _executor;
+ YACS::ENGINE::Task * _yacsTask;
+};
+
+}
+}
+
+#endif //__WLM_TASK_HXX__
if (isPyThread) _save = PyEval_SaveThread(); // allow Python threads when embedded in a Python thread
try
{
- RunB(graph, debug, fromscratch);
+ RunW(graph, debug, fromscratch);
}
catch (YACS::Exception& e)
{
%newobject *::createBloc;
%newobject *::createForLoop;
%newobject *::createForEachLoop;
+%newobject *::createForEachLoopDyn;
%newobject *::createWhileLoop;
%newobject *::createSwitch;
%newobject *::loadCatalog;
if (!QtGuiContext::getQtCurrent()->isEdition())
_formEachLoop->setEnabled (false);
Node* node=_subjectNode->getNode();
- ForEachLoop *fe = dynamic_cast<ForEachLoop*>(node);
+ ForEachLoopGen *fe = dynamic_cast<ForEachLoopGen*>(node);
if(fe)
_formEachLoop->lineEdit->setText(fe->edGetSamplePort()->edGetType()->name());
connect(_formEachLoop->sb_nbranch, SIGNAL(editingFinished()),
{
bool isOk = false;
Node* node=_subjectNode->getNode();
- ForEachLoop *fe = dynamic_cast<ForEachLoop*>(node);
+ ForEachLoopGen *fe = dynamic_cast<ForEachLoopGen*>(node);
InputPort* dp=fe->edGetSeqOfSamplesPort();
SubjectDataPort* sdp = QtGuiContext::getQtCurrent()->_mapOfSubjectDataPort[dp];
isOk=sdp->setValue(_formEachLoop->lineEdit_2->text().toStdString());
connect(sb_procNode, SIGNAL(valueChanged(const QString&)), this, SLOT(onModifyProcs(const QString&)));
connect(sb_nbprocpar, SIGNAL(valueChanged(const QString&)), this, SLOT(onModifyProcPar(const QString&)));
connect(sb_nbproc, SIGNAL(valueChanged(const QString&)), this, SLOT(onModifyProcRes(const QString&)));
+ connect(ch_pycache,SIGNAL(stateChanged(int)),this,SLOT(onModifyUsePyCache(int)));
}
FormAdvParamContainer::~FormAdvParamContainer()
else
le_workdir->setText("");
+ if(_container)
+ ch_pycache->setCheckState(_container->isUsingPythonCache()?Qt::Checked:Qt::Unchecked);
+ else
+ ch_pycache->setCheckState(Qt::Unchecked);
+
if(_properties.count("container_name"))
le_contname->setText(_properties["container_name"].c_str());
else
if (properties["resource_list"] != text.toStdString())
onModified();
}
+
+void FormAdvParamContainer::onModifyUsePyCache(int val)
+{
+ if (!_container)
+ return;
+ bool val2(false);
+ if(val==Qt::Unchecked)
+ val2=false;
+ if(val==Qt::Checked)
+ val2=true;
+ bool prop = _container->isUsingPythonCache();
+ if(prop!=val2)
+ {
+ _container->usePythonCache(val2);
+ map<string,string> properties = _container->getProperties();
+ _properties[Container::USE_PYCACHE_PROPERTY] = properties[Container::USE_PYCACHE_PROPERTY];
+ onModified();
+ }
+}
void onModifyProcRes(const QString &text);
void onModifyCompoList(const QString &text);
void onModifyResourceList(const QString &text);
-
+ void onModifyUsePyCache(int val);
protected:
bool _advanced;
<widget class="QLineEdit" name="le_workdir"/>
</item>
<item row="3" column="0" colspan="3">
+ <widget class="QCheckBox" name="ch_pycache">
+ <property name="text">
+ <string>Use python cache</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0" colspan="3">
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
<string>Parallel parameters</string>
</layout>
</widget>
</item>
- <item row="4" column="1">
+ <item row="5" column="1">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
DEBTRACE("FormContainer::FillPanel");
FormContainerBase::FillPanel(container);
if(container)
+ {
ch_aoc->setCheckState(container->isAttachedOnCloning()?Qt::Checked:Qt::Unchecked);
+ }
cb_type->clear();
cb_type->addItem("mono");
cb_type->addItem("multi");
else if (dynamic_cast<YACS::ENGINE::ForLoop*>(node)) nodeType = FORLOOP;
else if (dynamic_cast<YACS::ENGINE::WhileLoop*>(node)) nodeType = WHILELOOP;
else if (dynamic_cast<YACS::ENGINE::Switch*>(node)) nodeType = SWITCH;
- else if (dynamic_cast<YACS::ENGINE::ForEachLoop*>(node)) nodeType = FOREACHLOOP;
+ else if (dynamic_cast<YACS::ENGINE::ForEachLoopGen*>(node)) nodeType = FOREACHLOOP;
else if (dynamic_cast<YACS::ENGINE::OptimizerLoop*>(node)) nodeType = OPTIMIZERLOOP;
else if (dynamic_cast<YACS::ENGINE::PresetNode*>(node)) nodeType = PRESETNODE;
else if (dynamic_cast<YACS::ENGINE::OutNode*>(node)) nodeType = OUTNODE;
(dynamic_cast<YACS::ENGINE::Switch*>(father))->edSetNode(_swCase,son);
break;
case FOREACHLOOP:
- (dynamic_cast<YACS::ENGINE::ForEachLoop*>(father))->edSetNode(son);
+ (dynamic_cast<YACS::ENGINE::ForEachLoopGen*>(father))->edSetNode(son);
break;
case OPTIMIZERLOOP:
(dynamic_cast<YACS::ENGINE::OptimizerLoop*>(father))->edSetNode(son);
try
{
// Remove child except if it's the splitter node of a ForEachLoop
- if (dynamic_cast<ForEachLoop*>(father) == NULL ||
- getName() != ForEachLoop::NAME_OF_SPLITTERNODE)
+ if (dynamic_cast<ForEachLoopGen*>(father) == NULL ||
+ getName() != ForEachLoopGen::NAME_OF_SPLITTERNODE)
{
father->edRemoveChild(_node);
}
son = new SubjectSwitch(dynamic_cast<YACS::ENGINE::Switch*>(node), this);
break;
case FOREACHLOOP:
- son = new SubjectForEachLoop(dynamic_cast<YACS::ENGINE::ForEachLoop*>(node), this);
+ son = new SubjectForEachLoop(dynamic_cast<YACS::ENGINE::ForEachLoopGen*>(node), this);
break;
case OPTIMIZERLOOP:
son = new SubjectOptimizerLoop(dynamic_cast<YACS::ENGINE::OptimizerLoop*>(node), this);
void SubjectComposedNode::loadChildren()
{
list<Node *> setOfNode= _composedNode->edGetDirectDescendants();
- if (ForEachLoop *feloop = dynamic_cast<ForEachLoop*>(_composedNode))
+ if (ForEachLoopGen *feloop = dynamic_cast<ForEachLoopGen*>(_composedNode))
{
- Node *node2Insert=feloop->getChildByName(ForEachLoop::NAME_OF_SPLITTERNODE);
+ Node *node2Insert=feloop->getChildByName(ForEachLoopGen::NAME_OF_SPLITTERNODE);
if(find(setOfNode.begin(),setOfNode.end(),node2Insert)==setOfNode.end())
setOfNode.push_back(node2Insert);
}
std::string SubjectDynParaLoop::getValue()
{
- return _dynParaLoop->edGetNbOfBranchesPort()->getAsString();
+ InputPort *port(_dynParaLoop->edGetNbOfBranchesPort());
+ if(port)
+ return port->getAsString();
+ else
+ return std::string();
}
// ----------------------------------------------------------------------------
-SubjectForEachLoop::SubjectForEachLoop(YACS::ENGINE::ForEachLoop *forEachLoop, Subject *parent)
+SubjectForEachLoop::SubjectForEachLoop(YACS::ENGINE::ForEachLoopGen *forEachLoop, Subject *parent)
: SubjectDynParaLoop(forEachLoop, parent), _forEachLoop(forEachLoop)
{
_splitter = 0;
{
if (_inputPort->getName() == "select") _destructible = false;
}
- else if (ForEachLoop* foreach = dynamic_cast<ForEachLoop*>(node))
+ else if (ForEachLoopGen* foreach = dynamic_cast<ForEachLoopGen*>(node))
{
if (_inputPort->getName() == "nbBranches") _destructible = false;
}
class ForLoop;
class DynParaLoop;
class ForEachLoop;
+ class ForEachLoopGen;
class WhileLoop;
class Switch;
class OptimizerLoop;
class SubjectForEachLoop: public SubjectDynParaLoop
{
public:
- SubjectForEachLoop(YACS::ENGINE::ForEachLoop *forEachLoop, Subject *parent);
+ SubjectForEachLoop(YACS::ENGINE::ForEachLoopGen *forEachLoop, Subject *parent);
virtual ~SubjectForEachLoop();
virtual void completeChildrenSubjectList(SubjectNode *son);
virtual void removeNode(SubjectNode * child);
void localclean(Command *command=0);
virtual TypeOfElem getType(){return FOREACHLOOP;}
protected:
- YACS::ENGINE::ForEachLoop *_forEachLoop;
+ YACS::ENGINE::ForEachLoopGen *_forEachLoop;
SubjectNode* _splitter;
};
* transition method from const void* to CORBA::Any*
* \param data : const void * data
*/
-void CorbaCorba::put(const void *data) throw(ConversionException)
+void CorbaCorba::put(const void *data)
{
put((CORBA::Any *)data);
}
/*!
* \param data : CORBA::Any object
*/
-void CorbaCorba::put(CORBA::Any *data) throw(ConversionException)
+void CorbaCorba::put(CORBA::Any *data)
{
CORBA::Any *a = convertCorbaCorba(edGetType(),data);
_port->put(a);
{
public:
CorbaCorba(InputCorbaPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(CORBA::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(CORBA::Any *data);
};
}
* \param data : CORBA::Any object as a void * pointer
*/
- void CorbaCpp::put(const void *data) throw(ConversionException)
+ void CorbaCpp::put(const void *data)
{
put((CORBA::Any *)data);
}
/*!
* \param data : CORBA::Any object
*/
- void CorbaCpp::put(CORBA::Any *data) throw(ConversionException)
+ void CorbaCpp::put(CORBA::Any *data)
{
DEBTRACE("CorbaCpp::put");
YACS::ENGINE::Any *ob;
{
public:
CorbaCpp(InputPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(CORBA::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(CORBA::Any *data);
};
int isAdaptableCppCorba(const TypeCode *t1,const TypeCode *t2);
}
* \param data : CORBA::Any object as a void * pointer
*/
-void CorbaNeutral::put(const void *data) throw(ConversionException)
+void CorbaNeutral::put(const void *data)
{
put((CORBA::Any *)data);
}
/*!
* \param data : CORBA::Any object
*/
-void CorbaNeutral::put(CORBA::Any *data) throw(ConversionException)
+void CorbaNeutral::put(CORBA::Any *data)
{
DEBTRACE( "CorbaNeutral::put" )
YACS::ENGINE::Any *ob;
{
public:
CorbaNeutral(InputPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(CORBA::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(CORBA::Any *data);
};
}
}
InputPort::edRemoveManInit();
}
-void InputCorbaPort::put(const void *data) throw (ConversionException)
+void InputCorbaPort::put(const void *data)
{
put((CORBA::Any *)data);
}
{//do nothing - to be implemented
}
-void InputCorbaPort::put(CORBA::Any *data) throw (ConversionException)
+void InputCorbaPort::put(CORBA::Any *data)
{
#ifdef REFCNT
DEBTRACE("refcount CORBA : " << ((omni::TypeCode_base*)data->pd_tc.in())->pd_ref_count);
return new InputCorbaPort(*this,newHelder);
}
-void *InputCorbaPort::get() const throw(YACS::Exception)
+void *InputCorbaPort::get() const
{
return (void *)&_data;
}
#endif
}
-void OutputCorbaPort::put(const void *data) throw (ConversionException)
+void OutputCorbaPort::put(const void *data)
{
put((CORBA::Any *)data);
}
-void OutputCorbaPort::put(CORBA::Any *data) throw (ConversionException)
+void OutputCorbaPort::put(CORBA::Any *data)
{
InputPort *p;
virtual ~InputCorbaPort();
bool edIsManuallyInitialized() const;
void edRemoveManInit();
- virtual void put(const void *data) throw(ConversionException);
- void put(CORBA::Any *data) throw (ConversionException);
+ virtual void put(const void *data);
+ void put(CORBA::Any *data);
void releaseData() override;
InputPort *clone(Node *newHelder) const;
- void *get() const throw(Exception);
+ void *get() const ;
virtual bool isEmpty();
virtual CORBA::Any * getAny();
virtual std::string getAsString();
OutputCorbaPort(const std::string& name, Node *node, TypeCode * type);
OutputCorbaPort(const OutputCorbaPort& other, Node *newHelder);
virtual ~OutputCorbaPort();
- virtual void put(const void *data) throw(ConversionException);
- void put(CORBA::Any *data) throw (ConversionException);
+ virtual void put(const void *data);
+ void put(CORBA::Any *data);
OutputPort *clone(Node *newHelder) const;
virtual CORBA::Any * getAny();
virtual CORBA::Any * getAnyOut();
: ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
{}
-void CorbaPyDouble::put(const void *data) throw(ConversionException)
+void CorbaPyDouble::put(const void *data)
{
put((CORBA::Any *)data);
}
/*!
* \param data : CORBA::Any object
*/
-void CorbaPyDouble::put(CORBA::Any *data) throw(ConversionException)
+void CorbaPyDouble::put(CORBA::Any *data)
{
InterpreterUnlocker loc;
PyObject* ob=convertCorbaPyObject(edGetType(),data);
: ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
{}
-void CorbaPyInt::put(const void *data) throw(ConversionException)
+void CorbaPyInt::put(const void *data)
{
put((CORBA::Any *)data);
}
/*!
* \param data : CORBA::Any object
*/
-void CorbaPyInt::put(CORBA::Any *data) throw(ConversionException)
+void CorbaPyInt::put(CORBA::Any *data)
{
InterpreterUnlocker loc;
PyObject* ob=convertCorbaPyObject(edGetType(),data);
CorbaPyString::CorbaPyString(InputPyPort* p)
: ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
{}
-void CorbaPyString::put(const void *data) throw(ConversionException)
+void CorbaPyString::put(const void *data)
{
put((CORBA::Any *)data);
}
/*!
* \param data : CORBA::Any object
*/
-void CorbaPyString::put(CORBA::Any *data) throw(ConversionException)
+void CorbaPyString::put(CORBA::Any *data)
{
InterpreterUnlocker loc;
PyObject* ob=convertCorbaPyObject(edGetType(),data);
/*!Convert a CORBA::Any boolean to a PyObject boolean
* It's only a wrapper around put(CORBA::Any *data)
*/
-void CorbaPyBool::put(const void *data) throw(ConversionException)
+void CorbaPyBool::put(const void *data)
{
put((CORBA::Any *)data);
}
/*!
* \param data : CORBA::Any object
*/
-void CorbaPyBool::put(CORBA::Any *data) throw(ConversionException)
+void CorbaPyBool::put(CORBA::Any *data)
{
InterpreterUnlocker loc;
PyObject* ob=convertCorbaPyObject(edGetType(),data);
: ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode())
{}
-void CorbaPyObjref::put(const void *data) throw(ConversionException)
+void CorbaPyObjref::put(const void *data)
{
put((CORBA::Any *)data);
}
/*!
* \param data : CORBA::Any object
*/
-void CorbaPyObjref::put(CORBA::Any *data) throw(ConversionException)
+void CorbaPyObjref::put(CORBA::Any *data)
{
InterpreterUnlocker loc;
PyObject* ob=convertCorbaPyObject(edGetType(),data);
_dynfactory = getSALOMERuntime()->getDynFactory();
}
-void CorbaPySequence::put(const void *data) throw(ConversionException)
+void CorbaPySequence::put(const void *data)
{
put((CORBA::Any *)data);
}
/*!
* \param data : CORBA::Any object
*/
-void CorbaPySequence::put(CORBA::Any *data) throw(ConversionException)
+void CorbaPySequence::put(CORBA::Any *data)
{
InterpreterUnlocker loc;
PyObject* ob=convertCorbaPyObject(edGetType(),data);
{
}
-void CorbaPyStruct::put(const void *data) throw(ConversionException)
+void CorbaPyStruct::put(const void *data)
{
put((CORBA::Any *)data);
}
/*!
* \param data : CORBA::Any object
*/
-void CorbaPyStruct::put(CORBA::Any *data) throw(ConversionException)
+void CorbaPyStruct::put(CORBA::Any *data)
{
InterpreterUnlocker loc;
PyObject* ob=convertCorbaPyObject(edGetType(),data);
{
public:
CorbaPyDouble(InputPyPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(CORBA::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(CORBA::Any *data);
};
/*! \brief Class for conversion from CORBA Output port to Python Input port
{
public:
CorbaPyInt(InputPyPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(CORBA::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(CORBA::Any *data);
};
/*! \brief Class for conversion from CORBA Output port to Python Input port
{
public:
CorbaPyString(InputPyPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(CORBA::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(CORBA::Any *data);
};
/*! \brief Class for conversion from CORBA Output port to Python Input port
{
public:
CorbaPyBool(InputPyPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(CORBA::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(CORBA::Any *data);
};
/*! \brief Class for conversion from CORBA Output port to Python Input port
{
public:
CorbaPyObjref(InputPyPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(CORBA::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(CORBA::Any *data);
};
/*! \brief Class for conversion from CORBA Output port to Python Input port
{
public:
CorbaPySequence(InputPyPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(CORBA::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(CORBA::Any *data);
protected:
DynamicAny::DynAnyFactory_ptr _dynfactory;
};
{
public:
CorbaPyStruct(InputPyPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(CORBA::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(CORBA::Any *data);
};
}
* \param data : CORBA::Any object as a void * pointer
*/
-void CorbaXml::put(const void *data) throw(ConversionException)
+void CorbaXml::put(const void *data)
{
put((CORBA::Any *)data);
}
/*!
* \param data : CORBA::Any object
*/
-void CorbaXml::put(CORBA::Any *data) throw(ConversionException)
+void CorbaXml::put(CORBA::Any *data)
{
DEBTRACE("CorbaXml::put" );
std::string sss = convertCorbaXml(edGetType(),data);
{
public:
CorbaXml(InputXmlPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(CORBA::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(CORBA::Any *data);
};
}
}
return new OutputCalStreamPort(*this,newHelder);
}
-bool OutputCalStreamPort::addInPort(InPort *inPort) throw(YACS::Exception)
+bool OutputCalStreamPort::addInPort(InPort *inPort)
{
DEBTRACE("OutputCalStreamPort::addInPort " << InputCalStreamPort::NAME );
if(inPort->getNameOfTypeOfCurrentInstance()!=InputCalStreamPort::NAME)
}
-int OutputCalStreamPort::removeInPort(InPort *inPort, bool forward) throw(YACS::Exception)
+int OutputCalStreamPort::removeInPort(InPort *inPort, bool forward)
{
DEBTRACE("OutputCalStreamPort::removeInPort");
if(inPort->getNameOfTypeOfCurrentInstance()!=InputCalStreamPort::NAME && !forward)
void setSchema(const std::string& schema);
std::string getSchema(){return _schema;};
void setProperty(const std::string& name, const std::string& value);
- virtual bool addInPort(InPort *inPort) throw(Exception);
+ virtual bool addInPort(InPort *inPort) ;
std::string getNameOfTypeOfCurrentInstance() const;
OutputCalStreamPort * clone(Node *newHelder) const;
- virtual int removeInPort(InPort *inPort, bool forward) throw(Exception);
+ virtual int removeInPort(InPort *inPort, bool forward) ;
protected:
std::string _depend;
std::string _schema;
return convertNeutralCorba(t, data);
}
- void CppCorba::put(const void *data) throw(ConversionException)
+ void CppCorba::put(const void *data)
{
put((Any *)data);
}
* \param data : python object
*/
- void CppCorba::put(Any *data) throw(ConversionException)
+ void CppCorba::put(Any *data)
{
CORBA::Any* a = convertCppCorba(edGetType(), data);
_port->put(a);
public:
CppCorba(InputCorbaPort* p)
: ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode()) {}
- virtual void put(const void *data) throw(ConversionException);
- void put(Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(Any *data);
};
int isAdaptableCorbaCpp(const TypeCode *t1, const TypeCode *t2);
}
}
void CppComponent::run (const char * service, int nbIn, int nbOut,
- Any ** argIn, Any ** argOut) throw (YACS::Exception)
+ Any ** argIn, Any ** argOut)
{
int i;
returnInfo return_code;
virtual ~CppComponent();
void run(const char * service, int nbIn, int nbOut,
- Any ** argIn, Any ** argOut) throw (YACS::Exception);
+ Any ** argIn, Any ** argOut);
static const char KIND[];
virtual std::string getKind() const;
return NULL != _trueCont;
}
-void CppContainer::start(const Task *askingNode) throw (YACS::Exception)
+void CppContainer::start(const Task *askingNode)
{
_trueCont = LocalContainer::get();
}
return new CppContainer(*this);
}
-bool CppContainer::loadComponentLibrary(const std::string & componentName) throw (YACS::Exception)
+bool CppContainer::loadComponentLibrary(const std::string & componentName)
{
if (_trueCont)
{
return "/";
}
-void CppContainer::checkCapabilityToDealWith(const ComponentInstance *inst) const throw(YACS::Exception)
+void CppContainer::checkCapabilityToDealWith(const ComponentInstance *inst) const
{
if(inst->getKind()!=CppComponent::KIND)
throw Exception("CppContainer::checkCapabilityToDealWith : CppContainer is not able to deal with this type of ComponentInstance.");
virtual ~CppContainer();
std::string getKind() const;
bool isAlreadyStarted(const Task *askingNode) const;
- void start(const Task *askingNode) throw (YACS::Exception);
+ void start(const Task *askingNode);
void shutdown(int level);
std::string getPlacementId(const Task *askingNode) const;
std::string getFullPlacementId(const Task *askingNode) const;
void lock();
void unLock();
- void checkCapabilityToDealWith(const ComponentInstance *inst) const throw (YACS::Exception);
- bool loadComponentLibrary(const std::string & componentName) throw (YACS::Exception);
+ void checkCapabilityToDealWith(const ComponentInstance *inst) const;
+ bool loadComponentLibrary(const std::string & componentName);
CppComponent * createComponentInstance(const std::string & componentName);
void createInternalInstance(const std::string & componentName,
void *& obj, RunFunction &r, TerminateFunction &t);
* transition method from const void* to Any*
* \param data : const void * data
*/
- void CppCpp::put(const void *data) throw(ConversionException)
+ void CppCpp::put(const void *data)
{
put((Any *)data);
}
/*!
* \param data : Any object
*/
- void CppCpp::put(Any *data) throw(ConversionException)
+ void CppCpp::put(Any *data)
{
Any *a = convertCppCpp(edGetType(),data);
DEBTRACE( "before put refcnt: " << a->getRefCnt() );
{
public:
CppCpp(InputCppPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(Any *data);
};
}
{
}
- void CppNeutral::put(const void *data) throw(ConversionException)
+ void CppNeutral::put(const void *data)
{
DEBTRACE(" CppNeutral::put(const void *data)");
put((Any *)data);
* \param data : Neutral (Any *) value
*/
- void CppNeutral::put(Any *data) throw(ConversionException)
+ void CppNeutral::put(Any *data)
{
DEBTRACE("CppNeutral::put " << data);
Any *ob;
{
public:
CppNeutral(InputPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(Any *data) throw(ConversionException);
+ virtual void put(const void *data) ;
+ void put(Any *data);
};
int isAdaptableNeutralCpp(const TypeCode * t1, const TypeCode * t2);
}
InputPort::edRemoveManInit();
}
-void InputCppPort::put(const void *data) throw(ConversionException)
+void InputCppPort::put(const void *data)
{
put((YACS::ENGINE::Any *)data);
}
_data=nullptr;
}
-void InputCppPort::put(YACS::ENGINE::Any *data) throw(ConversionException)
+void InputCppPort::put(YACS::ENGINE::Any *data)
{
releaseData();
_data=data;
return _data;
}
-void *InputCppPort::get() const throw(YACS::Exception)
+void *InputCppPort::get() const
{
return (void*) _data;
}
{
}
-void OutputCppPort::put(const void *data) throw(ConversionException)
+void OutputCppPort::put(const void *data)
{
put((YACS::ENGINE::Any *)data);
}
-void OutputCppPort::put(YACS::ENGINE::Any *data) throw(ConversionException)
+void OutputCppPort::put(YACS::ENGINE::Any *data)
{
InputPort *p;
if(_data)
~InputCppPort();
bool edIsManuallyInitialized() const;
void edRemoveManInit();
- virtual void put(const void *data) throw(ConversionException);
- void put(YACS::ENGINE::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(YACS::ENGINE::Any *data);
void releaseData() override;
InputPort *clone(Node *newHelder) const;
virtual YACS::ENGINE::Any * getCppObj() const;
- void *get() const throw(Exception);
+ void *get() const ;
virtual bool isEmpty();
virtual void exSaveInit();
virtual void exRestoreInit();
OutputCppPort(const std::string& name, Node * node, TypeCode * type);
OutputCppPort(const OutputCppPort& other, Node *newHelder);
~OutputCppPort();
- virtual void put(const void *data) throw(ConversionException);
- void put(YACS::ENGINE::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(YACS::ENGINE::Any *data);
OutputPort *clone(Node *newHelder) const;
virtual YACS::ENGINE::Any * get() const;
virtual std::string dump();
/*!
* \param data : C++ value received
*/
- void CppPy::put(const void *data) throw(ConversionException)
+ void CppPy::put(const void *data)
{
put((Any *) data);
}
- void CppPy::put(Any *data) throw(ConversionException)
+ void CppPy::put(Any *data)
{
DEBTRACE(" CppPython::put(Any *data)");
PyObject *ob;
{
public:
CppPy(InputPyPort* p);
- virtual void put(const void *data) throw(ConversionException);
- virtual void put(Any *a) throw(ConversionException);
+ virtual void put(const void *data) ;
+ virtual void put(Any *a) ;
};
int isAdaptablePyObjectCpp(const TypeCode *t1, const TypeCode *t2);
}
* \param data : YACS::ENGINE::Any object as a void * pointer
*/
- void CppXml::put(const void *data) throw(ConversionException)
+ void CppXml::put(const void *data)
{
put((YACS::ENGINE::Any *)data);
}
/*!
* \param data : YACS::ENGINE::Any object
*/
- void CppXml::put(YACS::ENGINE::Any *data) throw(ConversionException)
+ void CppXml::put(YACS::ENGINE::Any *data)
{
DEBTRACE("CppXml::put");
std::string s = convertCppXml(edGetType(), data);
{
public:
CppXml(InputXmlPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(YACS::ENGINE::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(YACS::ENGINE::Any *data);
};
int isAdaptableXmlCpp(const TypeCode *t1, const TypeCode *t2);
}
if(!_container)
throw Exception("No container specified !");
SalomeContainer *containerCast0(dynamic_cast<SalomeContainer *>(_container));
- SalomeHPContainerBase *containerCast1(dynamic_cast<SalomeHPContainerBase *>(_container));
+ SalomeHPContainer *containerCast1(dynamic_cast<SalomeHPContainer *>(_container));
if(containerCast0)
objContainer=containerCast0->getContainerPtr(this);
else if(containerCast1)
{
- objContainer=containerCast1->getContainerPtr(this);
+ YACS::BASES::AutoCppPtr<SalomeContainerTmpForHP> tmpCont(SalomeContainerTmpForHP::BuildFrom(containerCast1,this));
+ objContainer=tmpCont->getContainerPtr(this);
}
else
throw Exception("Unrecognized type of container ! Salome one is expected !");
using namespace std;
-void NeutralCorbaInt::put(const void *data) throw(ConversionException)
+void NeutralCorbaInt::put(const void *data)
{
put((YACS::ENGINE::Any *)data);
}
* \param data : YACS::ENGINE::Any object
*/
-void NeutralCorbaInt::put(YACS::ENGINE::Any *data) throw(ConversionException)
+void NeutralCorbaInt::put(YACS::ENGINE::Any *data)
{
CORBA::Any *a =convertNeutralCorba(edGetType(),data);
_port->put(a);
delete a;
}
-void NeutralCorbaBool::put(const void *data) throw(ConversionException)
+void NeutralCorbaBool::put(const void *data)
{
put((YACS::ENGINE::Any *)data);
}
* \param data : YACS::ENGINE::Any object
*/
-void NeutralCorbaBool::put(YACS::ENGINE::Any *data) throw(ConversionException)
+void NeutralCorbaBool::put(YACS::ENGINE::Any *data)
{
CORBA::Any *a =convertNeutralCorba(edGetType(),data);
_port->put(a);
}
-void NeutralCorbaDouble::put(const void *data) throw(ConversionException)
+void NeutralCorbaDouble::put(const void *data)
{
put((YACS::ENGINE::Any *)data);
}
* \param data : YACS::ENGINE::Any object
*/
-void NeutralCorbaDouble::put(YACS::ENGINE::Any *data) throw(ConversionException)
+void NeutralCorbaDouble::put(YACS::ENGINE::Any *data)
{
CORBA::Any *a =convertNeutralCorba(edGetType(),data);
_port->put(a);
delete a;
}
-void NeutralCorbaSequence::put(const void *data) throw(ConversionException)
+void NeutralCorbaSequence::put(const void *data)
{
put((YACS::ENGINE::Any *)data);
}
/*!
* \param data : Neutral::Any object
*/
-void NeutralCorbaSequence::put(YACS::ENGINE::Any *data) throw(ConversionException)
+void NeutralCorbaSequence::put(YACS::ENGINE::Any *data)
{
CORBA::Any *a =convertNeutralCorba(edGetType(),data);
_port->put(a);
{
}
-void NeutralCorbaString::put(const void *data) throw(ConversionException)
+void NeutralCorbaString::put(const void *data)
{
put((YACS::ENGINE::Any *)data);
}
/*!
* \param data : Neutral::Any object
*/
-void NeutralCorbaString::put(YACS::ENGINE::Any *data) throw(ConversionException)
+void NeutralCorbaString::put(YACS::ENGINE::Any *data)
{
CORBA::Any *a =convertNeutralCorba(edGetType(),data);
_port->put(a);
{
}
-void NeutralCorbaObjref::put(const void *data) throw(ConversionException)
+void NeutralCorbaObjref::put(const void *data)
{
put((YACS::ENGINE::Any *)data);
}
/*!
* \param data : Neutral::Any object
*/
-void NeutralCorbaObjref::put(YACS::ENGINE::Any *data) throw(ConversionException)
+void NeutralCorbaObjref::put(YACS::ENGINE::Any *data)
{
CORBA::Any *a =convertNeutralCorba(edGetType(),data);
_port->put(a);
{
}
-void NeutralCorbaStruct::put(const void *data) throw(ConversionException)
+void NeutralCorbaStruct::put(const void *data)
{
put((YACS::ENGINE::Any *)data);
}
/*!
* \param data : Neutral::Any object
*/
-void NeutralCorbaStruct::put(YACS::ENGINE::Any *data) throw(ConversionException)
+void NeutralCorbaStruct::put(YACS::ENGINE::Any *data)
{
CORBA::Any *a =convertNeutralCorba(edGetType(),data);
_port->put(a);
public:
NeutralCorbaInt(InputCorbaPort* p)
: ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode()) {}
- virtual void put(const void *data) throw(ConversionException);
- void put(YACS::ENGINE::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(YACS::ENGINE::Any *data);
};
class NeutralCorbaDouble : public ProxyPort
public:
NeutralCorbaDouble(InputCorbaPort* p)
: ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode()) {}
- virtual void put(const void *data) throw(ConversionException);
- void put(YACS::ENGINE::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(YACS::ENGINE::Any *data);
};
class NeutralCorbaBool : public ProxyPort
public:
NeutralCorbaBool(InputCorbaPort* p)
: ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode()) {}
- virtual void put(const void *data) throw(ConversionException);
- void put(YACS::ENGINE::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(YACS::ENGINE::Any *data);
};
class NeutralCorbaSequence : public ProxyPort
public:
NeutralCorbaSequence(InputCorbaPort* p)
: ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode()) {}
- virtual void put(const void *data) throw(ConversionException);
- void put(YACS::ENGINE::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(YACS::ENGINE::Any *data);
};
class NeutralCorbaString : public ProxyPort
{
public:
NeutralCorbaString(InputCorbaPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(YACS::ENGINE::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(YACS::ENGINE::Any *data);
};
class NeutralCorbaObjref : public ProxyPort
{
public:
NeutralCorbaObjref(InputCorbaPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(YACS::ENGINE::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(YACS::ENGINE::Any *data);
};
class NeutralCorbaStruct : public ProxyPort
{
public:
NeutralCorbaStruct(InputCorbaPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(YACS::ENGINE::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(YACS::ENGINE::Any *data);
};
}
}
* transition method from const void* to Any*
* \param data : const void * data
*/
- void NeutralCpp::put(const void *data) throw(ConversionException)
+ void NeutralCpp::put(const void *data)
{
put((Any *)data);
}
/*!
* \param data : Any object
*/
- void NeutralCpp::put(Any *data) throw(ConversionException)
+ void NeutralCpp::put(Any *data)
{
Any *a = convertNeutralCpp(edGetType(),data);
DEBTRACE( "before put refcnt: " << a->getRefCnt() );
{
public:
NeutralCpp(InputCppPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(YACS::ENGINE::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(YACS::ENGINE::Any *data);
};
int isAdaptableCppNeutral(const TypeCode * t1, const TypeCode * t2);
}
{
}
-void NeutralInit::put(const void *data) throw(ConversionException)
+void NeutralInit::put(const void *data)
{
DEBTRACE(" NeutralInit::put(const void *data)");
put((YACS::ENGINE::Any *)data);
* \param data : YACS::ENGINE::Any object
*/
-void NeutralInit::put(YACS::ENGINE::Any *data) throw(ConversionException)
+void NeutralInit::put(YACS::ENGINE::Any *data)
{
DEBTRACE("NeutralInit::put " << data);
if(!edGetType()->isAdaptable(data->getType()))
{
public:
NeutralInit(InputPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(YACS::ENGINE::Any *data) throw(ConversionException);
+ virtual void put(const void *data) ;
+ void put(YACS::ENGINE::Any *data);
};
}
}
using namespace YACS::ENGINE;
using namespace std;
-void NeutralPyDouble::put(const void *data) throw(ConversionException)
+void NeutralPyDouble::put(const void *data)
{
put((YACS::ENGINE::Any *)data);
}
/*!
* \param data : YACS::ENGINE::Any object
*/
-void NeutralPyDouble::put(YACS::ENGINE::Any *data) throw(ConversionException)
+void NeutralPyDouble::put(YACS::ENGINE::Any *data)
{
InterpreterUnlocker loc;
PyObject* ob=convertNeutralPyObject(edGetType(),data);
}
-void NeutralPyInt::put(const void *data) throw(ConversionException)
+void NeutralPyInt::put(const void *data)
{
put((YACS::ENGINE::Any *)data);
}
/*!
* \param data : YACS::ENGINE::Any object
*/
-void NeutralPyInt::put(YACS::ENGINE::Any *data) throw(ConversionException)
+void NeutralPyInt::put(YACS::ENGINE::Any *data)
{
InterpreterUnlocker loc;
PyObject* ob=convertNeutralPyObject(edGetType(),data);
Py_DECREF(ob);
}
-void NeutralPyString::put(const void *data) throw(ConversionException)
+void NeutralPyString::put(const void *data)
{
put((YACS::ENGINE::Any *)data);
}
/*!
* \param data : YACS::ENGINE::Any object
*/
-void NeutralPyString::put(YACS::ENGINE::Any *data) throw(ConversionException)
+void NeutralPyString::put(YACS::ENGINE::Any *data)
{
InterpreterUnlocker loc;
PyObject* ob=convertNeutralPyObject(edGetType(),data);
Py_DECREF(ob);
}
-void NeutralPyBool::put(const void *data) throw(ConversionException)
+void NeutralPyBool::put(const void *data)
{
put((YACS::ENGINE::Any *)data);
}
/*!
* \param data : YACS::ENGINE::Any object
*/
-void NeutralPyBool::put(YACS::ENGINE::Any *data) throw(ConversionException)
+void NeutralPyBool::put(YACS::ENGINE::Any *data)
{
InterpreterUnlocker loc;
PyObject* ob=convertNeutralPyObject(edGetType(),data);
Py_DECREF(ob);
}
-void NeutralPyObjref::put(const void *data) throw(ConversionException)
+void NeutralPyObjref::put(const void *data)
{
put((YACS::ENGINE::Any *)data);
}
/*!
* \param data : Neutral::Any object
*/
-void NeutralPyObjref::put(YACS::ENGINE::Any *data) throw(ConversionException)
+void NeutralPyObjref::put(YACS::ENGINE::Any *data)
{
InterpreterUnlocker loc;
PyObject* ob=convertNeutralPyObject(edGetType(),data);
DEBTRACE( "ob refcnt: " << ob->ob_refcnt );
}
-void NeutralPySequence::put(const void *data) throw(ConversionException)
+void NeutralPySequence::put(const void *data)
{
put((YACS::ENGINE::Any *)data);
}
/*!
* \param data : Neutral::Any object
*/
-void NeutralPySequence::put(YACS::ENGINE::Any *data) throw(ConversionException)
+void NeutralPySequence::put(YACS::ENGINE::Any *data)
{
DEBTRACE( "--------NeutralPySequence::put" );
InterpreterUnlocker loc;
DEBTRACE( "ob refcnt: " << ob->ob_refcnt );
}
-void NeutralPyStruct::put(const void *data) throw(ConversionException)
+void NeutralPyStruct::put(const void *data)
{
put((YACS::ENGINE::Any *)data);
}
/*!
* \param data : Neutral::Any object
*/
-void NeutralPyStruct::put(YACS::ENGINE::Any *data) throw(ConversionException)
+void NeutralPyStruct::put(YACS::ENGINE::Any *data)
{
InterpreterUnlocker loc;
PyObject* ob=convertNeutralPyObject(edGetType(),data);
public:
NeutralPyDouble(InputPyPort* p)
: ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode()) {}
- virtual void put(const void *data) throw(ConversionException);
- void put(YACS::ENGINE::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(YACS::ENGINE::Any *data);
};
class NeutralPyInt : public ProxyPort
public:
NeutralPyInt(InputPyPort* p)
: ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode()) {}
- virtual void put(const void *data) throw(ConversionException);
- void put(YACS::ENGINE::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(YACS::ENGINE::Any *data);
};
class NeutralPyString : public ProxyPort
public:
NeutralPyString(InputPyPort* p)
: ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode()) {}
- virtual void put(const void *data) throw(ConversionException);
- void put(YACS::ENGINE::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(YACS::ENGINE::Any *data);
};
class NeutralPyBool : public ProxyPort
public:
NeutralPyBool(InputPyPort* p)
: ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode()) {}
- virtual void put(const void *data) throw(ConversionException);
- void put(YACS::ENGINE::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(YACS::ENGINE::Any *data);
};
class NeutralPyObjref : public ProxyPort
public:
NeutralPyObjref(InputPyPort* p)
: ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode()) {}
- virtual void put(const void *data) throw(ConversionException);
- void put(YACS::ENGINE::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(YACS::ENGINE::Any *data);
};
class NeutralPySequence : public ProxyPort
public:
NeutralPySequence(InputPyPort* p)
: ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode()) {}
- virtual void put(const void *data) throw(ConversionException);
- void put(YACS::ENGINE::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(YACS::ENGINE::Any *data);
};
class NeutralPyStruct : public ProxyPort
public:
NeutralPyStruct(InputPyPort* p)
: ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode()) {}
- virtual void put(const void *data) throw(ConversionException);
- void put(YACS::ENGINE::Any *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(YACS::ENGINE::Any *data);
};
}
}
{
}
-void NeutralXml::put(const void *data) throw(ConversionException)
+void NeutralXml::put(const void *data)
{
DEBTRACE(" NeutralXml::put(const void *data)");
put((YACS::ENGINE::Any *)data);
* \param data : YACS::ENGINE::Any object
*/
-void NeutralXml::put(YACS::ENGINE::Any *data) throw(ConversionException)
+void NeutralXml::put(YACS::ENGINE::Any *data)
{
DEBTRACE("NeutralXml::put " << data);
std::string sss = convertNeutralXml(edGetType(),data);
{
public:
NeutralXml(InputXmlPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(YACS::ENGINE::Any *data) throw(ConversionException);
+ virtual void put(const void *data) ;
+ void put(YACS::ENGINE::Any *data);
};
}
}
inp->setData(data);
}
-void OutNode::checkBasicConsistency() const throw(YACS::Exception)
+void OutNode::checkBasicConsistency() const
{
DEBTRACE("OutNode::checkBasicConsistency");
if (! _setOfOutputPort.empty())
OutNode(const OutNode& other, ComposedNode *father);
virtual void execute();
virtual void accept(Visitor *visitor);
- virtual void checkBasicConsistency() const throw(Exception);
+ virtual void checkBasicConsistency() const ;
virtual void setData(InputPort* port, const std::string& data);
virtual void dump(std::ostream &os);
virtual InputPort *createInputPort(const std::string& inputPortName, TypeCode* type);
outp->setData(data);
}
-void PresetNode::checkBasicConsistency() const throw(YACS::Exception)
+void PresetNode::checkBasicConsistency() const
{
DEBTRACE("PresetNode::checkBasicConsistency");
if (! _setOfInputPort.empty())
PresetNode(const PresetNode& other, ComposedNode *father);
virtual void execute();
virtual void accept(Visitor *visitor);
- virtual void checkBasicConsistency() const throw(Exception);
+ virtual void checkBasicConsistency() const ;
virtual void setData(OutputPort* port, const std::string& data);
virtual OutputPort *createOutputPort(const std::string& outputPortName, TypeCode* type);
virtual std::string typeName() {return "YACS__ENGINE__PresetNode";}
modified();
}
-void OutputPresetPort::checkBasicConsistency() const throw(YACS::Exception)
+void OutputPresetPort::checkBasicConsistency() const
{
DEBTRACE("OutputPresetPort::checkBasicConsistency " << _storeData);
if (_storeData.empty())
OutputPort *clone(Node *newHelder) const;
void setData(std::string data);
std::string getData();
- virtual void checkBasicConsistency() const throw(Exception);
+ virtual void checkBasicConsistency() const ;
virtual std::string dump();
virtual std::string getAsString();
virtual PyObject* getPyObj();
OptimizerAlgBase::finishProxy();
}
-void PyOptimizerAlgBase::initializeProxy(const Any *input) throw (YACS::Exception)
+void PyOptimizerAlgBase::initializeProxy(const Any *input)
{
GILState gs;
OptimizerAlgBase::initializeProxy(input);
virtual TypeCode *getTCForOutProxy() const;
virtual TypeCode *getTCForAlgoInitProxy() const;
virtual TypeCode *getTCForAlgoResultProxy() const;
- virtual void initializeProxy(const Any *input) throw (Exception);
+ virtual void initializeProxy(const Any *input) ;
virtual void startProxy();
virtual void takeDecisionProxy();
virtual void finishProxy();
/*!Convert a PyObject (integer) to CORBA::Any (integer)
* It's only a wrapper around put(PyObject *data)
*/
-void PyCorbaInt::put(const void *data) throw(ConversionException)
+void PyCorbaInt::put(const void *data)
{
put((PyObject *)data);
}
/*!
* \param data : python object
*/
-void PyCorbaInt::put(PyObject *data) throw(ConversionException)
+void PyCorbaInt::put(PyObject *data)
{
CORBA::Any *a= convertPyObjectCorba(_port->edGetType(),data);
YACS::ENGINE::InterpreterSaveThread _loc;
*
* \param data : python object
*/
-void PyCorbaBool::put(const void *data) throw(ConversionException)
+void PyCorbaBool::put(const void *data)
{
put((PyObject *)data);
}
*
* \param data : python object
*/
-void PyCorbaBool::put(PyObject *data) throw(ConversionException)
+void PyCorbaBool::put(PyObject *data)
{
CORBA::Any *a= convertPyObjectCorba(_port->edGetType(),data);
YACS::ENGINE::InterpreterSaveThread _loc;
delete a;
}
-void PyCorbaString::put(const void *data) throw(ConversionException)
+void PyCorbaString::put(const void *data)
{
put((PyObject *)data);
}
* \param data : python object
*/
-void PyCorbaString::put(PyObject *data) throw(ConversionException)
+void PyCorbaString::put(PyObject *data)
{
CORBA::Any *a= convertPyObjectCorba(_port->edGetType(),data);
YACS::ENGINE::InterpreterSaveThread _loc;
}
-void PyCorbaDouble::put(const void *data) throw(ConversionException)
+void PyCorbaDouble::put(const void *data)
{
put((PyObject *)data);
}
* \param data : python object
*/
-void PyCorbaDouble::put(PyObject *data) throw(ConversionException)
+void PyCorbaDouble::put(PyObject *data)
{
CORBA::Any *a= convertPyObjectCorba(_port->edGetType(),data);
YACS::ENGINE::InterpreterSaveThread _loc;
* \param data : python object
*/
-void PyCorbaSequence::put(const void *data) throw(ConversionException)
+void PyCorbaSequence::put(const void *data)
{
put((PyObject *)data);
}
-void PyCorbaSequence::put(PyObject *data) throw(ConversionException)
+void PyCorbaSequence::put(PyObject *data)
{
DEBTRACE("data refcnt: " << data->ob_refcnt);
#ifdef _DEVDEBUG_
* \param data : python object
*/
-void PyCorbaObjref::put(const void *data) throw(ConversionException)
+void PyCorbaObjref::put(const void *data)
{
put((PyObject *)data);
}
-void PyCorbaObjref::put(PyObject *data) throw(ConversionException)
+void PyCorbaObjref::put(PyObject *data)
{
DEBTRACE("data refcnt: " << data->ob_refcnt);
#ifdef _DEVDEBUG_
{
}
-void PyCorbaStruct::put(const void *data) throw(ConversionException)
+void PyCorbaStruct::put(const void *data)
{
put((PyObject *)data);
}
/*!
* \param data : python object
*/
-void PyCorbaStruct::put(PyObject *data) throw(ConversionException)
+void PyCorbaStruct::put(PyObject *data)
{
DEBTRACE("data refcnt: " << data->ob_refcnt);
#ifdef _DEVDEBUG_
public:
PyCorbaInt(InputCorbaPort* p)
: ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode()) {}
- virtual void put(const void *data) throw(ConversionException);
- void put(PyObject *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(PyObject *data);
};
class PyCorbaDouble : public ProxyPort
public:
PyCorbaDouble(InputCorbaPort* p)
: ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode()) {}
- virtual void put(const void *data) throw(ConversionException);
- void put(PyObject *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(PyObject *data);
};
class PyCorbaString : public ProxyPort
public:
PyCorbaString(InputCorbaPort* p)
: ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode()) {}
- virtual void put(const void *data) throw(ConversionException);
- void put(PyObject *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(PyObject *data);
};
class PyCorbaBool : public ProxyPort
public:
PyCorbaBool(InputCorbaPort* p)
: ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode()) {}
- virtual void put(const void *data) throw(ConversionException);
- void put(PyObject *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(PyObject *data);
};
class PyCorbaObjref : public ProxyPort
{
public:
PyCorbaObjref(InputCorbaPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(PyObject *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(PyObject *data);
protected:
PyObject * _pyorb;
CORBA::ORB_ptr _orb;
{
public:
PyCorbaSequence(InputCorbaPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(PyObject *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(PyObject *data);
};
class PyCorbaStruct : public ProxyPort
{
public:
PyCorbaStruct(InputCorbaPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(PyObject *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(PyObject *data);
};
}
return convertPyObjectNeutral(t, data);
}
- void PyCpp::put(const void *data) throw(ConversionException)
+ void PyCpp::put(const void *data)
{
put((PyObject *)data);
}
* \param data : python object
*/
- void PyCpp::put(PyObject *data) throw(ConversionException)
+ void PyCpp::put(PyObject *data)
{
YACS::ENGINE::Any *a;
//Do not need to take the Python GIL as put is called from Python node
public:
PyCpp(InputCppPort* p)
: ProxyPort(p), DataPort(p->getName(), p->getNode(), p->edGetType()), Port(p->getNode()) {}
- virtual void put(const void *data) throw(ConversionException);
- void put(PyObject *data) throw(ConversionException);
+ virtual void put(const void *data) ;
+ void put(PyObject *data);
};
int isAdaptableCppPyObject(const TypeCode *t1, const TypeCode *t2);
}
* \param data : PyObject object as a void * pointer
*/
-void PyInit::put(const void *data) throw(ConversionException)
+void PyInit::put(const void *data)
{
put((PyObject *)data);
}
/*!
* \param data : PyObject object
*/
-void PyInit::put(PyObject *data) throw(ConversionException)
+void PyInit::put(PyObject *data)
{
DEBTRACE("PyInit::put(PyObject *data)"<<data->ob_refcnt);
InterpreterUnlocker l;
{
public:
PyInit(InputPyPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(PyObject *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(PyObject *data);
};
}
}
{
}
-void PyNeutral::put(const void *data) throw(ConversionException)
+void PyNeutral::put(const void *data)
{
DEBTRACE( " PyNeutral::put(const void *data)" );
put((PyObject *)data);
* \param data : Python value
*/
-void PyNeutral::put(PyObject *data) throw(ConversionException)
+void PyNeutral::put(PyObject *data)
{
DEBTRACE( "PyNeutral::put " );
YACS::ENGINE::Any *ob;
{
public:
PyNeutral(InputPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(PyObject *data) throw(ConversionException);
+ virtual void put(const void *data) ;
+ void put(PyObject *data);
};
}
}
" args=pickle.loads(st)\n"
" return args\n";
-
PythonEntry::PythonEntry():_context(0),_pyfuncSer(0),_pyfuncUnser(0),_pyfuncSimpleSer(0)
{
}
Py_XDECREF(_context);
}
-void PythonEntry::commonRemoteLoadPart1(InlineNode *reqNode)
+void PythonEntry::loadRemoteContainer(InlineNode *reqNode)
{
DEBTRACE( "---------------PythonEntry::CommonRemoteLoad function---------------" );
Container *container(reqNode->getContainer());
bool isContAlreadyStarted(false);
if(container)
{
- isContAlreadyStarted=container->isAlreadyStarted(reqNode);
- if(!isContAlreadyStarted)
+ try
+ {
+ if(hasImposedResource())
+ container->start(reqNode, _imposedResource, _imposedContainer);
+ else
{
- try
- {
- container->start(reqNode);
- }
- catch(Exception& e)
- {
- reqNode->setErrorDetails(e.what());
- throw e;
- }
+ isContAlreadyStarted=container->isAlreadyStarted(reqNode);
+ if(!isContAlreadyStarted)
+ container->start(reqNode);
}
+ }
+ catch(Exception& e)
+ {
+ reqNode->setErrorDetails(e.what());
+ throw e;
+ }
}
else
{
if(!container)
throw YACS::Exception("No container specified !");
SalomeContainer *containerCast0(dynamic_cast<SalomeContainer *>(container));
- SalomeHPContainerBase *containerCast1(dynamic_cast<SalomeHPContainerBase *>(container));
+ SalomeHPContainer *containerCast1(dynamic_cast<SalomeHPContainer *>(container));
if(containerCast0)
{
isStandardCont = true;
}
else if(containerCast1)
{
- objContainer=containerCast1->getContainerPtr(reqNode);
+ YACS::BASES::AutoCppPtr<SalomeContainerTmpForHP> tmpCont(SalomeContainerTmpForHP::BuildFrom(containerCast1,reqNode));
+ objContainer=tmpCont->getContainerPtr(reqNode);
}
else
throw YACS::Exception("Unrecognized type of container ! Salome one is expected for PythonNode/PyFuncNode !");
return objContainer;
}
-Engines::Container_var PythonEntry::commonRemoteLoadPart2(InlineNode *reqNode, bool& isInitializeRequested)
+Engines::Container_var PythonEntry::loadPythonAdapter(InlineNode *reqNode, bool& isInitializeRequested)
{
bool isStandardCont(true);
Engines::Container_var objContainer(GetContainerObj(reqNode,isStandardCont));
isInitializeRequested=false;
try
{
- if(isStandardCont)
- {
- createRemoteAdaptedPyInterpretor(objContainer);
- }
- else
- {
- Engines::PyNodeBase_var dftPyScript(retrieveDftRemotePyInterpretorIfAny(objContainer));
- if(CORBA::is_nil(dftPyScript))
- {
- isInitializeRequested=true;
- createRemoteAdaptedPyInterpretor(objContainer);
- }
- else
- assignRemotePyInterpretor(dftPyScript);
- }
+ Engines::PyNodeBase_var dftPyScript(retrieveDftRemotePyInterpretorIfAny(objContainer));
+ if(CORBA::is_nil(dftPyScript))
+ {
+ isInitializeRequested=!isStandardCont;
+ createRemoteAdaptedPyInterpretor(objContainer);
+ }
+ else
+ assignRemotePyInterpretor(dftPyScript);
}
catch( const SALOME::SALOME_Exception& ex )
{
return objContainer;
}
-void PythonEntry::commonRemoteLoadPart3(InlineNode *reqNode, Engines::Container_ptr objContainer, bool isInitializeRequested)
+void PythonEntry::loadRemoteContext(InlineNode *reqNode, Engines::Container_ptr objContainer, bool isInitializeRequested)
{
Container *container(reqNode->getContainer());
Engines::PyNodeBase_var pynode(getRemoteInterpreterHandle());
void PythonEntry::commonRemoteLoad(InlineNode *reqNode)
{
- commonRemoteLoadPart1(reqNode);
+ loadRemoteContainer(reqNode);
bool isInitializeRequested;
- Engines::Container_var objContainer(commonRemoteLoadPart2(reqNode,isInitializeRequested));
- commonRemoteLoadPart3(reqNode,objContainer,isInitializeRequested);
+ Engines::Container_var objContainer(loadPythonAdapter(reqNode,isInitializeRequested));
+ loadRemoteContext(reqNode,objContainer,isInitializeRequested);
+}
+
+bool PythonEntry::hasImposedResource()const
+{
+ return !_imposedResource.empty() && !_imposedContainer.empty();
}
PythonNode::PythonNode(const PythonNode& other, ComposedNode *father):InlineNode(other,father),_autoSqueeze(other._autoSqueeze)
{
+ _pynode = Engines::PyScriptNode::_nil();
_implementation=IMPL_NAME;
{
AutoGIL agil;
PythonNode::PythonNode(const std::string& name):InlineNode(name)
{
+ _pynode = Engines::PyScriptNode::_nil();
_implementation=IMPL_NAME;
{
AutoGIL agil;
PythonNode::~PythonNode()
{
- if(!CORBA::is_nil(_pynode))
- {
- _pynode->UnRegister();
- }
+ freeKernelPynode();
}
-void PythonNode::checkBasicConsistency() const throw(YACS::Exception)
+void PythonNode::checkBasicConsistency() const
{
DEBTRACE("checkBasicConsistency");
InlineNode::checkBasicConsistency();
{
DEBTRACE( "++++++++++++++ PyNode::executeRemote: " << getName() << " ++++++++++++++++++++" );
if(!_pyfuncSer)
- throw Exception("DistributedPythonNode badly loaded");
+ throw Exception("PythonNode badly loaded");
//
if(dynamic_cast<HomogeneousPoolContainer *>(getContainer()))
{
bool dummy;
- commonRemoteLoadPart2(this,dummy);
+ loadPythonAdapter(this,dummy);
_pynode->assignNewCompiledCode(getScript().c_str());
}
//
_errorDetails=msg.str();
throw Exception(msg.str());
}
- if(!CORBA::is_nil(_pynode))
- {
- _pynode->UnRegister();
- }
- _pynode = Engines::PyScriptNode::_nil();
- //
- bool dummy;
- Engines::Container_var cont(GetContainerObj(this,dummy));
- cont->removePyScriptNode(getName().c_str());
+// if(!CORBA::is_nil(_pynode))
+// {
+// _pynode->UnRegister();
+// }
+// _pynode = Engines::PyScriptNode::_nil();
+// //
+// bool dummy;
+// Engines::Container_var cont(GetContainerObj(this,dummy));
+// cont->removePyScriptNode(getName().c_str());
DEBTRACE( "-----------------end of remote python invocation-----------------" );
//===========================================================================
// Get results, unpickle and put them in output ports
if(_autoSqueeze)
squeezeMemoryRemote();
}
+ //
+ if(!isUsingPythonCache())
+ {
+ freeKernelPynode();
+ bool dummy;
+ Engines::Container_var cont(GetContainerObj(this,dummy));
+ cont->removePyScriptNode(getName().c_str());
+ }
DEBTRACE( "++++++++++++++ ENDOF PyNode::executeRemote: " << getName() << " ++++++++++++++++++++" );
}
if(_mode=="local")return;
if(_container)
{
- if(!CORBA::is_nil(_pynode)) _pynode->UnRegister();
- _pynode=Engines::PyScriptNode::_nil();
+ freeKernelPynode();
_container->shutdown(level);
}
}
+void PythonNode::imposeResource(const std::string& resource_name,
+ const std::string& container_name)
+{
+ if(!resource_name.empty() && !container_name.empty())
+ {
+ _imposedResource = resource_name;
+ _imposedContainer = container_name;
+ }
+}
+
+bool PythonNode::canAcceptImposedResource()
+{
+ return _container != nullptr && _container->canAcceptImposedResource();
+}
+
+bool PythonNode::hasImposedResource()const
+{
+ return PythonEntry::hasImposedResource();
+}
+
+std::string PythonNode::pythonEntryName()const
+{
+ if(isUsingPythonCache())
+ return "DEFAULT_NAME_FOR_UNIQUE_PYTHON_NODE_ENTRY";
+ else
+ return getName();
+}
+
+bool PythonNode::isUsingPythonCache()const
+{
+ bool found = false;
+ if(_container)
+ found = _container->isUsingPythonCache();
+ return found;
+}
+
+void PythonNode::freeKernelPynode()
+{
+ if(!CORBA::is_nil(_pynode))
+ {
+ try
+ {
+ _pynode->UnRegister();
+ }
+ catch(...)
+ {
+ DEBTRACE("Trouble when pynode->UnRegister!")
+ }
+ _pynode = Engines::PyScriptNode::_nil();
+ }
+}
+
Node *PythonNode::simpleClone(ComposedNode *father, bool editionOnly) const
{
return new PythonNode(*this,father);
void PythonNode::createRemoteAdaptedPyInterpretor(Engines::Container_ptr objContainer)
{
- if(!CORBA::is_nil(_pynode))
- _pynode->UnRegister();
- _pynode=objContainer->createPyScriptNode(getName().c_str(),getScript().c_str());
+ freeKernelPynode();
+ _pynode=objContainer->createPyScriptNode(pythonEntryName().c_str(),getScript().c_str());
_pynode->Register();
}
Engines::PyNodeBase_var PythonNode::retrieveDftRemotePyInterpretorIfAny(Engines::Container_ptr objContainer) const
{
- Engines::PyScriptNode_var ret(objContainer->getDefaultPyScriptNode(getName().c_str()));
+ Engines::PyScriptNode_var ret(objContainer->getDefaultPyScriptNode(pythonEntryName().c_str()));
if(!CORBA::is_nil(ret))
{
ret->Register();
void PythonNode::assignRemotePyInterpretor(Engines::PyNodeBase_var remoteInterp)
{
- if(!CORBA::is_nil(_pynode))
+ if(CORBA::is_nil(_pynode))
+ _pynode=Engines::PyScriptNode::_narrow(remoteInterp);
+ else
+ {
+ Engines::PyScriptNode_var tmpp(Engines::PyScriptNode::_narrow(remoteInterp));
+ if(!_pynode->_is_equivalent(tmpp))
{
- Engines::PyScriptNode_var tmpp(Engines::PyScriptNode::_narrow(remoteInterp));
- if(_pynode->_is_equivalent(tmpp))
- {
- _pynode->UnRegister();
- return ;
- }
+ freeKernelPynode();
+ _pynode=Engines::PyScriptNode::_narrow(remoteInterp);
}
- if(!CORBA::is_nil(_pynode))
- _pynode->UnRegister();
- _pynode=Engines::PyScriptNode::_narrow(remoteInterp);
+ }
+ _pynode->assignNewCompiledCode(getScript().c_str());
}
Engines::PyNodeBase_var PythonNode::getRemoteInterpreterHandle()
setState(YACS::TORECONNECT);
}
-void PyFuncNode::checkBasicConsistency() const throw(YACS::Exception)
+void PyFuncNode::checkBasicConsistency() const
{
DEBTRACE("checkBasicConsistency");
InlineFuncNode::checkBasicConsistency();
if(dynamic_cast<HomogeneousPoolContainer *>(getContainer()))
{
bool dummy;
- commonRemoteLoadPart2(this,dummy);
+ loadPythonAdapter(this,dummy);
_pynode->executeAnotherPieceOfCode(getScript().c_str());
}
//
}
}
+void PyFuncNode::imposeResource(const std::string& resource_name,
+ const std::string& container_name)
+{
+ if(!resource_name.empty() && !container_name.empty())
+ {
+ _imposedResource = resource_name;
+ _imposedContainer = container_name;
+ }
+}
+
+bool PyFuncNode::canAcceptImposedResource()
+{
+ return _container != nullptr && _container->canAcceptImposedResource();
+}
+
+bool PyFuncNode::hasImposedResource()const
+{
+ return PythonEntry::hasImposedResource();
+}
+
virtual const char *getSerializationScript() const = 0;
//
void commonRemoteLoad(InlineNode *reqNode);
- void commonRemoteLoadPart1(InlineNode *reqNode);
- Engines::Container_var commonRemoteLoadPart2(InlineNode *reqNode, bool& isInitializeRequested);
- void commonRemoteLoadPart3(InlineNode *reqNode, Engines::Container_ptr objContainer, bool isInitializeRequested);
+ void loadRemoteContainer(InlineNode *reqNode);
+ Engines::Container_var loadPythonAdapter(InlineNode *reqNode, bool& isInitializeRequested);
+ void loadRemoteContext(InlineNode *reqNode, Engines::Container_ptr objContainer, bool isInitializeRequested);
static std::string GetContainerLog(const std::string& mode, Container *container, const Task *askingTask);
+ virtual bool hasImposedResource()const;
protected:
PyObject *_context;
PyObject *_pyfuncSer;
PyObject *_pyfuncUnser;
PyObject *_pyfuncSimpleSer;
+ std::string _imposedResource;
+ std::string _imposedContainer;
public:
static const char SCRIPT_FOR_SIMPLE_SERIALIZATION[];
};
void assignRemotePyInterpretor(Engines::PyNodeBase_var remoteInterp);
Engines::PyNodeBase_var getRemoteInterpreterHandle();
const char *getSerializationScript() const { return SCRIPT_FOR_SERIALIZATION; }
+ // A kernel container may manage several python contexts identified by
+ // their name (PyNode and PyScript node). This function returns the name
+ // of the context used by this object. See SALOME_Component.idl in KERNEL.
+ std::string pythonEntryName()const;
public:
PythonNode(const PythonNode& other, ComposedNode *father);
PythonNode(const std::string& name);
virtual ~PythonNode();
- virtual void checkBasicConsistency() const throw(Exception);
+ virtual void checkBasicConsistency() const ;
virtual void execute();
virtual void load();
virtual void loadRemote();
virtual void executeRemote();
virtual void executeLocal();
virtual void shutdown(int level);
+ void imposeResource(const std::string& resource_name,
+ const std::string& container_name) override;
+ bool canAcceptImposedResource()override;
+ bool hasImposedResource()const override;
+ bool isUsingPythonCache()const;
std::string getContainerLog();
PythonNode* cloneNode(const std::string& name);
virtual std::string typeName() { return "YACS__ENGINE__PythonNode"; }
protected:
void squeezeMemory();
void squeezeMemoryRemote();
+ void freeKernelPynode();
public:
static const char KIND[];
static const char IMPL_NAME[];
PyFuncNode(const std::string& name);
virtual ~PyFuncNode();
virtual void init(bool start=true);
- virtual void checkBasicConsistency() const throw(Exception);
+ virtual void checkBasicConsistency() const ;
virtual void execute();
virtual void load();
virtual void loadRemote();
virtual void executeRemote();
virtual void executeLocal();
virtual void shutdown(int level);
+ void imposeResource(const std::string& resource_name,
+ const std::string& container_name) override;
+ bool canAcceptImposedResource()override;
+ bool hasImposedResource()const override;
std::string getContainerLog();
PyFuncNode* cloneNode(const std::string& name);
virtual std::string typeName() { return "YACS__ENGINE__PyFuncNode"; }
InputPort::edRemoveManInit();
}
-void InputPyPort::put(const void *data) throw(ConversionException)
+void InputPyPort::put(const void *data)
{
put((PyObject *)data);
}
InputPyPort::releaseDataUnsafe();
}
-void InputPyPort::put(PyObject *data) throw(ConversionException)
+void InputPyPort::put(PyObject *data)
{
InterpreterUnlocker l;
InputPyPort::releaseDataUnsafe();
return _data;
}
-void *InputPyPort::get() const throw(YACS::Exception)
+void *InputPyPort::get() const
{
return (void*) _data;
}
Py_INCREF(_data);
}
-void OutputPyPort::put(const void *data) throw(ConversionException)
+void OutputPyPort::put(const void *data)
{
put((PyObject *)data);
}
-void OutputPyPort::putWithoutForward(PyObject *data) throw(ConversionException)
+void OutputPyPort::putWithoutForward(PyObject *data)
{
DEBTRACE( "OutputPyPort::put.ob refcnt: " << data->ob_refcnt );
#ifdef _DEVDEBUG_
//no registerPyObj : we steal the output reference of the node
}
-void OutputPyPort::put(PyObject *data) throw(ConversionException)
+void OutputPyPort::put(PyObject *data)
{
putWithoutForward(data);
DEBTRACE( "OutputPyPort::put.ob refcnt: " << data->ob_refcnt );
~InputPyPort();
bool edIsManuallyInitialized() const;
void edRemoveManInit();
- virtual void put(const void *data) throw(ConversionException);
+ virtual void put(const void *data);
void releaseData() override;
- void put(PyObject *data) throw(ConversionException);
+ void put(PyObject *data);
InputPort *clone(Node *newHelder) const;
//special typedef PyObj used in SWIG to increment ref count on output
virtual PyObj * getPyObj() const;
virtual std::string getAsString();
- void *get() const throw(Exception);
+ void *get() const ;
virtual std::string getHumanRepr();
virtual bool isEmpty();
virtual void exSaveInit();
OutputPyPort(const std::string& name, Node * node, TypeCode * type);
OutputPyPort(const OutputPyPort& other, Node *newHelder);
~OutputPyPort();
- virtual void put(const void *data) throw(ConversionException);
- void putWithoutForward(PyObject *data) throw(ConversionException);
- void put(PyObject *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void putWithoutForward(PyObject *data);
+ void put(PyObject *data);
OutputPort *clone(Node *newHelder) const;
virtual PyObject * get() const;
//special typedef PyObj used in SWIG to increment ref count on output
* \param data : PyObject object as a void * pointer
*/
-void PyXml::put(const void *data) throw(ConversionException)
+void PyXml::put(const void *data)
{
put((PyObject *)data);
}
/*!
* \param data : PyObject object
*/
-void PyXml::put(PyObject *data) throw(ConversionException)
+void PyXml::put(PyObject *data)
{
DEBTRACE("PyXml::put" );
std::string sss = convertPyObjectXml(edGetType(),data);
{
public:
PyXml(InputXmlPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(PyObject *data) throw(ConversionException);
+ virtual void put(const void *data);
+ void put(PyObject *data);
};
}
}
}
catch(SALOME_Exception& e)
{
- throw Exception("SalomeContainerToolsSpreadOverTheResDecorator::getParameters : Unable to contact the SALOME Naming Service");
+ throw Exception("RuntimeSALOME::getCatalogOfComputeNodes : Unable to contact the SALOME Naming Service");
}
CORBA::Object_var obj(namingService.Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS));
if(CORBA::is_nil(obj))
- throw Exception("SalomeContainerToolsSpreadOverTheResDecorator::getParameters : Unable to access to the resource manager !");
+ throw Exception("RuntimeSALOME::getCatalogOfComputeNodes : Unable to access to the resource manager !");
Engines::ResourcesManager_var resManager(Engines::ResourcesManager::_narrow(obj));
if(CORBA::is_nil(resManager))
- throw Exception("SalomeContainerToolsSpreadOverTheResDecorator::getParameters : Internal error ! The entry attached to the res manager in NS does not have right type !");
+ throw Exception("RuntimeSALOME::getCatalogOfComputeNodes : Internal error ! The entry attached to the res manager in NS does not have right type !");
std::vector< std::pair<std::string,int> > ret;
+ Engines::ResourceParameters params;
+ params.name = "";
+ params.hostname = "";
+ params.OS = "";
+ params.nb_proc = 0;
+ params.mem_mb = 0;
+ params.cpu_clock = 0;
+ params.nb_node = 0;
+ params.nb_proc_per_node = 0;
+ params.policy = "";
+ params.can_launch_batch_jobs = false;
+ params.can_run_containers = true;
+ params.componentList.length(0);
+ try
+ {
+ Engines::ResourceList_var resourceList;
+ resourceList = resManager->GetFittingResources(params);
+ ret.reserve(resourceList->length());
+ for(int i = 0; i<resourceList->length(); i++)
+ {
+ const char* resource_name = resourceList[i];
+ std::string std_resource_name = resource_name;
+ Engines::ResourceDefinition_var resource_definition
+ = resManager->GetResourceDefinition(resource_name);
+ int nb_cores = resource_definition->nb_node *
+ resource_definition->nb_proc_per_node;
+ ret.push_back(std::pair<std::string,int>(resource_name, nb_cores));
+ }
+ }
+ catch(SALOME::SALOME_Exception& e)
{
- Engines::ResourceList *rl(0);
- Engines::IntegerList *il(0);
- resManager->ListAllAvailableResources(rl,il);
- int sz(rl->length());
- if(il->length()!=sz)
- throw Exception("SalomeContainerToolsSpreadOverTheResDecorator::getParameters : Internal error ! Invalid size !");
- ret.resize(sz);
- for(int i=0;i<sz;i++)
- {
- std::string s((*rl)[i]);
- ret[i]=std::pair<std::string,int>(s,(*il)[i]);
- }
- delete rl;
- delete il;
+ std::string message;
+ message=e.details.text.in();
+ throw Exception(message);
}
+
return ret;
}
*/
InputPort* RuntimeSALOME::adapt(InputPort* source,
const std::string& impl,
- TypeCode * type,bool init) throw (ConversionException)
+ TypeCode * type,bool init)
{
string imp_source=source->getNode()->getImplementation();
if(imp_source == PythonNode::IMPL_NAME)
*/
InputPort* RuntimeSALOME::adapt(InPropertyPort* source,
const std::string& impl,
- TypeCode * type,bool init) throw (ConversionException)
+ TypeCode * type,bool init)
{
return adaptNeutral((InputPort *)source,impl,type,init);
}
* \return an adaptated input port of type InputCorbaPort
*/
InputPort* RuntimeSALOME::adaptNeutralToCorba(InputPort* inport,
- TypeCode * type) throw (ConversionException)
+ TypeCode * type)
{
// BEWARE : using the generic check
if(inport->edGetType()->isAdaptable(type))
* \return an adaptated input port of type InputPyPort
*/
InputPort* RuntimeSALOME::adaptNeutralToPython(InputPort* inport,
- TypeCode * type) throw (ConversionException)
+ TypeCode * type)
{
// BEWARE : using the generic check
if(inport->edGetType()->isAdaptable(type))
* \return an input port of type InputXmlPort
*/
InputPort* RuntimeSALOME::adaptNeutralToXml(InputPort* inport,
- TypeCode * type) throw (ConversionException)
+ TypeCode * type)
{
// BEWARE : using the generic check
if(inport->edGetType()->isAdaptable(type))
* \return an input port of type InputCppPort
*/
InputPort* RuntimeSALOME::adaptNeutralToCpp(InputPort* inport,
- TypeCode * type) throw (ConversionException)
+ TypeCode * type)
{
DEBTRACE("RuntimeSALOME::adaptNeutralToCpp(InputPort* inport" );
if(isAdaptableNeutralCpp(type,inport->edGetType()))
*/
InputPort* RuntimeSALOME::adaptNeutral(InputPort* source,
const std::string& impl,
- TypeCode * type,bool init) throw (ConversionException)
+ TypeCode * type,bool init)
{
if(impl == CppNode::IMPL_NAME)
{
*/
InputPort* RuntimeSALOME::adaptXmlToCorba(InputXmlPort* inport,
- TypeCode * type) throw (ConversionException)
+ TypeCode * type)
{
if(isAdaptableXmlCorba(type,inport->edGetType()))
{
* \return an adaptated input port of type InputPyPort
*/
InputPort* RuntimeSALOME::adaptXmlToPython(InputXmlPort* inport,
- TypeCode * type) throw (ConversionException)
+ TypeCode * type)
{
if(inport->edGetType()->isAdaptable(type))
{
* \return an adaptated input port of type InputPyPort
*/
InputPort* RuntimeSALOME::adaptXmlToCpp(InputXmlPort* inport,
- TypeCode * type) throw (ConversionException)
+ TypeCode * type)
{
DEBTRACE("RuntimeSALOME::adaptXmlToCpp(InputPort* inport" );
DEBTRACE(type->kind() << " " << inport->edGetType()->kind() );
* \return an adaptated input port of type Neutralxxxx
*/
InputPort* RuntimeSALOME::adaptXmlToNeutral(InputXmlPort* inport,
- TypeCode * type) throw (ConversionException)
+ TypeCode * type)
{
if(inport->edGetType()->isAdaptable(type))
{
* \return an adaptated input port of type Xmlxxxx
*/
InputPort* RuntimeSALOME::adaptXmlToXml(InputXmlPort* inport,
- TypeCode * type,bool init) throw (ConversionException)
+ TypeCode * type,bool init)
{
if(init)
return new ProxyPort(inport);
InputPort* RuntimeSALOME::adapt(InputXmlPort* source,
const std::string& impl,
- TypeCode * type,bool init) throw (ConversionException)
+ TypeCode * type,bool init)
{
if(impl == CORBANode::IMPL_NAME)
{
* \return an adaptator port of type InputCORBAPort
*/
InputPort* RuntimeSALOME::adaptCorbaToCorba(InputCorbaPort* inport,
- TypeCode * type) throw (ConversionException)
+ TypeCode * type)
{
if(type->isA(inport->edGetType()))
{
*/
InputPort* RuntimeSALOME::adaptCorbaToPython(InputCorbaPort* inport,
- TypeCode * type) throw (ConversionException)
+ TypeCode * type)
{
if(inport->edGetType()->kind() == Double)
{
*/
InputPort* RuntimeSALOME::adaptCorbaToXml(InputCorbaPort* inport,
- TypeCode * type) throw (ConversionException)
+ TypeCode * type)
{
// BEWARE : using the generic check
if(inport->edGetType()->isAdaptable(type))
*/
InputPort* RuntimeSALOME::adaptCorbaToCpp(InputCorbaPort* inport,
- TypeCode * type) throw (ConversionException)
+ TypeCode * type)
{
DEBTRACE("RuntimeSALOME::adaptCorbaToCpp(InputCorbaPort* inport" );
if(isAdaptableCorbaCpp(type,inport->edGetType()))
*/
InputPort* RuntimeSALOME::adaptCorbaToNeutral(InputCorbaPort* inport,
- TypeCode * type) throw (ConversionException)
+ TypeCode * type)
{
if(inport->edGetType()->kind() == Double)
{
InputPort* RuntimeSALOME::adapt(InputCorbaPort* source,
const std::string& impl,
- TypeCode * type,bool init) throw (ConversionException)
+ TypeCode * type,bool init)
{
if(impl == CppNode::IMPL_NAME)
{
*/
InputPort* RuntimeSALOME::adaptPythonToPython(InputPyPort* inport,
- TypeCode * type,bool init) throw (ConversionException)
+ TypeCode * type,bool init)
{
if(init)
return new PyInit(inport);
*/
InputPort* RuntimeSALOME::adaptPythonToCpp(InputPyPort* inport,
- TypeCode * type) throw (ConversionException)
+ TypeCode * type)
{
DEBTRACE("RuntimeSALOME::adaptPythonToCpp(InputPyPort* inport" );
if(isAdaptablePyObjectCpp(type,inport->edGetType()))
*/
InputPort* RuntimeSALOME::adaptPythonToNeutral(InputPyPort* inport,
- TypeCode * type) throw (ConversionException)
+ TypeCode * type)
{
if(inport->edGetType()->kind() == Double)
{
*/
InputPort* RuntimeSALOME::adaptPythonToCorba(InputPyPort* inport,
- TypeCode * type) throw (ConversionException)
+ TypeCode * type)
{
if(inport->edGetType()->kind() == Double)
{
*/
InputPort* RuntimeSALOME::adaptPythonToXml(InputPyPort* inport,
- TypeCode * type) throw (ConversionException)
+ TypeCode * type)
{
// BEWARE : using the generic check
if(inport->edGetType()->isAdaptable(type))
InputPort* RuntimeSALOME::adapt(InputPyPort* source,
const std::string& impl,
- TypeCode * type,bool init) throw (ConversionException)
+ TypeCode * type,bool init)
{
if(impl == CppNode::IMPL_NAME)
{
*/
InputPort* RuntimeSALOME::adaptCppToCorba(InputCppPort* inport,
- TypeCode * type) throw (ConversionException)
+ TypeCode * type)
{
DEBTRACE("RuntimeSALOME::adaptCppToCorba(InputCppPort* inport)");
if(isAdaptableCppCorba(type,inport->edGetType()))
* \return an adaptated input port of type InputPyPort
*/
InputPort* RuntimeSALOME::adaptCppToPython(InputCppPort* inport,
- TypeCode * type) throw (ConversionException)
+ TypeCode * type)
{
DEBTRACE("RuntimeSALOME::adaptCppToPython(InputCppPort* inport)");
if(isAdaptableCppPyObject(type,inport->edGetType()))
* \return an adaptated input port of type InputPyPort
*/
InputPort* RuntimeSALOME::adaptCppToCpp(InputCppPort* inport,
- TypeCode * type) throw (ConversionException)
+ TypeCode * type)
{
DEBTRACE("RuntimeSALOME::adaptCppToCpp(InputPort* inport" );
DEBTRACE(type->kind() << " " << inport->edGetType()->kind() );
* \return an adaptated input port of type InputPyPort
*/
InputPort* RuntimeSALOME::adaptCppToNeutral(InputCppPort* inport,
- TypeCode * type) throw (ConversionException)
+ TypeCode * type)
{
DEBTRACE("RuntimeSALOME::adaptCppToNeutral(InputPort* inport" );
DEBTRACE(type->kind() << " " << inport->edGetType()->kind() );
}
InputPort* RuntimeSALOME::adaptCppToXml(InputCppPort* inport,
- TypeCode * type) throw (ConversionException)
+ TypeCode * type)
{
DEBTRACE("RuntimeSALOME::adaptCppToXml(InputCppPort* inport" );
if(isAdaptableCppXml(type,inport->edGetType()))
InputPort* RuntimeSALOME::adapt(InputCppPort* source,
const std::string& impl,
- TypeCode * type,bool init) throw (ConversionException)
+ TypeCode * type,bool init)
{
DEBTRACE("RuntimeSALOME::adapt(InputCppPort* source)");
if(impl == CORBANode::IMPL_NAME)
virtual InputPort* adapt(InputPort* source,
const std::string& impl,
- TypeCode * type,bool init=false) throw (ConversionException);
+ TypeCode * type,bool init=false);
virtual InputPort* adapt(InPropertyPort* source,
const std::string& impl,
- TypeCode * type,bool init=false) throw (ConversionException);
+ TypeCode * type,bool init=false);
virtual InputPort* adaptNeutral(InputPort* source,
const std::string& impl,
- TypeCode * type,bool init) throw (ConversionException);
+ TypeCode * type,bool init);
virtual InputPort* adapt(InputCorbaPort* source,
const std::string& impl,
- TypeCode * type,bool init) throw (ConversionException);
+ TypeCode * type,bool init);
virtual InputPort* adaptCorbaToCorba(InputCorbaPort* source,
- TypeCode * type) throw (ConversionException);
+ TypeCode * type);
virtual InputPort* adaptCorbaToNeutral(InputCorbaPort* source,
- TypeCode * type) throw (ConversionException);
+ TypeCode * type);
virtual InputPort* adaptCorbaToPython(InputCorbaPort* source,
- TypeCode * type) throw (ConversionException);
+ TypeCode * type);
virtual InputPort* adaptCorbaToCpp(InputCorbaPort* source,
- TypeCode * type) throw (ConversionException);
+ TypeCode * type);
virtual InputPort* adaptCorbaToXml(InputCorbaPort* source,
- TypeCode * type) throw (ConversionException);
+ TypeCode * type);
virtual InputPort* adapt(InputPyPort* source,
const std::string& impl,
- TypeCode * type,bool init) throw (ConversionException);
+ TypeCode * type,bool init);
virtual InputPort* adaptPythonToCorba(InputPyPort* source,
- TypeCode * type) throw (ConversionException);
+ TypeCode * type);
virtual InputPort* adaptPythonToNeutral(InputPyPort* source,
- TypeCode * type) throw (ConversionException);
+ TypeCode * type);
virtual InputPort* adaptPythonToPython(InputPyPort* source,
- TypeCode * type,bool init) throw (ConversionException);
+ TypeCode * type,bool init);
virtual InputPort* adaptPythonToXml(InputPyPort* source,
- TypeCode * type) throw (ConversionException);
+ TypeCode * type);
virtual InputPort* adaptPythonToCpp(InputPyPort* source,
- TypeCode * type) throw (ConversionException);
+ TypeCode * type);
virtual InputPort* adapt(InputCppPort* source,
const std::string& impl,
- TypeCode * type,bool init) throw (ConversionException);
+ TypeCode * type,bool init);
virtual InputPort* adaptCppToCorba(InputCppPort* source,
- TypeCode * type) throw (ConversionException);
+ TypeCode * type);
virtual InputPort* adaptCppToNeutral(InputCppPort* source,
- TypeCode * type) throw (ConversionException);
+ TypeCode * type);
virtual InputPort* adaptCppToPython(InputCppPort* source,
- TypeCode * type) throw (ConversionException);
+ TypeCode * type);
virtual InputPort* adaptCppToXml(InputCppPort* source,
- TypeCode * type) throw (ConversionException);
+ TypeCode * type);
virtual InputPort* adaptCppToCpp(InputCppPort* source,
- TypeCode * type) throw (ConversionException);
+ TypeCode * type);
virtual InputPort* adapt(InputXmlPort* source,
const std::string& impl,
- TypeCode * type,bool init) throw (ConversionException);
+ TypeCode * type,bool init);
virtual InputPort* adaptXmlToCorba(InputXmlPort* source,
- TypeCode * type) throw (ConversionException);
+ TypeCode * type);
virtual InputPort* adaptXmlToPython(InputXmlPort* inport,
- TypeCode * type) throw (ConversionException);
+ TypeCode * type);
virtual InputPort* adaptXmlToCpp(InputXmlPort* inport,
- TypeCode * type) throw (ConversionException);
+ TypeCode * type);
virtual InputPort* adaptXmlToNeutral(InputXmlPort* inport,
- TypeCode * type) throw (ConversionException);
+ TypeCode * type);
virtual InputPort* adaptXmlToXml(InputXmlPort* inport,
- TypeCode * type,bool init) throw (ConversionException);
+ TypeCode * type,bool init);
virtual InputPort* adaptNeutralToXml(InputPort* inport,
- TypeCode * type) throw (ConversionException);
+ TypeCode * type);
virtual InputPort* adaptNeutralToPython(InputPort* inport,
- TypeCode * type) throw (ConversionException);
+ TypeCode * type);
virtual InputPort* adaptNeutralToCorba(InputPort* inport,
- TypeCode * type) throw (ConversionException);
+ TypeCode * type);
virtual InputPort* adaptNeutralToCpp(InputPort* inport,
- TypeCode * type) throw (ConversionException);
+ TypeCode * type);
virtual void* convertNeutral(TypeCode * type, Any *data);
virtual std::string convertNeutralAsString(TypeCode * type, Any *data);
return new SalomeContainer(*this);
}
-void SalomeContainer::checkCapabilityToDealWith(const ComponentInstance *inst) const throw(YACS::Exception)
+void SalomeContainer::checkCapabilityToDealWith(const ComponentInstance *inst) const
{
if(inst->getKind()!=SalomeComponent::KIND)
throw Exception("SalomeContainer::checkCapabilityToDealWith : SalomeContainer is not able to deal with this type of ComponentInstance.");
/*!
* \param inst the component instance
*/
-void SalomeContainer::start(const Task *askingNode) throw(YACS::Exception)
+void SalomeContainer::start(const Task *askingNode)
{
SalomeContainerTools::Start(_componentNames,_launchModeType,_sct,_shutdownLevel,this,askingNode);
}
+void SalomeContainer::start(const Task *askingNode,
+ const std::string& resource_name,
+ const std::string& container_name)
+{
+ if(canAcceptImposedResource()
+ && askingNode != nullptr
+ && askingNode->hasImposedResource())
+ {
+ SalomeContainerTools tempSct = _sct;
+ tempSct.setProperty("name", resource_name);
+ tempSct.setProperty("container_name", container_name);
+ //SalomeContainerTools::Start(_componentNames,_launchModeType,tempSct,_shutdownLevel,this,askingNode);
+ // components are not supported yet on this kind of start
+ std::vector<std::string> noComponentNames;
+ int shutdownLevel = 999;
+ SalomeContainerTools::Start(noComponentNames,_launchModeType,tempSct,shutdownLevel,this,askingNode);
+ }
+ else
+ start(askingNode);
+}
+
+bool SalomeContainer::canAcceptImposedResource()
+{
+ return _launchModeType->getType() == SalomeContainerMultiHelper::TYPE_NAME;
+}
+
void SalomeContainer::shutdown(int level)
{
DEBTRACE("SalomeContainer::shutdown: " << _name << "," << level << "," << _shutdownLevel);
std::string getKind() const;
bool isAlreadyStarted(const Task *askingNode) const;
Engines::Container_ptr getContainerPtr(const Task *askingNode) const;
- void start(const Task *askingNode) throw (Exception);
+ void start(const Task *askingNode) override;
+ void start(const Task *askingNode,
+ const std::string& resource_name,
+ const std::string& container_name) override;
+ bool canAcceptImposedResource() override;
Container *clone() const;
Container *cloneAlways() const;
std::string getPlacementId(const Task *askingNode) const;
std::string getFullPlacementId(const Task *askingNode) const;
- void checkCapabilityToDealWith(const ComponentInstance *inst) const throw (Exception);
+ void checkCapabilityToDealWith(const ComponentInstance *inst) const ;
void setProperty(const std::string& name, const std::string& value);
std::string getProperty(const std::string& name) const;
void clearProperties();
Engines::Container_var SalomeContainerMultiHelper::getContainer(const Task *askingNode) const
{
+ std::unique_lock<std::mutex> lock(_data_mutex);
const ComponentInstance *inst(askingNode?askingNode->getComponent():0);
- std::map<const ComponentInstance *,Engines::Container_var>::const_iterator it(_trueContainers.find(inst));
- if(it!=_trueContainers.end())
- return (*it).second;
+ if(inst == nullptr && askingNode != nullptr && askingNode->hasImposedResource())
+ {
+ std::map<const Task *,Engines::Container_var>::const_iterator it(_containersForTasks.find(askingNode));
+ if(it!=_containersForTasks.end())
+ return (*it).second;
+ else
+ return Engines::Container::_nil();
+ }
else
- return Engines::Container::_nil();
+ {
+ std::map<const ComponentInstance *,Engines::Container_var>::const_iterator it(_containersForComponents.find(inst));
+ if(it!=_containersForComponents.end())
+ return (*it).second;
+ else
+ return Engines::Container::_nil();
+ }
}
bool SalomeContainerMultiHelper::isAlreadyStarted(const Task *askingNode) const
{
+ std::unique_lock<std::mutex> lock(_data_mutex);
const ComponentInstance *inst(askingNode?askingNode->getComponent():0);
- if(_trueContainers.count(inst)==0)
- return false;
+ if(inst == nullptr && askingNode != nullptr && askingNode->hasImposedResource())
+ {
+ return _containersForTasks.count(askingNode) > 0;
+ }
else
- return true;
+ {
+ if(_containersForComponents.count(inst)==0)
+ return false;
+ else
+ return true;
+ }
}
void SalomeContainerMultiHelper::setContainer(const Task *askingNode, Engines::Container_var cont)
{
+ std::unique_lock<std::mutex> lock(_data_mutex);
const ComponentInstance *inst(askingNode?askingNode->getComponent():0);
- _trueContainers[inst]=cont;
+ if(inst == nullptr && askingNode != nullptr && askingNode->hasImposedResource())
+ {
+ _containersForTasks[askingNode] = cont;
+ }
+ else
+ {
+ _containersForComponents[inst]=cont;
#ifdef REFCNT
std::map<const ComponentInstance *, Engines::Container_var >::const_iterator it;
- for(it = _trueContainers.begin(); it != _trueContainers.end(); ++it)
+ for(it = _containersForComponents.begin(); it != _containersForComponents.end(); ++it)
{
DEBTRACE(it->second->_PR_getobj()->pd_refCount );
}
#endif
+ }
}
void SalomeContainerMultiHelper::shutdown()
{
- for(std::map<const ComponentInstance *, Engines::Container_var >::const_iterator it = _trueContainers.begin(); it != _trueContainers.end(); ++it)
+ std::unique_lock<std::mutex> lock(_data_mutex);
+ for(std::map<const Task *, Engines::Container_var >::const_iterator it = _containersForTasks.begin();
+ it != _containersForTasks.end(); ++it)
+ {
+ try
+ {
+ DEBTRACE("shutdown SALOME container: " );
+ CORBA::String_var containerName=it->second->name();
+ DEBTRACE(containerName);
+ it->second->Shutdown();
+ std::cerr << "shutdown SALOME container: " << containerName << std::endl;
+ }
+ catch(CORBA::Exception&)
+ {
+ DEBTRACE("Unexpected CORBA failure detected." );
+ }
+ catch(...)
+ {
+ DEBTRACE("Unknown exception ignored." );
+ }
+ }
+ _containersForTasks.clear();
+
+ for(std::map<const ComponentInstance *, Engines::Container_var >::const_iterator it = _containersForComponents.begin(); it != _containersForComponents.end(); ++it)
{
try
{
DEBTRACE("Unknown exception ignored." );
}
}
- _trueContainers.clear();
+ _containersForComponents.clear();
}
SalomeContainerMultiHelper::~SalomeContainerMultiHelper()
#include <map>
#include <string>
+#include <mutex>
namespace YACS
{
static const char TYPE_NAME[];
static const char DFT_LAUNCH_MODE[];
private:
- std::map<const ComponentInstance *,Engines::Container_var> _trueContainers;
+ std::map<const ComponentInstance *,Engines::Container_var> _containersForComponents;
+ std::map<const Task *,Engines::Container_var> _containersForTasks;
+ mutable std::mutex _data_mutex;
};
}
}
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-
+#define _DEVDEBUG_
#include "SalomeContainerTools.hxx"
#include "SALOME_LifeCycleCORBA.hxx"
#include "SALOME_NamingService.hxx"
using namespace YACS::ENGINE;
-/*!
- * \param [in] compoNames
- * \param [in,out] shutdownLevel
- */
-void SalomeContainerToolsBase::Start(const std::vector<std::string>& compoNames, SalomeContainerHelper *schelp, SalomeContainerToolsBase& sct, int& shutdownLevel, const Container *cont, const Task *askingNode)
-{
- CORBA::ORB_ptr orb(getSALOMERuntime()->getOrb());
- SALOME_NamingService ns;
- try
- {
- ns.init_orb(orb);
- }
- catch(SALOME_Exception& e)
- {
- throw Exception("SalomeContainer::start : Unable to contact the SALOME Naming Service");
- }
- CORBA::Object_var obj(ns.Resolve(SALOME_ContainerManager::_ContainerManagerNameInNS));
- Engines::ContainerManager_var contManager(Engines::ContainerManager::_narrow(obj));
-
- bool isEmptyName;
- std::string str(sct.getNotNullContainerName(cont,askingNode,isEmptyName));
- DEBTRACE("SalomeContainer::start " << str <<";"<< sct.getHostName() <<";"<< schelp->getType());
-
- // Finalize parameters with components found in the container
-
- for(std::vector<std::string>::const_iterator iter=compoNames.begin();iter!=compoNames.end();iter++)
- sct.addToComponentList(*iter);
-
- Engines::ContainerParameters myparams(sct.getParameters());
- {
- std::string dftLauchMode(schelp->getDftLaunchMode());
- myparams.mode=CORBA::string_dup(dftLauchMode.c_str());
- }
-
- //If a container_name is given try to find an already existing container in naming service
- //If not found start a new container with the given parameters
- if (dynamic_cast<SalomeContainerMonoHelper *>(schelp) && !isEmptyName)
- {
- myparams.mode=CORBA::string_dup("getorstart");
- }
-
- if (isEmptyName)
- {
- shutdownLevel=1;
- }
- //sct.setContainerName(str);
- SetContainerNameOf(myparams,str);
- Engines::Container_var trueCont(Engines::Container::_nil());
- if(!isEmptyName && shutdownLevel==999)
- {
- //Make this only the first time start is called (_shutdownLevel==999)
- //If the container is named, first try to get an existing container
- //If there is an existing container use it and set the shutdown level to 3
- //If there is no existing container, try to launch a new one and set the shutdown level to 2
- myparams.mode="get";
- try
- {
- trueCont=contManager->GiveContainer(myparams);
- }
- catch( const SALOME::SALOME_Exception& ex )
- {
- std::string msg="SalomeContainer::start : no existing container : ";
- msg += '\n';
- msg += ex.details.text.in();
- DEBTRACE( msg );
- }
- catch(...)
- {
- }
-
- if(!CORBA::is_nil(trueCont))
- {
- shutdownLevel=3;
- DEBTRACE( "container found: " << str << " " << _shutdownLevel );
- }
- else
- {
- shutdownLevel=2;
- myparams.mode="start";
- DEBTRACE( "container not found: " << str << " " << _shutdownLevel);
- }
- }
-
- if(CORBA::is_nil(trueCont))
- try
- {
- // --- GiveContainer is used in batch mode to retreive launched containers,
- // and is equivalent to StartContainer when not in batch.
- trueCont=contManager->GiveContainer(myparams);
- }
- catch( const SALOME::SALOME_Exception& ex )
- {
- std::string msg="SalomeContainer::start : Unable to launch container in Salome : ";
- msg += '\n';
- msg += ex.details.text.in();
- throw Exception(msg);
- }
- catch(CORBA::COMM_FAILURE&)
- {
- throw Exception("SalomeContainer::start : Unable to launch container in Salome : CORBA Comm failure detected");
- }
- catch(CORBA::Exception&)
- {
- throw Exception("SalomeContainer::start : Unable to launch container in Salome : Unexpected CORBA failure detected");
- }
-
- if(CORBA::is_nil(trueCont))
- throw Exception("SalomeContainer::start : Unable to launch container in Salome. Check your CatalogResources.xml file");
-
- schelp->setContainer(askingNode,trueCont);
-
- CORBA::String_var containerName(trueCont->name()),hostName(trueCont->getHostName());
- std::cerr << "SalomeContainer launched : " << containerName << " " << hostName << " " << trueCont->getPID() << std::endl;
-}
-
-CORBA::Object_ptr SalomeContainerToolsBase::LoadComponent(SalomeContainerHelper *launchModeType, Container *cont, Task *askingNode)
-{
- DEBTRACE("SalomeContainer::loadComponent ");
- const ComponentInstance *inst(askingNode?askingNode->getComponent():0);
- {
- YACS::BASES::AutoLocker<Container> alck(cont);//To be sure
- if(!cont->isAlreadyStarted(askingNode))
- cont->start(askingNode);
- }
- if(!inst)
- throw Exception("SalomeContainerTools::LoadComponent : no instance of component in the task requesting for a load of its component !");
- CORBA::Object_ptr objComponent=CORBA::Object::_nil();
- {
- YACS::BASES::AutoLocker<Container> alck(cont);//To be sure
- std::string compoName(inst->getCompoName());
- Engines::Container_var container(launchModeType->getContainer(askingNode));
-
- char *reason;
- bool isLoadable(container->load_component_Library(compoName.c_str(), reason));
- if(isLoadable)
- objComponent=CreateComponentInstance(cont,container,inst);
- }
- return objComponent;
-}
-
-CORBA::Object_ptr SalomeContainerToolsBase::CreateComponentInstance(Container *cont, Engines::Container_ptr contPtr, const ComponentInstance *inst)
-{
- if(!inst)
- throw Exception("SalomeContainerTools::CreateComponentInstance : no instance of component in the task requesting for a load of its component !");
- char *reason(0);
- std::string compoName(inst->getCompoName());
- CORBA::Object_ptr objComponent=CORBA::Object::_nil();
- int studyid(1);
- Proc* p(cont->getProc());
- if(p)
- {
- std::string value(p->getProperty("DefaultStudyID"));
- if(!value.empty())
- studyid= atoi(value.c_str());
- }
- // prepare component instance properties
- Engines::FieldsDict_var env(new Engines::FieldsDict);
- std::map<std::string, std::string> properties(inst->getProperties());
- if(p)
- {
- std::map<std::string,std::string> procMap=p->getProperties();
- properties.insert(procMap.begin(),procMap.end());
- }
-
- std::map<std::string, std::string>::const_iterator itm;
- env->length(properties.size());
- int item=0;
- for(itm = properties.begin(); itm != properties.end(); ++itm, item++)
- {
- DEBTRACE("envname="<<itm->first<<" envvalue="<< itm->second);
- env[item].key= CORBA::string_dup(itm->first.c_str());
- env[item].value <<= itm->second.c_str();
- }
-
- objComponent=contPtr->create_component_instance_env(compoName.c_str(), env, reason);
- if(CORBA::is_nil(objComponent))
- {
- std::string text="Error while trying to create a new component: component '"+ compoName;
- text=text+"' is not installed or it's a wrong name";
- text += '\n';
- text += reason;
- CORBA::string_free(reason);
- throw Exception(text);
- }
- return objComponent;
-}
-
-std::string SalomeContainerToolsBase::GetPlacementId(const SalomeContainerHelper *launchModeType, const Container *cont, const Task *askingNode)
-{
- if(cont->isAlreadyStarted(askingNode))
- {
- Engines::Container_var container(launchModeType->getContainer(askingNode));
- const char *what="/";
- CORBA::String_var corbaStr(container->name());
- std::string ret(corbaStr);
-
- //Salome FOREVER ...
- std::string::size_type i=ret.find_first_of(what,0);
- i=ret.find_first_of(what, i==std::string::npos ? i:i+1);
- if(i!=std::string::npos)
- return ret.substr(i+1);
- return ret;
- }
- else
- return "Not placed yet !!!";
-}
-
-std::string SalomeContainerToolsBase::GetFullPlacementId(const SalomeContainerHelper *launchModeType, const Container *cont, const Task *askingNode)
-{
- if(cont->isAlreadyStarted(askingNode))
- {
- Engines::Container_var container(launchModeType->getContainer(askingNode));
- try
- {
- CORBA::String_var corbaStr(container->name());
- std::string ret(corbaStr);
- return ret;
- }
- catch(...)
- {
- return "Unknown_placement";
- }
- }
- else
- return "Not_placed_yet";
-}
-
-void SalomeContainerToolsBase::SetContainerNameOf(Engines::ContainerParameters& params, const std::string& name)
-{
- params.container_name=CORBA::string_dup(name.c_str());
-}
-
-
-/////////////////////////////////
-
-SalomeContainerToolsInter::SalomeContainerToolsInter(const SalomeContainerToolsInter& other):_propertyMap(other._propertyMap)
-{
-}
-
-void SalomeContainerToolsInter::clearProperties()
-{
- _propertyMap.clear();
-}
-
-std::string SalomeContainerToolsInter::getProperty(const std::string& name) const
-{
- std::map<std::string,std::string>::const_iterator it(_propertyMap.find(name));
- if(it!=_propertyMap.end())
- return (*it).second;
- else
- return std::string();
-}
-
-std::map<std::string,std::string> SalomeContainerToolsInter::getResourceProperties(const std::string& name) const
-{
- std::map<std::string,std::string> properties;
-
- YACS::ENGINE::RuntimeSALOME* runTime = YACS::ENGINE::getSALOMERuntime();
- CORBA::ORB_ptr orb = runTime->getOrb();
- if (!orb) return properties;
- SALOME_NamingService namingService(orb);
- SALOME_LifeCycleCORBA lcc(&namingService);
- CORBA::Object_var obj = namingService.Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS);
- if (CORBA::is_nil(obj))
- return properties;
- Engines::ResourcesManager_var resManager = Engines::ResourcesManager::_narrow(obj);
- if (CORBA::is_nil(resManager))
- return properties;
-
- std::ostringstream value;
- Engines::ResourceDefinition_var resource_definition = resManager->GetResourceDefinition(name.c_str());
- properties["hostname"]=resource_definition->hostname.in();
- properties["OS"]=resource_definition->OS.in();
- value.str(""); value << resource_definition->mem_mb;
- properties["mem_mb"]=value.str();
- value.str(""); value << resource_definition->cpu_clock;
- properties["cpu_clock"]=value.str();
- value.str(""); value << resource_definition->nb_node;
- properties["nb_node"]=value.str();
- value.str(""); value << resource_definition->nb_proc_per_node;
- properties["nb_proc_per_node"]=value.str();
- /*
- properties["component_list"]="";
- for(CORBA::ULong i=0; i < resource_definition->componentList.length(); i++)
- {
- if(i > 0)
- properties["component_list"]=properties["component_list"]+",";
- properties["component_list"]=properties["component_list"]+resource_definition->componentList[i].in();
- }
- */
- return properties;
-}
-
-////////////////////////
-
SalomeContainerTools::SalomeContainerTools()
{
/* Init ContainerParameters */
SALOME_LifeCycleCORBA::preSet(_params);
}
-SalomeContainerTools::SalomeContainerTools(const SalomeContainerTools& other):SalomeContainerToolsInter(other),_params(other._params)
+SalomeContainerTools::SalomeContainerTools(const SalomeContainerTools& other):_params(other._params),_propertyMap(other._propertyMap)
{
}
-int SalomeContainerTools::getNumberOfCoresPerWorker() const
+void SalomeContainerTools::clearProperties()
{
- return _params.resource_params.nb_proc_per_node;
+ _propertyMap.clear();
+ _params=Engines::ContainerParameters();
}
-void SalomeContainerTools::clearProperties()
+std::string SalomeContainerTools::getProperty(const std::string& name) const
{
- SalomeContainerToolsInter::clearProperties();
- _params=Engines::ContainerParameters();
+ std::map<std::string,std::string>::const_iterator it(_propertyMap.find(name));
+ if(it!=_propertyMap.end())
+ return (*it).second;
+ else
+ return std::string();
}
void SalomeContainerTools::setProperty(const std::string& name, const std::string& value)
return std::string(_params.container_name);
}
-void SalomeContainerTools::setContainerName(const std::string& name)
+int SalomeContainerTools::getNumberOfCoresPerWorker() const
{
- SetContainerNameOf(_params,name);
+ return _params.resource_params.nb_proc_per_node;
}
-std::string SalomeContainerTools::getHostName() const
+void SalomeContainerTools::setContainerName(const std::string& name)
{
- return std::string(_params.resource_params.hostname);
+ SetContainerNameOf(_params,name);
}
std::string SalomeContainerTools::getNotNullContainerName(const Container *contPtr, const Task *askingNode, bool& isEmpty) const
}
}
-//////////////////////////
-
-std::string SalomeContainerToolsDecoratorBase::getProperty(const std::string& name) const
+std::string SalomeContainerTools::getHostName() const
{
- return _sct->getProperty(name);
+ return std::string(_params.resource_params.hostname);
}
-void SalomeContainerToolsDecoratorBase::setProperty(const std::string& name, const std::string& value)
+void SalomeContainerToolsBase::SetContainerNameOf(Engines::ContainerParameters& params, const std::string& name)
{
- _sct->setProperty(name,value);
+ params.container_name=CORBA::string_dup(name.c_str());
}
-const std::map<std::string,std::string>& SalomeContainerToolsDecoratorBase::getProperties() const
+std::map<std::string,std::string> SalomeContainerTools::getResourceProperties(const std::string& name) const
{
- return _sct->getProperties();
-}
+ std::map<std::string,std::string> properties;
-void SalomeContainerToolsDecoratorBase::clearProperties()
-{
- _sct->clearProperties();
-}
+ YACS::ENGINE::RuntimeSALOME* runTime = YACS::ENGINE::getSALOMERuntime();
+ CORBA::ORB_ptr orb = runTime->getOrb();
+ if (!orb) return properties;
+ SALOME_NamingService namingService(orb);
+ SALOME_LifeCycleCORBA lcc(&namingService);
+ CORBA::Object_var obj = namingService.Resolve(SALOME_ResourcesManager::_ResourcesManagerNameInNS);
+ if (CORBA::is_nil(obj))
+ return properties;
+ Engines::ResourcesManager_var resManager = Engines::ResourcesManager::_narrow(obj);
+ if (CORBA::is_nil(resManager))
+ return properties;
-std::map<std::string,std::string> SalomeContainerToolsDecoratorBase::getResourceProperties(const std::string& name) const
-{
- return _sct->getResourceProperties(name);
+ std::ostringstream value;
+ Engines::ResourceDefinition_var resource_definition = resManager->GetResourceDefinition(name.c_str());
+ properties["hostname"]=resource_definition->hostname.in();
+ properties["OS"]=resource_definition->OS.in();
+ value.str(""); value << resource_definition->mem_mb;
+ properties["mem_mb"]=value.str();
+ value.str(""); value << resource_definition->cpu_clock;
+ properties["cpu_clock"]=value.str();
+ value.str(""); value << resource_definition->nb_node;
+ properties["nb_node"]=value.str();
+ value.str(""); value << resource_definition->nb_proc_per_node;
+ properties["nb_proc_per_node"]=value.str();
+ /*
+ properties["component_list"]="";
+ for(CORBA::ULong i=0; i < resource_definition->componentList.length(); i++)
+ {
+ if(i > 0)
+ properties["component_list"]=properties["component_list"]+",";
+ properties["component_list"]=properties["component_list"]+resource_definition->componentList[i].in();
+ }
+ */
+ return properties;
}
-void SalomeContainerToolsDecoratorBase::addToComponentList(const std::string& name)
+/*!
+ * \param [in] compoNames
+ * \param [in,out] shutdownLevel
+ */
+void SalomeContainerToolsBase::Start(const std::vector<std::string>& compoNames, SalomeContainerHelper *schelp, SalomeContainerToolsBase& sct, int& shutdownLevel, const Container *cont, const Task *askingNode)
{
- _sct->addToComponentList(name);
-}
+ CORBA::ORB_ptr orb(getSALOMERuntime()->getOrb());
+ SALOME_NamingService ns;
+ try
+ {
+ ns.init_orb(orb);
+ }
+ catch(SALOME_Exception& e)
+ {
+ throw Exception("SalomeContainer::start : Unable to contact the SALOME Naming Service");
+ }
+ CORBA::Object_var obj(ns.Resolve(SALOME_ContainerManager::_ContainerManagerNameInNS));
+ Engines::ContainerManager_var contManager(Engines::ContainerManager::_narrow(obj));
-void SalomeContainerToolsDecoratorBase::addToResourceList(const std::string& name)
-{
- _sct->addToResourceList(name);
-}
+ bool isEmptyName;
+ std::string str(sct.getNotNullContainerName(cont,askingNode,isEmptyName));
+ DEBTRACE("SalomeContainer::start " << str <<";"<< sct.getHostName() );
-Engines::ContainerParameters SalomeContainerToolsDecoratorBase::getParameters() const
-{
- return _sct->getParameters();
+ // Finalize parameters with components found in the container
+
+ for(std::vector<std::string>::const_iterator iter=compoNames.begin();iter!=compoNames.end();iter++)
+ sct.addToComponentList(*iter);
+
+ Engines::ContainerParameters myparams(sct.getParameters());
+ {
+ std::string dftLauchMode(schelp->getDftLaunchMode());
+ myparams.mode=CORBA::string_dup(dftLauchMode.c_str());
+ }
+
+ //If a container_name is given try to find an already existing container in naming service
+ //If not found start a new container with the given parameters
+ if (dynamic_cast<SalomeContainerMonoHelper *>(schelp) && !isEmptyName)
+ {
+ myparams.mode=CORBA::string_dup("getorstart");
+ }
+
+ if (isEmptyName)
+ {
+ shutdownLevel=1;
+ }
+ //sct.setContainerName(str);
+ SetContainerNameOf(myparams,str);
+ Engines::Container_var trueCont(Engines::Container::_nil());
+ if(!isEmptyName && shutdownLevel==999)
+ {
+ //Make this only the first time start is called (_shutdownLevel==999)
+ //If the container is named, first try to get an existing container
+ //If there is an existing container use it and set the shutdown level to 3
+ //If there is no existing container, try to launch a new one and set the shutdown level to 2
+ myparams.mode="get";
+ try
+ {
+ DEBTRACE("GiveContainer " << str << " mode " << myparams.mode);
+ trueCont=contManager->GiveContainer(myparams);
+ }
+ catch( const SALOME::SALOME_Exception& ex )
+ {
+ std::string msg="SalomeContainer::start : no existing container : ";
+ msg += '\n';
+ msg += ex.details.text.in();
+ DEBTRACE( msg );
+ }
+ catch(...)
+ {
+ }
+
+ if(!CORBA::is_nil(trueCont))
+ {
+ shutdownLevel=3;
+ DEBTRACE( "container found: " << str << " " << shutdownLevel );
+ }
+ else
+ {
+ shutdownLevel=2;
+ myparams.mode="start";
+ DEBTRACE( "container not found: " << str << " " << shutdownLevel);
+ }
+ }
+
+ int nbTries=0;
+ while(CORBA::is_nil(trueCont))
+ {
+ try
+ {
+ // --- GiveContainer is used in batch mode to retreive launched containers,
+ // and is equivalent to StartContainer when not in batch.
+ DEBTRACE("GiveContainer " << str << " mode " << myparams.mode);
+ trueCont=contManager->GiveContainer(myparams);
+ }
+ catch( const SALOME::SALOME_Exception& ex )
+ {
+ std::string msg="SalomeContainer::start : Unable to launch container in Salome : ";
+ msg += '\n';
+ msg += ex.details.text.in();
+ throw Exception(msg);
+ }
+ catch(CORBA::COMM_FAILURE&)
+ {
+ //std::cerr << "SalomeContainer::start : CORBA Comm failure detected. Make another try!" << std::endl;
+ DEBTRACE("SalomeContainer::start :" << str << " :CORBA Comm failure detected. Make another try!");
+ nbTries++;
+ if(nbTries > 5)
+ throw Exception("SalomeContainer::start : Unable to launch container in Salome : CORBA Comm failure detected");
+ }
+ catch(CORBA::Exception&)
+ {
+ throw Exception("SalomeContainer::start : Unable to launch container in Salome : Unexpected CORBA failure detected");
+ }
+ }
+
+ if(CORBA::is_nil(trueCont))
+ throw Exception("SalomeContainer::start : Unable to launch container in Salome. Check your CatalogResources.xml file");
+
+ // TODO : thread safety!
+ schelp->setContainer(askingNode,trueCont);
+
+ CORBA::String_var containerName(trueCont->name()),hostName(trueCont->getHostName());
+ //std::cerr << "SalomeContainer launched : " << containerName << " " << hostName << " " << trueCont->getPID() << std::endl;
+ DEBTRACE("SalomeContainer launched : " << containerName << " " << hostName << " " << trueCont->getPID() );
}
-std::string SalomeContainerToolsDecoratorBase::getContainerName() const
+CORBA::Object_ptr SalomeContainerToolsBase::LoadComponent(SalomeContainerHelper *launchModeType, Container *cont, Task *askingNode)
{
- return _sct->getContainerName();
+ DEBTRACE("SalomeContainer::loadComponent ");
+ const ComponentInstance *inst(askingNode?askingNode->getComponent():0);
+ {
+ YACS::BASES::AutoLocker<Container> alck(cont);//To be sure
+ if(!cont->isAlreadyStarted(askingNode))
+ cont->start(askingNode);
+ }
+ if(!inst)
+ throw Exception("SalomeContainerToolsBase::LoadComponent : no instance of component in the task requesting for a load of its component !");
+ CORBA::Object_ptr objComponent=CORBA::Object::_nil();
+ {
+ YACS::BASES::AutoLocker<Container> alck(cont);//To be sure
+ std::string compoName(inst->getCompoName());
+ Engines::Container_var container(launchModeType->getContainer(askingNode));
+
+ char *reason;
+ bool isLoadable(container->load_component_Library(compoName.c_str(), reason));
+ if(isLoadable)
+ objComponent=CreateComponentInstance(cont,container,inst);
+ }
+ return objComponent;
}
-void SalomeContainerToolsDecoratorBase::setContainerName(const std::string& name)
+CORBA::Object_ptr SalomeContainerToolsBase::CreateComponentInstance(Container *cont, Engines::Container_ptr contPtr, const ComponentInstance *inst)
{
- _sct->setContainerName(name);
+ if(!inst)
+ throw Exception("SalomeContainerToolsBase::CreateComponentInstance : no instance of component in the task requesting for a load of its component !");
+ char *reason(0);
+ std::string compoName(inst->getCompoName());
+ CORBA::Object_ptr objComponent=CORBA::Object::_nil();
+ Proc* p(cont->getProc());
+ // prepare component instance properties
+ Engines::FieldsDict_var env(new Engines::FieldsDict);
+ std::map<std::string, std::string> properties(inst->getProperties());
+ if(p)
+ {
+ std::map<std::string,std::string> procMap=p->getProperties();
+ properties.insert(procMap.begin(),procMap.end());
+ }
+
+ std::map<std::string, std::string>::const_iterator itm;
+ env->length(properties.size());
+ int item=0;
+ for(itm = properties.begin(); itm != properties.end(); ++itm, item++)
+ {
+ DEBTRACE("envname="<<itm->first<<" envvalue="<< itm->second);
+ env[item].key= CORBA::string_dup(itm->first.c_str());
+ env[item].value <<= itm->second.c_str();
+ }
+
+ objComponent=contPtr->create_component_instance_env(compoName.c_str(), env, reason);
+ if(CORBA::is_nil(objComponent))
+ {
+ std::string text="Error while trying to create a new component: component '"+ compoName;
+ text=text+"' is not installed or it's a wrong name";
+ text += '\n';
+ text += reason;
+ CORBA::string_free(reason);
+ throw Exception(text);
+ }
+ return objComponent;
}
-std::string SalomeContainerToolsDecoratorBase::getHostName() const
+std::string SalomeContainerToolsBase::GetPlacementId(const SalomeContainerHelper *launchModeType, const Container *cont, const Task *askingNode)
{
- return _sct->getHostName();
-}
+ if(cont->isAlreadyStarted(askingNode))
+ {
+ Engines::Container_var container(launchModeType->getContainer(askingNode));
+ const char *what="/";
+ CORBA::String_var corbaStr(container->name());
+ std::string ret(corbaStr);
+ //Salome FOREVER ...
+ std::string::size_type i=ret.find_first_of(what,0);
+ i=ret.find_first_of(what, i==std::string::npos ? i:i+1);
+ if(i!=std::string::npos)
+ return ret.substr(i+1);
+ return ret;
+ }
+ else
+ return "Not placed yet !!!";
+}
-std::string SalomeContainerToolsDecoratorBase::getNotNullContainerName(const Container *contPtr, const Task *askingNode, bool& isEmpty) const
+std::string SalomeContainerToolsBase::GetFullPlacementId(const SalomeContainerHelper *launchModeType, const Container *cont, const Task *askingNode)
{
- return _sct->getNotNullContainerName(contPtr,askingNode,isEmpty);
+ if(cont->isAlreadyStarted(askingNode))
+ {
+ Engines::Container_var container(launchModeType->getContainer(askingNode));
+ try
+ {
+ CORBA::String_var corbaStr(container->name());
+ std::string ret(corbaStr);
+ return ret;
+ }
+ catch(...)
+ {
+ return "Unknown_placement";
+ }
+ }
+ else
+ return "Not_placed_yet";
}
-//////////////////////////////
-
-Engines::ContainerParameters SalomeContainerToolsSpreadOverTheResDecorator::getParameters() const
+Engines::ContainerParameters SalomeContainerToolsDecorator::getParameters() const
{
- Engines::ContainerParameters ret(getWorker()->getParameters());
+ Engines::ContainerParameters ret(_decorated->getParameters());
std::string st(ret.resource_params.hostname);
if(!st.empty())
return ret;
- int nbProcPerNode(ret.resource_params.nb_proc_per_node);
+ int nbProcPerNode(this->_nb_cores_per_worker);
std::size_t iPos(_vh->locateTask(_node)),nPos(_vh->size());
if(_vh->size()!=_pg->getNumberOfWorkers(nbProcPerNode))
- throw YACS::Exception("SalomeContainerToolsSpreadOverTheResDecorator::getParameters : Internal error !");
+ throw YACS::Exception("SalomeContainerToolsDecorator::getParameters : Internal error !");
std::string zeMachine(_pg->deduceMachineFrom(iPos,nbProcPerNode));
ret.resource_params.hostname=CORBA::string_dup(zeMachine.c_str());
return ret;
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#ifndef __SALOMECONTAINERTOOLS_HXX__
-#define __SALOMECONTAINERTOOLS_HXX__
+#pragma once
#include "YACSRuntimeSALOMEExport.hxx"
#include "SALOMEconfig.h"
virtual std::string getProperty(const std::string& name) const = 0;
virtual void setProperty(const std::string& name, const std::string& value) = 0;
virtual const std::map<std::string,std::string>& getProperties() const = 0;
- virtual void clearProperties() = 0;
virtual std::map<std::string,std::string> getResourceProperties(const std::string& name) const = 0;
+ virtual void clearProperties() = 0;
virtual void addToComponentList(const std::string& name) = 0;
virtual void addToResourceList(const std::string& name) = 0;
virtual Engines::ContainerParameters getParameters() const = 0;
- virtual std::string getContainerName() const = 0;
virtual void setContainerName(const std::string& name) = 0;
virtual std::string getHostName() const = 0;
virtual std::string getNotNullContainerName(const Container *contPtr, const Task *askingNode, bool& isEmpty) const = 0;
+ virtual std::string getContainerName() const = 0;
+ virtual int getNumberOfCoresPerWorker() const = 0;
+ public:
+ static void SetContainerNameOf(Engines::ContainerParameters& params, const std::string& name);
public:
static void Start(const std::vector<std::string>& compoNames, SalomeContainerHelper *schelp, SalomeContainerToolsBase& sct, int& shutdownLevel, const Container *cont, const Task *askingNode);
static CORBA::Object_ptr LoadComponent(SalomeContainerHelper *launchModeType, Container *cont, Task *askingNode);
static CORBA::Object_ptr CreateComponentInstance(Container *cont, Engines::Container_ptr contPtr, const ComponentInstance *inst);
static std::string GetPlacementId(const SalomeContainerHelper *launchModeType, const Container *cont, const Task *askingNode);
static std::string GetFullPlacementId(const SalomeContainerHelper *launchModeType, const Container *cont, const Task *askingNode);
- static void SetContainerNameOf(Engines::ContainerParameters& params, const std::string& name);
- };
-
- class YACSRUNTIMESALOME_EXPORT SalomeContainerToolsInter : public SalomeContainerToolsBase
- {
- public:
- SalomeContainerToolsInter() { }
- SalomeContainerToolsInter(const SalomeContainerToolsInter& other);
- std::string getProperty(const std::string& name) const;
- const std::map<std::string,std::string>& getProperties() const { return _propertyMap; }
- void clearProperties();
- std::map<std::string,std::string> getResourceProperties(const std::string& name) const;
- protected:
- std::map<std::string,std::string> _propertyMap;
};
- class YACSRUNTIMESALOME_EXPORT SalomeContainerTools : public SalomeContainerToolsInter
+ class YACSRUNTIMESALOME_EXPORT SalomeContainerTools : public SalomeContainerToolsBase
{
public:
SalomeContainerTools();
SalomeContainerTools(const SalomeContainerTools& other);
- int getNumberOfCoresPerWorker() const;
- public:
- Engines::ContainerParameters getParameters() const { return _params; }
- void clearProperties();
- void setProperty(const std::string& name, const std::string& value);
- void addToComponentList(const std::string& name);
- void addToResourceList(const std::string& name);
- std::string getContainerName() const;
- void setContainerName(const std::string& name);
- std::string getHostName() const;
- std::string getNotNullContainerName(const Container *contPtr, const Task *askingNode, bool& isEmpty) const;
- protected:
+ ~SalomeContainerTools() { }
+ std::string getProperty(const std::string& name) const override;
+ void setProperty(const std::string& name, const std::string& value) override;
+ const std::map<std::string,std::string>& getProperties() const override { return _propertyMap; }
+ std::map<std::string,std::string> getResourceProperties(const std::string& name) const override;
+ void clearProperties() override;
+ void addToComponentList(const std::string& name) override;
+ void addToResourceList(const std::string& name) override;
+ Engines::ContainerParameters getParameters() const override { return _params; }
+ void setContainerName(const std::string& name) override;
+ std::string getHostName() const override;
+ std::string getNotNullContainerName(const Container *contPtr, const Task *askingNode, bool& isEmpty) const override;
+ std::string getContainerName() const override;
+ int getNumberOfCoresPerWorker() const override;
+ private:
+ std::map<std::string,std::string> _propertyMap;
Engines::ContainerParameters _params;
};
class PlayGround;
-
- class YACSRUNTIMESALOME_EXPORT SalomeContainerToolsDecoratorBase : public SalomeContainerToolsBase
- {
- protected:
- SalomeContainerToolsDecoratorBase(SalomeContainerToolsBase *sct):_sct(sct) { }
- SalomeContainerToolsBase *getWorker() { return _sct; }
- const SalomeContainerToolsBase *getWorker() const { return _sct; }
- public:
- std::string getProperty(const std::string& name) const;
- void setProperty(const std::string& name, const std::string& value);
- const std::map<std::string,std::string>& getProperties() const;
- void clearProperties();
- std::map<std::string,std::string> getResourceProperties(const std::string& name) const;
- void addToComponentList(const std::string& name);
- void addToResourceList(const std::string& name);
- Engines::ContainerParameters getParameters() const;
- std::string getContainerName() const;
- void setContainerName(const std::string& name);
- std::string getHostName() const;
- std::string getNotNullContainerName(const Container *contPtr, const Task *askingNode, bool& isEmpty) const;
- private:
- SalomeContainerToolsBase *_sct;
- };
-
class SalomeHPContainerVectOfHelper;
-
- class YACSRUNTIMESALOME_EXPORT SalomeContainerToolsSpreadOverTheResDecorator : public SalomeContainerToolsDecoratorBase
+
+ class YACSRUNTIMESALOME_EXPORT SalomeContainerToolsDecorator : public SalomeContainerToolsBase
{
public:
- SalomeContainerToolsSpreadOverTheResDecorator(SalomeContainerToolsBase *sct, const PlayGround *pg, const SalomeHPContainerVectOfHelper *vh, const Task *node):SalomeContainerToolsDecoratorBase(sct),_pg(pg),_vh(vh),_node(node) { }
- Engines::ContainerParameters getParameters() const;
- private:
- static std::string DeduceMachineFrom(const std::vector< std::pair<std::string,int> >& allResInfo, int iPos, int sz, int nbProcPerNode);
+ SalomeContainerToolsDecorator(SalomeContainerToolsBase *decorated, const PlayGround *pg, SalomeHPContainerVectOfHelper *vh, const Task *node, int nbCoresPerWorker)
+ :_decorated(decorated),_pg(pg),_vh(vh),_node(node),_nb_cores_per_worker(nbCoresPerWorker) { }
+ std::string getProperty(const std::string& name) const override { return _decorated->getProperty(name); }
+ void setProperty(const std::string& name, const std::string& value) override { return _decorated->setProperty(name,value); }
+ const std::map<std::string,std::string>& getProperties() const override { return _decorated->getProperties(); }
+ std::map<std::string,std::string> getResourceProperties(const std::string& name) const override { return _decorated->getResourceProperties(name); }
+ void clearProperties() override { return _decorated->clearProperties(); }
+ void addToComponentList(const std::string& name) override { return _decorated->addToComponentList(name); }
+ void addToResourceList(const std::string& name) override { return _decorated->addToResourceList(name); }
+ // Everything for it
+ Engines::ContainerParameters getParameters() const override;
+ void setContainerName(const std::string& name) override { return _decorated->setContainerName(name); }
+ std::string getHostName() const override { return _decorated->getHostName(); }
+ std::string getNotNullContainerName(const Container *contPtr, const Task *askingNode, bool& isEmpty) const override { return _decorated->getNotNullContainerName(contPtr,askingNode,isEmpty); }
+ std::string getContainerName() const override { return _decorated->getContainerName(); }
+ int getNumberOfCoresPerWorker() const override { return _decorated->getNumberOfCoresPerWorker(); }
private:
+ SalomeContainerToolsBase *_decorated;
const PlayGround *_pg;
- const SalomeHPContainerVectOfHelper *_vh;
+ SalomeHPContainerVectOfHelper *_vh;
const Task *_node;
+ int _nb_cores_per_worker;
};
}
}
-
-#endif
#include "SalomeHPComponent.hxx"
#include "SalomeContainerTmpForHP.hxx"
#include "AutoLocker.hxx"
-#include "AutoRefCnt.hxx"
#include <algorithm>
+#include <utility>
using namespace YACS::ENGINE;
const char SalomeHPContainer::KIND[]="HPSalome";
-SalomeHPContainerBase::SalomeHPContainerBase(SalomeHPContainerVectOfHelper *resShared):_launchModeType(resShared),_shutdownLevel(999)
+SalomeHPContainer::SalomeHPContainer():_shutdownLevel(999)
{
}
-SalomeHPContainerBase::SalomeHPContainerBase(const SalomeHPContainerBase& other):_shutdownLevel(999),_launchModeType(new SalomeHPContainerVectOfHelper),_initScript(other._initScript)
+SalomeHPContainer::SalomeHPContainer(const SalomeHPContainer& other):_componentNames(other._componentNames),_shutdownLevel(999),_sct(other._sct),_initScript(other._initScript)
{
}
-SalomeHPContainer *SalomeHPContainerBase::getTheBoss()
+void SalomeHPContainer::assignPG(const PlayGround *pg)
{
- HomogeneousPoolContainer *ret(this);
- while(ret->getDirectFather())
- ret=ret->getDirectFather();
- SalomeHPContainer *retC(dynamic_cast<SalomeHPContainer *>(ret));
- if(!retC)
- throw Exception("SalomeHPContainerBase::getTheBoss : unexpected type of object !");
- return retC;
+ HomogeneousPoolContainer::assignPG(pg);
+ int nbOfWorkers(getPG()->getNumberOfWorkers(this->getNumberOfCoresPerWorker()));
+ this->setSizeOfPool(nbOfWorkers);
}
-const SalomeHPContainer *SalomeHPContainerBase::getTheBoss() const
+void SalomeHPContainer::setSizeOfPool(int sz)
{
- const HomogeneousPoolContainer *ret(this);
- while(ret->getDirectFather())
- ret=ret->getDirectFather();
- const SalomeHPContainer *retC(dynamic_cast<const SalomeHPContainer *>(ret));
- if(!retC)
- throw Exception("SalomeHPContainerBase::getTheBoss : unexpected type of object !");
- return retC;
+ _launchModeType.resize(sz);
}
-void SalomeHPContainerBase::startInternal(const Task *askingNode, SalomeContainerToolsBase& sct, const std::vector<std::string>& compoNames)
+int SalomeHPContainer::getSizeOfPool() const
{
- SalomeContainerMonoHelper *helper(_launchModeType->getHelperOfTaskThreadSafe(askingNode));
- SalomeContainerTools::Start(compoNames,helper,sct,_shutdownLevel,this,askingNode);
+ return _launchModeType.size();
}
-void SalomeHPContainerBase::shutdown(int level)
+std::size_t SalomeHPContainer::getNumberOfFreePlace() const
{
- if(level < _shutdownLevel)
- return;
- _shutdownLevel=999;
- _launchModeType->shutdown();
+ return getPG()->getNumberOfFreePlace(this->getNumberOfCoresPerWorker());
}
-SalomeHPContainerBase::SalomeHPContainerBase(SalomeHPContainerVectOfHelper *resShared, bool isRefEaten):_launchModeType(resShared)
+class PairVecIterator : public std::iterator<
+ std::input_iterator_tag, // iterator_category
+ std::pair<const Task *,std::size_t>, // value_type
+ long, // difference_type
+ const std::pair<const Task *,std::size_t>*, // pointer
+ std::pair<const Task *,std::size_t> > // reference
{
- if(!isRefEaten)
- if(_launchModeType.isNotNull())
- _launchModeType->incrRef();
-}
+ const std::vector< const Task *> *_v0;
+ const std::vector<std::size_t> *_v1;
+ std::size_t _num;
+public:
+ explicit PairVecIterator(const std::vector< const Task * > *v0, const std::vector<std::size_t> *v1, const std::size_t num) : _v0(v0),_v1(v1),_num(num) { }
+ PairVecIterator& operator++() { _num++; return *this; }
+ bool operator==(PairVecIterator other) const { return _num == other._num; }
+ bool operator!=(PairVecIterator other) const { return !(*this == other); }
+ reference operator*() const { return std::pair<const Task *,std::size_t>((*_v0)[_num],(*_v1)[_num]); }
+};
-bool SalomeHPContainerBase::isAlreadyStarted(const Task *askingNode) const
+void SalomeHPContainer::allocateFor(const std::vector<const Task *>& nodes)
{
- const SalomeContainerMonoHelper *helper(_launchModeType->getHelperOfTaskThreadSafe(askingNode));
- return helper->isAlreadyStarted(askingNode);
+ std::vector<std::size_t> workerIdsAllocated(getPG()->allocateFor(nodes.size(),this->getNumberOfCoresPerWorker()));
+ std::vector<std::pair<const Task *,std::size_t>> nodesAndIds(PairVecIterator(&nodes,&workerIdsAllocated,0),PairVecIterator(&nodes,&workerIdsAllocated,nodes.size()));
+ _launchModeType.allocateForCrude(nodesAndIds);
}
-void SalomeHPContainerBase::release(const Task *node)
+void SalomeHPContainer::release(const Task *node)
{
- _launchModeType->release(node);
+ std::size_t workerId(_launchModeType.release(node));
+ getPG()->release(workerId,this->getNumberOfCoresPerWorker());
}
-void SalomeHPContainerBase::lock()
+SalomeHPContainer::~SalomeHPContainer()
{
- _launchModeType->lock();
}
-void SalomeHPContainerBase::unLock()
+std::string SalomeHPContainer::getKind() const
{
- _launchModeType->unLock();
+ return KIND;
}
-void SalomeHPContainerBase::setSizeOfPool(int sz)
+std::string SalomeHPContainer::getDiscreminantStrOfThis(const Task *askingNode) const
{
- _launchModeType->resize(sz);
+ YACS::BASES::AutoCppPtr<SalomeContainerTmpForHP> tmpCont(SalomeContainerTmpForHP::BuildFrom(this,askingNode));
+ return tmpCont->getDiscreminantStrOfThis(askingNode);
}
-int SalomeHPContainerBase::getSizeOfPool() const
+bool SalomeHPContainer::isAlreadyStarted(const Task *askingNode) const
{
- return _launchModeType->size();
+ const SalomeContainerMonoHelper *helper(_launchModeType.getHelperOfTaskThreadSafe(this,askingNode));
+ return helper->isAlreadyStarted(askingNode);
}
-void SalomeHPContainerBase::setProperty(const std::string& name,const std::string& value)
+void SalomeHPContainer::start(const Task *askingNode)
{
- if(name==AOC_ENTRY)//no sense to set it ! It is always true ! ignore it !
- return ;
- else if(name==SIZE_OF_POOL_KEY)
- {
- std::istringstream iss(value);
- int val(0);
- iss >> val;
- setSizeOfPool(val);
- }
- else if(name==INITIALIZE_SCRIPT_KEY)
- {
- _initScript=value;
- }
- else
- getTheBoss()->getContainerInfo().setProperty(name,value);
+ SalomeContainerMonoHelper *helper(_launchModeType.getHelperOfTaskThreadSafe(this,askingNode));
+ SalomeContainerToolsDecorator sctDeco(&_sct,this->getPG(),&_launchModeType,askingNode,this->getNumberOfCoresPerWorker());
+ SalomeContainerTools::Start(_componentNames,helper,_sct,_shutdownLevel,this,askingNode);
}
-std::string SalomeHPContainerBase::getProperty(const std::string& name) const
+void SalomeHPContainer::shutdown(int level)
{
- if(name==AOC_ENTRY)
- {
- return std::string("1");
- }
- else if(name==SIZE_OF_POOL_KEY)
- {
- std::ostringstream oss; oss << getSizeOfPool();
- return oss.str();
- }
- else if(name==INITIALIZE_SCRIPT_KEY)
+ if(level < _shutdownLevel)
+ return;
+ _shutdownLevel=999;
+ for(std::size_t i=0;i<_launchModeType.size();i++)
{
- return _initScript;
+ SalomeContainerMonoHelper *helper(_launchModeType.at(i));
+ helper->shutdown();
}
- else
- return getTheBoss()->getContainerInfo().getProperty(name);
}
-std::map<std::string,std::string> SalomeHPContainerBase::getProperties() const
+std::string SalomeHPContainer::getPlacementId(const Task *askingNode) const
{
- std::map<std::string,std::string> ret(getTheBoss()->getContainerInfo().getProperties());
- std::ostringstream oss; oss << getSizeOfPool();
- ret[SIZE_OF_POOL_KEY]=oss.str();
- if(!_initScript.empty())
- ret[INITIALIZE_SCRIPT_KEY]=_initScript;
- return ret;
-}
-
-void SalomeHPContainerBase::clearProperties()
-{
- _initScript.clear();
- getTheBoss()->getContainerInfo().clearProperties();
-}
-
-std::string SalomeHPContainerBase::getPlacementId(const Task *askingNode) const
-{
- const SalomeContainerMonoHelper *helper(0);
+ const SalomeContainerMonoHelper *helper(nullptr);
{
- YACS::BASES::AutoLocker<Container> alckCont(const_cast<SalomeHPContainerBase *>(this));
- helper=_launchModeType->getHelperOfTask(askingNode);
+ std::lock_guard<std::mutex> lg(getPG()->getLocker());
+ helper=_launchModeType.getHelperOfTask(askingNode);
}
return SalomeContainerTools::GetPlacementId(helper,this,askingNode);
}
-std::string SalomeHPContainerBase::getFullPlacementId(const Task *askingNode) const
+std::string SalomeHPContainer::getFullPlacementId(const Task *askingNode) const
{
- const SalomeContainerMonoHelper *helper(0);
+ const SalomeContainerMonoHelper *helper(nullptr);
{
- YACS::BASES::AutoLocker<Container> alckCont(const_cast<SalomeHPContainerBase *>(this));
- helper=_launchModeType->getHelperOfTask(askingNode);
+ std::lock_guard<std::mutex> lg(getPG()->getLocker());
+ helper=_launchModeType.getHelperOfTask(askingNode);
}
return SalomeContainerTools::GetFullPlacementId(helper,this,askingNode);
}
-std::map<std::string,std::string> SalomeHPContainerBase::getResourceProperties(const std::string& name) const
-{
- return getTheBoss()->getResourceProperties(name);
-}
-
-void SalomeHPContainerBase::addComponentName(const std::string& name)
-{
- getTheBoss()->addComponentNameSpe(name);
-}
-
-void SalomeHPContainerBase::checkCapabilityToDealWith(const ComponentInstance *inst) const throw(YACS::Exception)
-{
- getTheBoss()->checkCapabilityToDealWith(inst);
-}
-
-YACS::BASES::AutoRefCnt<HomogeneousPoolContainer> SalomeHPContainerBase::decorate(YACS::BASES::AutoConstRefCnt<PartDefinition> pd)
-{
- YACS::BASES::AutoRefCnt<HomogeneousPoolContainer> ret(new SalomeHPContainerShared(pd,_launchModeType,this));
- return ret;
-}
-
-Engines::Container_var SalomeHPContainerBase::getContainerPtr(const Task *askingNode) const
-{
- const SalomeContainerMonoHelper *helper(0);
- {
- YACS::BASES::AutoLocker<SalomeHPContainerBase> alck(const_cast<SalomeHPContainerBase *>(this));
- helper=_launchModeType->getHelperOfTask(askingNode);
- }
- return helper->getContainer(NULL);
-}
-
-std::vector<std::string> SalomeHPContainerBase::getKernelContainerNames() const
-{
- return _launchModeType->getKernelContainerNames();
-}
-
-////////////////
-
-SalomeHPContainer::SalomeHPContainer():SalomeHPContainerBase(new SalomeHPContainerVectOfHelper)
-{
-}
-
-SalomeHPContainer::SalomeHPContainer(const SalomeHPContainer& other):SalomeHPContainerBase(other),_sct(other._sct),_componentNames(other._componentNames)
-{
-}
-
-std::size_t SalomeHPContainer::getNumberOfFreePlace() const
-{
- return _launchModeType->getNumberOfFreePlace();
-}
-
-void SalomeHPContainer::allocateFor(const std::vector<const Task *>& nodes)
-{
- _launchModeType->allocateFor(nodes);
-}
-
-SalomeHPContainer::~SalomeHPContainer()
-{
-}
-
-std::string SalomeHPContainer::getKind() const
-{
- return KIND;
-}
-
-std::string SalomeHPContainer::getDiscreminantStrOfThis(const Task *askingNode) const
-{
- YACS::BASES::AutoCppPtr<SalomeContainerTmpForHP> tmpCont(SalomeContainerTmpForHP::BuildFrom(this,askingNode));
- return tmpCont->getDiscreminantStrOfThis(askingNode);
-}
-
-void SalomeHPContainer::start(const Task *askingNode) throw(YACS::Exception)
-{
- startInternal(askingNode,_sct,_componentNames);
-}
-
/*!
* It is not a bug here ! clone for homogeneous container is not supposed to be copied !
*/
return new SalomeHPContainer(*this);
}
-int SalomeHPContainer::getNumberOfCoresPerWorker() const
-{
- return _sct.getNumberOfCoresPerWorker();
-}
-
-std::map<std::string,std::string> SalomeHPContainer::getResourcePropertiesSpe(const std::string& name) const
-{
- return _sct.getResourceProperties(name);
-}
-
-void SalomeHPContainer::addComponentNameSpe(const std::string& name)
-{
- _componentNames.push_back(name);
-}
-
-void SalomeHPContainer::checkCapabilityToDealWithSpe(const ComponentInstance *inst) const throw(YACS::Exception)
-{
- if(inst->getKind()!=SalomeHPComponent::KIND)
- throw Exception("SalomeHPContainer::checkCapabilityToDealWithSpe : SalomeContainer is not able to deal with this type of ComponentInstance.");
-}
-
-void SalomeHPContainer::forYourTestsOnly(ForTestOmlyHPContCls *data) const
-{
- data->setContainerType("HPContainer");
-}
-
-//////////////////////////////////
-
-SalomeHPContainerShared::SalomeHPContainerShared(YACS::BASES::AutoConstRefCnt<PartDefinition> pd, SalomeHPContainerVectOfHelper *resShared, SalomeHPContainerBase *directFather):SalomeHPContainerBase(resShared,false),_pd(pd)
-{
- if(!directFather)
- throw Exception("SalomeHPContainerShared : NULL pointer not allowed !");
- _directFather.takeRef(directFather);
-}
-
-std::string SalomeHPContainerShared::getKind() const
-{
- return SalomeHPContainer::KIND;
-}
-
-void SalomeHPContainerShared::prepareMaskForExecution() const
+void SalomeHPContainer::setProperty(const std::string& name,const std::string& value)
{
- _idsOfKernelContainers=_pd->computeWorkerIdsCovered(getNumberOfCoresPerWorker());
+ if(name==AOC_ENTRY)//no sense to set it ! It is always true ! ignore it !
+ return ;
+ else if(name==SIZE_OF_POOL_KEY)
+ {
+ std::istringstream iss(value);
+ int val(0);
+ iss >> val;
+ setSizeOfPool(val);
+ }
+ else if(name==INITIALIZE_SCRIPT_KEY)
+ {
+ _initScript=value;
+ }
+ else
+ _sct.setProperty(name,value);
}
-/*!
- * It is not a bug here ! clone for homogeneous container is not supposed to be copied !
- */
-Container *SalomeHPContainerShared::clone() const
+std::string SalomeHPContainer::getProperty(const std::string& name) const
{
- incrRef();
- return const_cast<SalomeHPContainerShared*>(this);
+ if(name==AOC_ENTRY)
+ {
+ return std::string("1");
+ }
+ else if(name==SIZE_OF_POOL_KEY)
+ {
+ std::ostringstream oss; oss << getSizeOfPool();
+ return oss.str();
+ }
+ else if(name==INITIALIZE_SCRIPT_KEY)
+ {
+ return _initScript;
+ }
+ else
+ return _sct.getProperty(name);
}
-Container *SalomeHPContainerShared::cloneAlways() const
+void SalomeHPContainer::clearProperties()
{
- throw Exception("SalomeHPContainerShared::cloneAlways : you are not supposed to be in this situation ! This type of container has only existence during execution !");
+ _initScript.clear();
+ _sct.clearProperties();
}
-std::string SalomeHPContainerShared::getName() const
+void SalomeHPContainer::addComponentName(const std::string& name)
{
- return getTheBoss()->getName();
+ _componentNames.push_back(name);
}
-std::string SalomeHPContainerShared::getDiscreminantStrOfThis(const Task *askingNode) const
+std::map<std::string,std::string> SalomeHPContainer::getProperties() const
{
- return getTheBoss()->getDiscreminantStrOfThis(askingNode);
+ std::map<std::string,std::string> ret(_sct.getProperties());
+ std::ostringstream oss; oss << getSizeOfPool();
+ ret[SIZE_OF_POOL_KEY]=oss.str();
+ if(!_initScript.empty())
+ ret[INITIALIZE_SCRIPT_KEY]=_initScript;
+ return ret;
}
-void SalomeHPContainerShared::start(const Task *askingNode) throw(YACS::Exception)
+std::map<std::string,std::string> SalomeHPContainer::getResourceProperties(const std::string& name) const
{
- SalomeContainerToolsSpreadOverTheResDecorator sct(&getTheBoss()->getContainerInfo(),_pd->getPlayGround(),_launchModeType,askingNode);
- startInternal(askingNode,sct,getTheBoss()->getComponentNames());
+ return _sct.getResourceProperties(name);
}
-void SalomeHPContainerShared::allocateFor(const std::vector<const Task *>& nodes)
+void SalomeHPContainer::checkCapabilityToDealWith(const ComponentInstance *inst) const
{
- _launchModeType->allocateForAmong(_idsOfKernelContainers,nodes);
+ if(inst->getKind()!=SalomeHPComponent::KIND)
+ throw Exception("SalomeHPContainer::checkCapabilityToDealWith : SalomeContainer is not able to deal with this type of ComponentInstance.");
}
-std::size_t SalomeHPContainerShared::getNumberOfFreePlace() const
+std::vector<std::string> SalomeHPContainer::getKernelContainerNames() const
{
- return _launchModeType->getNumberOfFreePlaceAmong(_idsOfKernelContainers);
+ return _launchModeType.getKernelContainerNames(this);
}
-void SalomeHPContainerShared::forYourTestsOnly(ForTestOmlyHPContCls *data) const
+int SalomeHPContainer::getNumberOfCoresPerWorker() const
{
- data->setContainerType("HPContainerShared");
- data->setPD(_pd);
- data->setIDS(_idsOfKernelContainers);
+ return _sct.getNumberOfCoresPerWorker();
}
-
-/*
- * SalomeHPContainerVectOfHelper is an holder of vector of SalomeContainerMonoHelper (holding itself a Kernel Container)
- * SalomeContainerTools is a Engines::ContainerParameters holder. It is the data keeper for GiveContainer invokation.
- *
- */
#include "SalomeContainerHelper.hxx"
#include "SalomeContainerTools.hxx"
#include "SalomeHPContainerTools.hxx"
-#include "PlayGround.hxx"
-
#include "Mutex.hxx"
-#include "AutoRefCnt.hxx"
-
#include <string>
#include <vector>
#include <map>
+#include <mutex>
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(SALOME_Component)
#include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
{
class Task;
class SalomeComponent;
- class SalomeHPContainer;
-
- class YACSRUNTIMESALOME_EXPORT SalomeHPContainerBase : public HomogeneousPoolContainer
- {
- protected:
- SalomeHPContainerBase(SalomeHPContainerVectOfHelper *resShared);
- SalomeHPContainerBase(SalomeHPContainerVectOfHelper *resShared, bool isRefEaten);
- SalomeHPContainerBase(const SalomeHPContainerBase& other);
- void startInternal(const Task *askingNode, SalomeContainerToolsBase& sct, const std::vector<std::string>& compoNames);
- SalomeHPContainer *getTheBoss();
- const SalomeHPContainer *getTheBoss() const;
- public:
- void release(const Task *node);
- //
- bool isAlreadyStarted(const Task *askingNode) const;
- void shutdown(int level);
- //! For thread safety for concurrent load operation on same Container.
- void lock();
- //! For thread safety for concurrent load operation on same Container.
- void unLock();
- void setSizeOfPool(int sz);
- int getSizeOfPool() const;
- void setProperty(const std::string& name,const std::string& value);
- std::string getProperty(const std::string& name) const;
- std::map<std::string,std::string> getProperties() const;
- void clearProperties();
- std::string getPlacementId(const Task *askingNode) const;
- std::string getFullPlacementId(const Task *askingNode) const;
- std::map<std::string,std::string> getResourceProperties(const std::string& name) const;
- void addComponentName(const std::string& name);
- void checkCapabilityToDealWith(const ComponentInstance *inst) const throw(YACS::Exception);
- Engines::Container_var getContainerPtr(const Task *askingNode) const;
- std::vector<std::string> getKernelContainerNames() const;
- public:
- int getShutdownLev() const { return _shutdownLevel; }
- YACS::BASES::AutoRefCnt<HomogeneousPoolContainer> decorate(YACS::BASES::AutoConstRefCnt<PartDefinition> pd);
-#ifndef SWIG
- const SalomeHPContainerVectOfHelper *getDirectAccessToVecOfCont() const { return _launchModeType; }
-#endif
- protected:
- int _shutdownLevel;
- YACS::BASES::AutoRefCnt<SalomeHPContainerVectOfHelper> _launchModeType;
- std::string _initScript;
- };
-
- class YACSRUNTIMESALOME_EXPORT SalomeHPContainer : public SalomeHPContainerBase
+
+ class YACSRUNTIMESALOME_EXPORT SalomeHPContainer : public HomogeneousPoolContainer
{
public:
SalomeHPContainer();
SalomeHPContainer(const SalomeHPContainer& other);
//HP specific part
+ void assignPG(const PlayGround *pg) override;
+ void setSizeOfPool(int sz);
+ int getSizeOfPool() const;
std::size_t getNumberOfFreePlace() const;
void allocateFor(const std::vector<const Task *>& nodes);
+ void release(const Task *node) override;
+ //! For thread safety for concurrent load operation on same Container.
+ void lock() { _lock.lock(); }
+ //! For thread safety for concurrent load operation on same Container.
+ void unLock() { _lock.unlock(); }
//
std::string getKind() const;
std::string getDiscreminantStrOfThis(const Task *askingNode) const;
- void start(const Task *askingNode) throw(Exception);
+ bool isAlreadyStarted(const Task *askingNode) const;
+ void start(const Task *askingNode) ;
+ void shutdown(int level);
+ std::string getPlacementId(const Task *askingNode) const;
+ std::string getFullPlacementId(const Task *askingNode) const;
Container *clone() const;
Container *cloneAlways() const;
+ void setProperty(const std::string& name,const std::string& value);
+ std::string getProperty(const std::string& name) const;
+ void clearProperties();
+ void addComponentName(const std::string& name);
+ std::map<std::string,std::string> getProperties() const;
+ std::map<std::string,std::string> getResourceProperties(const std::string& name) const;
+ void checkCapabilityToDealWith(const ComponentInstance *inst) const ;
+ std::vector<std::string> getKernelContainerNames() const;
int getNumberOfCoresPerWorker() const;
- //! do nothing. because no special actions to do. Only for decorators
- void prepareMaskForExecution() const { }
//
#ifndef SWIG
- void forYourTestsOnly(ForTestOmlyHPContCls *data) const;
- std::map<std::string,std::string> getResourcePropertiesSpe(const std::string& name) const;
- void addComponentNameSpe(const std::string& name);
- void checkCapabilityToDealWithSpe(const ComponentInstance *inst) const throw(YACS::Exception);
- std::size_t locateTask(const Task *askingNode) const { return _launchModeType->locateTask(askingNode); }
+ std::size_t locateTask(const Task *askingNode) const { return _launchModeType.locateTask(askingNode); }
const SalomeContainerTools &getContainerInfo() const { return _sct; }
- SalomeContainerTools &getContainerInfo() { return _sct; }
std::vector<std::string> getComponentNames() const { return _componentNames; }
- SalomeContainerMonoHelper *getHelperOfTask(const Task *node) { return _launchModeType->getHelperOfTask(node); }
- const SalomeContainerMonoHelper *getHelperOfTask(const Task *node) const { return _launchModeType->getHelperOfTask(node); }
- //
- HomogeneousPoolContainer *getDirectFather() { return NULL; }
- const HomogeneousPoolContainer *getDirectFather() const { return NULL; }
+ int getShutdownLev() const { return _shutdownLevel; }
+ SalomeContainerMonoHelper *getHelperOfTask(const Task *node) { return _launchModeType.getHelperOfTask(node); }
+ const SalomeContainerMonoHelper *getHelperOfTask(const Task *node) const { return _launchModeType.getHelperOfTask(node); }
#endif
public:
static const char KIND[];
~SalomeHPContainer();
#endif
protected:
+ std::mutex _lock;
+ int _shutdownLevel;
SalomeContainerTools _sct;
std::vector<std::string> _componentNames;
- };
-
-#ifndef SWIG
- class YACSRUNTIMESALOME_EXPORT SalomeHPContainerShared : public SalomeHPContainerBase
- {
- public:
- SalomeHPContainerShared(YACS::BASES::AutoConstRefCnt<PartDefinition> pd, SalomeHPContainerVectOfHelper *resShared, SalomeHPContainerBase *directFather);
- HomogeneousPoolContainer *getDirectFather() { return _directFather; }
- const HomogeneousPoolContainer *getDirectFather() const { return _directFather; }
- int getNumberOfCoresPerWorker() const { return _directFather->getNumberOfCoresPerWorker(); }
- std::string getProperty(const std::string& name) const { return _directFather->getProperty(name); }
- void prepareMaskForExecution() const;
- void forYourTestsOnly(ForTestOmlyHPContCls *data) const;
- std::string getName() const;
- std::string getDiscreminantStrOfThis(const Task *askingNode) const;
- public:
- std::string getKind() const;
- void start(const Task *askingNode) throw(Exception);
- Container *clone() const;
- Container *cloneAlways() const;
//
- void allocateFor(const std::vector<const Task *>& nodes);
- std::size_t getNumberOfFreePlace() const;
- private:
- YACS::BASES::AutoRefCnt<SalomeHPContainerBase> _directFather;
- YACS::BASES::AutoConstRefCnt<PartDefinition> _pd;
- //! ids in _launchModeType covered by _pd.
- mutable std::vector<std::size_t> _idsOfKernelContainers;
+ SalomeHPContainerVectOfHelper _launchModeType;
+ std::string _initScript;
};
-#endif
}
}
#include "Exception.hxx"
#include <algorithm>
-#include <limits>
using namespace YACS::ENGINE;
return std::count(_whichOccupied.begin(),_whichOccupied.end(),false);
}
-std::size_t SalomeHPContainerVectOfHelper::getNumberOfFreePlaceAmong(const std::vector<std::size_t>& idsOfKernelContainers) const
-{
- std::size_t ret(0);
- for(std::vector<std::size_t>::const_iterator it=idsOfKernelContainers.begin();it!=idsOfKernelContainers.end();it++)
- if(!_whichOccupied[*it])
- ret++;
- return ret;
-}
-
void SalomeHPContainerVectOfHelper::allocateFor(const std::vector<const Task *>& nodes)
{
for(std::vector<const Task *>::const_iterator it=nodes.begin();it!=nodes.end();it++)
}
}
-void SalomeHPContainerVectOfHelper::allocateForAmong(const std::vector<std::size_t>& idsOfKernelContainers, const std::vector<const Task *>& nodes)
+void SalomeHPContainerVectOfHelper::allocateForCrude(const std::vector<std::pair<const Task *,std::size_t>>& nodes)
{
- for(std::vector<const Task *>::const_iterator it=nodes.begin();it!=nodes.end();it++)
+ for(auto it : nodes)
{
- if(!(*it))
- continue;
- if(_currentlyWorking.find(*it)!=_currentlyWorking.end())
- throw Exception("Searching 2 to allocate for a ServiceNode instance already declared as allocated !");
- std::size_t it2(std::numeric_limits<std::size_t>::max());
- for(std::vector<std::size_t>::const_iterator it=idsOfKernelContainers.begin();it!=idsOfKernelContainers.end();it++)
- if(!_whichOccupied[*it])
- {
- it2=*it;
- break;
- }
- if(it2==std::numeric_limits<std::size_t>::max())
- throw Exception("All 2 ressources are already occupied ! You are expected to wait for released resources !");
- _currentlyWorking[*it]=it2; _whichOccupied[it2]=true;
+ std::size_t workerId(it.second);
+ if(workerId>=size())
+ throw Exception("SalomeHPContainerVectOfHelper::allocateForCrude : Internal error ! WorkerId is greater or equal to size of HPCont !");
+ if(_whichOccupied[workerId])
+ throw Exception("SalomeHPContainerVectOfHelper::allocateForCrude : Mismatch between Playground info and HPContainer info !");
+ }
+ for(auto it : nodes)
+ {
+ const Task *task(it.first);
+ std::size_t workerId(it.second);
+ _currentlyWorking[task]=workerId;
+ _whichOccupied[workerId]=true;
}
}
-void SalomeHPContainerVectOfHelper::release(const Task *node)
+std::size_t SalomeHPContainerVectOfHelper::release(const Task *node)
{
if(!node)
- return ;
+ return std::numeric_limits<std::size_t>::max();
std::map< const Task *,std::size_t >::iterator it(_currentlyWorking.find(node));
if(it==_currentlyWorking.end())
throw Exception("Request to release a resource not declared as working !");
_whichOccupied[(*it).second]=false;
_currentlyWorking.erase(it);
+ return (*it).second;
}
std::size_t SalomeHPContainerVectOfHelper::locateTask(const Task *node) const
return ret;
}
-const SalomeContainerMonoHelper *SalomeHPContainerVectOfHelper::getHelperOfTaskThreadSafe(const Task *node) const
+const SalomeContainerMonoHelper *SalomeHPContainerVectOfHelper::getHelperOfTaskThreadSafe(const SalomeHPContainer *cont, const Task *node) const
{
- YACS::BASES::AutoLocker<SalomeHPContainerVectOfHelper> alck(const_cast<SalomeHPContainerVectOfHelper *>(this));
+ YACS::BASES::AutoLocker<Container> alck(const_cast<SalomeHPContainer *>(cont));
return _launchModeType[locateTask(node)];
}
return _launchModeType[locateTask(node)];
}
-SalomeContainerMonoHelper *SalomeHPContainerVectOfHelper::getHelperOfTaskThreadSafe(const Task *node)
+SalomeContainerMonoHelper *SalomeHPContainerVectOfHelper::getHelperOfTaskThreadSafe(SalomeHPContainer *cont, const Task *node)
{
- YACS::BASES::AutoLocker<SalomeHPContainerVectOfHelper> alck(this);
+ YACS::BASES::AutoLocker<Container> alck(cont);
return _launchModeType[locateTask(node)];
}
return _launchModeType[locateTask(node)];
}
-void SalomeHPContainerVectOfHelper::checkNoCurrentWork() const
-{
- for(std::map<const Task *,std::size_t >::const_iterator it=_currentlyWorking.begin();it!=_currentlyWorking.end();it++)
- if((*it).first)
- throw Exception("Something wrong a node is still declared to be using the ressource !");
- for(std::vector< YACS::BASES::AutoRefCnt<SalomeContainerMonoHelper> >::const_iterator it=_launchModeType.begin();it!=_launchModeType.end();it++)
- if((*it)->isAlreadyStarted(0))
- throw Exception("Some of the containers have be started ! Please shutdown them before !");
-}
-
-void SalomeHPContainerVectOfHelper::checkPosInVec(std::size_t pos) const
-{
- if(pos<0 || pos>=_launchModeType.size())
- throw Exception("The task has been found, but its id is not in the correct range ! resize of of container size during run ?");
-}
-
-void SalomeHPContainerVectOfHelper::shutdown()
-{
- for(std::vector< BASES::AutoRefCnt<YACS::ENGINE::SalomeContainerMonoHelper> >::iterator it=_launchModeType.begin();it!=_launchModeType.end();it++)
- if((*it).isNotNull())
- if(!(*it)->isKernelContNull())
- (*it)->shutdown();
-}
-
-std::vector<std::string> SalomeHPContainerVectOfHelper::getKernelContainerNames() const
+std::vector<std::string> SalomeHPContainerVectOfHelper::getKernelContainerNames(const SalomeHPContainer *cont) const
{
std::vector<std::string> ret;
{
- YACS::BASES::AutoLocker<SalomeHPContainerVectOfHelper> alck(const_cast<SalomeHPContainerVectOfHelper *>(this));
+ YACS::BASES::AutoLocker<Container> alck(const_cast<SalomeHPContainer *>(cont));
std::size_t sz(_launchModeType.size());
ret.resize(sz);
for(std::size_t i=0;i<sz;i++)
return ret;
}
-void SalomeHPContainerVectOfHelper::lock()
+void SalomeHPContainerVectOfHelper::checkNoCurrentWork() const
{
- _mutex.lock();
+ for(std::map<const Task *,std::size_t >::const_iterator it=_currentlyWorking.begin();it!=_currentlyWorking.end();it++)
+ if((*it).first)
+ throw Exception("Something wrong a node is still declared to be using the ressource !");
+ for(std::vector< YACS::BASES::AutoRefCnt<SalomeContainerMonoHelper> >::const_iterator it=_launchModeType.begin();it!=_launchModeType.end();it++)
+ if((*it)->isAlreadyStarted(0))
+ throw Exception("Some of the containers have be started ! Please shutdown them before !");
}
-void SalomeHPContainerVectOfHelper::unLock()
+void SalomeHPContainerVectOfHelper::checkPosInVec(std::size_t pos) const
{
- _mutex.unLock();
+ if(pos<0 || pos>=_launchModeType.size())
+ throw Exception("The task has been found, but its id is not in the correct range ! resize of of container size during run ?");
}
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
-#ifndef __SALOMEHPCONTAINERTOOLS_HXX__
-#define __SALOMEHPCONTAINERTOOLS_HXX__
+#pragma once
#include "YACSRuntimeSALOMEExport.hxx"
#include "SalomeContainerHelper.hxx"
-#include "RefCounter.hxx"
-
-#include "Mutex.hxx"
#include "AutoRefCnt.hxx"
#include <map>
class SalomeComponent;
class SalomeHPContainer;
class SalomeContainerMonoHelper;
- class SalomeHPContainerVectOfHelper : public RefCounter
+ class SalomeHPContainerVectOfHelper
{
public:
std::size_t size() const { return _launchModeType.size(); }
void resize(std::size_t sz);
std::size_t getNumberOfFreePlace() const;
- std::size_t getNumberOfFreePlaceAmong(const std::vector<std::size_t>& idsOfKernelContainers) const;
void allocateFor(const std::vector<const Task *>& nodes);
- void allocateForAmong(const std::vector<std::size_t>& idsOfKernelContainers, const std::vector<const Task *>& nodes);
- void release(const Task *node);
+ void allocateForCrude(const std::vector<std::pair<const Task *,std::size_t>>& nodes);
+ std::size_t release(const Task *node);
std::size_t locateTask(const Task *node) const;
const SalomeContainerMonoHelper *at(std::size_t pos) const { checkPosInVec(pos); return _launchModeType[pos]; }
SalomeContainerMonoHelper *at(std::size_t pos) { checkPosInVec(pos); return _launchModeType[pos]; }
- const SalomeContainerMonoHelper *getHelperOfTaskThreadSafe(const Task *node) const;
+ const SalomeContainerMonoHelper *getHelperOfTaskThreadSafe(const SalomeHPContainer *cont, const Task *node) const;
const SalomeContainerMonoHelper *getHelperOfTask(const Task *node) const;
- SalomeContainerMonoHelper *getHelperOfTaskThreadSafe(const Task *node);
+ SalomeContainerMonoHelper *getHelperOfTaskThreadSafe(SalomeHPContainer *cont, const Task *node);
SalomeContainerMonoHelper *getHelperOfTask(const Task *node);
- void shutdown();
- //! For thread safety for concurrent load operation on same Container.
- void lock();
- //! For thread safety for concurrent load operation on same Container.
- void unLock();
- public:
- std::vector<std::string> getKernelContainerNames() const;
+ std::vector<std::string> getKernelContainerNames(const SalomeHPContainer *cont) const;
private:
- ~SalomeHPContainerVectOfHelper() { }
void checkNoCurrentWork() const;
void checkPosInVec(std::size_t pos) const;
private:
- YACS::BASES::Mutex _mutex;
std::vector<bool> _whichOccupied;
std::vector< BASES::AutoRefCnt<YACS::ENGINE::SalomeContainerMonoHelper> > _launchModeType;
std::map<const Task *,std::size_t > _currentlyWorking;
};
}
}
-
-#endif
DEBTRACE("+++++++ end StudyInNode::execute +++++++++++" );
}
-void StudyInNode::checkBasicConsistency() const throw(YACS::Exception)
+void StudyInNode::checkBasicConsistency() const
{
DEBTRACE("StudyInNode::checkBasicConsistency");
if (! _setOfInputPort.empty())
DEBTRACE("+++++++ end StudyOutNode::execute +++++++++++" );
}
-void StudyOutNode::checkBasicConsistency() const throw(YACS::Exception)
+void StudyOutNode::checkBasicConsistency() const
{
DEBTRACE("StudyOutNode::checkBasicConsistency");
if (! _setOfOutputPort.empty())
StudyInNode(const StudyInNode& other, ComposedNode *father);
virtual void execute();
virtual void accept(Visitor *visitor);
- virtual void checkBasicConsistency() const throw(Exception);
+ virtual void checkBasicConsistency() const ;
virtual void setData(OutputPort* port, const std::string& data);
virtual OutputPort *createOutputPort(const std::string& outputPortName, TypeCode* type);
virtual std::string typeName() {return "YACS__ENGINE__StudyInNode";}
StudyOutNode(const StudyOutNode& other, ComposedNode *father);
virtual void execute();
virtual void accept(Visitor *visitor);
- virtual void checkBasicConsistency() const throw(Exception);
+ virtual void checkBasicConsistency() const ;
virtual void setData(InputPort* port, const std::string& data);
virtual InputPort *createInputPort(const std::string& inputPortName, TypeCode* type);
virtual std::string typeName() {return "YACS__ENGINE__StudyOutNode";}
inline Echo_i() {}
virtual ~Echo_i() {}
virtual char* echoString(const char* mesg);
- CORBA::Long echoLong(CORBA::Long i) throw(eo::SALOME_Exception);
+ CORBA::Long echoLong(CORBA::Long i);
void echoDouble(CORBA::Double i,CORBA::Double& j) ;
void echoDoubleVec(const eo::DoubleVec& i,eo::DoubleVec_out j) ;
void echoDoubleVecVec(const eo::DoubleVecVec&, eo::DoubleVecVec_out);
out=new eo::DoubleVecVec(in);
}
-CORBA::Long Echo_i::echoLong(CORBA::Long i ) throw(eo::SALOME_Exception)
+CORBA::Long Echo_i::echoLong(CORBA::Long i )
{
DEBTRACE("Echo_i::echoLong " << i);
if(i < 0) {
Runtime *RuntimeTest::_myRuntime = 0;
bool RuntimeTest::endTests = false;
+RuntimeForTest::RuntimeForTest()
+: RuntimeSALOME(UsePython+UseCorba+UseXml+UseCpp+UseSalome, 0, nullptr)
+{
+}
+
+RuntimeForTest::~RuntimeForTest()
+{
+}
+
+std::vector< std::pair<std::string,int> >
+RuntimeForTest::getCatalogOfComputeNodes() const
+{
+ std::vector< std::pair<std::string,int> > result(1);
+ std::pair<std::string,int> localhost;
+ localhost.first = "localhost";
+ localhost.second = 8;
+ result[0] = localhost;
+ return result;
+}
+
+void RuntimeForTest::setRuntime()
+{
+ if (! Runtime::_singleton)
+ Runtime::_singleton = new RuntimeForTest;
+}
+
void RuntimeTest::setUp()
{
if (_ltc.size() == 0)
{
// --- init runtime
std::cerr << std::endl;
- RuntimeSALOME::setRuntime();
+ RuntimeForTest::setRuntime();
_myRuntime = getRuntime();
// --- init typecodes
}
}
-void myTestRun(int nIn, int nOut, Any **In, Any **Out) throw (YACS::Exception)
+void myTestRun(int nIn, int nOut, Any **In, Any **Out)
{
double x, y;
cerr << "myTestRun nIn = " << nIn << endl;
namespace YACS
{
+ class RuntimeForTest : public YACS::ENGINE::RuntimeSALOME
+ {
+ public:
+ static void setRuntime();
+ RuntimeForTest();
+ virtual ~RuntimeForTest();
+ std::vector< std::pair<std::string,int> > getCatalogOfComputeNodes() const override;
+ };
+
class RuntimeTest
#ifdef USE_CPPUNIT
: public CppUnit::TestFixture
{
}
-void XmlCorba::put(const void *data) throw(ConversionException)
+void XmlCorba::put(const void *data)
{
DEBTRACE((const char *)data);
put((const char *)data);
/*!
* \param data : Xml::char *
*/
-void XmlCorba::put(const char *data) throw(ConversionException)
+void XmlCorba::put(const char *data)
{
DEBTRACE(data);
xmlDocPtr doc;
{
public:
XmlCorba(InputCorbaPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(const char *data) throw(ConversionException);
+ virtual void put(const void *data) ;
+ void put(const char *data);
};
}
}
{
}
- void XmlCpp::put(const void *data) throw(ConversionException)
+ void XmlCpp::put(const void *data)
{
DEBTRACE(" XmlCpp::put(const void *data)");
put((const char *)data);
* \param data : Xml::char *
*/
- void XmlCpp::put(const char *data) throw(ConversionException)
+ void XmlCpp::put(const char *data)
{
DEBTRACE("XmlCpp::put " << data);
xmlDocPtr doc;
{
public:
XmlCpp(InputPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(const char *data) throw(ConversionException);
+ virtual void put(const void *data) ;
+ void put(const char *data);
};
int isAdaptableCppXml(const TypeCode *t1, const TypeCode *t2);
}
{
}
-void XmlNeutral::put(const void *data) throw(ConversionException)
+void XmlNeutral::put(const void *data)
{
DEBTRACE(" XmlNeutral::put(const void *data)");
put((const char *)data);
* \param data : Xml::char *
*/
-void XmlNeutral::put(const char *data) throw(ConversionException)
+void XmlNeutral::put(const char *data)
{
DEBTRACE("XmlNeutral::put " << data);
xmlDocPtr doc;
{
public:
XmlNeutral(InputPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(const char *data) throw(ConversionException);
+ virtual void put(const void *data) ;
+ void put(const char *data);
};
}
}
return _data.c_str();
}
-void *InputXmlPort::get() const throw(YACS::Exception)
+void *InputXmlPort::get() const
{
return (void *) _data.c_str();
}
-void InputXmlPort::put(const void *data) throw (ConversionException)
+void InputXmlPort::put(const void *data)
{
DEBTRACE("put(void *)");
put((const char*)data);
}
-void InputXmlPort::put(const char *data) throw (ConversionException)
+void InputXmlPort::put(const char *data)
{
DEBTRACE(data);
_data = data;
{
}
-const char * OutputXmlPort::get() const throw (ConversionException)
+const char * OutputXmlPort::get() const
{
return _data.c_str();
}
-void OutputXmlPort::put(const void *data) throw (ConversionException)
+void OutputXmlPort::put(const void *data)
{
put((const char*)data);
}
-void OutputXmlPort::put(const char *data) throw (ConversionException)
+void OutputXmlPort::put(const char *data)
{
DEBTRACE(data);
InputPort *p;
InputXmlPort(const InputXmlPort& other, Node *newHelder);
bool edIsManuallyInitialized() const;
void edRemoveManInit();
- virtual void put(const void *data) throw (ConversionException);
- void put(const char *data) throw (ConversionException);
+ virtual void put(const void *data);
+ void put(const char *data);
void releaseData() override;
InputPort *clone(Node *newHelder) const;
virtual const char * getXml() const;
- void *get() const throw(Exception);
+ void *get() const ;
bool isEmpty();
virtual void exSaveInit();
virtual void exRestoreInit();
public:
OutputXmlPort(const std::string& name, Node* node, TypeCode * type);
OutputXmlPort(const OutputXmlPort& other, Node *newHelder);
- virtual void put(const void *data) throw (ConversionException);
- void put(const char *data) throw (ConversionException);
- virtual const char * get() const throw (ConversionException);
+ virtual void put(const void *data);
+ void put(const char *data);
+ virtual const char * get() const;
OutputPort *clone(Node *newHelder) const;
virtual std::string dump();
virtual std::string valToStr();
{
}
-void XmlPython::put(const void *data) throw(ConversionException)
+void XmlPython::put(const void *data)
{
DEBTRACE((const char *)data);
put((const char *)data);
* \param data : Xml::char *
*/
-void XmlPython::put(const char *data) throw(ConversionException)
+void XmlPython::put(const char *data)
{
DEBTRACE(data);
xmlDocPtr doc;
{
public:
XmlPython(InputPyPort* p);
- virtual void put(const void *data) throw(ConversionException);
- void put(const char *data) throw(ConversionException);
+ virtual void put(const void *data) ;
+ void put(const char *data);
};
}
}
--- /dev/null
+# Copyright (C) 2020 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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+SET (_link_LIBRARIES
+ #Threads::Threads
+ ${PTHREAD_LIBRARIES}
+)
+
+SET (_wlm_sources
+ Task.cxx
+ WorkloadManager.cxx
+ DefaultAlgorithm.cxx
+)
+
+SET (_wlm_headers
+ Task.hxx
+ WorkloadManager.hxx
+ WorkloadAlgorithm.hxx
+ DefaultAlgorithm.hxx
+)
+
+ADD_LIBRARY(YACSlibWorkloadmanager ${_wlm_sources})
+TARGET_LINK_LIBRARIES(YACSlibWorkloadmanager ${_link_LIBRARIES})
+INSTALL(TARGETS YACSlibWorkloadmanager EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
+INSTALL(FILES ${_wlm_headers} DESTINATION ${SALOME_INSTALL_HEADERS}/workloadmanager)
+
+IF(SALOME_BUILD_TESTS)
+ ADD_SUBDIRECTORY(Test)
+ENDIF(SALOME_BUILD_TESTS)
--- /dev/null
+// Copyright (C) 2020 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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#include "DefaultAlgorithm.hxx"
+#include "Task.hxx"
+#include <stdexcept>
+#include <limits>
+#include <algorithm>
+
+namespace WorkloadManager
+{
+void DefaultAlgorithm::addTask(Task* t)
+{
+ // put the tasks which need more cores in front.
+ float newNeedCores = t->type().neededCores;
+ if(_waitingTasks.empty())
+ _waitingTasks.push_back(t);
+ else if(_waitingTasks.back()->type().neededCores >= newNeedCores)
+ _waitingTasks.push_back(t);
+ else
+ {
+ std::list<Task*>::iterator it = _waitingTasks.begin();
+ while(it != _waitingTasks.end() && (*it)->type().neededCores >= newNeedCores)
+ it++;
+ _waitingTasks.insert(it, t);
+ }
+}
+
+bool DefaultAlgorithm::empty()const
+{
+ return _waitingTasks.empty();
+}
+
+void DefaultAlgorithm::addResource(const Resource& r)
+{
+ _resources.emplace_back(r);
+}
+
+WorkloadAlgorithm::LaunchInfo DefaultAlgorithm::chooseTask()
+{
+ LaunchInfo result;
+ std::list<Task*>::iterator chosenTaskIt;
+ for( std::list<Task*>::iterator itTask = _waitingTasks.begin();
+ !result.taskFound && itTask != _waitingTasks.end();
+ itTask ++)
+ {
+ const ContainerType& ctype = (*itTask)->type();
+ if(ctype.ignoreResources)
+ result.taskFound = true;
+ else
+ {
+ std::list<ResourceLoadInfo>::iterator best_resource;
+ best_resource = _resources.end();
+ float best_cost = std::numeric_limits<float>::max();
+ bool isSupported = false;
+ for(auto itResource = _resources.begin();
+ itResource != _resources.end();
+ itResource++)
+ if(itResource->isSupported(ctype)
+ && (*itTask)->isAccepted(itResource->resource()))
+ {
+ if(itResource->isAllocPossible(ctype))
+ {
+ float thisCost = itResource->cost(ctype);
+ if( best_cost > thisCost)
+ {
+ best_cost = thisCost;
+ best_resource = itResource;
+ }
+ }
+ }
+ if(best_resource != _resources.end())
+ {
+ result.taskFound = true;
+ result.worker.resource = best_resource->resource();
+ result.worker.index = best_resource->alloc(ctype);
+ }
+ else if(!isSupported)
+ {
+ // TODO: This task can never be run by any available resource.
+ }
+ }
+ if(result.taskFound)
+ {
+ chosenTaskIt = itTask;
+ result.task = (*itTask);
+ result.worker.type = ctype;
+ }
+ }
+ if(result.taskFound)
+ _waitingTasks.erase(chosenTaskIt);
+ return result;
+}
+
+void DefaultAlgorithm::liberate(const LaunchInfo& info)
+{
+ const ContainerType& ctype = info.worker.type;
+ if(!ctype.ignoreResources)
+ {
+ const Resource& r = info.worker.resource;
+ unsigned int index = info.worker.index;
+ std::list<ResourceLoadInfo>::iterator it = std::find(_resources.begin(),
+ _resources.end(),
+ r);
+ it->free(ctype, index); // we are sure to find it
+ }
+}
+
+// ResourceInfoForContainer
+
+DefaultAlgorithm::ResourceInfoForContainer::ResourceInfoForContainer
+ (const Resource& r, const ContainerType& ctype)
+: _ctype(ctype)
+, _resource(r)
+, _runningContainers()
+, _firstFreeContainer(0)
+{
+}
+
+unsigned int DefaultAlgorithm::ResourceInfoForContainer::maxContainers()const
+{
+ return float(_resource.nbCores) / _ctype.neededCores;
+}
+
+unsigned int DefaultAlgorithm::ResourceInfoForContainer::alloc()
+{
+ unsigned int result = _firstFreeContainer;
+ _runningContainers.insert(result);
+ _firstFreeContainer++;
+ while(isContainerRunning(_firstFreeContainer))
+ _firstFreeContainer++;
+ return result;
+}
+
+void DefaultAlgorithm::ResourceInfoForContainer::free(unsigned int index)
+{
+ _runningContainers.erase(index);
+ if(index < _firstFreeContainer)
+ _firstFreeContainer = index;
+}
+
+unsigned int DefaultAlgorithm::ResourceInfoForContainer::nbRunningContainers()const
+{
+ return _runningContainers.size();
+}
+
+bool DefaultAlgorithm::ResourceInfoForContainer::isContainerRunning
+ (unsigned int index)const
+{
+ return _runningContainers.find(index)!=_runningContainers.end();
+}
+
+// ResourceLoadInfo
+
+DefaultAlgorithm::ResourceLoadInfo::ResourceLoadInfo(const Resource& r)
+: _resource(r)
+, _load(0.0)
+, _loadCost(0.0)
+, _ctypes()
+{
+}
+
+bool DefaultAlgorithm::ResourceLoadInfo::isSupported
+ (const ContainerType& ctype)const
+{
+ return ctype.neededCores <= _resource.nbCores ;
+}
+
+bool DefaultAlgorithm::ResourceLoadInfo::isAllocPossible
+ (const ContainerType& ctype)const
+{
+ return ctype.neededCores + _load <= _resource.nbCores;
+}
+
+float DefaultAlgorithm::ResourceLoadInfo::cost
+ (const ContainerType& ctype)const
+{
+ return _loadCost * 100.0 / float(_resource.nbCores);
+}
+
+unsigned int DefaultAlgorithm::ResourceLoadInfo::alloc
+ (const ContainerType& ctype)
+{
+ std::list<ResourceInfoForContainer>::iterator it = std::find(_ctypes.begin(),
+ _ctypes.end(),
+ ctype);
+ // add the type if not found
+ if(it == _ctypes.end())
+ {
+ _ctypes.emplace_back(_resource, ctype);
+ it = _ctypes.end();
+ it--;
+ }
+ _load += ctype.neededCores;
+ if(ctype.neededCores == 0)
+ _loadCost += COST_FOR_0_CORE_TASKS;
+ else
+ _loadCost += ctype.neededCores;
+ return it->alloc();
+}
+
+void DefaultAlgorithm::ResourceLoadInfo::free
+ (const ContainerType& ctype, int index)
+{
+ _load -= ctype.neededCores;
+ if(ctype.neededCores == 0)
+ _loadCost -= COST_FOR_0_CORE_TASKS;
+ else
+ _loadCost -= ctype.neededCores;
+ std::list<ResourceInfoForContainer>::iterator it = std::find(_ctypes.begin(),
+ _ctypes.end(),
+ ctype);
+ it->free(index);
+}
+
+}
--- /dev/null
+// Copyright (C) 2020 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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef ALGORITHMIMPLEMENT_H
+#define ALGORITHMIMPLEMENT_H
+
+#include "YACSlibWorkloadmanagerExport.hxx"
+#include "WorkloadAlgorithm.hxx"
+#include <set>
+#include <map>
+#include <list>
+
+namespace WorkloadManager
+{
+/**
+ * @todo write docs
+ */
+class YACSLIBWLM_EXPORT DefaultAlgorithm : public WorkloadAlgorithm
+{
+public:
+ void addTask(Task* t)override;
+ void addResource(const Resource& r)override;
+ LaunchInfo chooseTask()override;
+ void liberate(const LaunchInfo& info)override;
+ bool empty()const override;
+
+// ----------------------------- PRIVATE ----------------------------- //
+private:
+ class ResourceInfoForContainer
+ {
+ public:
+ ResourceInfoForContainer(const Resource& r, const ContainerType& ctype);
+ unsigned int maxContainers()const;
+ unsigned int alloc();
+ void free(unsigned int index);
+ unsigned int nbRunningContainers()const;
+ bool isContainerRunning(unsigned int index)const;
+ bool operator<(const ResourceInfoForContainer& other)const
+ { return _ctype < other._ctype;}
+ bool operator==(const ContainerType& other)const
+ { return _ctype == other;}
+ const ContainerType& type()const { return _ctype;}
+ private:
+ ContainerType _ctype;
+ const Resource& _resource; // same ref as ResourceLoadInfo
+ std::set<unsigned int> _runningContainers; // 0 to max possible containers on this resource
+ unsigned int _firstFreeContainer;
+ };
+
+ class ResourceLoadInfo
+ {
+ public:
+ ResourceLoadInfo(const Resource& r);
+ bool isSupported(const ContainerType& ctype)const;
+ bool isAllocPossible(const ContainerType& ctype)const;
+ float cost(const ContainerType& ctype)const;
+ unsigned int alloc(const ContainerType& ctype);
+ void free(const ContainerType& ctype, int index);
+ bool operator<(const ResourceLoadInfo& other)const
+ { return _resource < other._resource;}
+ bool operator==(const Resource& other)const
+ { return _resource == other;}
+ const Resource& resource()const { return _resource;}
+ float COST_FOR_0_CORE_TASKS = 1.0 / 4096.0 ;
+ private:
+ Resource _resource;
+ float _load;
+ float _loadCost;
+ std::list<ResourceInfoForContainer> _ctypes;
+ };
+
+private:
+ std::list<ResourceLoadInfo> _resources;
+ std::list<Task*> _waitingTasks;
+};
+}
+#endif // ALGORITHMIMPLEMENT_H
--- /dev/null
+// Copyright (C) 2020 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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#include "Task.hxx"
--- /dev/null
+// Copyright (C) 2020 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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef _TASK_H_
+#define _TASK_H_
+
+#include "YACSlibWorkloadmanagerExport.hxx"
+
+#include <string>
+
+namespace WorkloadManager
+{
+ struct YACSLIBWLM_EXPORT ContainerType
+ {
+ // parameters needed by WorkloadManager
+ float neededCores = 0.0;
+ bool ignoreResources = false; // if true, the task can be run as soon as
+ // added to the manager without any resource
+ // allocation
+ // parameters for client use, used by WorkloadManager to distinguish objects
+ std::string name;
+ int id = 0;
+ bool operator==(const ContainerType& other)const
+ { return id == other.id && name == other.name;}
+ bool operator<(const ContainerType& other)const
+ {
+ return (id < other.id) ||
+ (id == other.id && name < other.name);
+ }
+ };
+
+ struct YACSLIBWLM_EXPORT Resource
+ {
+ unsigned int nbCores = 0; // needed by WorkloadManager
+ // parameters for client use, used by WorkloadManager to distinguish objects
+ std::string name;
+ int id = 0;
+ bool operator==(const Resource& other)const
+ { return id == other.id && name == other.name;}
+ bool operator<(const Resource& other)const
+ {
+ return (id < other.id) ||
+ (id == other.id && name < other.name);
+ }
+ };
+
+ struct YACSLIBWLM_EXPORT RunInfo
+ {
+ ContainerType type;
+ Resource resource;
+ unsigned int index=0; // worker index on the resource for this type
+ };
+
+ /**
+ * @todo write docs
+ */
+ class YACSLIBWLM_EXPORT Task
+ {
+ public:
+ virtual ~Task(){};
+ virtual const ContainerType& type()const =0;
+ virtual void run(const RunInfo& c)=0;
+
+ // Is it possible to run the task on this resource?
+ virtual bool isAccepted(const Resource& r)
+ {
+ // by default, a task can be run on any resource.
+ return true;
+ }
+ };
+}
+
+#endif // _TASK_H_
--- /dev/null
+# Copyright (C) 2020 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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+SET(_link_LIBRARIES
+ ${CPPUNIT_LIBRARIES}
+ ${PTHREAD_LIBRARIES}
+ YACSlibWorkloadmanager
+)
+
+ADD_EXECUTABLE(WorkloadManagerTest TestMain.cxx)
+TARGET_LINK_LIBRARIES(WorkloadManagerTest ${_link_LIBRARIES})
+ADD_TEST(WorkloadManager WorkloadManagerTest)
+
+# For salome test
+SET(LOCAL_TEST_DIR ${SALOME_YACS_INSTALL_TEST}/workloadmanager)
+INSTALL(TARGETS WorkloadManagerTest DESTINATION ${LOCAL_TEST_DIR})
+INSTALL(FILES CTestTestfileInstall.cmake
+ DESTINATION ${LOCAL_TEST_DIR}
+ RENAME CTestTestfile.cmake)
--- /dev/null
+# Copyright (C) 2020 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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+IF(NOT WIN32)
+ SET(TEST_NAME ${COMPONENT_NAME}_WorkloadManager)
+ ADD_TEST(${TEST_NAME} WorkloadManagerTest)
+ SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES
+ LABELS "${COMPONENT_NAME}"
+ ENVIRONMENT "LD_LIBRARY_PATH=${YACS_TEST_LIB}:$ENV{LD_LIBRARY_PATH}"
+ )
+ENDIF()
--- /dev/null
+// Copyright (C) 2020 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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+//
+
+#include <cppunit/TestFixture.h>
+#include <stdexcept>
+
+#include <iostream>
+#include <fstream>
+#include <cstdlib>
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <string>
+#include <sstream>
+
+#include <chrono>
+#include <ctime>
+#include <thread>
+
+#include "../WorkloadManager.hxx"
+#include "../DefaultAlgorithm.hxx"
+
+constexpr bool ACTIVATE_DEBUG_LOG = false;
+template<typename... Ts>
+void DEBUG_LOG(Ts... args)
+{
+ if(! ACTIVATE_DEBUG_LOG)
+ return;
+ if(sizeof...(Ts) == 0)
+ return;
+ std::ostringstream message;
+ // TODO: C++17 solution: ( (message << args), ...);
+ // since initializer lists guarantee sequencing, this can be used to
+ // call a function on each element of a pack, in order:
+ int dummy[] = { (message << args, 0)...};
+ message << std::endl;
+ std::cerr << message.str();
+}
+
+class MyTask;
+class AbstractChecker
+{
+public:
+ virtual void check(const WorkloadManager::RunInfo& c, MyTask* t)=0;
+};
+
+template <std::size_t size_R, std::size_t size_T>
+class Checker : public AbstractChecker
+{
+public:
+ Checker();
+ void check(const WorkloadManager::RunInfo& c, MyTask* t)override;
+ void globalCheck();
+ void reset();
+
+ WorkloadManager::Resource resources[size_R];
+ WorkloadManager::ContainerType types[size_T];
+private:
+ std::mutex _mutex;
+ int _maxContainersForResource[size_R][size_T];
+};
+
+class MyTask : public WorkloadManager::Task
+{
+public:
+ const WorkloadManager::ContainerType& type()const override {return *_type;}
+ void run(const WorkloadManager::RunInfo& c)override
+ {
+ _check->check(c, this);
+
+ DEBUG_LOG("Running task ", _id, " on ", c.resource.name, "-", c.type.name,
+ "-", c.index);
+ std::this_thread::sleep_for(std::chrono::seconds(_sleep));
+ DEBUG_LOG("Finish task ", _id);
+ }
+
+ void reset(int id,
+ const WorkloadManager::ContainerType* type,
+ int sleep,
+ AbstractChecker * check
+ )
+ {
+ _id = id;
+ _type = type;
+ _sleep = sleep;
+ _check = check;
+ }
+private:
+ int _id = 0;
+ const WorkloadManager::ContainerType* _type = nullptr;
+ int _sleep = 0;
+ AbstractChecker * _check;
+};
+
+template <std::size_t size_R, std::size_t size_T>
+Checker<size_R, size_T>::Checker()
+{
+ for(std::size_t i=0; i < size_R; i ++)
+ {
+ resources[i].id = i;
+ std::ostringstream name;
+ name << "r" << i;
+ resources[i].name = name.str();
+ }
+
+ for(std::size_t i=0; i < size_T; i ++)
+ {
+ types[i].id = i;
+ std::ostringstream name;
+ name << "t" << i;
+ types[i].name = name.str();
+ }
+
+ for(std::size_t i=0; i < size_R; i++)
+ for(std::size_t j=0; j < size_T; j++)
+ _maxContainersForResource[i][j] = 0;
+}
+
+template <std::size_t size_R, std::size_t size_T>
+void Checker<size_R, size_T>::check(const WorkloadManager::RunInfo& c,
+ MyTask* t)
+{
+ std::unique_lock<std::mutex> lock(_mutex);
+ int& max = _maxContainersForResource[c.resource.id][c.type.id];
+ if( max < c.index)
+ max = c.index;
+}
+
+template <std::size_t size_R, std::size_t size_T>
+void Checker<size_R, size_T>::globalCheck()
+{
+ for(std::size_t i=0; i < size_R; i++)
+ {
+ float global_max = 0;
+ for(std::size_t j=0; j < size_T; j++)
+ {
+ int max = _maxContainersForResource[i][j];
+ DEBUG_LOG(resources[i].name, ", ", types[j].name,
+ " max simultaneous runs:", max+1);
+ CPPUNIT_ASSERT( (max+1) * types[j].neededCores <= resources[i].nbCores );
+ global_max += types[j].neededCores * float(max+1);
+ }
+ DEBUG_LOG(resources[i].name, " max cores added for evry type: ", global_max);
+ // This assertion may be false if there are more resources than needed.
+ CPPUNIT_ASSERT(global_max >= resources[i].nbCores); // cores fully used
+ }
+}
+
+template <std::size_t size_R, std::size_t size_T>
+void Checker<size_R, size_T>::reset()
+{
+ for(std::size_t i=0; i < size_R; i++)
+ for(std::size_t j=0; j < size_T; j++)
+ _maxContainersForResource[i][j] = 0;
+}
+
+class MyTest: public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE(MyTest);
+ CPPUNIT_TEST(atest);
+ CPPUNIT_TEST(btest);
+ CPPUNIT_TEST_SUITE_END();
+public:
+ void atest();
+ void btest(); // ignore resources
+};
+
+/**
+ * General test with 150 tasks of 3 types:
+ * - 50 tasks which need 4 cores for 2s each
+ * - 50 tasks which need 1 core for 1s each
+ * - 50 tasks which need no core but take 2s each
+ * We use 2 resources: 10 cores and 18 cores
+ * We verify the global time of execution.
+ */
+void MyTest::atest()
+{
+ constexpr std::size_t resourcesNumber = 2;
+ constexpr std::size_t typesNumber = 3;
+ Checker<resourcesNumber, typesNumber> check;
+ check.resources[0].nbCores = 10;
+ check.resources[1].nbCores = 18;
+ check.types[0].neededCores = 4.0;
+ check.types[1].neededCores = 1.0;
+ check.types[2].neededCores = 0.0; // tasks to be run with no cost
+
+ for(std::size_t i=0; i < resourcesNumber; i ++)
+ DEBUG_LOG(check.resources[i].name, " has ", check.resources[i].nbCores,
+ " cores.");
+ for(std::size_t i=0; i < typesNumber; i ++)
+ DEBUG_LOG(check.types[i].name, " needs ", check.types[i].neededCores,
+ " cores.");
+
+ constexpr std::size_t tasksNumber = 150;
+ MyTask tasks[tasksNumber];
+ for(int type_id = 0; type_id < typesNumber; type_id++)
+ for(int j = type_id * tasksNumber / typesNumber;
+ j < (type_id + 1) * tasksNumber / typesNumber;
+ j++)
+ // id, ContainerType, sleep (1|2s)
+ tasks[j].reset(j, &check.types[type_id], 2-type_id%2, &check);
+
+ DEBUG_LOG("Number of tasks: ", tasksNumber);
+ for(int type_id = 0; type_id < typesNumber; type_id++)
+ DEBUG_LOG("Tasks from ", type_id * tasksNumber / typesNumber,
+ " to ", (type_id + 1) * tasksNumber / typesNumber,
+ " are of type ", check.types[type_id].name);
+
+ WorkloadManager::DefaultAlgorithm algo;
+ WorkloadManager::WorkloadManager wlm(algo);
+ for(std::size_t i=0; i < resourcesNumber; i ++)
+ wlm.addResource(check.resources[i]);
+
+ // Add 4 core tasks first
+ check.reset();
+ for(std::size_t i = 0; i < tasksNumber; i++)
+ wlm.addTask(&tasks[i]);
+ std::chrono::steady_clock::time_point start_time;
+ start_time = std::chrono::steady_clock::now();
+ wlm.start(); // tasks can be added before start.
+ wlm.stop();
+ std::chrono::steady_clock::time_point end_time;
+ end_time = std::chrono::steady_clock::now();
+ std::chrono::seconds duration;
+ duration = std::chrono::duration_cast<std::chrono::seconds>
+ (end_time - start_time);
+ std::chrono::seconds maxExpectedDuration(22);
+ CPPUNIT_ASSERT( duration < maxExpectedDuration );
+ DEBUG_LOG("Test step duration : ", duration.count(), "s");
+ check.globalCheck();
+
+ // Add 1 core tasks first
+ check.reset();
+ // WARNING: std::size_t is always >= 0
+ for(int i = tasksNumber-1; i >= 0; i--)
+ wlm.addTask(&tasks[i]);
+ start_time = std::chrono::steady_clock::now();
+ wlm.start(); // tasks can be added before start.
+ wlm.stop();
+ end_time = std::chrono::steady_clock::now();
+ duration = std::chrono::duration_cast<std::chrono::seconds>
+ (end_time - start_time);
+ CPPUNIT_ASSERT( duration < maxExpectedDuration );
+ DEBUG_LOG("Test step duration : ", duration.count(), "s");
+ check.globalCheck();
+
+ // Add 1 core tasks first & start before addTask
+ check.reset();
+ start_time = std::chrono::steady_clock::now();
+ wlm.start();
+ for(int i = tasksNumber-1; i >= 0; i--)
+ wlm.addTask(&tasks[i]);
+ wlm.stop();
+ end_time = std::chrono::steady_clock::now();
+ duration = std::chrono::duration_cast<std::chrono::seconds>
+ (end_time - start_time);
+ CPPUNIT_ASSERT( duration < maxExpectedDuration );
+ DEBUG_LOG("Test step duration : ", duration.count(), "s");
+ check.globalCheck();
+
+}
+
+/**
+ * Test the case of tasks which need no resources and can be run whithout
+ * waiting.
+ */
+void MyTest::btest()
+{
+ Checker<1, 1> check;
+ WorkloadManager::ContainerType ctype;
+ ctype.ignoreResources = true;
+ constexpr std::size_t tasksNumber = 20;
+ MyTask tasks[tasksNumber];
+ for(std::size_t i = 0; i < tasksNumber; i++)
+ tasks[i].reset(i, &ctype, 1, &check);
+ WorkloadManager::DefaultAlgorithm algo;
+ WorkloadManager::WorkloadManager wlm(algo);
+ // no resource needed
+ std::chrono::steady_clock::time_point start_time;
+ std::chrono::steady_clock::time_point end_time;
+ std::chrono::seconds duration;
+ start_time = std::chrono::steady_clock::now();
+ wlm.start();
+ for(std::size_t i = 0; i < tasksNumber; i++)
+ wlm.addTask(&tasks[i]);
+ wlm.stop();
+ end_time = std::chrono::steady_clock::now();
+ duration = std::chrono::duration_cast<std::chrono::seconds>
+ (end_time - start_time);
+ std::chrono::seconds maxExpectedDuration(2);
+ CPPUNIT_ASSERT( duration <= maxExpectedDuration);
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(MyTest);
+
+#include "BasicMainTest.hxx"
--- /dev/null
+// Copyright (C) 2020 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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef WORKLOADALGORITHM_H
+#define WORKLOADALGORITHM_H
+
+#include "YACSlibWorkloadmanagerExport.hxx"
+#include "Task.hxx"
+
+namespace WorkloadManager
+{
+class YACSLIBWLM_EXPORT WorkloadAlgorithm
+{
+public:
+ struct LaunchInfo
+ {
+ bool taskFound=false;
+ RunInfo worker;
+ Task* task=nullptr;
+ };
+
+ virtual void addTask(Task* t)=0;
+ virtual void addResource(const Resource& r)=0;
+ virtual LaunchInfo chooseTask()=0;
+ virtual void liberate(const LaunchInfo& info)=0;
+ virtual bool empty()const =0;
+};
+}
+#endif // WORKLOADALGORITHM_H
--- /dev/null
+// Copyright (C) 2020 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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#include "WorkloadManager.hxx"
+#include "Task.hxx"
+
+namespace WorkloadManager
+{
+ WorkloadManager::WorkloadManager(WorkloadAlgorithm& algo)
+ : _runningTasks()
+ , _finishedTasks()
+ , _nextIndex(0)
+ , _data_mutex()
+ , _startCondition()
+ , _endCondition()
+ , _stop(false)
+ , _otherThreads()
+ , _algo(algo)
+ {
+ }
+
+ WorkloadManager::~WorkloadManager()
+ {
+ stop();
+ }
+
+ void WorkloadManager::addResource(const Resource& r)
+ {
+ std::unique_lock<std::mutex> lock(_data_mutex);
+ _algo.addResource(r);
+ _startCondition.notify_one();
+ }
+
+ void WorkloadManager::addTask(Task* t)
+ {
+ std::unique_lock<std::mutex> lock(_data_mutex);
+ _algo.addTask(t);
+ _startCondition.notify_one();
+ }
+
+ void WorkloadManager::start()
+ {
+ {
+ std::unique_lock<std::mutex> lock(_data_mutex);
+ _stop = false;
+ }
+ _otherThreads.emplace_back(std::async([this]
+ {
+ runTasks();
+ }));
+ _otherThreads.emplace_back(std::async([this]
+ {
+ endTasks();
+ }));
+ }
+
+ void WorkloadManager::stop()
+ {
+ {
+ std::unique_lock<std::mutex> lock(_data_mutex);
+ _stop = true;
+ }
+ _startCondition.notify_one();
+ _endCondition.notify_one();
+ for(std::future<void>& th : _otherThreads)
+ th.wait();
+ }
+
+ void WorkloadManager::runTasks()
+ {
+ bool threadStop = false;
+ while(!threadStop)
+ {
+ std::unique_lock<std::mutex> lock(_data_mutex);
+ _startCondition.wait(lock, [this] {return !_algo.empty() || _stop;});
+ RunningInfo taskInfo;
+ while(chooseTaskToRun(taskInfo))
+ {
+ _runningTasks.emplace(taskInfo.id, std::async([this, taskInfo]
+ {
+ runOneTask(taskInfo);
+ }));
+ }
+ threadStop = _stop && _algo.empty();
+ }
+ }
+
+ void WorkloadManager::runOneTask(const RunningInfo& taskInfo)
+ {
+ taskInfo.info.task->run(taskInfo.info.worker);
+
+ {
+ std::unique_lock<std::mutex> lock(_data_mutex);
+ _finishedTasks.push(taskInfo);
+ _endCondition.notify_one();
+ }
+ }
+
+ void WorkloadManager::endTasks()
+ {
+ bool threadStop = false;
+ while(!threadStop)
+ {
+ std::unique_lock<std::mutex> lock(_data_mutex);
+ _endCondition.wait(lock, [this]
+ {
+ return !_finishedTasks.empty() ||
+ (_stop && _runningTasks.empty() && _algo.empty());
+ });
+ while(!_finishedTasks.empty())
+ {
+ RunningInfo taskInfo = _finishedTasks.front();
+ _finishedTasks.pop();
+ _runningTasks[taskInfo.id].wait();
+ _runningTasks.erase(taskInfo.id);
+ _algo.liberate(taskInfo.info);
+ }
+ threadStop = _stop && _runningTasks.empty() && _algo.empty();
+ _startCondition.notify_one();
+ }
+ }
+
+ bool WorkloadManager::chooseTaskToRun(RunningInfo& taskInfo)
+ {
+ // We are already under the lock
+ taskInfo.id = _nextIndex;
+ taskInfo.info = _algo.chooseTask();
+ if(taskInfo.info.taskFound)
+ _nextIndex ++;
+ return taskInfo.info.taskFound;
+ }
+
+}
--- /dev/null
+// Copyright (C) 2020 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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef WORKLOADMANAGER_H
+#define WORKLOADMANAGER_H
+#include "YACSlibWorkloadmanagerExport.hxx"
+
+#include <mutex>
+#include <future>
+#include <condition_variable> // notifications
+#include <map>
+#include <queue>
+#include <list>
+#include "Task.hxx"
+#include "WorkloadAlgorithm.hxx"
+
+namespace WorkloadManager
+{
+ class YACSLIBWLM_EXPORT WorkloadManager
+ {
+ public:
+ WorkloadManager(WorkloadAlgorithm& algo);
+ WorkloadManager(const WorkloadManager&) = delete;
+ WorkloadManager()=delete;
+ ~WorkloadManager();
+ void addTask(Task* t);
+ void addResource(const Resource& r);
+ void start(); //! start execution
+ void stop(); //! stop execution
+
+ private:
+ typedef unsigned long TaskId;
+ struct RunningInfo
+ {
+ TaskId id;
+ WorkloadAlgorithm::LaunchInfo info;
+ };
+ std::map<TaskId, std::future<void> > _runningTasks;
+ std::queue<RunningInfo> _finishedTasks;
+ TaskId _nextIndex;
+ std::mutex _data_mutex;
+ std::condition_variable _startCondition; // start tasks thread notification
+ std::condition_variable _endCondition; // end tasks thread notification
+ bool _stop;
+ std::vector< std::future<void> > _otherThreads;
+ WorkloadAlgorithm& _algo;
+
+ void runTasks();
+ void endTasks();
+ void runOneTask(const RunningInfo& taskInfo);
+ // choose a task and block a resource
+ bool chooseTaskToRun(RunningInfo& taskInfo);
+ };
+}
+#endif // WORKLOADMANAGER_H
--- /dev/null
+// Copyright (C) 2006-2020 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
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef _YACSLIBWORKLOADMANAGEREXPORT_HXX_
+#define _YACSLIBWORKLOADMANAGEREXPORT_HXX_
+
+#ifdef WIN32
+# if defined YACSlibWorkloadManager_EXPORTS
+# define YACSLIBWLM_EXPORT __declspec( dllexport )
+# else
+# define YACSLIBWLM_EXPORT __declspec( dllimport )
+# endif
+#else
+# define YACSLIBWLM_EXPORT
+#endif
+
+#ifdef WIN32
+#pragma warning(disable:4251) // Warning DLL Interface ...
+#pragma warning(disable:4290) // Warning Exception ...
+#endif
+
+#endif
virtual YACS::ENGINE::TypeCode *getTCForAlgoInit() const;
//! returns typecode of type expected as algo result. OwnerShip of returned pointer is held by this.
virtual YACS::ENGINE::TypeCode *getTCForAlgoResult() const;
- virtual void initialize(const YACS::ENGINE::Any *input) throw (YACS::Exception);
+ virtual void initialize(const YACS::ENGINE::Any *input);
virtual void startToTakeDecision();
virtual void finish();//! Called when optimization has succeed.
virtual YACS::ENGINE::Any * getAlgoResult();
* future to initialize an algorithm with custom data.
*/
void OptimizerAlgASyncExample::initialize(const YACS::ENGINE::Any *input)
- throw (YACS::Exception)
{
std::cout << "Algo initialize, input = " << input->getIntValue() << std::endl;
}
YACS::ENGINE::OptimizerAlgBase * createOptimizerAlgASyncExample(YACS::ENGINE::Pool *pool)
{
return new OptimizerAlgASyncExample(pool);
-}
\ No newline at end of file
+}
virtual YACS::ENGINE::TypeCode *getTCForAlgoInit() const;
//! returns typecode of type expected as algo result. OwnerShip of returned pointer is held by this.
virtual YACS::ENGINE::TypeCode *getTCForAlgoResult() const;
- virtual void initialize(const YACS::ENGINE::Any *input) throw (YACS::Exception);
+ virtual void initialize(const YACS::ENGINE::Any *input);
virtual void start(); //! Update _pool attribute before performing anything.
virtual void takeDecision();//! _pool->getCurrentId gives the \b id at the origin of this call.
//! Perform the job of analysing to know what new jobs to do (_pool->pushInSample)
* future to initialize an algorithm with custom data.
*/
void OptimizerAlgSyncExample::initialize(const YACS::ENGINE::Any *input)
- throw (YACS::Exception)
{
std::cout << "Algo initialize, input = " << input->getIntValue() << std::endl;
}
YACS::ENGINE::OptimizerAlgBase * createOptimizerAlgSyncExample(YACS::ENGINE::Pool *pool)
{
return new OptimizerAlgSyncExample(pool);
-}
\ No newline at end of file
+}
virtual ~Echo_i() {}
virtual char* echoString(const char* mesg);
virtual CORBA::Boolean echoBoolean(CORBA::Boolean b);
- CORBA::Long echoLong(CORBA::Long i) throw(eo::SALOME_Exception);
+ CORBA::Long echoLong(CORBA::Long i);
void echoDouble(CORBA::Double i,CORBA::Double& j) ;
void echoDoubleVec(const eo::DoubleVec& i,eo::DoubleVec_out j) ;
void echoDoubleVecVec(const eo::DoubleVecVec&, eo::DoubleVecVec_out);
out=new eo::DoubleVecVec(in);
}
-CORBA::Long Echo_i::echoLong(CORBA::Long i ) throw(eo::SALOME_Exception)
+CORBA::Long Echo_i::echoLong(CORBA::Long i )
{
DEBTRACE("Echo_i::echoLong " << i);
if(i < 0) {
//fullname += ".splitter";
//currentProc->nodeMap[fullname]=b->getChildByShortName("splitter");
}
- virtual void foreach (YACS::ENGINE::ForEachLoop* const& b)
+ virtual void foreach (YACS::ENGINE::ForEachLoopGen* const& b)
{
DEBTRACE( "bloc_foreach_set: " << b->getName() )
_bloc->edAddChild(b);
else if(element == "bloc")pp=&bloctypeParser<>::blocParser;
else if(element == "forloop")pp=&forlooptypeParser<>::forloopParser;
- else if(element == "foreach")pp=&foreachlooptypeParser<>::foreachloopParser;
+ else if(element == "foreach")pp=&foreachlooptypeParser<ENGINE::ForEachLoop *>::foreachloopParser;
+ else if(element == "foreachdyn")pp=&foreachlooptypeParser<ENGINE::ForEachLoopDyn *>::foreachloopParser;
else if(element == "optimizer")pp=&optimizerlooptypeParser<>::optimizerloopParser;
else if(element == "while")pp=&whilelooptypeParser<>::whileloopParser;
else if(element == "switch")pp=&switchtypeParser::switchParser;
else if(element == "bloc")bloc(((bloctypeParser<>*)child)->post());
else if(element == "forloop")forloop(((forlooptypeParser<>*)child)->post());
else if(element == "optimizer")optimizer(((optimizerlooptypeParser<>*)child)->post());
- else if(element == "foreach")foreach(((foreachlooptypeParser<>*)child)->post());
+ else if(element == "foreach")foreach(((foreachlooptypeParser<ENGINE::ForEachLoop *>*)child)->post());
+ else if(element == "foreachdyn")foreach(((foreachlooptypeParser<ENGINE::ForEachLoopDyn *>*)child)->post());
else if(element == "while")while_(((whilelooptypeParser<>*)child)->post());
else if(element == "switch")switch_(((switchtypeParser*)child)->post());
virtual void remote (ENGINE::InlineNode* const& n);
virtual void node (ENGINE::InlineNode* const& n);
virtual void forloop (ENGINE::ForLoop* const& b);
- virtual void foreach (ENGINE::ForEachLoop* const& b);
+ virtual void foreach (ENGINE::ForEachLoopGen* const& b);
virtual void optimizer (ENGINE::OptimizerLoop* const& b);
virtual void while_ (ENGINE::WhileLoop* const& b);
virtual void switch_ (ENGINE::Switch* const& b);
currentProc->nodeMap[fullname]=b;
}
template <class T>
-void looptypeParser<T>::foreach (ENGINE::ForEachLoop* const& b)
+void looptypeParser<T>::foreach (ENGINE::ForEachLoopGen* const& b)
{
DEBTRACE("loop_foreach" << b->getName())
_cnode->edSetNode(b);
ENGINE::Node * getNode() { return _node; }
// Those two methods should never be called
- bool edAddLink(ENGINE::OutPort *start, ENGINE::InPort *end) throw(Exception) { YASSERT(false); }
- bool edAddDFLink(ENGINE::OutPort *start, ENGINE::InPort *end) throw(Exception) { YASSERT(false); }
+ bool edAddLink(ENGINE::OutPort *start, ENGINE::InPort *end) { YASSERT(false); }
+ bool edAddDFLink(ENGINE::OutPort *start, ENGINE::InPort *end) { YASSERT(false); }
protected:
ENGINE::Node * _node;
{
// Foreach loop specialization
-template <class T=ENGINE::ForEachLoop*>
+template<class T>
+T buildFrom(ENGINE::Runtime *theRuntime, const std::string& name, ENGINE::TypeCode *type);
+
+template<>
+ENGINE::ForEachLoop *buildFrom<ENGINE::ForEachLoop *>(ENGINE::Runtime *theRuntime, const std::string& name, ENGINE::TypeCode *type)
+{ return theRuntime->createForEachLoop(name,type); }
+
+template<>
+ENGINE::ForEachLoopDyn *buildFrom<ENGINE::ForEachLoopDyn *>(ENGINE::Runtime *theRuntime, const std::string& name, ENGINE::TypeCode *type)
+{ return theRuntime->createForEachLoopDyn(name,type); }
+
+
+template <class T>
struct foreachlooptypeParser:dynparalooptypeParser<T>
{
static foreachlooptypeParser<T> foreachloopParser;
t->incrRef();
}
}
- this->_cnode=theRuntime->createForEachLoop(_name,currentProc->typeMap[_datatype]);
+ this->_cnode=buildFrom<T>(theRuntime,_name,currentProc->typeMap[_datatype]);
//set number of branches
if(_nbranch > 0)this->_cnode->edGetNbOfBranchesPort()->edInit(_nbranch);
if(_weight > 0)this->_cnode->setWeight(_weight);
};
template <class T> foreachlooptypeParser<T> foreachlooptypeParser<T>::foreachloopParser;
-
}
namespace YACS
this->maxcount("node",1,element);
this->maxcount("forloop",1,element);
this->maxcount("foreach",1,element);
+ this->maxcount("foreachdyn",1,element);
this->maxcount("optimizer",1,element);
this->maxcount("while",1,element);
this->maxcount("switch",1,element);
else if(element == "node")pp=&nodetypeParser<>::nodeParser;
else if(element == "forloop")pp=&forlooptypeParser<>::forloopParser;
- else if(element == "foreach")pp=&foreachlooptypeParser<>::foreachloopParser;
+ else if(element == "foreach")pp=&foreachlooptypeParser<ENGINE::ForEachLoop *>::foreachloopParser;
+ else if(element == "foreachdyn")pp=&foreachlooptypeParser<ENGINE::ForEachLoopDyn *>::foreachloopParser;
else if(element == "optimizer")pp=&optimizerlooptypeParser<>::optimizerloopParser;
else if(element == "while")pp=&whilelooptypeParser<>::whileloopParser;
else if(element == "switch")pp=&switchtypeParser::switchParser;
else if(element == "node")node(((nodetypeParser<>*)child)->post());
else if(element == "forloop")forloop(((forlooptypeParser<>*)child)->post());
- else if(element == "foreach")foreach(((foreachlooptypeParser<>*)child)->post());
+ else if(element == "foreach")foreach(((foreachlooptypeParser<ENGINE::ForEachLoop *>*)child)->post());
+ else if(element == "foreachdyn")foreach(((foreachlooptypeParser<ENGINE::ForEachLoopDyn *>*)child)->post());
else if(element == "optimizer")optimizer(((optimizerlooptypeParser<>*)child)->post());
else if(element == "while")while_(((whilelooptypeParser<>*)child)->post());
else if(element == "switch")switch_(((switchtypeParser*)child)->post());
else if(element == "bloc")pp=&bloctypeParser<>::blocParser;
else if(element == "forloop")pp=&forlooptypeParser<>::forloopParser;
- else if(element == "foreach")pp=&foreachlooptypeParser<>::foreachloopParser;
+ else if(element == "foreach")pp=&foreachlooptypeParser<ENGINE::ForEachLoop *>::foreachloopParser;
+ else if(element == "foreachdyn")pp=&foreachlooptypeParser<ENGINE::ForEachLoopDyn *>::foreachloopParser;
else if(element == "optimizer")pp=&optimizerlooptypeParser<>::optimizerloopParser;
else if(element == "while")pp=&whilelooptypeParser<>::whileloopParser;
else if(element == "switch")pp=&switchtypeParser::switchParser;
else if(element == "bloc")this->bloc(((bloctypeParser<>*)child)->post());
else if(element == "forloop")this->forloop(((forlooptypeParser<>*)child)->post());
- else if(element == "foreach")this->foreach(((foreachlooptypeParser<>*)child)->post());
+ else if(element == "foreach")this->foreach(((foreachlooptypeParser<ENGINE::ForEachLoop *>*)child)->post());
+ else if(element == "foreachdyn")this->foreach(((foreachlooptypeParser<ENGINE::ForEachLoopDyn *>*)child)->post());
else if(element == "optimizer")this->optimizer(((optimizerlooptypeParser<>*)child)->post());
else if(element == "while")this->while_(((whilelooptypeParser<>*)child)->post());
else if(element == "switch")this->switch_(((switchtypeParser*)child)->post());
--- /dev/null
+<?xml version='1.0' encoding='iso-8859-1' ?>
+<proc name="newSchema_1">
+ <property name="executor" value="workloadmanager"/>
+ <type name="string" kind="string"/>
+ <struct name="Engines/dataref">
+ <member name="ref" type="string"/>
+ </struct>
+ <type name="bool" kind="bool"/>
+ <sequence name="boolvec" content="bool"/>
+ <type name="double" kind="double"/>
+ <sequence name="dblevec" content="double"/>
+ <objref name="file" id="file"/>
+ <type name="int" kind="int"/>
+ <sequence name="intvec" content="int"/>
+ <struct name="stringpair">
+ <member name="name" type="string"/>
+ <member name="value" type="string"/>
+ </struct>
+ <sequence name="propvec" content="stringpair"/>
+ <objref name="pyobj" id="python:obj:1.0"/>
+ <sequence name="seqboolvec" content="boolvec"/>
+ <sequence name="seqdblevec" content="dblevec"/>
+ <sequence name="seqint" content="int"/>
+ <sequence name="seqintvec" content="intvec"/>
+ <sequence name="seqpyobj" content="pyobj"/>
+ <sequence name="stringvec" content="string"/>
+ <sequence name="seqstringvec" content="stringvec"/>
+ <container name="DefaultContainer">
+ <property name="container_kind" value="Salome"/>
+ <property name="attached_on_cloning" value="0"/>
+ <property name="container_name" value="FactoryServer"/>
+ <property name="name" value="localhost"/>
+ </container>
+ <container name="c1">
+ <property name="container_kind" value="Salome"/>
+ <property name="attached_on_cloning" value="1"/>
+ <property name="nb_parallel_procs" value="1"/>
+ <property name="type" value="multi"/>
+ </container>
+ <container name="c2">
+ <property name="container_kind" value="Salome"/>
+ <property name="attached_on_cloning" value="1"/>
+ <property name="nb_parallel_procs" value="4"/>
+ <property name="type" value="multi"/>
+ </container>
+ <inline name="Begin">
+ <script><code><![CDATA[import time
+vals = [ i for i in range(40)]
+nbbranches = len(vals)
+t0=time.time()
+]]></code></script>
+ <outport name="t0" type="pyobj"/>
+ <outport name="vals" type="intvec"/>
+ <outport name="nbbranches" type="int"/>
+ </inline>
+ <inline name="End">
+ <script><code><![CDATA[import time
+tf=time.time()
+r=int(tf-t0)
+]]></code></script>
+ <inport name="t0" type="pyobj"/>
+ <outport name="r" type="int"/>
+ </inline>
+ <foreach name="ForEach1" nbranch="1" loopWeight="-1" type="int">
+ <remote name="PyScript6" elementaryWeight="-1">
+ <script><code><![CDATA[import time
+time.sleep(1)
+]]></code></script>
+ <load container="c1"/>
+ <inport name="v" type="int"/>
+ </remote>
+ </foreach>
+ <foreach name="ForEach2" nbranch="1" loopWeight="-1" type="int">
+ <remote name="PyScript7" elementaryWeight="-1">
+ <script><code><![CDATA[import time
+time.sleep(1)
+]]></code></script>
+ <load container="c2"/>
+ <inport name="v" type="int"/>
+ </remote>
+ </foreach>
+ <control> <fromnode>Begin</fromnode> <tonode>ForEach1</tonode> </control>
+ <control> <fromnode>Begin</fromnode> <tonode>ForEach2</tonode> </control>
+ <control> <fromnode>Begin</fromnode> <tonode>End</tonode> </control>
+ <control> <fromnode>ForEach1</fromnode> <tonode>End</tonode> </control>
+ <control> <fromnode>ForEach2</fromnode> <tonode>End</tonode> </control>
+ <datalink control="false">
+ <fromnode>Begin</fromnode> <fromport>t0</fromport>
+ <tonode>End</tonode> <toport>t0</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>Begin</fromnode> <fromport>vals</fromport>
+ <tonode>ForEach1</tonode> <toport>SmplsCollection</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>Begin</fromnode> <fromport>vals</fromport>
+ <tonode>ForEach2</tonode> <toport>SmplsCollection</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>Begin</fromnode> <fromport>nbbranches</fromport>
+ <tonode>ForEach2</tonode> <toport>nbBranches</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>Begin</fromnode> <fromport>nbbranches</fromport>
+ <tonode>ForEach1</tonode> <toport>nbBranches</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>ForEach1</fromnode> <fromport>evalSamples</fromport>
+ <tonode>ForEach1.PyScript6</tonode> <toport>v</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>ForEach2</fromnode> <fromport>evalSamples</fromport>
+ <tonode>ForEach2.PyScript7</tonode> <toport>v</toport>
+ </datalink>
+ <parameter>
+ <tonode>ForEach1</tonode><toport>nbBranches</toport>
+ <value><int>1</int></value>
+ </parameter>
+ <parameter>
+ <tonode>ForEach2</tonode><toport>nbBranches</toport>
+ <value><int>1</int></value>
+ </parameter>
+ <presentation name="ForEach1" x="201.5" y="146" width="171.5" height="155" expanded="1" expx="201.5" expy="146" expWidth="171.5" expHeight="155" shownState="0"/>
+ <presentation name="ForEach1.PyScript6" x="9.5" y="88" width="158" height="63" expanded="1" expx="9.5" expy="88" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="ForEach2.PyScript7" x="13" y="92" width="158" height="63" expanded="1" expx="13" expy="92" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="ForEach2" x="204" y="313.5" width="175" height="159" expanded="1" expx="204" expy="313.5" expWidth="175" expHeight="159" shownState="0"/>
+ <presentation name="End" x="402.5" y="85" width="158" height="63" expanded="1" expx="402.5" expy="85" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="Begin" x="9" y="86" width="158" height="117" expanded="1" expx="9" expy="86" expWidth="158" expHeight="117" shownState="0"/>
+ <presentation name="__ROOT__" x="0" y="0" width="564.5" height="476.5" expanded="1" expx="0" expy="0" expWidth="564.5" expHeight="476.5" shownState="0"/>
+</proc>
--- /dev/null
+<?xml version='1.0' encoding='iso-8859-1' ?>
+<proc name="2foreach_with_cache">
+ <property name="executor" value="workloadmanager"/>
+ <type name="string" kind="string"/>
+ <struct name="Engines/dataref">
+ <member name="ref" type="string"/>
+ </struct>
+ <type name="bool" kind="bool"/>
+ <sequence name="boolvec" content="bool"/>
+ <type name="double" kind="double"/>
+ <sequence name="dblevec" content="double"/>
+ <objref name="file" id="file"/>
+ <type name="int" kind="int"/>
+ <sequence name="intvec" content="int"/>
+ <struct name="stringpair">
+ <member name="name" type="string"/>
+ <member name="value" type="string"/>
+ </struct>
+ <sequence name="propvec" content="stringpair"/>
+ <objref name="pyobj" id="python:obj:1.0"/>
+ <sequence name="seqboolvec" content="boolvec"/>
+ <sequence name="seqdblevec" content="dblevec"/>
+ <sequence name="seqint" content="int"/>
+ <sequence name="seqintvec" content="intvec"/>
+ <sequence name="seqpyobj" content="pyobj"/>
+ <sequence name="stringvec" content="string"/>
+ <sequence name="seqstringvec" content="stringvec"/>
+ <container name="DefaultContainer">
+ <property name="container_kind" value="Salome"/>
+ <property name="attached_on_cloning" value="0"/>
+ <property name="container_name" value="FactoryServer"/>
+ <property name="name" value="localhost"/>
+ </container>
+ <container name="c1">
+ <property name="container_kind" value="Salome"/>
+ <property name="attached_on_cloning" value="1"/>
+ <property name="nb_parallel_procs" value="1"/>
+ <property name="type" value="multi"/>
+ <property name="use_py_cache" value="1"/>
+ </container>
+ <container name="c2">
+ <property name="container_kind" value="Salome"/>
+ <property name="attached_on_cloning" value="1"/>
+ <property name="nb_parallel_procs" value="4"/>
+ <property name="type" value="multi"/>
+ <property name="use_py_cache" value="1"/>
+ </container>
+ <inline name="Begin">
+ <script><code><![CDATA[import time
+vals = [ i for i in range(40)]
+nbbranches = len(vals)
+t0=time.time()
+]]></code></script>
+ <outport name="t0" type="pyobj"/>
+ <outport name="vals" type="intvec"/>
+ <outport name="nbbranches" type="int"/>
+ </inline>
+ <inline name="End">
+ <script><code><![CDATA[import time
+tf=time.time()
+total_time=int(tf-t0)
+
+ok = True
+s_expected = sum(vals)
+
+tr1={}
+for cont_name, s in r1:
+ if cont_name in tr1.keys():
+ v = tr1[cont_name]
+ if s > v:
+ tr1[cont_name] = s
+ else:
+ tr1[cont_name] = s
+
+s1 = sum(tr1.values())
+if s_expected != s1:
+ ok = False
+ print("Error on the first foreach.")
+ print("Expected sum:", s_expected)
+ print("Obtained sum:", s1)
+
+tr2={}
+for cont_name, s in r2:
+ if cont_name in tr2.keys():
+ v = tr2[cont_name]
+ if s > v:
+ tr2[cont_name] = s
+ else:
+ tr2[cont_name] = s
+
+s2 = sum(tr2.values())
+if s_expected != s2:
+ ok = False
+ print("Error on the second foreach.")
+ print("Expected sum:", s_expected)
+ print("Obtained sum:", s2)
+
+coeff_cont = len(tr1) + ( 4 * len(tr2))
+#print(r1)
+#print(r2)
+]]></code></script>
+ <inport name="t0" type="pyobj"/>
+ <inport name="r1" type="seqpyobj"/>
+ <inport name="r2" type="seqpyobj"/>
+ <inport name="vals" type="intvec"/>
+ <outport name="total_time" type="int"/>
+ <outport name="ok" type="bool"/>
+ <outport name="coeff_cont" type="int"/>
+ </inline>
+ <foreach name="ForEach1" nbranch="1" loopWeight="-1" type="int">
+ <remote name="PyNode1" elementaryWeight="-1">
+ <script><code><![CDATA[import time
+if "s" not in globals():
+ # long initialization here to be done only once
+ time.sleep(1)
+ s=0
+s += v
+container_name = my_container.name
+result = (container_name, s)
+time.sleep(1)
+]]></code></script>
+ <load container="c1"/>
+ <inport name="v" type="int"/>
+ <outport name="result" type="pyobj"/>
+ </remote>
+ </foreach>
+ <foreach name="ForEach2" nbranch="1" loopWeight="-1" type="int">
+ <remote name="PyNode2" elementaryWeight="-1">
+ <script><code><![CDATA[import time
+if "s" not in globals():
+ # long initialization here to be done only once
+ time.sleep(1)
+ s=0
+s += v
+container_name = my_container.name
+result = (container_name, s)
+time.sleep(1)
+]]></code></script>
+ <load container="c2"/>
+ <inport name="v" type="int"/>
+ <outport name="result" type="pyobj"/>
+ </remote>
+ </foreach>
+ <control> <fromnode>Begin</fromnode> <tonode>ForEach1</tonode> </control>
+ <control> <fromnode>Begin</fromnode> <tonode>ForEach2</tonode> </control>
+ <control> <fromnode>Begin</fromnode> <tonode>End</tonode> </control>
+ <control> <fromnode>ForEach1</fromnode> <tonode>End</tonode> </control>
+ <control> <fromnode>ForEach2</fromnode> <tonode>End</tonode> </control>
+ <datalink control="false">
+ <fromnode>Begin</fromnode> <fromport>t0</fromport>
+ <tonode>End</tonode> <toport>t0</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>Begin</fromnode> <fromport>vals</fromport>
+ <tonode>ForEach2</tonode> <toport>SmplsCollection</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>Begin</fromnode> <fromport>vals</fromport>
+ <tonode>ForEach1</tonode> <toport>SmplsCollection</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>Begin</fromnode> <fromport>vals</fromport>
+ <tonode>End</tonode> <toport>vals</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>Begin</fromnode> <fromport>nbbranches</fromport>
+ <tonode>ForEach2</tonode> <toport>nbBranches</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>Begin</fromnode> <fromport>nbbranches</fromport>
+ <tonode>ForEach1</tonode> <toport>nbBranches</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>ForEach1</fromnode> <fromport>evalSamples</fromport>
+ <tonode>ForEach1.PyNode1</tonode> <toport>v</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>ForEach2</fromnode> <fromport>evalSamples</fromport>
+ <tonode>ForEach2.PyNode2</tonode> <toport>v</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>ForEach1.PyNode1</fromnode> <fromport>result</fromport>
+ <tonode>End</tonode> <toport>r1</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>ForEach2.PyNode2</fromnode> <fromport>result</fromport>
+ <tonode>End</tonode> <toport>r2</toport>
+ </datalink>
+ <parameter>
+ <tonode>ForEach2</tonode><toport>nbBranches</toport>
+ <value><int>1</int></value>
+ </parameter>
+ <parameter>
+ <tonode>ForEach1</tonode><toport>nbBranches</toport>
+ <value><int>1</int></value>
+ </parameter>
+ <presentation name="ForEach1.PyNode1" x="9.5" y="88" width="158" height="63" expanded="1" expx="9.5" expy="88" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="ForEach2" x="204" y="313.5" width="175" height="159" expanded="1" expx="204" expy="313.5" expWidth="175" expHeight="159" shownState="0"/>
+ <presentation name="ForEach1" x="201.5" y="146" width="171.5" height="155" expanded="1" expx="201.5" expy="146" expWidth="171.5" expHeight="155" shownState="0"/>
+ <presentation name="End" x="402.5" y="85" width="158" height="144" expanded="1" expx="402.5" expy="85" expWidth="158" expHeight="144" shownState="0"/>
+ <presentation name="Begin" x="9" y="86" width="158" height="117" expanded="1" expx="9" expy="86" expWidth="158" expHeight="117" shownState="0"/>
+ <presentation name="ForEach2.PyNode2" x="13" y="92" width="158" height="63" expanded="1" expx="13" expy="92" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="__ROOT__" x="0" y="0" width="564.5" height="476.5" expanded="1" expx="0" expy="0" expWidth="564.5" expHeight="476.5" shownState="0"/>
+</proc>
--- /dev/null
+<?xml version='1.0' encoding='iso-8859-1' ?>
+<proc name="wlm_8nodes">
+ <property name="executor" value="workloadmanager"/>
+ <type name="string" kind="string"/>
+ <struct name="Engines/dataref">
+ <member name="ref" type="string"/>
+ </struct>
+ <type name="bool" kind="bool"/>
+ <sequence name="boolvec" content="bool"/>
+ <type name="double" kind="double"/>
+ <sequence name="dblevec" content="double"/>
+ <objref name="file" id="file"/>
+ <type name="int" kind="int"/>
+ <sequence name="intvec" content="int"/>
+ <struct name="stringpair">
+ <member name="name" type="string"/>
+ <member name="value" type="string"/>
+ </struct>
+ <sequence name="propvec" content="stringpair"/>
+ <objref name="pyobj" id="python:obj:1.0"/>
+ <sequence name="seqboolvec" content="boolvec"/>
+ <sequence name="seqdblevec" content="dblevec"/>
+ <sequence name="seqintvec" content="intvec"/>
+ <sequence name="seqpyobj" content="pyobj"/>
+ <sequence name="stringvec" content="string"/>
+ <sequence name="seqstringvec" content="stringvec"/>
+ <container name="DefaultContainer">
+ <property name="container_kind" value="Salome"/>
+ <property name="attached_on_cloning" value="0"/>
+ <property name="container_name" value="FactoryServer"/>
+ <property name="name" value="localhost"/>
+ </container>
+ <container name="cont">
+ <property name="container_kind" value="Salome"/>
+ <property name="attached_on_cloning" value="1"/>
+ <property name="name" value="localhost"/>
+ <property name="type" value="multi"/>
+ </container>
+ <inline name="Begin">
+ <script><code><![CDATA[import time
+t0=time.time()
+time_to_sleep=3
+]]></code></script>
+ <load container="DefaultContainer"/>
+ <outport name="t0" type="pyobj"/>
+ <outport name="time_to_sleep" type="int"/>
+ </inline>
+ <inline name="End">
+ <script><code><![CDATA[import time
+tf=time.time()
+total_time=int(tf-t0)
+err_message = ""
+if total_time < 2 * time_to_sleep:
+ ok = True
+else:
+ ok = False
+ print("Error during the test wlm_8nodes")
+ err_message = "Total time ({}s) exeeds maximum expected time ({}s)"
+ err_message = err_message.format(total_time, 2*time_to_sleep)
+ print(err_message)
+
+names = [n1, n2, n3, n4, n5, n6, n7, n8]
+
+for n in names:
+ if names.count(n) > 1 :
+ ok = False
+ print("Error during the test wlm_8nodes")
+ err_message = "Container name {} found {} times"
+ err_message = err_message.format(n, names.count(n))
+ print(err_message)
+]]></code></script>
+ <load container="DefaultContainer"/>
+ <inport name="t0" type="pyobj"/>
+ <inport name="time_to_sleep" type="int"/>
+ <inport name="n1" type="string"/>
+ <inport name="n2" type="string"/>
+ <inport name="n3" type="string"/>
+ <inport name="n4" type="string"/>
+ <inport name="n5" type="string"/>
+ <inport name="n6" type="string"/>
+ <inport name="n7" type="string"/>
+ <inport name="n8" type="string"/>
+ <outport name="ok" type="bool"/>
+ <outport name="err_message" type="string"/>
+ </inline>
+ <remote name="n1" elementaryWeight="-1">
+ <script><code><![CDATA[import time
+time.sleep(time_to_sleep)
+container_name = my_container.name
+]]></code></script>
+ <load container="cont"/>
+ <inport name="time_to_sleep" type="int"/>
+ <outport name="container_name" type="string"/>
+ </remote>
+ <remote name="n2" elementaryWeight="-1">
+ <script><code><![CDATA[import time
+time.sleep(time_to_sleep)
+container_name = my_container.name
+]]></code></script>
+ <load container="cont"/>
+ <inport name="time_to_sleep" type="int"/>
+ <outport name="container_name" type="string"/>
+ </remote>
+ <remote name="n3" elementaryWeight="-1">
+ <script><code><![CDATA[import time
+time.sleep(time_to_sleep)
+container_name = my_container.name
+]]></code></script>
+ <load container="cont"/>
+ <inport name="time_to_sleep" type="int"/>
+ <outport name="container_name" type="string"/>
+ </remote>
+ <remote name="n4" elementaryWeight="-1">
+ <script><code><![CDATA[import time
+time.sleep(time_to_sleep)
+container_name = my_container.name
+]]></code></script>
+ <load container="cont"/>
+ <inport name="time_to_sleep" type="int"/>
+ <outport name="container_name" type="string"/>
+ </remote>
+ <remote name="n5" elementaryWeight="-1">
+ <script><code><![CDATA[import time
+time.sleep(time_to_sleep)
+container_name = my_container.name
+]]></code></script>
+ <load container="cont"/>
+ <inport name="time_to_sleep" type="int"/>
+ <outport name="container_name" type="string"/>
+ </remote>
+ <remote name="n6" elementaryWeight="-1">
+ <script><code><![CDATA[import time
+time.sleep(time_to_sleep)
+container_name = my_container.name
+]]></code></script>
+ <load container="cont"/>
+ <inport name="time_to_sleep" type="int"/>
+ <outport name="container_name" type="string"/>
+ </remote>
+ <remote name="n7" elementaryWeight="-1">
+ <script><code><![CDATA[import time
+time.sleep(time_to_sleep)
+container_name = my_container.name
+]]></code></script>
+ <load container="cont"/>
+ <inport name="time_to_sleep" type="int"/>
+ <outport name="container_name" type="string"/>
+ </remote>
+ <remote name="n8" elementaryWeight="-1">
+ <script><code><![CDATA[import time
+time.sleep(time_to_sleep)
+container_name = my_container.name
+]]></code></script>
+ <load container="cont"/>
+ <inport name="time_to_sleep" type="int"/>
+ <outport name="container_name" type="string"/>
+ </remote>
+ <control> <fromnode>Begin</fromnode> <tonode>End</tonode> </control>
+ <control> <fromnode>Begin</fromnode> <tonode>n1</tonode> </control>
+ <control> <fromnode>Begin</fromnode> <tonode>n2</tonode> </control>
+ <control> <fromnode>Begin</fromnode> <tonode>n3</tonode> </control>
+ <control> <fromnode>Begin</fromnode> <tonode>n4</tonode> </control>
+ <control> <fromnode>Begin</fromnode> <tonode>n5</tonode> </control>
+ <control> <fromnode>Begin</fromnode> <tonode>n6</tonode> </control>
+ <control> <fromnode>Begin</fromnode> <tonode>n7</tonode> </control>
+ <control> <fromnode>Begin</fromnode> <tonode>n8</tonode> </control>
+ <control> <fromnode>n1</fromnode> <tonode>End</tonode> </control>
+ <control> <fromnode>n2</fromnode> <tonode>End</tonode> </control>
+ <control> <fromnode>n3</fromnode> <tonode>End</tonode> </control>
+ <control> <fromnode>n4</fromnode> <tonode>End</tonode> </control>
+ <control> <fromnode>n5</fromnode> <tonode>End</tonode> </control>
+ <control> <fromnode>n6</fromnode> <tonode>End</tonode> </control>
+ <control> <fromnode>n7</fromnode> <tonode>End</tonode> </control>
+ <control> <fromnode>n8</fromnode> <tonode>End</tonode> </control>
+ <datalink control="false">
+ <fromnode>Begin</fromnode> <fromport>t0</fromport>
+ <tonode>End</tonode> <toport>t0</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>Begin</fromnode> <fromport>time_to_sleep</fromport>
+ <tonode>n1</tonode> <toport>time_to_sleep</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>Begin</fromnode> <fromport>time_to_sleep</fromport>
+ <tonode>n2</tonode> <toport>time_to_sleep</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>Begin</fromnode> <fromport>time_to_sleep</fromport>
+ <tonode>End</tonode> <toport>time_to_sleep</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>Begin</fromnode> <fromport>time_to_sleep</fromport>
+ <tonode>n5</tonode> <toport>time_to_sleep</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>Begin</fromnode> <fromport>time_to_sleep</fromport>
+ <tonode>n4</tonode> <toport>time_to_sleep</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>Begin</fromnode> <fromport>time_to_sleep</fromport>
+ <tonode>n3</tonode> <toport>time_to_sleep</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>Begin</fromnode> <fromport>time_to_sleep</fromport>
+ <tonode>n6</tonode> <toport>time_to_sleep</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>Begin</fromnode> <fromport>time_to_sleep</fromport>
+ <tonode>n8</tonode> <toport>time_to_sleep</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>Begin</fromnode> <fromport>time_to_sleep</fromport>
+ <tonode>n7</tonode> <toport>time_to_sleep</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>n1</fromnode> <fromport>container_name</fromport>
+ <tonode>End</tonode> <toport>n1</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>n2</fromnode> <fromport>container_name</fromport>
+ <tonode>End</tonode> <toport>n2</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>n3</fromnode> <fromport>container_name</fromport>
+ <tonode>End</tonode> <toport>n3</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>n4</fromnode> <fromport>container_name</fromport>
+ <tonode>End</tonode> <toport>n4</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>n5</fromnode> <fromport>container_name</fromport>
+ <tonode>End</tonode> <toport>n5</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>n6</fromnode> <fromport>container_name</fromport>
+ <tonode>End</tonode> <toport>n6</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>n7</fromnode> <fromport>container_name</fromport>
+ <tonode>End</tonode> <toport>n7</toport>
+ </datalink>
+ <datalink control="false">
+ <fromnode>n8</fromnode> <fromport>container_name</fromport>
+ <tonode>End</tonode> <toport>n8</toport>
+ </datalink>
+ <presentation name="n1" x="199" y="106.806" width="158" height="63" expanded="1" expx="199" expy="106.806" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="n7" x="197.548" y="488.857" width="158" height="63" expanded="1" expx="197.548" expy="488.857" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="End" x="410.5" y="32" width="158" height="306" expanded="1" expx="410.5" expy="32" expWidth="158" expHeight="306" shownState="0"/>
+ <presentation name="Begin" x="4" y="32" width="158" height="90" expanded="1" expx="4" expy="32" expWidth="158" expHeight="90" shownState="0"/>
+ <presentation name="n2" x="197.65" y="170.306" width="158" height="63" expanded="1" expx="197.65" expy="170.306" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="n4" x="199.05" y="297.306" width="158" height="63" expanded="1" expx="199.05" expy="297.306" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="n3" x="196.65" y="233.806" width="158" height="63" expanded="1" expx="196.65" expy="233.806" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="n6" x="197.499" y="424.306" width="158" height="63" expanded="1" expx="197.499" expy="424.306" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="n8" x="197.898" y="552.357" width="158" height="63" expanded="1" expx="197.898" expy="552.357" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="n5" x="196.749" y="360.806" width="158" height="63" expanded="1" expx="196.749" expy="360.806" expWidth="158" expHeight="63" shownState="0"/>
+ <presentation name="__ROOT__" x="0" y="0" width="572.5" height="619.357" expanded="1" expx="0" expy="0" expWidth="572.5" expHeight="619.357" shownState="0"/>
+</proc>
virtual void remote (ENGINE::InlineNode* const& n);
virtual void node (ENGINE::InlineNode* const& n);
virtual void forloop (ENGINE::ForLoop* const& n);
- virtual void foreach (ENGINE::ForEachLoop* const& n);
+ virtual void foreach (ENGINE::ForEachLoopGen* const& n);
virtual void optimizer (ENGINE::OptimizerLoop* const& n);
virtual void while_ (ENGINE::WhileLoop* const& n);
virtual void switch_ (ENGINE::Switch* const& n);
std::string fullname=currentProc->names.back()+ n->getName();
currentProc->nodeMap[fullname]=n;
}
- void casetypeParser::foreach (ENGINE::ForEachLoop* const& n)
+ void casetypeParser::foreach (ENGINE::ForEachLoopGen* const& n)
{
_cnode=n;
std::string fullname=currentProc->names.back()+ n->getName();
else if(element == "remote")pp=&remotetypeParser<>::remoteParser;
else if(element == "node")pp=&nodetypeParser<>::nodeParser;
else if(element == "forloop")pp=&forlooptypeParser<>::forloopParser;
- else if(element == "foreach")pp=&foreachlooptypeParser<>::foreachloopParser;
+ else if(element == "foreach")pp=&foreachlooptypeParser<ENGINE::ForEachLoop *>::foreachloopParser;
+ else if(element == "foreachdyn")pp=&foreachlooptypeParser<ENGINE::ForEachLoopDyn *>::foreachloopParser;
else if(element == "optimizer")pp=&optimizerlooptypeParser<>::optimizerloopParser;
else if(element == "while")pp=&whilelooptypeParser<>::whileloopParser;
else if(element == "switch")pp=&switchtypeParser::switchParser;
else if(element == "remote")remote(((remotetypeParser<>*)child)->post());
else if(element == "node")node(((nodetypeParser<>*)child)->post());
else if(element == "forloop")forloop(((forlooptypeParser<>*)child)->post());
- else if(element == "foreach")foreach(((foreachlooptypeParser<>*)child)->post());
+ else if(element == "foreach")foreach(((foreachlooptypeParser<ENGINE::ForEachLoop *>*)child)->post());
+ else if(element == "foreachdyn")foreach(((foreachlooptypeParser<ENGINE::ForEachLoopDyn *>*)child)->post());
else if(element == "optimizer")optimizer(((optimizerlooptypeParser<>*)child)->post());
else if(element == "while")while_(((whilelooptypeParser<>*)child)->post());
else if(element == "switch")switch_(((switchtypeParser*)child)->post());
testResume.py
testSave.py
testSaveLoadRun.py
- testHPDecorator.py
optim_plugin.py
testValidationChecks.py
testProgress.py
testExecForEachGeoMesh.py
async_plugin.py
+ testWorkloadManager.py
+ testPynodeWithCache.py
)
INSTALL(PROGRAMS ${LOCAL_TEST_FILES}
DESTINATION ${LOCAL_TEST_DIR})
ADD_TEST(${TEST_NAME} ${SALOME_TEST_DRIVER} ${TIMEOUT} StdAloneYacsLoaderTest1.py)
SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES
LABELS "${COMPONENT_NAME}"
- )
+ )
+
+ SET(TEST_NAME ${COMPONENT_NAME}_PyNodeWithCache_swig)
+ ADD_TEST(${TEST_NAME} ${SALOME_TEST_DRIVER} ${TIMEOUT} testPynodeWithCache.py)
+ SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES
+ LABELS "${COMPONENT_NAME}"
+ )
+
+ SET(TEST_NAME ${COMPONENT_NAME}_WorkloadManager_swig)
+ ADD_TEST(${TEST_NAME} ${SALOME_TEST_DRIVER} ${TIMEOUT} testWorkloadManager.py)
+ SET_TESTS_PROPERTIES(${TEST_NAME} PROPERTIES
+ LABELS "${COMPONENT_NAME}"
+ )
ENDIF()
exit $ret7
fi
-python3 @CMAKE_CURRENT_SOURCE_DIR@/testHPDecorator.py
-ret8=$?
-if [ $ret8 -gt 0 ]; then
- echo "exec status testHPDecorator : " $ret8
- exit $ret8
-fi
-
-let ret=$ret0+$ret1+$ret2+$ret3+$ret4+$ret5+$ret6+$ret7+$ret8
+let ret=$ret0+$ret1+$ret2+$ret3+$ret4+$ret5+$ret6+$ret7
# --- return unit tests status
export TESTCOMPONENT_ROOT_DIR=`pwd`/../runtime
-python3 -m unittest discover
+#python3 -m unittest discover
+MODULES_TO_TEST="testEdit testExec testLoader testProgress testRefcount \
+testResume testSave testSaveLoadRun testValidationChecks"
+
+python3 -m unittest $MODULES_TO_TEST
ret=$?
echo "exec status salome_test_driver " $ret
kill -9 $pidecho
-exit $ret
\ No newline at end of file
+exit $ret
--- /dev/null
+import pilot
+import SALOMERuntime
+import loader
+import datetime
+
+fname="testFEDyn.xml"
+fname2="REtestFEDyn.xml"
+SALOMERuntime.RuntimeSALOME.setRuntime()
+l=loader.YACSLoader()
+r=SALOMERuntime.getSALOMERuntime()
+p=r.createProc("prTest1")
+td=p.createType("double","double")
+ti=p.createType("int","int")
+cont=p.createContainer("gg","HPSalome")
+cont.setProperty("nb_proc_per_node","1")
+#
+pg=pilot.PlayGround()
+#pg.loadFromKernelCatalog()
+pg.setData([("localhost",4)])
+#
+#cont.setSizeOfPool(4)
+cont.setProperty("name","localhost")
+cont.setProperty("hostname","localhost")
+ti=p.createType("int","int")
+tsi=p.createSequenceTc("seqint","seqint",ti)
+# Level0
+n0=r.createScriptNode("","n0")
+o0=n0.edAddOutputPort("o0",tsi)
+n0.setScript("o0=[ elt for elt in range(8) ]")
+p.edAddChild(n0)
+n1=r.createForEachLoopDyn("n1",ti)#Dyn
+#n1.getInputPort("nbBranches").edInitPy(2)
+n10=r.createScriptNode("","n10")
+n10.setExecutionMode("remote")
+n10.setContainer(cont)
+n1.edAddChild(n10)
+n10.setScript("""
+import time
+time.sleep(1)
+o2=2*i1
+""")
+i1=n10.edAddInputPort("i1",ti)
+o2=n10.edAddOutputPort("o2",ti)
+p.edAddChild(n1)
+p.edAddLink(o0,n1.edGetSeqOfSamplesPort())
+p.edAddLink(n1.edGetSamplePort(),i1)
+p.edAddCFLink(n0,n1)
+n2=r.createScriptNode("","n2")
+n2.setScript("o4=i3")
+i3=n2.edAddInputPort("i3",tsi)
+i4=n2.edAddInputPort("i4",tsi)
+o4=n2.edAddOutputPort("o4",tsi)
+n2.setScript("o4=[a+b for a,b in zip(i3,i4)]")
+p.edAddChild(n2)
+p.edAddCFLink(n1,n2)
+p.edAddLink(o2,i3)
+# Second parallel foreach
+n11=r.createForEachLoopDyn("n11",ti)
+#n11.getInputPort("nbBranches").edInitPy(2)
+n110=r.createScriptNode("","n110")
+n110.setExecutionMode("remote")
+n110.setContainer(cont)
+n11.edAddChild(n110)
+n110.setScript("""
+import time
+time.sleep(10)
+o2=3*i1
+""")
+i1_1=n110.edAddInputPort("i1",ti)
+o2_1=n110.edAddOutputPort("o2",ti)
+p.edAddChild(n11)
+p.edAddLink(o0,n11.edGetSeqOfSamplesPort())
+p.edAddLink(n11.edGetSamplePort(),i1_1)
+p.edAddCFLink(n0,n11)
+p.edAddCFLink(n11,n2)
+p.edAddLink(o2_1,i4)
+#
+p.saveSchema(fname)
+p=l.load(fname)
+p.saveSchema(fname2)
+p.init()
+p.propagePlayGround(pg)
+ex=pilot.ExecutorSwig()
+assert(p.getState()==pilot.READY)
+stt = datetime.datetime.now()
+ex.RunW(p,0)
+print(str(datetime.datetime.now()-stt))
+assert(p.getState()==pilot.DONE)
+o4=p.getChildByName("n2").getOutputPort("o4")
+assert(o4.getPyObj()==[0, 5, 10, 15, 20, 25, 30, 35])
+# Ideal ForEachDyn time = 22 s
+# ForEach time = 40 s"""
\ No newline at end of file
--- /dev/null
+import pilot
+import SALOMERuntime
+import loader
+import datetime
+
+fname="testFEDyn.xml"
+fname2="REtestFEDyn.xml"
+SALOMERuntime.RuntimeSALOME.setRuntime()
+l=loader.YACSLoader()
+r=SALOMERuntime.getSALOMERuntime()
+p=r.createProc("prTest1")
+td=p.createType("double","double")
+ti=p.createType("int","int")
+cont=p.createContainer("gg","HPSalome")
+cont.setProperty("nb_proc_per_node","1")
+cont2=p.createContainer("gg2","HPSalome")
+cont2.setProperty("nb_proc_per_node","4")
+#
+pg=pilot.PlayGround()
+#pg.loadFromKernelCatalog()
+pg.setData([("localhost",4)])
+#
+#cont.setSizeOfPool(4)
+cont.setProperty("name","localhost")
+cont.setProperty("hostname","localhost")
+ti=p.createType("int","int")
+tsi=p.createSequenceTc("seqint","seqint",ti)
+# Level0
+n0=r.createScriptNode("","n0")
+o0=n0.edAddOutputPort("o0",tsi)
+n0.setScript("o0=[ elt for elt in range(8) ]")
+p.edAddChild(n0)
+n1=r.createForEachLoopDyn("n1",ti)#Dyn
+#n1.getInputPort("nbBranches").edInitPy(2)
+n10=r.createScriptNode("","n10")
+n10.setExecutionMode("remote")
+n10.setContainer(cont2)
+n1.edAddChild(n10)
+n10.setScript("""
+import time
+time.sleep(1)
+o2=2*i1
+""")
+i1=n10.edAddInputPort("i1",ti)
+o2=n10.edAddOutputPort("o2",ti)
+p.edAddChild(n1)
+p.edAddLink(o0,n1.edGetSeqOfSamplesPort())
+p.edAddLink(n1.edGetSamplePort(),i1)
+p.edAddCFLink(n0,n1)
+n2=r.createScriptNode("","n2")
+n2.setScript("o4=i3")
+i3=n2.edAddInputPort("i3",tsi)
+i4=n2.edAddInputPort("i4",tsi)
+o4=n2.edAddOutputPort("o4",tsi)
+n2.setScript("o4=[a+b for a,b in zip(i3,i4)]")
+p.edAddChild(n2)
+p.edAddCFLink(n1,n2)
+p.edAddLink(o2,i3)
+# Second parallel foreach
+n11=r.createForEachLoopDyn("n11",ti)
+#n11.getInputPort("nbBranches").edInitPy(2)
+n110=r.createScriptNode("","n110")
+n110.setExecutionMode("remote")
+n110.setContainer(cont)
+n11.edAddChild(n110)
+n110.setScript("""
+import time
+time.sleep(10)
+o2=3*i1
+""")
+i1_1=n110.edAddInputPort("i1",ti)
+o2_1=n110.edAddOutputPort("o2",ti)
+p.edAddChild(n11)
+p.edAddLink(o0,n11.edGetSeqOfSamplesPort())
+p.edAddLink(n11.edGetSamplePort(),i1_1)
+p.edAddCFLink(n0,n11)
+p.edAddCFLink(n11,n2)
+p.edAddLink(o2_1,i4)
+#
+p.saveSchema(fname)
+p=l.load(fname)
+p.saveSchema(fname2)
+p.init()
+p.propagePlayGround(pg)
+ex=pilot.ExecutorSwig()
+assert(p.getState()==pilot.READY)
+stt = datetime.datetime.now()
+ex.RunW(p,0)
+print(str(datetime.datetime.now()-stt))
+assert(p.getState()==pilot.DONE)
+o4=p.getChildByName("n2").getOutputPort("o4")
+assert(o4.getPyObj()==[0, 5, 10, 15, 20, 25, 30, 35])
+# Ideal ForEachDyn time = 28 s
+++ /dev/null
-# Copyright (C) 2006-2020 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
-# License as published by the Free Software Foundation; either
-# version 2.1 of the License, or (at your option) any later version.
-#
-# This library is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-# Lesser General Public License for more details.
-#
-# You should have received a copy of the GNU Lesser General Public
-# License along with this library; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-#
-# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-#
-
-import pilot
-import SALOMERuntime
-import unittest
-
-class TestHPDecortator(unittest.TestCase):
- def test0(self):
- """ First test coming from the big boss."""
- SALOMERuntime.RuntimeSALOME.setRuntime()
- r=SALOMERuntime.getSALOMERuntime()
- pg=pilot.PlayGround()
- pg.loadFromKernelCatalog()
- assert(len(pg.getData())!=0)
- p=r.createProc("p0")
- td=p.createType("double","double")
- tdd=p.createSequenceTc("seqdouble","seqdouble",td)
- hp1=p.createContainer("HP1","HPSalome")
- hp4=p.createContainer("HP4","HPSalome")
- #
- n0=r.createScriptNode("Salome","n0")
- n0.setExecutionMode("remote")
- out0_0=n0.edAddOutputPort("o1",tdd)
- n0.setScript("""o1=[float(i)+0.1 for i in range(1000)]""")
- n0.setContainer(hp4)
- p.edAddChild(n0)
- #
- n1_0=r.createForEachLoop("n1_0",td)
- p.edAddChild(n1_0)
- p.edAddCFLink(n0,n1_0)
- p.edAddLink(out0_0,n1_0.edGetSeqOfSamplesPort())
- ##
- n1_0_sc=r.createScriptNode("Salome","n1_0_sc")
- n1_0.edAddChild(n1_0_sc)
- n1_0_sc.setExecutionMode("remote")
- n1_0_sc.setScript("""2*i1""")
- i1_0_sc=n1_0_sc.edAddInputPort("i1",td)
- p.edAddLink(n1_0.edGetSamplePort(),i1_0_sc)
- n1_0_sc.setContainer(hp4)
- ##
- #
- n1_1=r.createForEachLoop("n1_1",td)
- p.edAddChild(n1_1)
- p.edAddCFLink(n0,n1_1)
- p.edAddLink(out0_0,n1_1.edGetSeqOfSamplesPort())
- ##
- n1_1_sc=r.createScriptNode("Salome","n1_1_sc")
- n1_1.edAddChild(n1_1_sc)
- n1_1_sc.setExecutionMode("remote")
- n1_1_sc.setScript("""3*i1""")
- n1_1.setWeight(4.)
- i1_1_sc=n1_1_sc.edAddInputPort("i1",td)
- p.edAddLink(n1_1.edGetSamplePort(),i1_1_sc)
- n1_1_sc.setContainer(hp1)
- ##
- hp1.setProperty("nb_proc_per_node","1")
- hp4.setProperty("nb_proc_per_node","4")
- pg.setData([("m0",8),("m1",8),("m2",8),("m3",8)]) # virtual machine with 32 cores spread over 4 nodes
- assert(n1_0.getWeight().getSimpleLoopWeight()==-1.)
- assert(n1_1.getWeight().getSimpleLoopWeight()==4.)
- p.fitToPlayGround(pg)########### ZE CALL
- fyto=pilot.ForTestOmlyHPContCls()
- assert(hp4.getSizeOfPool()==8)# 32/4
- n1_0_sc.getContainer().forYourTestsOnly(fyto)
- assert(fyto.getContainerType()=="HPContainerShared")
- pd=fyto.getPD()
- assert(isinstance(pd,pilot.ContigPartDefinition))
- assert(pd.getStart()==0 and pd.getStop()==16)
- assert(fyto.getIDS()==(0,1,2,3))
- #
- assert(hp1.getSizeOfPool()==32)# 32/1
- fyto=pilot.ForTestOmlyHPContCls()
- n1_1_sc.getContainer().forYourTestsOnly(fyto)
- assert(fyto.getContainerType()=="HPContainerShared")
- pd=fyto.getPD()
- assert(isinstance(pd,pilot.ContigPartDefinition))
- assert(pd.getStart()==16 and pd.getStop()==32)
- assert(fyto.getIDS()==(16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31))
- assert(n1_0.edGetNbOfBranchesPort().getPyObj()==4)
- assert(n1_1.edGetNbOfBranchesPort().getPyObj()==16)
- #
- fyto=pilot.ForTestOmlyHPContCls()
- n0.getContainer().forYourTestsOnly(fyto)
- assert(fyto.getContainerType()=="HPContainerShared")
- pd=fyto.getPD()
- assert(isinstance(pd,pilot.AllPartDefinition))
- assert(list(fyto.getIDS())==list(range(8)))
- #############################
- # Change weight of ForEach #
- #############################
- n1_0.setWeight(1)
- p.fitToPlayGround(pg)########### ZE CALL
- assert(hp4.getSizeOfPool()==8)# 32/4
- n1_0_sc.getContainer().forYourTestsOnly(fyto)
- assert(fyto.getContainerType()=="HPContainerShared")
- pd=fyto.getPD()
- assert(isinstance(pd,pilot.ContigPartDefinition))
- assert(pd.getStart()==0 and pd.getStop()==16)
- assert(fyto.getIDS()==(0,1,2,3))
- assert(hp1.getSizeOfPool()==32)# 32/1
- fyto=pilot.ForTestOmlyHPContCls()
- n1_1_sc.getContainer().forYourTestsOnly(fyto)
- assert(fyto.getContainerType()=="HPContainerShared")
- pd=fyto.getPD()
- assert(isinstance(pd,pilot.ContigPartDefinition))
- assert(pd.getStart()==16 and pd.getStop()==32)
- assert(fyto.getIDS()==(16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31))
- assert(n1_0.edGetNbOfBranchesPort().getPyObj()==4)
- assert(n1_1.edGetNbOfBranchesPort().getPyObj()==16)
- #
- fyto=pilot.ForTestOmlyHPContCls()
- n0.getContainer().forYourTestsOnly(fyto)
- assert(fyto.getContainerType()=="HPContainerShared")
- pd=fyto.getPD()
- assert(isinstance(pd,pilot.AllPartDefinition))
- assert(list(fyto.getIDS())==list(range(8)))
- pass
-
- def test1(self):
- """ Second test as test0 + script node in // with 2 FE"""
- SALOMERuntime.RuntimeSALOME.setRuntime()
- r=SALOMERuntime.getSALOMERuntime()
- pg=pilot.PlayGround()
- pg.loadFromKernelCatalog()
- assert(len(pg.getData())!=0)
- p=r.createProc("p0")
- td=p.createType("double","double")
- tdd=p.createSequenceTc("seqdouble","seqdouble",td)
- hp1=p.createContainer("HP1","HPSalome")
- hp4=p.createContainer("HP4","HPSalome")
- #
- n0=r.createScriptNode("Salome","n0")
- n0.setExecutionMode("remote")
- out0_0=n0.edAddOutputPort("o1",tdd)
- n0.setScript("""o1=[float(i)+0.1 for i in range(1000)]""")
- n0.setContainer(hp4)
- p.edAddChild(n0)
- #
- n1_0=r.createForEachLoop("n1_0",td)
- p.edAddChild(n1_0)
- p.edAddCFLink(n0,n1_0)
- p.edAddLink(out0_0,n1_0.edGetSeqOfSamplesPort())
- n1_0.setWeight(1.)
- ##
- n1_0_sc=r.createScriptNode("Salome","n1_0_sc")
- n1_0.edAddChild(n1_0_sc)
- n1_0_sc.setExecutionMode("remote")
- n1_0_sc.setScript("""2*i1""")
- i1_0_sc=n1_0_sc.edAddInputPort("i1",td)
- p.edAddLink(n1_0.edGetSamplePort(),i1_0_sc)
- n1_0_sc.setContainer(hp4)
- ##
- #
- n1_1=r.createForEachLoop("n1_1",td)
- p.edAddChild(n1_1)
- p.edAddCFLink(n0,n1_1)
- p.edAddLink(out0_0,n1_1.edGetSeqOfSamplesPort())
- n1_1.setWeight(4.)
- ##
- n1_1_sc=r.createScriptNode("Salome","n1_1_sc")
- n1_1.edAddChild(n1_1_sc)
- n1_1_sc.setExecutionMode("remote")
- n1_1_sc.setScript("""3*i1""")
- i1_1_sc=n1_1_sc.edAddInputPort("i1",td)
- p.edAddLink(n1_1.edGetSamplePort(),i1_1_sc)
- n1_1_sc.setContainer(hp1)
- #
- n1_2=r.createScriptNode("Salome","n1_2")
- p.edAddChild(n1_2)
- n1_2.setExecutionMode("remote")
- n1_2.setContainer(hp4)
- n1_2.setScript("""my_container""")
- p.edAddCFLink(n0,n1_2)
- ##
- hp1.setProperty("nb_proc_per_node","1")
- hp4.setProperty("nb_proc_per_node","4")
- pg.setData([("m0",8),("m1",8),("m2",8),("m3",8),("m4",4)]) # virtual machine with 32 cores spread over 4 nodes
- assert(n1_0.getWeight().getSimpleLoopWeight()==1.)
- assert(n1_1.getWeight().getSimpleLoopWeight()==4.)
- p.fitToPlayGround(pg)########### ZE CALL
- assert(hp4.getSizeOfPool()==9)# 36/4
- fyto=pilot.ForTestOmlyHPContCls()
- n1_0_sc.getContainer().forYourTestsOnly(fyto)
- assert(fyto.getContainerType()=="HPContainerShared")
- pd=fyto.getPD()
- assert(isinstance(pd,pilot.ContigPartDefinition))
- assert(pd.getStart()==0 and pd.getStop()==16)
- assert(fyto.getIDS()==(0,1,2,3))
- #
- assert(hp1.getSizeOfPool()==36)# 36/1
- fyto=pilot.ForTestOmlyHPContCls()
- n1_1_sc.getContainer().forYourTestsOnly(fyto)
- assert(fyto.getContainerType()=="HPContainerShared")
- pd=fyto.getPD()
- assert(isinstance(pd,pilot.ContigPartDefinition))
- assert(pd.getStart()==20 and pd.getStop()==36)
- assert(fyto.getIDS()==(20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35))
- assert(n1_0.edGetNbOfBranchesPort().getPyObj()==4)
- assert(n1_1.edGetNbOfBranchesPort().getPyObj()==16)
- #
- fyto=pilot.ForTestOmlyHPContCls()
- n0.getContainer().forYourTestsOnly(fyto)
- assert(fyto.getContainerType()=="HPContainerShared")
- pd=fyto.getPD()
- assert(isinstance(pd,pilot.AllPartDefinition))
- assert(list(fyto.getIDS())==list(range(9)))
- fyto=pilot.ForTestOmlyHPContCls()
- n1_2.getContainer().forYourTestsOnly(fyto)
- assert(fyto.getContainerType()=="HPContainerShared")
- pd=fyto.getPD()
- assert(isinstance(pd,pilot.ContigPartDefinition))
- assert(list(fyto.getIDS())==[4])
- pass
-
- @unittest.skip("requires 2 machines in catalog")
- def test2(self):
- """ This test is desactivated because it requires multi nodes. To be moved at the right place to support this.
- This test is not launched here because it requires 2 machines in catalog"""
- m1="dsp0764200"
- m2="dsp0764412"
- SALOMERuntime.RuntimeSALOME.setRuntime()
- r=SALOMERuntime.getSALOMERuntime()
- pg=pilot.PlayGround()
- pg.loadFromKernelCatalog()
- assert(len(pg.getData())!=0)
- p=r.createProc("p0")
- td=p.createType("double","double")
- tdd=p.createSequenceTc("seqdouble","seqdouble",td)
- hp1=p.createContainer("HP1","HPSalome")
- #
- n0=r.createScriptNode("Salome","n0")
- n0.setExecutionMode("remote")
- out0_0=n0.edAddOutputPort("o1",tdd)
- n0.setScript("""o1=[float(i)+0.1 for i in range(1000)]""")
- n0.setContainer(hp1)
- p.edAddChild(n0)
- ##
- n1_0_sc=r.createScriptNode("Salome","n1_0_sc")
- p.edAddChild(n1_0_sc)
- p.edAddCFLink(n0,n1_0_sc)
- n1_0_sc.setExecutionMode("remote")
- n1_0_sc.setScript("""assert(my_container.getHostName()=="%s")"""%m1)
- n1_0_sc.setContainer(hp1)
- ##
- n1_1_sc=r.createScriptNode("Salome","n1_1_sc")
- p.edAddChild(n1_1_sc)
- p.edAddCFLink(n0,n1_1_sc)
- n1_1_sc.setExecutionMode("remote")
- n1_1_sc.setScript("""assert(my_container.getHostName()=="%s")"""%m2)
- n1_1_sc.setContainer(hp1)
- ##
- hp1.setProperty("nb_proc_per_node","1")
- pg.setData([(m1,8),(m2,8)])
- p.fitToPlayGround(pg)########### ZE CALL
- assert(hp1.getSizeOfPool()==16)# 16/1
- fyto=pilot.ForTestOmlyHPContCls()
- n1_0_sc.getContainer().forYourTestsOnly(fyto)
- assert(fyto.getContainerType()=="HPContainerShared")
- pd=fyto.getPD()
- assert(isinstance(pd,pilot.ContigPartDefinition))
- assert(pd.getStart()==0 and pd.getStop()==8)
- assert(fyto.getIDS()==(0,1,2,3,4,5,6,7))
- #
- fyto=pilot.ForTestOmlyHPContCls()
- n1_1_sc.getContainer().forYourTestsOnly(fyto)
- assert(fyto.getContainerType()=="HPContainerShared")
- pd=fyto.getPD()
- assert(isinstance(pd,pilot.ContigPartDefinition))
- assert(pd.getStart()==8 and pd.getStop()==16)
- assert(fyto.getIDS()==(8,9,10,11,12,13,14,15))
- #
- exe=pilot.ExecutorSwig()
- assert(p.getState()==pilot.READY)
- exe.RunW(p,0)
- assert(p.getState()==pilot.DONE)
- pass
-
- def test3(self):
- """ First test coming from the big boss."""
- SALOMERuntime.RuntimeSALOME.setRuntime()
- r=SALOMERuntime.getSALOMERuntime()
- pg=pilot.PlayGround()
- pg.loadFromKernelCatalog()
- assert(len(pg.getData())!=0)
- p=r.createProc("p0")
- td=p.createType("double","double")
- tdd=p.createSequenceTc("seqdouble","seqdouble",td)
- hp1=r.createContainer("HPSalome") ; hp1.setName("HP1")
- #
- n0=r.createScriptNode("Salome","n0")
- n0.setExecutionMode("local")
- out0_0=n0.edAddOutputPort("o1",tdd)
- n0.setScript("""o1=[float(i)+0.1 for i in range(1000)]""")
- p.edAddChild(n0)
- #
- n1_0=r.createForEachLoop("n1_0",td)
- n2_0=r.createForEachLoop("n2_0",td)
- p.edAddChild(n1_0)
- p.edAddChild(n2_0)
- p.edAddCFLink(n0,n1_0)
- p.edAddCFLink(n1_0,n2_0)
- p.edAddLink(out0_0,n1_0.edGetSeqOfSamplesPort())
- p.edAddLink(out0_0,n2_0.edGetSeqOfSamplesPort())
- ##
- n1_0_sc=r.createScriptNode("Salome","n1_0_sc")
- n1_0.edAddChild(n1_0_sc)
- n1_0_sc.setExecutionMode("remote")
- n1_0_sc.setScript("""2*i1""")
- i1_0_sc=n1_0_sc.edAddInputPort("i1",td)
- p.edAddLink(n1_0.edGetSamplePort(),i1_0_sc)
- n1_0_sc.setContainer(hp1)
- ##
- n2_0_sc=r.createScriptNode("Salome","n2_0_sc")
- n2_0.edAddChild(n2_0_sc)
- n2_0_sc.setExecutionMode("remote")
- n2_0_sc.setScript("""2*i1""")
- i2_0_sc=n2_0_sc.edAddInputPort("i1",td)
- p.edAddLink(n2_0.edGetSamplePort(),i2_0_sc)
- n2_0_sc.setContainer(hp1)
- ##
- hp1.setProperty("nb_proc_per_node","1")
- pg.setData([("localhost",3)])
- p.fitToPlayGround(pg)########### ZE CALL
- assert(hp1.getSizeOfPool()==3)
- fyto=pilot.ForTestOmlyHPContCls()
- n1_0_sc.getContainer().forYourTestsOnly(fyto)
- assert(fyto.getContainerType()=="HPContainerShared")
- pd=fyto.getPD()
- assert(isinstance(pd,pilot.AllPartDefinition))
- assert(fyto.getIDS()==(0,1,2))
- fyto=pilot.ForTestOmlyHPContCls()
- n2_0_sc.getContainer().forYourTestsOnly(fyto)
- assert(fyto.getContainerType()=="HPContainerShared")
- pd=fyto.getPD()
- assert(isinstance(pd,pilot.AllPartDefinition))
- assert(fyto.getIDS()==(0,1,2))
- assert(n1_0.edGetNbOfBranchesPort().getPyObj()==3)
- assert(n2_0.edGetNbOfBranchesPort().getPyObj()==3)
- #
- exe=pilot.ExecutorSwig()
- assert(p.getState()==pilot.READY)
- exe.RunW(p,0)
- assert(len(set(hp1.getKernelContainerNames()))==3)
- pass
-
- def test4(self):
- """ two branch whose on with one elementary node and on foreach"""
- SALOMERuntime.RuntimeSALOME.setRuntime()
- r=SALOMERuntime.getSALOMERuntime()
- pg=pilot.PlayGround()
- pg.loadFromKernelCatalog()
- assert(len(pg.getData())!=0)
- p=r.createProc("p0")
- td=p.createType("double","double")
- tdd=p.createSequenceTc("seqdouble","seqdouble",td)
- hp1=p.createContainer("HP1","HPSalome")
- #
- ##
- n0=r.createScriptNode("Salome","n0")
- n0.setExecutionMode("remote")
- out0_0=n0.edAddOutputPort("o1",tdd)
- n0.setScript("""o1=[float(i)+0.1 for i in range(1000)]""")
- n0.setContainer(hp1)
- p.edAddChild(n0)
- #
- b0 = r.createBloc("Bloc0")
- p.edAddChild(b0)
- p.edAddCFLink(n0,b0)
- ##
- n1_0=r.createForEachLoop("n1_0",td)
- b0.edAddChild(n1_0)
- p.edAddLink(out0_0,n1_0.edGetSeqOfSamplesPort())
- n1_0.setWeight(10.)
- ##
- n1_0_sc=r.createScriptNode("Salome","n1_0_sc")
- n1_0.edAddChild(n1_0_sc)
- n1_0_sc.setExecutionMode("remote")
- n1_0_sc.setScript("""2*i1""")
- i1_0_sc=n1_0_sc.edAddInputPort("i1",td)
- p.edAddLink(n1_0.edGetSamplePort(),i1_0_sc)
- n1_0_sc.setContainer(hp1)
- ##
- n1_0_1=r.createScriptNode("Salome","n1_0_1")
- n1_0_1.setExecutionMode("remote")
- n1_0_1.setScript("""a=2""")
- b0.edAddChild(n1_0_1)
- p.edAddCFLink(n1_0,n1_0_1)
- n1_0_1.setContainer(hp1)
- n1_0_1.setWeight(20.)
- ##
- #
- n1_1=r.createForEachLoop("n1_1",td)
- p.edAddChild(n1_1)
- p.edAddCFLink(n0,n1_1)
- p.edAddLink(out0_0,n1_1.edGetSeqOfSamplesPort())
- n1_1.setWeight(100.)
- ##
- n1_1_sc=r.createScriptNode("Salome","n1_1_sc")
- n1_1.edAddChild(n1_1_sc)
- n1_1_sc.setExecutionMode("remote")
- n1_1_sc.setScript("""3*i1""")
- i1_1_sc=n1_1_sc.edAddInputPort("i1",td)
- p.edAddLink(n1_1.edGetSamplePort(),i1_1_sc)
- n1_1_sc.setContainer(hp1)
-
- hp1.setProperty("nb_proc_per_node","1")
- pg.setData([("m0",12)])
- w=pilot.ComplexWeight()
- b0.getWeightRegardingDPL(w)
- assert(w.getElementaryWeight()==20.)
- assert(w.calculateTotalLength(1)==30.)
- assert(w.calculateTotalLength(2)==25.)
- p.fitToPlayGround(pg)########### ZE CALL
- assert(n1_0.edGetNbOfBranchesPort().getPyObj()==7)
- assert(n1_1.edGetNbOfBranchesPort().getPyObj()==5)
- #
- fyto=pilot.ForTestOmlyHPContCls()
- n1_0_sc.getContainer().forYourTestsOnly(fyto)
- assert(fyto.getContainerType()=="HPContainerShared")
- pd=fyto.getPD()
- assert(isinstance(pd,pilot.ContigPartDefinition))
- print (pd.getStart(),pd.getStop())
- assert(pd.getStart()==0 and pd.getStop()==7)
-
- #########################
- ## change HPcontainer
- ## very important: if you change HPcontainer you have to reload the graph
- #########################
- p=r.createProc("p0")
- n0=r.createScriptNode("Salome","n0")
- n0.setExecutionMode("remote")
- out0_0=n0.edAddOutputPort("o1",tdd)
- n0.setScript("""o1=[float(i)+0.1 for i in range(1000)]""")
- n0.setContainer(hp1)
- p.edAddChild(n0)
- #
- b0 = r.createBloc("Bloc0")
- p.edAddChild(b0)
- p.edAddCFLink(n0,b0)
- ##
- n1_0=r.createForEachLoop("n1_0",td)
- b0.edAddChild(n1_0)
- p.edAddLink(out0_0,n1_0.edGetSeqOfSamplesPort())
- ##
- n1_0_sc=r.createScriptNode("Salome","n1_0_sc")
- n1_0.edAddChild(n1_0_sc)
- n1_0_sc.setExecutionMode("remote")
- n1_0_sc.setScript("""2*i1""")
- i1_0_sc=n1_0_sc.edAddInputPort("i1",td)
- p.edAddLink(n1_0.edGetSamplePort(),i1_0_sc)
- n1_0_sc.setContainer(hp1)
- ##
- n1_0_1=r.createForEachLoop("n1_0_1",td)
- b0.edAddChild(n1_0_1)
- p.edAddLink(out0_0,n1_0_1.edGetSeqOfSamplesPort())
- p.edAddCFLink(n1_0,n1_0_1)
- ##
- n1_0_1sc=r.createScriptNode("Salome","n1_0_1sc")
- n1_0_1.edAddChild(n1_0_1sc)
- n1_0_1sc.setExecutionMode("remote")
- n1_0_1sc.setScript("""a=2""")
- i1_0_1sc=n1_0_1sc.edAddInputPort("i1",td)
- p.edAddLink(n1_0_1.edGetSamplePort(),i1_0_1sc)
- ##
- #
- n1_1=r.createForEachLoop("n1_1",td)
- p.edAddChild(n1_1)
- p.edAddCFLink(n0,n1_1)
- p.edAddLink(out0_0,n1_1.edGetSeqOfSamplesPort())
- ##
- n1_1_sc=r.createScriptNode("Salome","n1_1_sc")
- n1_1.edAddChild(n1_1_sc)
- n1_1_sc.setExecutionMode("remote")
- n1_1_sc.setScript("""3*i1""")
- i1_1_sc=n1_1_sc.edAddInputPort("i1",td)
- p.edAddLink(n1_1.edGetSamplePort(),i1_1_sc)
- n1_1_sc.setContainer(hp1)
- ##
- ##
- hp4=p.createContainer("HP4","HPSalome")
- hp4.setProperty("nb_proc_per_node","4")
- n1_0.setWeight(40.)
- n1_0_1.setWeight(20)
- n1_1.setWeight(100.)
- n1_0_1sc.setContainer(hp4)
- w=pilot.ComplexWeight()
- b0.getWeightRegardingDPL(w)
- assert(w.getElementaryWeight()==-1.)
- assert(w.calculateTotalLength(4)==30.)
- assert(w.calculateTotalLength(8)==15.)
- pg.setData([("m0",120)])
- p.fitToPlayGround(pg)########### ZE CALL
- assert(n1_0.edGetNbOfBranchesPort().getPyObj()==64)
- assert(n1_0_1.edGetNbOfBranchesPort().getPyObj()==16)
- assert(n1_1.edGetNbOfBranchesPort().getPyObj()==56)
- #
- fyto=pilot.ForTestOmlyHPContCls()
- n1_0_sc.getContainer().forYourTestsOnly(fyto)
- assert(fyto.getContainerType()=="HPContainerShared")
- pd=fyto.getPD()
- assert(isinstance(pd,pilot.ContigPartDefinition))
- assert(pd.getStart()==0 and pd.getStop()==64)
- pass
-
- pass
-
-if __name__ == '__main__':
- unittest.main()
--- /dev/null
+#!/usr/bin/env python3
+# Copyright (C) 2006-2020 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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+import sys
+import pilot
+import SALOMERuntime
+import loader
+import unittest
+import tempfile
+import os
+
+dir_test = tempfile.mkdtemp(suffix=".yacstest")
+
+class TestEdit(unittest.TestCase):
+
+ def setUp(self):
+ SALOMERuntime.RuntimeSALOME_setRuntime()
+ self.r = pilot.getRuntime()
+ self.l = loader.YACSLoader()
+ self.e = pilot.ExecutorSwig()
+ pass
+
+ def test1(self):
+ """ Test the conservation of the python context between two nodes sharing
+ the same container.
+ Schema: n1 -> n2
+ """
+ runtime=self.r
+ executor=self.e
+ yacsloader=self.l
+ proc=runtime.createProc("MySchema")
+ ti=proc.createType("int","int")
+ cont=proc.createContainer("MyContainer","Salome")
+ # type "multi" : the workload manager chooses the resource
+ # type "mono" : the resource is chosen by kernel, using the old rules.
+ cont.setProperty("type","multi")
+ # number of cores used by the container
+ cont.setProperty("nb_parallel_procs", "1")
+ n1=runtime.createScriptNode("","n1")
+ n2=runtime.createScriptNode("","n2")
+ n1.setExecutionMode("remote")
+ n2.setExecutionMode("remote")
+ n1.setContainer(cont)
+ n2.setContainer(cont)
+ n1.setScript("v=42")
+ res_port=n2.edAddOutputPort("v", ti)
+ proc.edAddChild(n1)
+ proc.edAddChild(n2)
+ proc.edAddCFLink(n1,n2)
+ # set the default execution mode using the workload manager
+ # if no property is set, the old executor is used
+ proc.setProperty("executor", "workloadmanager")
+ # reuse the same python context for every execution
+ cont.usePythonCache(True)
+ # save & reload
+ schema_file = os.path.join(dir_test,"pynode_with_cache1.xml")
+ proc.saveSchema(schema_file)
+ reloaded_proc = yacsloader.load(schema_file)
+ # default run method of the executor which uses the property "executor"
+ # in order to choose the actual run method
+ executor.RunW(reloaded_proc,0)
+ # you can also directly call the executor you wish, ignoring the property
+ #executor.RunB(proc,0) # always use the "old" executor
+ #executor.runWlm(proc,0) # always use the workload manager based executor
+ reloaded_res_port = reloaded_proc.getChildByName("n2").getOutputPort("v")
+ self.assertEqual(reloaded_res_port.getPyObj(), 42)
+
+ def test2(self):
+ """ Same as test1, but using the old executor instead of workload manager.
+ """
+ runtime=self.r
+ executor=self.e
+ yacsloader=self.l
+ proc=runtime.createProc("MySchema")
+ ti=proc.createType("int","int")
+ cont=proc.createContainer("MyContainer","Salome")
+ # With the old executor the type multi imposes the creation of a new
+ # container for every node. We need the type "mono" in order to have
+ # the same container used for both yacs nodes.
+ cont.setProperty("type","mono")
+ n1=runtime.createScriptNode("","n1")
+ n2=runtime.createScriptNode("","n2")
+ n1.setExecutionMode("remote")
+ n2.setExecutionMode("remote")
+ n1.setContainer(cont)
+ n2.setContainer(cont)
+ n1.setScript("v=42")
+ res_port=n2.edAddOutputPort("v", ti)
+ proc.edAddChild(n1)
+ proc.edAddChild(n2)
+ proc.edAddCFLink(n1,n2)
+ # reuse the same python context for every execution
+ cont.usePythonCache(True)
+ # save & reload
+ schema_file = os.path.join(dir_test,"pynode_with_cache2.xml")
+ proc.saveSchema(schema_file)
+ reloaded_proc = yacsloader.load(schema_file)
+ # default run method of the executor which uses the property "executor"
+ # in order to choose the actual run method
+ executor.RunW(reloaded_proc,0)
+ # you can also directly call the executor you wish, ignoring the property
+ #executor.RunB(proc,0) # always use the "old" executor
+ reloaded_res_port = reloaded_proc.getChildByName("n2").getOutputPort("v")
+ self.assertEqual(reloaded_res_port.getPyObj(), 42)
+
+if __name__ == '__main__':
+ file_test = os.path.join(dir_test,"UnitTestsResult")
+ with open(file_test, 'a') as f:
+ f.write(" --- TEST src/yacsloader: testPynodeWithCache.py\n")
+ suite = unittest.makeSuite(TestEdit)
+ result=unittest.TextTestRunner(f, descriptions=1, verbosity=1).run(suite)
+ sys.exit(not result.wasSuccessful())
p=self.r.createProc("prTest0")
td=p.createType("double","double")
ti=p.createType("int","int")
+ pg=pilot.PlayGround()
+ pg.setData([("localhost",4)])
cont=p.createContainer("gg","HPSalome")
- cont.setSizeOfPool(4)
cont.setProperty("name","localhost")
cont.setProperty("hostname","localhost")
+ cont.setProperty("nb_proc_per_node","1")
script0="""
def ff(nb,dbg):
from math import cos
ex=pilot.ExecutorSwig()
self.assertEqual(p.getState(),pilot.READY)
st=datetime.datetime.now()
+ p.propagePlayGround(pg)
# 1st exec
ex.RunW(p,0)
print("Time spend of test0 to run 1st %s"%(str(datetime.datetime.now()-st)))
p=self.r.createProc("prTest1")
td=p.createType("double","double")
ti=p.createType("int","int")
+ pg=pilot.PlayGround()
+ pg.setData([("localhost",4)])
cont=p.createContainer("gg","HPSalome")
- cont.setSizeOfPool(4)
cont.setProperty("InitializeScriptKey","aa=123.456")
cont.setProperty("name","localhost")
cont.setProperty("hostname","localhost")
+ cont.setProperty("nb_proc_per_node","1")
script0="""
def ff(nb,dbg):
from math import cos
p.saveSchema(fname)
p=l.load(fname)
self.assertEqual(p.edGetDirectDescendants()[0].getContainer().getProperty("InitializeScriptKey"),"aa=123.456")
+ p.propagePlayGround(pg)
# 1st exec
ex=pilot.ExecutorSwig()
self.assertEqual(p.getState(),pilot.READY)
ti=p.createType("int","int")
tdi=p.createSequenceTc("seqint","seqint",ti)
tdd=p.createSequenceTc("seqdouble","seqdouble",td)
+ pg=pilot.PlayGround()
+ pg.setData([("localhost",4)])
cont=p.createContainer("gg","HPSalome")
- cont.setSizeOfPool(4)
cont.setProperty("InitializeScriptKey","aa=123.456")
cont.setProperty("name","localhost")
cont.setProperty("hostname","localhost")
+ cont.setProperty("nb_proc_per_node","1")
#
node0=self.r.createFuncNode("Salome","PyFunction0") # PyFuncNode remote
p.edAddChild(node0)
# 1st exec
refExpected=16016013.514623128
ex=pilot.ExecutorSwig()
+ p.propagePlayGround(pg)
self.assertEqual(p.getState(),pilot.READY)
st=datetime.datetime.now()
ex.RunW(p,0)
def test3(self):
""" Test that focuses on parallel load of containers."""
- script0="""def ff():
- global aa
- print("%%lf - %%s"%%(aa,str(my_container)))
- return 100*[%i],0
+ script0="""
+if "aa" not in globals():
+ aa=123.456
+print("%%lf - %%s"%%(aa,str(my_container)))
+o1=100*[%i]
+o2=0
"""
script1="""from math import cos
import datetime
ref=datetime.datetime.now()
+if "aa" not in globals():
+ aa=123.456
o2=0. ; pas=1./float(i1)
for i in range(i1):
for j in range(i1):
"""
script2="""o9=sum(i8)
"""
- fname=os.path.join(self.workdir, "TestSaveLoadRun3.xml")
nbOfNodes=8
sqrtOfNumberOfTurn=10
l=loader.YACSLoader()
p=self.r.createProc("prTest1")
+ p.setProperty("executor","workloadmanager")
td=p.createType("double","double")
ti=p.createType("int","int")
tdi=p.createSequenceTc("seqint","seqint",ti)
tdd=p.createSequenceTc("seqdouble","seqdouble",td)
- cont=p.createContainer("gg","HPSalome")
- cont.setSizeOfPool(8)
- cont.setProperty("InitializeScriptKey","aa=123.456")
+ cont=p.createContainer("gg","Salome")
cont.setProperty("name","localhost")
cont.setProperty("hostname","localhost")
+ # no limit for the number of containers launched
+ cont.setProperty("nb_proc_per_node","0")
+ cont.setProperty("type","multi")
+ cont.usePythonCache(True)
+ cont.attachOnCloning()
#
- node0=self.r.createFuncNode("Salome","PyFunction0") # PyFuncNode remote
+ node0=self.r.createScriptNode("Salome","Node0")
p.edAddChild(node0)
- node0.setFname("ff")
node0.setContainer(cont)
node0.setScript(script0%(sqrtOfNumberOfTurn))
out0_0=node0.edAddOutputPort("o1",tdi)
p.edAddLink(out0_0,node1.edGetSeqOfSamplesPort())
node1.edGetNbOfBranchesPort().edInitInt(16)
#
- node2=self.r.createScriptNode("Salome","PyScript3")
+ node2=self.r.createScriptNode("Salome","Node2")
node1.edAddChild(node2)
node2.setContainer(cont)
node2.setScript(script1)
out1_2=node2.edAddOutputPort("o3",ti)
node2.setExecutionMode("remote")
#
- node3=self.r.createScriptNode("Salome","PyScript7")
+ node3=self.r.createScriptNode("Salome","Node3")
p.edAddChild(node3)
node3.setScript(script2)
p.edAddCFLink(node1,node3)
o9=node3.edAddOutputPort("o9",td)
p.edAddLink(out0_2,i8)
#
+ fname=os.path.join(self.workdir, "t3_new.xml")
p.saveSchema(fname)
p=l.load(fname)
- o9=p.getChildByName("PyScript7").getOutputPort("o9")
- self.assertTrue(len(p.edGetDirectDescendants()[1].getChildByName("PyScript3").getContainer().getProperty("InitializeScriptKey"))!=0)
+ o9=p.getChildByName("Node3").getOutputPort("o9")
# 1st exec
refExpected=11000.008377058712
ex=pilot.ExecutorSwig()
self.assertEqual(p.getState(),pilot.DONE)
self.assertAlmostEqual(refExpected,o9.getPyObj(),5)
pass
-
+
def test4(self):
- """Non regression test of multi pyScriptNode, pyFuncNode sharing the same HPContainer instance."""
+ """Double foreach."""
fname=os.path.join(self.workdir, "TestSaveLoadRun4.xml")
script1="""nb=7
ii=0
l=loader.YACSLoader()
ex=pilot.ExecutorSwig()
p=self.r.createProc("pr")
- cont=p.createContainer("gg","HPSalome")
- cont.setSizeOfPool(10)
+ p.setProperty("executor","workloadmanager")
+ cont=p.createContainer("gg","Salome")
+ cont.setProperty("name","localhost")
+ cont.setProperty("hostname","localhost")
+ # no limit for the number of containers launched
+ cont.setProperty("nb_proc_per_node","0")
+ cont.setProperty("type","multi")
+ cont.attachOnCloning()
td=p.createType("int","int")
td2=p.createSequenceTc("seqint","seqint",td)
td3=p.createSequenceTc("seqintvec","seqintvec",td2)
def test5(self):
"""Non regression test 2 of multi pyNode, pyFuncNode sharing the same HPContainer instance."""
+ # TODO : This test is DEPRECATED. HPContainer will be removed.
+ self.skipTest("HPContainer deprecated.")
fname=os.path.join(self.workdir, "TestSaveLoadRun5.xml")
script1="""nb=7
ii=0
l=loader.YACSLoader()
ex=pilot.ExecutorSwig()
p=self.r.createProc("pr")
+ pg=pilot.PlayGround()
+ pg.setData([("localhost",10)])
cont=p.createContainer("gg","HPSalome")
- cont.setSizeOfPool(10)
+ cont.setProperty("nb_proc_per_node","1")
td=p.createType("int","int")
td2=p.createSequenceTc("seqint","seqint",td)
td3=p.createSequenceTc("seqintvec","seqintvec",td2)
p.edAddLink(o15,i8)
p.saveSchema(fname)
p=l.load(fname)
+ p.propagePlayGround(pg)
ex = pilot.ExecutorSwig()
self.assertEqual(p.getState(),pilot.READY)
ex.RunW(p,0)
l=loader.YACSLoader()
#
p=self.r.createProc("PROC")
+ p.setProperty("executor","workloadmanager")
ti=p.createType("int","int")
tdi=p.createSequenceTc("seqint","seqint",ti)
# Level0
# run remote
p=l.load(fname)
- cont=p.createContainer("gg","HPSalome")
- cont.setSizeOfPool(2)
+ cont=p.createContainer("gg","Salome")
+ cont.setProperty("name","localhost")
+ cont.setProperty("hostname","localhost")
+ # no limit for the number of containers launched
+ cont.setProperty("nb_proc_per_node","0")
+ cont.setProperty("type","multi")
+ #cont.usePythonCache(True)
+ cont.attachOnCloning()
n1=p.getChildByName("FE0.b0.n1") ; n1.setExecutionMode("remote") ; n1.setContainer(cont)
n2=p.getChildByName("FE0.b0.FE1.n2") ; n2.setExecutionMode("remote") ; n2.setContainer(cont)
-
p.init()
self.assertEqual(p.getState(),pilot.READY)
ex.RunW(p,0)
pass
xmlFileName="test20.xml"
p=self.r.createProc("test26")
+ p.setProperty("executor","workloadmanager")
#
- cont=p.createContainer("gg","HPSalome") # very important ! HP Container needed for the test !
- cont.setSizeOfPool(8) # important make this figure >= 6
+ cont=p.createContainer("gg","Salome")
+ cont.setProperty("name","localhost")
+ cont.setProperty("hostname","localhost")
+ # no limit for the number of containers launched
+ cont.setProperty("nb_proc_per_node","0")
+ cont.setProperty("type","multi")
+ cont.usePythonCache(True)
+ cont.attachOnCloning()
#
po=p.createInterfaceTc("python:obj:1.0","pyobj",[])
sop=p.createSequenceTc("list[pyobj]","list[pyobj]",po)
p.edAddLink(dd,fe0.edGetSeqOfSamplesPort())
p.edAddLink(fe0.edGetSamplePort(),c1)
#
+ #xmlFileName="test20.xml"
#p.saveSchema(xmlFileName)
p.getChildByName("test26/main.test26/FE0").edGetNbOfBranchesPort().edInitInt(1) # very important 1 !
#
n1.edAddChild(n10)
n10.setScript("""
import time
-time.sleep(2)
+time.sleep(4)
o2=2*i1
""")
i1=n10.edAddInputPort("i1",ti)
myRun=threading.Thread(None, ex.RunW, None, (p,0))
myRun.start()
import time
- time.sleep(5)
+ time.sleep(7)
SALOMERuntime.schemaSaveState(p, ex, xmlStateFileName)
a,b,c=n1.getPassedResults(ex)
myRun.join()
--- /dev/null
+#!/usr/bin/env python3
+# Copyright (C) 2006-2020 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
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+
+import sys
+import pilot
+import SALOMERuntime
+import loader
+import unittest
+import tempfile
+import os
+import salome
+
+NB_NODE=16
+class TestEdit(unittest.TestCase):
+
+ def setUp(self):
+ SALOMERuntime.RuntimeSALOME_setRuntime()
+ self.r = pilot.getRuntime()
+ self.l = loader.YACSLoader()
+ self.e = pilot.ExecutorSwig()
+ # We need a catalog which contains only one resource named "localhost"
+ # with 16 cores. The modifications made here are not saved to the
+ # catalog file.
+ salome.salome_init()
+ resourceManager = salome.lcc.getResourcesManager()
+ resource_definition = resourceManager.GetResourceDefinition("localhost")
+ resource_definition.nb_node = NB_NODE
+ resourceManager.AddResource(resource_definition, False, "")
+ resource_required = salome.ResourceParameters()
+ resource_required.can_run_containers = True
+ res_list = resourceManager.GetFittingResources(resource_required)
+ for r in res_list:
+ if r != "localhost":
+ resourceManager.RemoveResource(r, False, "")
+ resource_definition = resourceManager.GetResourceDefinition("localhost")
+ self.assertEqual(resource_definition.nb_node, NB_NODE)
+
+ def tearDown(self):
+ cm = salome.lcc.getContainerManager()
+ cm.ShutdownContainers()
+
+ def test1(self):
+ """ Two parallel foreach-s with different containers
+ """
+ proc = self.l.load("samples/wlm_2foreach.xml")
+ self.e.RunW(proc,0)
+ self.assertEqual(proc.getState(),pilot.DONE)
+ res_port = proc.getChildByName("End").getOutputPort("r")
+ # theoretical time should be 15s
+ execution_time = res_port.getPyObj()
+ # lower time means some resources are overloaded
+ msg = "Execution time is too short : {}s".format(execution_time)
+ self.assertTrue(execution_time > 13, msg)
+ # The containers may need some time to be launched.
+ # We need some delay to add to the 15s.
+ msg = "Execution time is too long : {}s".format(execution_time)
+ self.assertTrue(execution_time < 25, msg)
+
+ def test2(self):
+ """ Two parallel foreach-s with different containers and python nodes
+ using cache.
+ """
+ proc = self.l.load("samples/wlm_2foreach_with_cache.xml")
+ self.e.RunW(proc,0)
+ self.assertEqual(proc.getState(),pilot.DONE)
+ ok = proc.getChildByName("End").getOutputPort("ok")
+ self.assertTrue(ok)
+ total_time = proc.getChildByName("End").getOutputPort("total_time")
+ # theoretical time should be 16s
+ execution_time = total_time.getPyObj()
+ # lower time means some resources are overloaded
+ msg = "Execution time is too short : {}s".format(execution_time)
+ self.assertTrue(execution_time > 14, msg)
+ # The containers may need some time to be launched.
+ # We need some delay to add to the 16s.
+ msg = "Execution time is too long : {}s".format(execution_time)
+ self.assertTrue(execution_time < 26, msg)
+ coeff_cont = proc.getChildByName("End").getOutputPort("coeff_cont").getPyObj()
+ msg = "coeff_cont too low:"+str(coeff_cont)
+ self.assertTrue(coeff_cont >= NB_NODE, msg)
+ msg = "coeff_cont too high:"+str(coeff_cont)
+ self.assertTrue(coeff_cont <= 2*NB_NODE, msg)
+
+ def test3(self):
+ """ Launch 8 independent nodes in parallel.
+ """
+ proc = self.l.load("samples/wlm_8nodes.xml")
+ self.e.RunW(proc,0)
+ self.assertEqual(proc.getState(),pilot.DONE)
+ ok = proc.getChildByName("End").getOutputPort("ok")
+ if not ok :
+ err_message = proc.getChildByName("End").getOutputPort("err_message").getPyObj()
+ self.fail(err_message)
+
+if __name__ == '__main__':
+ dir_test = tempfile.mkdtemp(suffix=".yacstest")
+ file_test = os.path.join(dir_test,"UnitTestsResult")
+ with open(file_test, 'a') as f:
+ f.write(" --- TEST src/yacsloader: testWorkloadManager.py\n")
+ suite = unittest.makeSuite(TestEdit)
+ result=unittest.TextTestRunner(f, descriptions=1, verbosity=1).run(suite)
+ sys.exit(not result.wasSuccessful())