#include "Visitor.hxx"
#include "ForEachLoop.hxx"
#include "InlineNode.hxx"
+#include "ServiceNode.hxx"
+#include "ServerNode.hxx"
#include "HomogeneousPoolContainer.hxx"
using namespace YACS::ENGINE;
//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)
{
- static const char MSG[]="Bloc::propagePlayGround : Not implemented yet for this type of node !";
- class MyVisitor : public Visitor
- {
- public:
- MyVisitor(ComposedNode *root):Visitor(root) { }
- void visitBloc(Bloc *node) { node->ComposedNode::accept(this); }
- void visitElementaryNode(ElementaryNode *node) { }
- void visitForEachLoop(ForEachLoop *node) { throw YACS::Exception(MSG); }
- 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); }
- void visitInlineNode(InlineNode *node)
- {
- Container *cont(node->getContainer());
- HomogeneousPoolContainer *cont2(dynamic_cast<HomogeneousPoolContainer *>(cont));
- if(!cont2)
- return ;
- _cont2.insert(cont2);
- }
- void visitInlineFuncNode(InlineFuncNode *node) { throw YACS::Exception(MSG); }
- void visitLoop(Loop *node) { throw YACS::Exception(MSG); }
- void visitProc(Proc *node) { node->ComposedNode::accept(this); }
- void visitServiceNode(ServiceNode *node) { throw YACS::Exception(MSG); }
- void visitServerNode(ServerNode *node) { throw YACS::Exception(MSG); }
- 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;
- };
- MyVisitor vis(this);
+ MyVisitorPropagate vis(this);
this->accept(&vis);
for(auto cont : vis._cont2)
cont->assignPG(pg);
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)
tdi=p.createSequenceTc("seqint","seqint",ti)
tdd=p.createSequenceTc("seqdouble","seqdouble",td)
cont=p.createContainer("gg","HPSalome")
- cont.setSizeOfPool(8)
+ pg=pilot.PlayGround()
+ pg.setData([("localhost",8)])
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=11000.008377058712
ex=pilot.ExecutorSwig()
+ p.propagePlayGround(pg)
self.assertEqual(p.getState(),pilot.READY)
st=datetime.datetime.now()
ex.RunW(p,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()
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)
cont.setProperty("nb_proc_per_node","7") # <- here
self.assertEqual(n00.getMaxLevelOfParallelism(),7) # <- here
pass
-
+
def test19(self):
"""This test checks the mechanism of YACS that allow PythonNodes to know their DynParaLoop context."""
fname=os.path.join(self.workdir, "test19.xml")
# run remote
p=l.load(fname)
+ pg=pilot.PlayGround()
+ pg.setData([("localhost",4)])
cont=p.createContainer("gg","HPSalome")
- cont.setSizeOfPool(2)
+ cont.setProperty("nb_proc_per_node","1")
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)
+ p.propagePlayGround(pg)
ex.RunW(p,0)
self.assertEqual(p.getState(),pilot.DONE)
pass
xmlFileName="test20.xml"
p=self.r.createProc("test26")
#
+ pg=pilot.PlayGround()
+ pg.setData([("localhost",8)]) # important make this figure >= 6
cont=p.createContainer("gg","HPSalome") # very important ! HP Container needed for the test !
- cont.setSizeOfPool(8) # important make this figure >= 6
+ cont.setProperty("nb_proc_per_node","1")
#
po=p.createInterfaceTc("python:obj:1.0","pyobj",[])
sop=p.createSequenceTc("list[pyobj]","list[pyobj]",po)
p.getChildByName("test26/main.test26/FE0").edGetNbOfBranchesPort().edInitInt(1) # very important 1 !
#
ex=pilot.ExecutorSwig()
+ p.propagePlayGround(pg)
self.assertEqual(p.getState(),pilot.READY)
ex.RunW(p,0)
self.assertEqual(p.getState(),pilot.DONE)