From a59c2c61226d9a7349224d33ef1082c9f28fa651 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Tue, 31 Mar 2020 17:19:17 +0200 Subject: [PATCH] Test mixing 2 HP container --- src/yacsloader_swig/Test/testFEDyn2.py | 36 +++++++++++++++++++++----- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/yacsloader_swig/Test/testFEDyn2.py b/src/yacsloader_swig/Test/testFEDyn2.py index 8b72aa2a3..7be80586f 100644 --- a/src/yacsloader_swig/Test/testFEDyn2.py +++ b/src/yacsloader_swig/Test/testFEDyn2.py @@ -13,12 +13,14 @@ 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",8)]) +pg.setData([("localhost",4)]) # -cont.setSizeOfPool(1) +#cont.setSizeOfPool(4) cont.setProperty("name","localhost") cont.setProperty("hostname","localhost") ti=p.createType("int","int") @@ -32,11 +34,11 @@ n1=r.createForEachLoopDyn("n1",ti)#Dyn #n1.getInputPort("nbBranches").edInitPy(2) n10=r.createScriptNode("","n10") n10.setExecutionMode("remote") -n10.setContainer(cont) +n10.setContainer(cont2) n1.edAddChild(n10) n10.setScript(""" import time -time.sleep(0.1) +time.sleep(1) o2=2*i1 """) i1=n10.edAddInputPort("i1",ti) @@ -48,16 +50,38 @@ 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 for a in i3]") +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() @@ -65,6 +89,6 @@ 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, 2, 4, 6, 8, 10, 12, 14]) +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 -- 2.39.2