/[escript]/branches/split/escriptcore/src/SplitWorld.cpp
ViewVC logotype

Diff of /branches/split/escriptcore/src/SplitWorld.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4796 by jfenwick, Mon Mar 24 04:57:35 2014 UTC revision 4802 by jfenwick, Wed Mar 26 05:48:28 2014 UTC
# Line 95  namespace Line 95  namespace
95  // This is implemented by sending to rank 0  // This is implemented by sending to rank 0
96  bool checkResultInt(int res, int& mres, esysUtils::JMPI& info)  bool checkResultInt(int res, int& mres, esysUtils::JMPI& info)
97  {  {
98    #ifdef ESYS_MPI
99      const int leader=0;      const int leader=0;
100      const int BIGTAG=esysUtils::getSubWorldTag();      const int BIGTAG=esysUtils::getSubWorldTag();
101      if (info->size==1)      if (info->size==1)
# Line 151  bool checkResultInt(int res, int& mres, Line 152  bool checkResultInt(int res, int& mres,
152                
153      }      }
154      return true;      return true;
155    #else
156        mres=res;
157        return true;
158    #endif
159  }  }
160    
161    
# Line 167  void SplitWorld::runJobs() Line 172  void SplitWorld::runJobs()
172      // now we actually need to run the jobs      // now we actually need to run the jobs
173      // everybody will be executing their localworld's jobs      // everybody will be executing their localworld's jobs
174      int res=localworld->runJobs(err);        int res=localworld->runJobs(err);  
175        // take this opportunity to clean up
176        
177        localworld->clearImportExports();
178      // now we find out about the other worlds      // now we find out about the other worlds
179      if (!checkResultInt(res, mres, globalcom))      if (!checkResultInt(res, mres, globalcom))
180      {      {
181          throw SplitWorldException("MPI appears to have failed.");          throw SplitWorldException("MPI appears to have failed.");
182      }      }
183      } while (mres==1);      } while (mres==1);
184      if (mres==2)      if (mres==0)
185        {
186        return;
187        }
188        else if (mres==2)
189      {      {
190      throw SplitWorldException("At least one Job's work() function did not return True/False.");      throw SplitWorldException("At least one Job's work() function did not return True/False.");
191      }      }
# Line 191  void SplitWorld::runJobs() Line 203  void SplitWorld::runJobs()
203      s+=resultstr;      s+=resultstr;
204      throw SplitWorldException(s);      throw SplitWorldException(s);
205      }      }
206        else if (mres==4)
207        {
208        throw SplitWorldException("While processing exports: "+err);
209        
210        }
211        else
212        {
213        throw SplitWorldException("Unexpected return value from runJobs.");
214        }
215  }  }
216    
217  /**  /**
# Line 207  void SplitWorld::addJob(boost::python::o Line 228  void SplitWorld::addJob(boost::python::o
228  // and trap any python exceptions etc, but for now I'll just call the constructor  // and trap any python exceptions etc, but for now I'll just call the constructor
229  void SplitWorld::addVariable(std::string name, boost::python::object creator, boost::python::tuple ntup, boost::python::dict kwargs)  void SplitWorld::addVariable(std::string name, boost::python::object creator, boost::python::tuple ntup, boost::python::dict kwargs)
230  {  {
     if (varmap.find(name)!=varmap.end())  
     {  
     std::ostringstream oss;  
     oss << "There is already a variable called " << name;  
     throw SplitWorldException(oss.str());      
     }  
231      object red=creator(*ntup, **kwargs);      object red=creator(*ntup, **kwargs);
232      extract<Reducer_ptr> ex(red);      extract<Reducer_ptr> ex(red);
233      if (!ex.check())      if (!ex.check())
# Line 220  void SplitWorld::addVariable(std::string Line 235  void SplitWorld::addVariable(std::string
235      throw SplitWorldException("Creator function did not produce a reducer.");      throw SplitWorldException("Creator function did not produce a reducer.");
236      }      }
237      Reducer_ptr rp=ex();      Reducer_ptr rp=ex();
238      varmap[name]=rp;      localworld->addVariable(name, rp);
239  }  }
240    
241    
242  void SplitWorld::removeVariable(std::string name)  void SplitWorld::removeVariable(std::string name)
243  {  {
244      varmap.erase(name);      localworld->removeVariable(name);
245  }  }
246    
247  void SplitWorld::clearPendingJobs()  void SplitWorld::clearPendingJobs()

Legend:
Removed from v.4796  
changed lines
  Added in v.4802

  ViewVC Help
Powered by ViewVC 1.1.26