Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Master.hh
Go to the documentation of this file.
1 // -*- mode:c++;tab-width:2;indent-tabs-mode:t;show-trailing-whitespace:t;rm-trailing-spaces:t -*-
2 // vi: set ts=2 noet:
3 //
4 // (c) Copyright Rosetta Commons Member Institutions.
5 // (c) This file is part of the Rosetta software suite and is made available under license.
6 // (c) The Rosetta software is developed by the contributing members of the Rosetta Commons.
7 // (c) For more information, see http://www.rosettacommons.org. Questions about this can be
8 // (c) addressed to University of Washington UW TechTransfer, email: license@u.washington.edu.
9 
10 /// @file protocols/elscripts/Master.hh
11 /// @brief The Master role in elscripts, handles trajectories, generating workunits, processing of results
12 /// This is the non MPI version of the master, which is used by the Single Node Role
13 /// Splitting this from MPI_Master so Single Node can be compiled without MPI
14 /// @author Ken Jung
15 
16 #ifndef INCLUDED_protocols_elscripts_Master_hh
17 #define INCLUDED_protocols_elscripts_Master_hh
18 #ifdef USELUA
22 
23 #include <boost/date_time/posix_time/posix_time_types.hpp>
24 
25 namespace protocols {
26 namespace elscripts {
27 
28 void lregister_Master( lua_State * lstate );
29 
30 class Master : public BaseRole {
31  public:
32  // default memory limit is 1GB
33  // default reserved mem size is 100MB as recommended by fpd
34  Master( int num_trajectories = 1, boost::uint64_t mem_limit=2147483648, boost::uint64_t reserved_mem=104857600, boost::uint64_t reserved_mem_multiplier=5 );
35  ~Master(){}
36 
37  virtual void go();
38 
39  boost::uint64_t available_mem() {
40  boost::uint64_t buff_mem =
41  slave_comm_->current_mem() +
42  reserved_mem_ * reserved_mem_multiplier_ +
43  trajectories_mem();
44  if( buff_mem >= mem_limit_ ) {
45  return 0;
46  } else {
47  return mem_limit_ - buff_mem;
48  }
49  }
50 
54 
55 
56  void make_wu_copied( std::string const & wuname, core::io::serialization::PipeMapSP pmap, protocols::moves::SerializableStateSP state );
57  void make_wu_until_limit( std::string const & wuname, int num);
58  void end_traj();
59 
60  void interpreter();
61 
62  // this is me being sloppy and lazy
63  protocols::wum2::WUQueue & inq() { return slave_comm_->inq(); }
64  protocols::wum2::WUQueue & outq() { return slave_comm_->outq(); }
65 
66  protected:
67  boost::uint64_t current_mem() {
68  return slave_comm_->current_mem() +
69  trajectories_mem(); // slaves_ memory trivial
70  }
71 
72  virtual int inputter_rank() {
73  // handles if there is or is not pool logic, needed for inputter offset
74  // doesnt do anything now
75  return 1;
76  }
77 
78  // use Inputters to fill trajectory pipe up to limit
79  // if inputters have no more decoys, then ask pool for structures
80  void fill_trajectories();
81 
82  void update_trajectories_mem();
83  boost::uint64_t trajectories_mem() { return trajectories_mem_; }
84 
85  protected:
86  protocols::wum2::EndPointSP slave_comm_;
87 
88  int num_trajectories_;
89  core::io::serialization::PipeSP trajectories_;
90  boost::uint64_t trajectories_mem_;
91 
92  int num_trajectories_finished_;
93 
94  int mpicounter_; // simple counter to avoid calling into lua too often
95 
96  int traj_idx_; // used as a global
97  // traj_idx is set before fxns make_wu are called
98  // this gets rid of traj_idx in lua script
99 
100  boost::posix_time::ptime last_generate_initial_wu_time_;
101 };
102 
103 // luabind doesn't understand default parameters, so need to create wrapper fxns for them
104 void master_make_wu_nostate( Master * master, std::string const & wuname, core::pose::PoseSP p );
105 void master_make_wu_nostate( Master * master, std::string const & wuname, core::io::serialization::PipeSP p );
106 void master_make_wu_nostate( Master * master, std::string const & wuname, core::io::serialization::PipeMapSP p );
107 
108 } //elscripts
109 } //protocols
110 #endif
111 #endif