Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MPIWorkPoolJobDistributor.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/jd2/MPIWorkPoolJobDistributor.hh
11 /// @brief header for MPIWorkPoolJobDistributor - intended for MPI jobs on large numbers of nodes where the head node is dedicated to handing out new job ids
12 /// @author P. Douglas Renfrew (renfrew@unc.edu)
13 
14 #ifndef INCLUDED_protocols_jd2_MPIWorkPoolJobDistributor_hh
15 #define INCLUDED_protocols_jd2_MPIWorkPoolJobDistributor_hh
16 
17 // Unit headers
19 
20 // Package headers
22 #include <protocols/jd2/Job.fwd.hh>
23 // AUTO-REMOVED #include <protocols/jd2/JobDistributorFactory.hh>
24 
26 #include <core/pose/Pose.fwd.hh>
27 
28 // Utility headers
29 #include <core/types.hh>
30 
31 // C++ headers
32 #include <string>
33 
34 #include <platform/types.hh>
36 #include <protocols/jd2/Job.hh>
41 #include <utility/down_cast.hh>
42 #include <utility/vector1.fwd.hh>
43 #include <utility/vector1.hh>
44 #include <utility/vector1_bool.hh>
45 #include <utility/vectorL.fwd.hh>
46 #include <utility/vectorL.hh>
47 #include <utility/vectorL_Selector.hh>
48 #include <utility/vectorL_bool.hh>
49 #include <utility/pointer/ReferenceCount.fwd.hh>
50 #include <utility/pointer/ReferenceCount.hh>
51 #include <utility/pointer/access_ptr.fwd.hh>
52 #include <utility/pointer/access_ptr.hh>
53 #include <utility/pointer/owning_ptr.functions.hh>
54 #include <utility/pointer/owning_ptr.fwd.hh>
55 #include <utility/pointer/owning_ptr.hh>
56 #include <numeric/xyzVector.fwd.hh>
57 #include <algorithm>
58 #include <cassert>
59 #include <cstddef>
60 #include <iosfwd>
61 #include <limits>
62 #include <list>
63 #include <map>
64 #include <vector>
65 
66 
67 namespace protocols {
68 namespace jd2 {
69 
70 ///@brief Tags used to tag messeges sent by MPI functions used to decide whether a slave is requesting a new job id or
71 ///flagging as job as being a bad input
72 enum mpi_tags {
78 };
79 
80 ///@details This job distributor is meant for running jobs where the machine you are using has a large number of
81 ///processors, the number of jobs is much greater than the number of processors, or the runtimes of the individual jobs
82 ///could vary greatly. It dedicates the head node (whichever processor gets processor rank #0) to handling job requests
83 ///from the slave nodes (all nonzero ranks). Unlike the MPIWorkPartitionJobDistributor, this JD will not work at all
84 ///without MPI and the implementations of all but the interface functions have been put inside of ifdef directives.
85 ///Generally each function has a master and slave version, and the interface functions call one or the other depending
86 ///on processor rank.
88 {
89 protected:
90  ///@brief ctor is protected; singleton pattern
92 
93  virtual void handle_interrupt() {}
94 
95 public:
96  ///WARNING WARNING! SINGLETONS' DESTRUCTORS ARE NEVER CALLED IN MINI! DO NOT TRY TO PUT THINGS IN THIS FUNCTION!
97  ///here's a nice link explaining why: http://www.research.ibm.com/designpatterns/pubs/ph-jun96.txt
99 
100  ///@brief dummy for master/slave version
101  virtual
102  void
103  go( protocols::moves::MoverOP mover );
104 
105  ///@brief dummy for master/slave version
106  virtual
107  core::Size
108  get_new_job_id();
109 
110  ///@brief dummy for master/slave version
111  virtual
112  void
114 
115 
116  ///@brief dummy for master/slave version
117  virtual
118  void
120 
121  ///@brief dummy for master/slave version
122  virtual
123  void
124  job_succeeded(core::pose::Pose & pose, core::Real run_time);
125 
126  ///@brief should the go() function call MPI_finalize()? It probably should, this is true by default.
127  virtual
128  void mpi_finalize(bool finalize);
129 
130  friend class JobDistributorFactory; //ctor access
131 
132 protected:
133 
134  ///@brief Handles the receiving of job requests and the sending of job ids to and from slaves
135  virtual
136  void
138 
139  ///@brief Proceeds to the parent class go_main() as usual
140  virtual
141  void
143 
144  ///@brief Always returns zero, simply increments next_job_to_assign_ to the next job that should be run based
145  ///on what has been completeted and the overwrite flags
146  virtual
147  core::Size
149 
150  ///@brief requests, receives, and returns a new job id from the master node or returns the current job id if the
151  ///repeat_job_ flag is set to true
152  virtual
153  core::Size
155 
156  ///@brief This should never be called as this is handled internally by the slave nodes, it utility_exits
157  virtual
158  void
160 
161  ///@brief Sets the repeat_job_ flag to true
162  virtual
163  void
165 
166  ///@brief Simply increments next_job_to_assign_ to the next job that should be run based on what has been
167  ///completed and if the input job tag of the job marked as having bad input
168  virtual
169  void
171 
172  ///@brief Sends a message to the head node that contains the id of a job that had bad input
173  virtual
174  void
176 
177  ///@brief This should never be called as this is handled internally by the slave nodes, it utility_exits
178  virtual
179  void
181 
182  ///@brief Sends a message to the head node upon successful job completion to avoid output interleaving
183  virtual
184  void
186 
187 protected:
188 
189  ///@brief total number of processing elements
191 
192  ///@brief rank of the "local" instance
194 
195  ///@brief where slave jobs store current job id
197 
198  ///@brief where master stores next job to assign (in a good state after get_new_job_id up until it's used)
200 
201  ///@brief where master temporarily stores id of jobs with bad input
203 
204  ///@brief where slave stores whether it should repeat its current job id
206 
207  ///@brief should the go() function call MPI_finalize? There are very few cases where this should be false
209 
210 
211 };
212 
213 }//jd2
214 }//protocols
215 
216 #endif //INCLUDED_protocols_jd2_MPIWorkPoolJobDistributor_HH