Salome HOME
Remaining instabilities on tests[3,4,5] and current Node to be located is not marked...
authorAnthony Geay <anthony.geay@edf.fr>
Tue, 31 Mar 2020 21:01:05 +0000 (23:01 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Tue, 31 Mar 2020 21:01:05 +0000 (23:01 +0200)
src/engine/Bloc_impl.cxx
src/yacsloader_swig/Test/testFEDyn2.py
src/yacsloader_swig/Test/testSaveLoadRun.py

index 8110ba54df9836c0b3e04332b71baab842450b75..8402ec8bfd7b2f9079879fb0002812a85b956bb7 100644 (file)
@@ -22,6 +22,8 @@
 #include "Visitor.hxx"
 #include "ForEachLoop.hxx"
 #include "InlineNode.hxx"
+#include "ServiceNode.hxx"
+#include "ServerNode.hxx"
 #include "HomogeneousPoolContainer.hxx"
 
 using namespace YACS::ENGINE;
@@ -109,44 +111,47 @@ void Bloc::fitToPlayGround(const PlayGround *pg)
   //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);
index 7be80586f133d372bffee28935547ad1d4586de4..0b898a29b4ef52f3c65e98be139a0f7a74e0fd12 100644 (file)
@@ -90,5 +90,4 @@ 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
+# Ideal ForEachDyn time = 28 s
index bbbb58acbb615f5bd7e1c817eadf509fe8fed579..efafa9c7557588e833fe9212d31849653716063c 100755 (executable)
@@ -43,10 +43,12 @@ class TestSaveLoadRun(unittest.TestCase):
     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
@@ -111,6 +113,7 @@ print("coucou from script1-%i  -> %s"%(dbg,str(datetime.datetime.now()-ref)))
     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)))
@@ -136,11 +139,13 @@ print("coucou from script1-%i  -> %s"%(dbg,str(datetime.datetime.now()-ref)))
     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
@@ -197,6 +202,7 @@ aa+=1.
     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)
@@ -247,11 +253,13 @@ o3=0
     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)
@@ -293,6 +301,7 @@ o3=0
     # 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)
@@ -345,10 +354,12 @@ o3=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)
@@ -390,6 +401,7 @@ o3=0
     # 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)
@@ -428,8 +440,10 @@ for i in range(nb):
     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)
@@ -487,6 +501,7 @@ for i in range(nb):
     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)
@@ -513,8 +528,10 @@ for i in range(nb):
     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)
@@ -574,6 +591,7 @@ for i in range(nb):
     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)
@@ -1319,7 +1337,7 @@ for i in i8:
     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")
@@ -1375,13 +1393,15 @@ assert(my_dpl_localization[0][1]>=0 and my_dpl_localization[0][1]<3)
 
     # 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
@@ -1394,8 +1414,10 @@ assert(my_dpl_localization[0][1]>=0 and my_dpl_localization[0][1]<3)
     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)
@@ -1456,6 +1478,7 @@ dd=range(10)""")
     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)