ALPS MPS Codes
Reference documentation.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | List of all members
Scheduler Class Reference

#include <scheduler.hpp>

Public Member Functions

 Scheduler (const Options &)
 
void run ()
 

Detailed Description

Definition at line 44 of file scheduler.hpp.

Constructor & Destructor Documentation

Scheduler::Scheduler ( const Options opt)

Definition at line 39 of file scheduler.cpp.

40 : stop_callback(opt.time_limit)
41 {
42  outfilepath = opt.jobfilename;
43  infilepath = opt.jobfilename;
44 
45  infilepath = boost::filesystem::absolute(infilepath);
46  outfilepath = boost::filesystem::absolute(outfilepath);
47 
48  if (!opt.jobfilename.empty())
49  parse_job_file(infilepath);
50 }
boost::filesystem::path jobfilename
Definition: options.hpp:48
double time_limit
Definition: options.hpp:44

Member Function Documentation

void Scheduler::run ( )

Definition at line 156 of file scheduler.cpp.

157 {
158  // do all Tasks
159  try {
160  for(unsigned int i=0; i<tasks.size(); i++) {
161  boost::chrono::high_resolution_clock::time_point t0 = boost::chrono::high_resolution_clock::now();
162  double time_left = stop_callback.time_left().count();
163  if (stop_callback.valid() && time_left < 0)
164  throw dmrg::time_limit();
165 
166  if (tasks[i].status == TaskFinished)
167  std::cout << "Task " << i+1 << " finished." << std::endl;
168  else if (tasks[i].status == TaskNotStarted || tasks[i].status == TaskRunning ||
169  tasks[i].status == TaskHalted) {
170 
171  tasks[i].status = TaskRunning;
172  std::cout << "Running task " << i+1 << "." << std::endl;
173  if (!boost::filesystem::exists(tasks[i].out))
174  copy(tasks[i].in, tasks[i].out);
175 
176  /// Start task
177  run_sim(tasks[i].in, tasks[i].out, time_left);
178  tasks[i].status = TaskFinished;
179  }
180  else
181  boost::throw_exception( std::logic_error("illegal Task status"));
182 
183  boost::chrono::high_resolution_clock::time_point t1 = boost::chrono::high_resolution_clock::now();
184  std::cout << "This task took " << boost::chrono::duration<double>(t1-t0) << "." << std::endl;
185  checkpoint_status();
186  }
187  std::cout << "Finished with everything." << std::endl;
188  } catch (dmrg::time_limit const& e) {
189  std::cout << "Time limit exceeded." << std::endl;
190  checkpoint_status();
191  }
192 }
boost::chrono::duration< double > time_left() const
bool valid() const
void run_sim(const boost::filesystem::path &infile, const boost::filesystem::path &outfile, bool write_xml=false, double time_limit=-1.)
Definition: run_measure.cpp:36

The documentation for this class was generated from the following files: