1 // Copyright (C) 2012-2016 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (EDF R&D)
21 #include "YACSEvalYFXPattern.hxx"
22 #include "YACSEvalResource.hxx"
23 #include "YACSEvalSeqAny.hxx"
24 #include "YACSEvalSession.hxx"
25 #include "YACSEvalObserver.hxx"
26 #include "YACSEvalSessionInternal.hxx"
27 #include "YACSEvalAutoPtr.hxx"
28 #include "YACSEvalExecParams.hxx"
30 #include "ElementaryNode.hxx"
31 #include "RuntimeSALOME.hxx"
32 #include "Dispatcher.hxx"
33 #include "Executor.hxx"
34 #include "InputPort.hxx"
35 #include "LinkInfo.hxx"
36 #include "TypeCode.hxx"
38 #include "Dispatcher.hxx"
40 #include "PythonPorts.hxx"
41 #include "ForEachLoop.hxx"
42 #include "PythonNode.hxx"
43 #include "InlineNode.hxx"
44 #include "ServiceNode.hxx"
45 #include "PyStdout.hxx"
46 #include "AutoGIL.hxx"
48 #include "ResourcesManager.hxx"
59 const char YACSEvalYFXPattern::ST_OK[]="ALL_OK";
61 const char YACSEvalYFXPattern::ST_FAILED[]="SOME_SAMPLES_FAILED_AND_ALL_OF_THEM_FAILED_DETERMINISTICALLY";
63 const char YACSEvalYFXPattern::ST_ERROR[]="SOME_SAMPLES_FAILED_BUT_IMPOSSIBLE_TO_CONCLUDE_ON_THEM";
65 const std::size_t YACSEvalYFXPattern::MAX_LGTH_OF_INP_DUMP=10000;
67 const char YACSEvalYFXGraphGen::DFT_PROC_NAME[]="YFX";
69 const char YACSEvalYFXGraphGen::FIRST_FE_SUBNODE_NAME[]="Bloc";
71 const char YACSEvalYFXGraphGen::GATHER_NODE_NAME[]="__gather__";
73 class MyAutoThreadSaver
76 MyAutoThreadSaver(bool isToSave):_isToSave(isToSave),_save(0)
80 PyThreadState *save(PyThreadState_Swap(NULL));// safe call of PyEval_SaveThread()
88 ~MyAutoThreadSaver() { if(_isToSave) if(_save) { PyEval_AcquireLock(); PyThreadState_Swap(_save); /*safe call of PyEval_RestoreThread*/ } }
94 std::vector< YACSEvalInputPort *> YACSEvalYFXPattern::getFreeInputPorts() const
96 std::size_t sz(_inputs.size());
97 std::vector< YACSEvalInputPort *> ret;
98 std::vector< YACSEvalInputPort >::const_iterator it(_inputs.begin());
99 for(std::size_t i=0;i<sz;i++,it++)
100 ret.push_back(const_cast<YACSEvalInputPort *>(&(*it)));
104 std::vector< YACSEvalOutputPort *> YACSEvalYFXPattern::getFreeOutputPorts() const
106 std::size_t sz(_outputs.size());
107 std::vector< YACSEvalOutputPort *> ret;
108 std::vector< YACSEvalOutputPort >::const_iterator it(_outputs.begin());
109 for(std::size_t i=0;i<sz;i++,it++)
110 ret.push_back(const_cast<YACSEvalOutputPort *>(&(*it)));
114 YACSEvalYFXPattern *YACSEvalYFXPattern::FindPatternFrom(YACSEvalYFX *boss, YACS::ENGINE::Proc *scheme, bool ownScheme)
117 throw YACS::Exception("YACSEvalYFXPattern::FindPatternFrom : input scheme must be not null !");
119 YACS::ENGINE::ComposedNode *zeRunNode(0);
120 bool isMatchingRunOnlyPattern(YACSEvalYFXRunOnlyPattern::IsMatching(scheme,zeRunNode));
121 if(isMatchingRunOnlyPattern)
122 return new YACSEvalYFXRunOnlyPattern(boss,scheme,ownScheme,zeRunNode);
124 throw YACS::Exception("YACSEvalYFXPattern::FindPatternFrom : no pattern found for the input scheme !");
127 bool YACSEvalYFXPattern::isAlreadyComputedResources() const
132 void YACSEvalYFXPattern::checkNonAlreadyComputedResources() const
134 if(isAlreadyComputedResources())
135 throw YACS::Exception("checkNonAlreadyComputedResources : instance of computed resources already computed !");
138 void YACSEvalYFXPattern::checkAlreadyComputedResources() const
140 if(!isAlreadyComputedResources())
141 throw YACS::Exception("checkAlreadyComputedResources : instance of computed resources not already computed !");
144 void YACSEvalYFXPattern::checkLocked() const
147 throw YACS::Exception("YACSEvalYFXPattern::checkLocked : Pattern is not locked !");
150 void YACSEvalYFXPattern::checkNonLocked() const
153 throw YACS::Exception("YACSEvalYFXPattern::checkNonLocked : Pattern is locked !");
156 void YACSEvalYFXPattern::CheckNodeIsOK(YACS::ENGINE::ComposedNode *node)
158 /*YACS::ENGINE::LinkInfo info(YACS::ENGINE::LinkInfo::WARN_ONLY_DONT_STOP);
161 node->checkConsistency(info);
163 catch(YACS::Exception& e)
166 if(info.getNumberOfErrLinks(YACS::ENGINE::E_ALL)!=0)
167 throw YACS::Exception("YACSEvalYFXPattern::CheckNodeIsOK : found node is not OK !");
168 std::list<YACS::ENGINE::ElementaryNode *> allNodes(node->getRecursiveConstituents());
169 for(std::list<YACS::ENGINE::ElementaryNode *>::const_iterator it=allNodes.begin();it!=allNodes.end();it++)
171 YACS::ENGINE::ServiceNode *node0(dynamic_cast<YACS::ENGINE::ServiceNode *>(*it));
172 YACS::ENGINE::InlineNode *node1(dynamic_cast<YACS::ENGINE::InlineNode *>(*it));
175 YACS::ENGINE::Container *cont(node0->getContainer());
176 YACS::ENGINE::ComponentInstance *comp(node0->getComponent());
179 std::ostringstream oss; oss << "YACSEvalYFXPattern::CheckNodeIsOK : ServiceNode called \"" << node0->getName() << "\" is not correctly defined !";
180 throw YACS::Exception(oss.str());
185 YACS::ENGINE::Container *cont(node1->getContainer());
186 if(!cont && node1->getExecutionMode()==YACS::ENGINE::InlineNode::REMOTE_STR)
188 std::ostringstream oss; oss << "YACSEvalYFXPattern::CheckNodeIsOK : InlineNode called \"" << node1->getName() << "\" is not correctly defined !";
189 throw YACS::Exception(oss.str());
195 void YACSEvalYFXPattern::registerObserver(YACSEvalObserver *observer)
197 if(_observer==observer)
200 _observer->decrRef();
203 _observer->incrRef();
206 YACSEvalYFXPattern::YACSEvalYFXPattern(YACSEvalYFX *boss, YACS::ENGINE::Proc *scheme, bool ownScheme):_boss(boss),_scheme(scheme),_ownScheme(ownScheme),_parallelizeStatus(true),_rm(new ResourcesManager_cpp),_res(0),_observer(0)
210 YACS::ENGINE::TypeCode *YACSEvalYFXPattern::CreateSeqTypeCodeFrom(YACS::ENGINE::Proc *scheme, const std::string& zeType)
212 std::ostringstream oss; oss << "list[" << zeType << "]";
213 YACS::ENGINE::TypeCode *tc(scheme->getTypeCode(zeType));
214 return scheme->createSequenceTc(oss.str(),oss.str(),tc);
217 void YACSEvalYFXPattern::setResources(YACSEvalListOfResources *res)
219 checkNonAlreadyComputedResources();
225 void YACSEvalYFXPattern::resetResources()
231 YACSEvalSeqAny *YACSEvalYFXPattern::BuildValueInPort(YACS::ENGINE::InputPyPort *port)
234 throw YACS::Exception("YACSEvalYFXPattern::GetValueInPort : null input port !");
235 PyObject *obj(port->getPyObj());
236 YACS::ENGINE::TypeCode *tc(port->edGetType());
237 YACS::ENGINE::TypeCodeSeq *tcc(dynamic_cast<YACS::ENGINE::TypeCodeSeq *>(tc));
240 std::ostringstream oss; oss << "YACSEvalYFXPattern::GetValueInPort : internal error for tc of input \"" << port->getName() << "\"";
241 throw YACS::Exception(oss.str());
243 const YACS::ENGINE::TypeCode *tcct(tcc->contentType());
244 if(!PyList_Check(obj))
245 throw YACS::Exception("YACSEvalYFXPattern::GetValueInPort : internal error 2 !");
246 std::size_t sz(PyList_Size(obj));
247 if(tcct->kind()==YACS::ENGINE::Double)
249 std::vector<double> eltCpp(sz);
250 for(std::size_t i=0;i<sz;i++)
252 PyObject *elt(PyList_GetItem(obj,i));
253 eltCpp[i]=PyFloat_AsDouble(elt);
255 YACS::AutoCppPtr<YACSEvalSeqAnyDouble> elt(new YACSEvalSeqAnyDouble(eltCpp));
256 return elt.dettach();
258 else if(tcct->kind()==YACS::ENGINE::Int)
260 std::vector<int> eltCpp(sz);
261 for(std::size_t i=0;i<sz;i++)
263 PyObject *elt(PyList_GetItem(obj,i));
264 eltCpp[i]=PyLong_AsLong(elt);
266 YACS::AutoCppPtr<YACSEvalSeqAnyInt> elt(new YACSEvalSeqAnyInt(eltCpp));
267 return elt.dettach();
270 throw YACS::Exception("YACSEvalYFXPattern::GetValueInPort : not implemented yet for other than Double and Int !");
273 YACSEvalSeqAny *YACSEvalYFXPattern::BuildValueFromEngineFrmt(YACS::ENGINE::SequenceAny *data)
275 unsigned int sz(data->size());
276 std::vector<double> eltCpp(sz);
277 for(unsigned int ii=0;ii<sz;ii++)
279 YACS::ENGINE::AnyPtr elt((*data)[ii]);
280 YACS::ENGINE::Any *eltPtr((YACS::ENGINE::Any *)elt);
281 YACS::ENGINE::AtomAny *eltPtr2(dynamic_cast<YACS::ENGINE::AtomAny *>(eltPtr));
284 std::ostringstream oss; oss << "YACSEvalYFXPattern::BuildValueFromEngineFrmt : error at pos #" << ii << " ! It is not an AtomAny !";
285 throw YACS::Exception(oss.str());
287 eltCpp[ii]=eltPtr2->getDoubleValue();
289 return new YACSEvalSeqAnyDouble(eltCpp);
292 void YACSEvalYFXPattern::cleanScheme()
299 YACSEvalYFXPattern::~YACSEvalYFXPattern()
302 _observer->decrRef();
307 /////////////////////
309 class YACSEvalYFXRunOnlyPatternInternalObserver : public YACS::ENGINE::Observer
312 YACSEvalYFXRunOnlyPatternInternalObserver(YACSEvalYFXRunOnlyPattern *boss):_boss(boss) { if(!_boss) throw YACS::Exception("YACSEvalYFXRunOnlyPatternInternalObserver constructor : null boss not supported :)"); }
313 void notifyObserver2(YACS::ENGINE::Node *object, const std::string& event, void *something);
315 YACSEvalYFXRunOnlyPattern *_boss;
318 void YACSEvalYFXRunOnlyPatternInternalObserver::notifyObserver2(YACS::ENGINE::Node *object, const std::string& event, void *something)
320 YACS::ENGINE::ForEachLoop *object2(_boss->getUndergroundForEach());
321 YACSEvalObserver *obs(_boss->getObserver());
324 if(event=="progress_ok" && object2==object)
326 int *casted(reinterpret_cast<int *>(something));
327 obs->notifySampleOK(_boss->getBoss(),*casted);
330 if(event=="progress_ko" && object2==object)
332 int *casted(reinterpret_cast<int *>(something));
333 obs->notifySampleKO(_boss->getBoss(),*casted);
338 /////////////////////
340 YACSEvalYFXRunOnlyPattern::YACSEvalYFXRunOnlyPattern(YACSEvalYFX *boss, YACS::ENGINE::Proc *scheme, bool ownScheme, YACS::ENGINE::ComposedNode *runNode):YACSEvalYFXPattern(boss,scheme,ownScheme),_lockedStatus(false),_runNode(runNode),_gen(0),_obs(new YACSEvalYFXRunOnlyPatternInternalObserver(this))
343 throw YACS::Exception("YACSEvalYFXRunOnlyPattern : internal run node must be not null !");
348 YACSEvalYFXRunOnlyPattern::~YACSEvalYFXRunOnlyPattern()
354 void YACSEvalYFXRunOnlyPattern::setOutPortsOfInterestForEvaluation(const std::vector<YACSEvalOutputPort *>& outputsOfInterest)
357 _outputsOfInterest=outputsOfInterest;
361 void YACSEvalYFXRunOnlyPattern::resetOutputsOfInterest()
364 _outputsOfInterest.clear();
368 void YACSEvalYFXRunOnlyPattern::generateGraph()
371 if(getResourcesInternal()->isInteractive())
372 _gen=new YACSEvalYFXGraphGenInteractive(this);
374 _gen=new YACSEvalYFXGraphGenCluster(this);
375 _gen->generateGraph();
378 void YACSEvalYFXRunOnlyPattern::resetGeneratedGraph()
381 _gen->resetGeneratedGraph();
384 int YACSEvalYFXRunOnlyPattern::assignNbOfBranches()
386 checkAlreadyComputedResources();
388 throw YACS::Exception("YACSEvalYFXRunOnlyPattern::assignNbOfBranches : generator is NULL ! Please invoke generateGraph before !");
389 return _gen->assignNbOfBranches();
392 void YACSEvalYFXRunOnlyPattern::assignRandomVarsInputs()
394 std::size_t sz(std::numeric_limits<std::size_t>::max());
395 for(std::vector< YACSEvalInputPort >::const_iterator it=_inputs.begin();it!=_inputs.end();it++)
396 if((*it).isRandomVar())
398 std::size_t locSize((*it).initializeUndergroundWithSeq());
399 if(sz==std::numeric_limits<std::size_t>::max())
403 throw YACS::Exception("YACSEvalYFXRunOnlyPattern::assignRandomVarsInputs : length of sequences in random vars must be the same !");
407 bool YACSEvalYFXRunOnlyPattern::isLocked() const
409 return _lockedStatus;
412 YACSEvalListOfResources *YACSEvalYFXRunOnlyPattern::giveResources()
415 if(!isAlreadyComputedResources())
417 YACS::ENGINE::DeploymentTree dt(_runNode->getDeploymentTree());
418 _runNode->removeRecursivelyRedundantCL();
419 YACSEvalListOfResources *res(new YACSEvalListOfResources(_runNode->getMaxLevelOfParallelism(),getCatalogInAppli(),dt));
422 return getResourcesInternal();
425 YACS::ENGINE::Proc *YACSEvalYFXRunOnlyPattern::getUndergroundGeneratedGraph() const
427 return getGenerator()->getUndergroundGeneratedGraph();
430 std::string YACSEvalYFXRunOnlyPattern::getErrorDetailsInCaseOfFailure() const
432 std::string st(getStatusOfRunStr());//test if a run has occurred.
434 throw YACS::Exception("YACSEvalYFXRunOnlyPattern::getErrorDetailsInCaseOfFailure : The execution of scheme has been carried out to the end without any problem !");
435 // All the problem can only comes from foreach -> scan it
436 YACS::ENGINE::ForEachLoop *fe(getUndergroundForEach());
437 YACS::ENGINE::NodeStateNameMap nsm;
438 unsigned nbB(fe->getNumberOfBranchesCreatedDyn());
439 std::ostringstream oss;
440 for(unsigned j=0;j<nbB;j++)
442 YACS::ENGINE::Node *nn(fe->getChildByNameExec(YACSEvalYFXGraphGen::FIRST_FE_SUBNODE_NAME,j));
443 YACS::ENGINE::Bloc *nnc(dynamic_cast<YACS::ENGINE::Bloc *>(nn));
445 throw YACS::Exception("YACSEvalYFXRunOnlyPattern::getErrorDetailsInCaseOfFailure : internal error 1 ! The direct son of main foreach is expected to be a Bloc !");
446 if(nnc->getState()==YACS::DONE)
448 std::list< YACS::ENGINE::ElementaryNode *> fec(nnc->getRecursiveConstituents());
449 for(std::list< YACS::ENGINE::ElementaryNode *>::reverse_iterator it1=fec.rbegin();it1!=fec.rend();it1++)
451 YACS::StatesForNode st0((*it1)->getState());
454 oss << "NODE = " << nnc->getChildName(*it1) << std::endl;
455 oss << "STATUS = " << nsm[st0] << std::endl;
456 oss << "BRANCH ID = " << j << std::endl;
457 std::list<YACS::ENGINE::InputPort *> inps((*it1)->getSetOfInputPort());
458 for(std::list<YACS::ENGINE::InputPort *>::const_iterator it2=inps.begin();it2!=inps.end();it2++)
460 std::string d((*it2)->getHumanRepr());
462 d=d.substr(0,MAX_LGTH_OF_INP_DUMP);
463 oss << "INPUT \"" << (*it2)->getName() << "\" = " << d << std::endl;
465 oss << "DETAILS = " << std::endl;
466 oss << (*it1)->getErrorDetails();
473 std::string YACSEvalYFXRunOnlyPattern::getStatusOfRunStr() const
475 YACS::StatesForNode st(getUndergroundGeneratedGraph()->getState());
481 case YACS::TOACTIVATE:
482 case YACS::ACTIVATED:
483 case YACS::SUSPENDED:
486 case YACS::DESACTIVATED:
488 std::ostringstream oss; oss << "YACSEvalYFXRunOnlyPattern::getStatusOfRunStr : Unexpected state \"" << YACS::ENGINE::Node::getStateName(st) << "\" ! Did you invoke run ?";
489 throw YACS::Exception(oss.str());
491 case YACS::LOADFAILED:
492 case YACS::EXECFAILED:
494 case YACS::INTERNALERR:
495 return std::string(ST_ERROR);
497 return std::string(ST_FAILED);
499 return std::string(ST_OK);
502 std::ostringstream oss; oss << "YACSEvalYFXRunOnlyPattern::getStatusOfRunStr : unrecognized and managed state \"" << YACS::ENGINE::Node::getStateName(st) << "\" !";
503 throw YACS::Exception(oss.str());
508 std::vector<YACSEvalSeqAny *> YACSEvalYFXRunOnlyPattern::getResults() const
510 return _gen->getResults();
514 * This method works if run succeeded (true return) and also if graph has failed. Graph failed means soft error of evaluation due to error in evaluation (example 1/0 or a normal throw from one node)
515 * If a more serious error occured (SIGSEGV of a server or internal error in YACS engine, cluster error, loose of connection...) this method will throw an exception to warn the caller that the results may be
517 std::vector<YACSEvalSeqAny *> YACSEvalYFXRunOnlyPattern::getResultsInCaseOfFailure(std::vector<unsigned int>& passedIds) const
519 YACS::StatesForNode st(getUndergroundGeneratedGraph()->getState());
523 std::vector<YACSEvalSeqAny *> ret(getResults());
527 throw YACS::Exception("YACSEvalYFXRunOnlyPattern::getResultsInCaseOfFailure : internal error ! The returned vector has a null pointer at pos #0 !");
528 std::size_t sz(ret[0]->size());
529 passedIds.resize(sz);
530 for(std::size_t i=0;i<sz;i++)
535 getStatusOfRunStr();// To check that the status is recognized.
536 std::list<YACS::ENGINE::Node *> lns(getUndergroundGeneratedGraph()->edGetDirectDescendants());
537 YACS::ENGINE::ForEachLoop *fe(getUndergroundForEach());
539 YACS::ENGINE::Executor exe;
540 std::vector<YACS::ENGINE::SequenceAny *> outputs;
541 std::vector<std::string> nameOfOutputs;
542 passedIds=fe->getPassedResults(&exe,outputs,nameOfOutputs);//<- the key invokation is here.
543 std::size_t sz(passedIds.size()),ii(0);
544 std::vector<YACSEvalSeqAny *> ret(_outputsOfInterest.size());
545 for(std::vector<YACSEvalOutputPort *>::const_iterator it1=_outputsOfInterest.begin();it1!=_outputsOfInterest.end();it1++,ii++)
547 YACS::ENGINE::OutputPort *p((*it1)->getUndergroundPtr());
548 std::string st(_runNode->getOutPortName(p));
549 std::ostringstream oss; oss << YACSEvalYFXGraphGen::FIRST_FE_SUBNODE_NAME << '.' << _runNode->getName() << '.' << st;
551 YACS::ENGINE::ForEachLoop::InterceptorizeNameOfPort(st);
552 std::vector<std::string>::iterator it2(std::find(nameOfOutputs.begin(),nameOfOutputs.end(),st));
553 if(it2==nameOfOutputs.end())
555 std::ostringstream oss; oss << "YACSEvalYFXRunOnlyPattern::getResultsInCaseOfFailure : internal error 3 ! Unable to locate interceptor with name " << st << " ! Possibilities are : ";
556 std::copy(nameOfOutputs.begin(),nameOfOutputs.end(),std::ostream_iterator<std::string>(oss," "));
558 throw YACS::Exception(oss.str());
560 std::size_t pos(std::distance(nameOfOutputs.begin(),it2));
561 ret[ii]=BuildValueFromEngineFrmt(outputs[pos]);
566 void YACSEvalYFXRunOnlyPattern::emitStart() const
568 YACSEvalObserver *obs(getObserver());
571 obs->startComputation(getBoss());
574 bool YACSEvalYFXRunOnlyPattern::go(const YACSEvalExecParams& params, YACSEvalSession *session) const
577 YACS::ENGINE::Dispatcher *disp(YACS::ENGINE::Dispatcher::getDispatcher());
578 disp->addObserver(_obs,getUndergroundForEach(),"progress_ok");
579 disp->addObserver(_obs,getUndergroundForEach(),"progress_ko");
580 bool ret(getGenerator()->go(params,session));
581 disp->removeObserver(_obs,getUndergroundForEach(),"progress_ok");
582 disp->removeObserver(_obs,getUndergroundForEach(),"progress_ko");
586 YACS::ENGINE::ForEachLoop *YACSEvalYFXRunOnlyPattern::getUndergroundForEach() const
588 return getGenerator()->getUndergroundForEach();
591 bool YACSEvalYFXRunOnlyPattern::IsMatching(YACS::ENGINE::Proc *scheme, YACS::ENGINE::ComposedNode *& runNode)
593 std::list<YACS::ENGINE::Node *> nodes(scheme->getChildren());
596 bool areAllElementary(true);
597 for(std::list<YACS::ENGINE::Node *>::const_iterator it=nodes.begin();it!=nodes.end() && areAllElementary;it++)
598 if(!dynamic_cast<YACS::ENGINE::ElementaryNode *>(*it))
599 areAllElementary=false;
603 CheckNodeIsOK(scheme);
609 YACS::ENGINE::ComposedNode *candidate(dynamic_cast<YACS::ENGINE::ComposedNode *>(nodes.front()));
612 CheckNodeIsOK(candidate);
616 void YACSEvalYFXRunOnlyPattern::buildInputPorts()
619 std::list< YACS::ENGINE::InputPort *> allInputPorts(_runNode->getSetOfInputPort());
620 std::vector<std::string> allNames;
621 for(std::list< YACS::ENGINE::InputPort *>::const_iterator it=allInputPorts.begin();it!=allInputPorts.end();it++)
623 YACS::ENGINE::InputPort *elt(*it);
625 throw YACS::Exception("YACSEvalYFXRunOnlyPattern::buildInputPorts : presence of null input !");
626 std::set<YACS::ENGINE::OutPort *> bls(elt->edSetOutPort());
629 if(YACSEvalPort::IsInputPortPublishable(elt))
631 std::string inpName(elt->getName());
633 throw YACS::Exception("YACSEvalYFXRunOnlyPattern::buildInputPorts : an input has empty name ! Should not !");
634 _inputs.push_back(YACSEvalInputPort(elt));
635 if(std::find(allNames.begin(),allNames.end(),inpName)!=allNames.end())
637 std::ostringstream oss; oss << "YACSEvalYFXRunOnlyPattern::buildInputPorts : input name \"" << inpName << "\" appears more than once !";
638 throw YACS::Exception(oss.str());
640 allNames.push_back(inpName);
646 void YACSEvalYFXRunOnlyPattern::buildOutputPorts()
649 std::list< YACS::ENGINE::OutputPort *> allOutputPorts(_runNode->getSetOfOutputPort());
650 std::vector<std::string> allNames;
651 for(std::list< YACS::ENGINE::OutputPort *>::const_iterator it=allOutputPorts.begin();it!=allOutputPorts.end();it++)
653 YACS::ENGINE::OutputPort *elt(*it);
654 if(YACSEvalPort::IsOutputPortPublishable(elt))
657 throw YACS::Exception("YACSEvalYFXRunOnlyPattern::buildOutputPorts : presence of null output !");
658 std::string outpName(elt->getName());
660 throw YACS::Exception("YACSEvalYFXRunOnlyPattern::buildOutputPorts : an output has empty name ! Should not !");
661 if(std::find(allNames.begin(),allNames.end(),outpName)!=allNames.end())
663 std::ostringstream oss; oss << "YACSEvalYFXRunOnlyPattern::buildOutputPorts : output name \"" << outpName << "\" appears more than once !";
664 throw YACS::Exception(oss.str());
666 _outputs.push_back(YACSEvalOutputPort(*it));
671 YACSEvalYFXGraphGen *YACSEvalYFXRunOnlyPattern::getGenerator() const
674 throw YACS::Exception("getGenerator : generator is NULL !");
678 /////////////////////
680 YACSEvalYFXGraphGen::YACSEvalYFXGraphGen(YACSEvalYFXRunOnlyPattern *boss):_boss(boss),_generatedGraph(0),_FEInGeneratedGraph(0)
683 throw YACS::Exception("YACSEvalYFXGraphGen constructor : boss is NULL !");
686 YACSEvalYFXGraphGen::~YACSEvalYFXGraphGen()
688 //delete _generatedGraph;// -> TODO : AGY why ?
691 void YACSEvalYFXGraphGen::resetGeneratedGraph()
693 delete _generatedGraph;
694 _generatedGraph=0; _FEInGeneratedGraph=0;
697 bool YACSEvalYFXGraphGen::isLocked() const
699 return _generatedGraph!=0;
702 int YACSEvalYFXGraphGen::assignNbOfBranches()
705 throw YACS::Exception("YACSEvalYFXGraphGen::assignNbOfBranches : the generated graph has not been created !");
706 std::list<YACS::ENGINE::Node *> nodes(_generatedGraph->getChildren());
707 YACS::ENGINE::ForEachLoop *zeMainNode(0);
708 for(std::list<YACS::ENGINE::Node *>::const_iterator it=nodes.begin();it!=nodes.end();it++)
710 YACS::ENGINE::ForEachLoop *isZeMainNode(dynamic_cast<YACS::ENGINE::ForEachLoop *>(*it));
714 zeMainNode=isZeMainNode;
716 throw YACS::Exception("YACSEvalYFXGraphGen::assignNbOfBranches : internal error 1 !");
720 throw YACS::Exception("YACSEvalYFXGraphGen::assignNbOfBranches : internal error 2 !");
721 unsigned int nbProcsDeclared(getBoss()->getResourcesInternal()->getNumberOfProcsDeclared());
722 nbProcsDeclared=std::max(nbProcsDeclared,4u);
724 if(getBoss()->getParallelizeStatus())
726 nbOfBranch=(nbProcsDeclared/getBoss()->getResourcesInternal()->getMaxLevelOfParallelism());
727 nbOfBranch=std::max(nbOfBranch,1);
729 YACS::ENGINE::InputPort *zeInputToSet(zeMainNode->edGetNbOfBranchesPort());
730 YACS::ENGINE::AnyInputPort *zeInputToSetC(dynamic_cast<YACS::ENGINE::AnyInputPort *>(zeInputToSet));
732 throw YACS::Exception("YACSEvalYFXGraphGen::assignNbOfBranches : internal error 3 !");
733 YACS::ENGINE::Any *a(YACS::ENGINE::AtomAny::New(nbOfBranch));
734 zeInputToSetC->put(a);
735 zeInputToSetC->exSaveInit();
740 void YACSEvalYFXGraphGenInteractive::generateGraph()
743 { delete _generatedGraph; _generatedGraph=0; _FEInGeneratedGraph=0; }
744 static const char LISTPYOBJ_STR[]="list[pyobj]";
745 if(getBoss()->getOutputsOfInterest().empty())
747 YACS::ENGINE::RuntimeSALOME::setRuntime();
748 YACS::ENGINE::RuntimeSALOME *r(YACS::ENGINE::getSALOMERuntime());
749 _generatedGraph=r->createProc(DFT_PROC_NAME);
750 YACS::ENGINE::TypeCode *pyobjTC(_generatedGraph->createInterfaceTc("python:obj:1.0","pyobj",std::list<YACS::ENGINE::TypeCodeObjref *>()));
751 std::ostringstream oss; oss << "Loop_" << getBoss()->getRunNode()->getName();
752 _generatedGraph->createType(YACSEvalAnyDouble::TYPE_REPR,"double");
753 _generatedGraph->createType(YACSEvalAnyInt::TYPE_REPR,"int");
755 YACS::ENGINE::InlineNode *n0(r->createScriptNode(YACS::ENGINE::PythonNode::KIND,"__initializer__"));
756 _generatedGraph->edAddChild(n0);
757 YACS::ENGINE::TypeCode *listPyobjTC(_generatedGraph->createSequenceTc(LISTPYOBJ_STR,LISTPYOBJ_STR,pyobjTC));
758 YACS::ENGINE::OutputPort *sender(n0->edAddOutputPort("sender",listPyobjTC));
759 std::ostringstream var0;
760 const std::vector< YACSEvalInputPort >& inputs(getBoss()->getInputs());
761 for(std::vector< YACSEvalInputPort >::const_iterator it=inputs.begin();it!=inputs.end();it++)
763 if((*it).isRandomVar())
765 var0 << (*it).getName() << ",";
766 YACS::ENGINE::TypeCode *tc(YACSEvalYFXPattern::CreateSeqTypeCodeFrom(_generatedGraph,(*it).getTypeOfData()));
767 YACS::ENGINE::InputPort *inp(n0->edAddInputPort((*it).getName(),tc));
768 YACS::ENGINE::InputPyPort *inpc(dynamic_cast<YACS::ENGINE::InputPyPort *>(inp));
770 throw YACS::Exception("YACSEvalYFXRunOnlyPattern::generateGraph : internal error 1 !");
771 (*it).setUndergroundPortToBeSet(inpc);
774 std::ostringstream n0Script; n0Script << "sender=zip(" << var0.str() << ")\n";
775 n0->setScript(n0Script.str());
777 YACS::ENGINE::ForEachLoop *n1(r->createForEachLoop(oss.str(),pyobjTC));
778 _FEInGeneratedGraph=n1;
779 _generatedGraph->edAddChild(n1);
780 _generatedGraph->edAddCFLink(n0,n1);
781 _generatedGraph->edAddDFLink(sender,n1->edGetSeqOfSamplesPort());
782 YACS::ENGINE::InlineNode *n2(r->createScriptNode(YACS::ENGINE::PythonNode::KIND,GATHER_NODE_NAME));
783 _generatedGraph->edAddChild(n2);
784 _generatedGraph->edAddCFLink(n1,n2);
786 YACS::ENGINE::Bloc *n10(r->createBloc(FIRST_FE_SUBNODE_NAME));
788 YACS::ENGINE::InlineNode *n100(r->createScriptNode(YACS::ENGINE::PythonNode::KIND,"__dispatch__"));
789 YACS::ENGINE::ComposedNode *runNode(getBoss()->getRunNode());
790 YACS::ENGINE::Node *n101(runNode->cloneWithoutCompAndContDeepCpy(0,true));
791 n10->edAddChild(n100);
792 n10->edAddChild(n101);
793 YACS::ENGINE::InputPort *dispatchIn(n100->edAddInputPort("i0",pyobjTC));
794 n10->edAddCFLink(n100,n101);
795 n1->edAddDFLink(n1->edGetSamplePort(),dispatchIn);
796 std::ostringstream var1;
797 for(std::vector< YACSEvalInputPort >::const_iterator it=inputs.begin();it!=inputs.end();it++)
799 if((*it).isRandomVar())
801 var1 << (*it).getName() << ",";
802 YACS::ENGINE::OutputPort *myOut(n100->edAddOutputPort((*it).getName(),_generatedGraph->getTypeCode((*it).getTypeOfData())));
803 std::string tmpPortName(runNode->getInPortName((*it).getUndergroundPtr()));
804 YACS::ENGINE::InputPort *myIn(n101->getInputPort(tmpPortName));
805 n10->edAddDFLink(myOut,myIn);
808 std::ostringstream n100Script; n100Script << var1.str() << "=i0\n";
809 n100->setScript(n100Script.str());
810 const std::vector<YACSEvalOutputPort *>& outputsOfInt(getBoss()->getOutputsOfInterest());
811 for(std::vector< YACSEvalOutputPort * >::const_iterator it=outputsOfInt.begin();it!=outputsOfInt.end();it++)
813 YACS::ENGINE::TypeCode *tc(YACSEvalYFXPattern::CreateSeqTypeCodeFrom(_generatedGraph,(*it)->getTypeOfData()));
814 YACS::ENGINE::InputPort *myIn(n2->edAddInputPort((*it)->getName(),tc));
815 std::string tmpPortName(runNode->getOutPortName((*it)->getUndergroundPtr()));
816 YACS::ENGINE::OutputPort *myOut(n101->getOutputPort(tmpPortName));
817 _generatedGraph->edAddDFLink(myOut,myIn);
819 _generatedGraph->updateContainersAndComponents();
822 bool YACSEvalYFXGraphGenInteractive::go(const YACSEvalExecParams& params, YACSEvalSession *session) const
824 YACS::ENGINE::Executor exe;
825 exe.setKeepGoingProperty(!params.getStopASAPAfterErrorStatus());
827 MyAutoThreadSaver locker(!session->isAlreadyPyThreadSaved());
828 exe.RunW(getUndergroundGeneratedGraph());
830 return getUndergroundGeneratedGraph()->getState()==YACS::DONE;
833 std::vector<YACSEvalSeqAny *> YACSEvalYFXGraphGenInteractive::getResults() const
835 if(getUndergroundGeneratedGraph()->getState()!=YACS::DONE)
836 throw YACS::Exception("YACSEvalYFXRunOnlyPattern::getResults : the execution did not finished correctly ! getResults should not be called !");
837 const std::vector<YACSEvalOutputPort *>& outputsOfInt(getBoss()->getOutputsOfInterest());
838 std::vector<YACSEvalSeqAny *> ret(outputsOfInt.size());
839 YACS::ENGINE::Node *node(getUndergroundGeneratedGraph()->getChildByName(YACSEvalYFXGraphGen::GATHER_NODE_NAME));
840 YACS::ENGINE::PythonNode *nodeC(dynamic_cast<YACS::ENGINE::PythonNode *>(node));
842 throw YACS::Exception("YACSEvalYFXRunOnlyPattern::getResults : internal error !");
844 for(std::vector< YACSEvalOutputPort * >::const_iterator it=outputsOfInt.begin();it!=outputsOfInt.end();it++,ii++)
846 YACS::ENGINE::InPort *input(nodeC->getInPort((*it)->getName()));
847 YACS::ENGINE::InputPyPort *inputC(dynamic_cast<YACS::ENGINE::InputPyPort *>(input));
850 std::ostringstream oss; oss << "YACSEvalYFXRunOnlyPattern::getResults : internal error for input \"" << (*it)->getName() << "\"";
851 throw YACS::Exception(oss.str());
853 ret[ii]=YACSEvalYFXPattern::BuildValueInPort(inputC);
860 void YACSEvalYFXGraphGenCluster::generateGraph()
862 YACS::ENGINE::AutoGIL agil;
864 { delete _generatedGraph; _generatedGraph=0; _FEInGeneratedGraph=0; }
866 const char EFXGenFileName[]="EFXGenFileName";
867 const char EFXGenContent[]="import getpass,datetime,os\nn=datetime.datetime.now()\nreturn os.path.join(os.path.sep,\"tmp\",\"EvalYFX_%s_%s_%s.xml\"%(getpass.getuser(),n.strftime(\"%d%m%y\"),n.strftime(\"%H%M%S\")))";
868 const char EFXGenContent2[]="import getpass,datetime\nn=datetime.datetime.now()\nreturn \"EvalYFX_%s_%s_%s\"%(getpass.getuser(),n.strftime(\"%d%m%y\"),n.strftime(\"%H%M%S\"))";
870 YACS::ENGINE::AutoPyRef func(YACS::ENGINE::evalPy(EFXGenFileName,EFXGenContent));
871 YACS::ENGINE::AutoPyRef val(YACS::ENGINE::evalFuncPyWithNoParams(func));
872 _locSchemaFile=PyBytes_AsString(val);
873 func=YACS::ENGINE::evalPy(EFXGenFileName,EFXGenContent2);
874 val=YACS::ENGINE::evalFuncPyWithNoParams(func);
875 _jobName=PyBytes_AsString(val);
877 static const char LISTPYOBJ_STR[]="list[pyobj]";
878 if(getBoss()->getOutputsOfInterest().empty())
880 YACS::ENGINE::RuntimeSALOME::setRuntime();
881 YACS::ENGINE::RuntimeSALOME *r(YACS::ENGINE::getSALOMERuntime());
882 _generatedGraph=r->createProc(DFT_PROC_NAME);
883 YACS::ENGINE::TypeCode *pyobjTC(_generatedGraph->createInterfaceTc("python:obj:1.0","pyobj",std::list<YACS::ENGINE::TypeCodeObjref *>()));
884 std::ostringstream oss; oss << "Loop_" << getBoss()->getRunNode()->getName();
885 _generatedGraph->createType(YACSEvalAnyDouble::TYPE_REPR,"double");
886 _generatedGraph->createType(YACSEvalAnyInt::TYPE_REPR,"int");
888 YACS::ENGINE::InlineNode *n0(r->createScriptNode(YACS::ENGINE::PythonNode::KIND,"__initializer__"));
889 _generatedGraph->edAddChild(n0);
890 YACS::ENGINE::TypeCode *listPyobjTC(_generatedGraph->createSequenceTc(LISTPYOBJ_STR,LISTPYOBJ_STR,pyobjTC));
891 YACS::ENGINE::OutputPort *sender(n0->edAddOutputPort("sender",listPyobjTC));
892 std::ostringstream var0;
893 const std::vector< YACSEvalInputPort >& inputs(getBoss()->getInputs());
894 for(std::vector< YACSEvalInputPort >::const_iterator it=inputs.begin();it!=inputs.end();it++)
896 if((*it).isRandomVar())
898 var0 << (*it).getName() << ",";
899 YACS::ENGINE::TypeCode *tc(YACSEvalYFXPattern::CreateSeqTypeCodeFrom(_generatedGraph,(*it).getTypeOfData()));
900 YACS::ENGINE::InputPort *inp(n0->edAddInputPort((*it).getName(),tc));
901 YACS::ENGINE::InputPyPort *inpc(dynamic_cast<YACS::ENGINE::InputPyPort *>(inp));
903 throw YACS::Exception("YACSEvalYFXRunOnlyPattern::generateGraph : internal error 1 !");
904 (*it).setUndergroundPortToBeSet(inpc);
907 std::ostringstream n0Script; n0Script << "sender=zip(" << var0.str() << ")\n";
908 n0->setScript(n0Script.str());
910 YACS::ENGINE::ForEachLoop *n1(r->createForEachLoop(oss.str(),pyobjTC));
911 _FEInGeneratedGraph=n1;
912 _generatedGraph->edAddChild(n1);
913 _generatedGraph->edAddCFLink(n0,n1);
914 _generatedGraph->edAddDFLink(sender,n1->edGetSeqOfSamplesPort());
915 YACS::ENGINE::InlineNode *n2(r->createScriptNode(YACS::ENGINE::PythonNode::KIND,GATHER_NODE_NAME));
916 _generatedGraph->edAddChild(n2);
917 _generatedGraph->edAddCFLink(n1,n2);
919 YACS::ENGINE::Bloc *n10(r->createBloc(FIRST_FE_SUBNODE_NAME));
921 YACS::ENGINE::InlineNode *n100(r->createScriptNode(YACS::ENGINE::PythonNode::KIND,"__dispatch__"));
922 YACS::ENGINE::ComposedNode *runNode(getBoss()->getRunNode());
923 YACS::ENGINE::Node *n101(runNode->cloneWithoutCompAndContDeepCpy(0,true));
924 n10->edAddChild(n100);
925 n10->edAddChild(n101);
926 YACS::ENGINE::InputPort *dispatchIn(n100->edAddInputPort("i0",pyobjTC));
927 n10->edAddCFLink(n100,n101);
928 n1->edAddDFLink(n1->edGetSamplePort(),dispatchIn);
929 std::ostringstream var1;
930 for(std::vector< YACSEvalInputPort >::const_iterator it=inputs.begin();it!=inputs.end();it++)
932 if((*it).isRandomVar())
934 var1 << (*it).getName() << ",";
935 YACS::ENGINE::OutputPort *myOut(n100->edAddOutputPort((*it).getName(),_generatedGraph->getTypeCode((*it).getTypeOfData())));
936 std::string tmpPortName(runNode->getInPortName((*it).getUndergroundPtr()));
937 YACS::ENGINE::InputPort *myIn(n101->getInputPort(tmpPortName));
938 n10->edAddDFLink(myOut,myIn);
941 std::ostringstream n100Script; n100Script << var1.str() << "=i0\n";
942 n100->setScript(n100Script.str());
943 const std::vector<YACSEvalOutputPort *>& outputsOfInt(getBoss()->getOutputsOfInterest());
944 std::ostringstream n2Script; n2Script << "zeRes=[";
945 for(std::vector< YACSEvalOutputPort * >::const_iterator it=outputsOfInt.begin();it!=outputsOfInt.end();it++)
947 YACS::ENGINE::TypeCode *tc(YACSEvalYFXPattern::CreateSeqTypeCodeFrom(_generatedGraph,(*it)->getTypeOfData()));
948 YACS::ENGINE::InputPort *myIn(n2->edAddInputPort((*it)->getName(),tc));
949 n2Script << (*it)->getName() << ", ";
950 std::string tmpPortName(runNode->getOutPortName((*it)->getUndergroundPtr()));
951 YACS::ENGINE::OutputPort *myOut(n101->getOutputPort(tmpPortName));
952 _generatedGraph->edAddDFLink(myOut,myIn);
954 n2Script << "]\nf=file(\"" << _jobName << "\",\"w\") ; f.write(str(zeRes)) ; del f";
955 n2->setScript(n2Script.str());
956 _generatedGraph->updateContainersAndComponents();
959 bool YACSEvalYFXGraphGenCluster::go(const YACSEvalExecParams& params, YACSEvalSession *session) const
961 YACS::ENGINE::AutoGIL agil;
962 getUndergroundGeneratedGraph()->saveSchema(_locSchemaFile);
963 YACSEvalListOfResources *rss(getBoss()->getResourcesInternal());
964 const YACSEvalParamsForCluster& cli(rss->getAddParamsForCluster());
965 std::vector<std::string> machines(rss->getAllChosenMachines());
966 if(machines.size()!=1)
967 throw YACS::Exception("YACSEvalYFXGraphGenCluster::go : internal error ! In batch mode and not exactly one machine !");
968 Engines::SalomeLauncher_var sl(session->getInternal()->goFetchingSalomeLauncherInNS());
969 Engines::ResourceParameters rr;
970 rr.name=CORBA::string_dup(machines[0].c_str());
971 rr.hostname=CORBA::string_dup("");
972 rr.can_launch_batch_jobs=true;
973 rr.can_run_containers=true;
974 rr.OS=CORBA::string_dup("Linux");
975 rr.componentList.length(0);
976 rr.nb_proc=rss->getNumberOfProcsDeclared();// <- important
979 rr.nb_node=1;// useless only nb_proc used.
980 rr.nb_proc_per_node=1;// useless only nb_proc used.
981 rr.policy=CORBA::string_dup("cycl");
982 rr.resList.length(0);
983 Engines::JobParameters jp;
984 jp.job_name=CORBA::string_dup(_jobName.c_str());
985 jp.job_type=CORBA::string_dup("yacs_file");
986 jp.job_file=CORBA::string_dup(_locSchemaFile.c_str());
987 jp.env_file=CORBA::string_dup("");
988 jp.in_files.length(0);
989 jp.out_files.length(1);
990 jp.out_files[0]=CORBA::string_dup(_jobName.c_str());
991 jp.work_directory=CORBA::string_dup(cli.getRemoteWorkingDir().c_str());
992 jp.local_directory=CORBA::string_dup(cli.getLocalWorkingDir().c_str());
993 jp.result_directory=CORBA::string_dup(cli.getLocalWorkingDir().c_str());
994 jp.maximum_duration=CORBA::string_dup(cli.getMaxDuration().c_str());
995 jp.resource_required=rr;
996 jp.queue=CORBA::string_dup("");
998 jp.mem_per_cpu=rr.mem_mb;
999 jp.wckey=CORBA::string_dup(cli.getWCKey().c_str());
1000 jp.extra_params=CORBA::string_dup("");
1001 jp.specific_parameters.length(0);
1002 jp.launcher_file=CORBA::string_dup("");
1003 jp.launcher_args=CORBA::string_dup("");
1004 _jobid=sl->createJob(jp);
1005 sl->launchJob(_jobid);
1009 PyRun_SimpleString("import time ; time.sleep(10)");
1010 char *state(sl->getJobState(_jobid));//"CREATED", "IN_PROCESS", "QUEUED", "RUNNING", "PAUSED", "FINISHED" or "FAILED"
1011 std::string sstate(state);
1012 CORBA::string_free(state);
1013 if(sstate=="FINISHED" || sstate=="FAILED")
1015 ret=sstate=="FINISHED";
1019 sl->getJobResults(_jobid,cli.getLocalWorkingDir().c_str());
1023 std::ostringstream oss; oss << "import os" << std::endl << "p=os.path.join(\"" << cli.getLocalWorkingDir() << "\",\"" << _jobName << "\")" << std::endl;
1024 oss << "if not os.path.exists(p):\n return None\n";
1025 oss << "f=file(p,\"r\")" << std::endl;
1026 oss << "return eval(f.read())";
1027 std::string zeInput(oss.str());
1028 YACS::ENGINE::AutoPyRef func(YACS::ENGINE::evalPy("fetch",zeInput));
1029 YACS::ENGINE::AutoPyRef val(YACS::ENGINE::evalFuncPyWithNoParams(func));
1030 if(!PyList_Check(val))
1031 throw YACS::Exception("Fetched file does not contain a list !");
1032 Py_ssize_t sz(PyList_Size(val));
1034 for(Py_ssize_t i=0;i<sz;i++)
1036 std::vector<double>& res0(_res[i]);
1037 PyObject *elt0(PyList_GetItem(val,i));
1038 if(!PyList_Check(elt0))
1039 throw YACS::Exception("Fetched file does contain a list of list !");
1040 Py_ssize_t sz0(PyList_Size(elt0)); res0.resize(sz0);
1041 for(Py_ssize_t j=0;j<sz0;j++)
1043 PyObject *elt1(PyList_GetItem(elt0,j));
1044 res0[j]=PyFloat_AsDouble(elt1);
1048 std::ostringstream oss1; oss1 << "import os" << std::endl << "p=os.path.join(\"" << cli.getLocalWorkingDir() << "\",\"" << _jobName << "\") ; os.remove(p)" << std::endl;
1049 std::string s1(oss1.str());
1050 PyRun_SimpleString(s1.c_str());
1051 if(!params.getFetchRemoteDirForClusterStatus())
1053 std::ostringstream oss2; oss2 << "import os,shutil" << std::endl << "p=os.path.join(\"" << cli.getLocalWorkingDir() << "\",\"logs\") ; shutil.rmtree(p)" << std::endl;
1054 std::string s2(oss2.str());
1055 PyRun_SimpleString(s2.c_str());
1058 catch(YACS::Exception& e)
1067 std::vector<YACSEvalSeqAny *> YACSEvalYFXGraphGenCluster::getResults() const
1069 std::size_t sz(_res.size());
1070 std::vector<YACSEvalSeqAny *> ret(sz);
1071 for(std::size_t i=0;i<sz;i++)
1073 YACS::AutoCppPtr<YACSEvalSeqAnyDouble> elt(new YACSEvalSeqAnyDouble(_res[i]));
1074 ret[i]=elt.dettach();