Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MPIMultiCommJobDistributor.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 intended to do JD2-based distribution of jobs where each job can run a parallel MPI protocol
12 /// @brief prominent example... ReplicaExchange... run N trajectories of M Replica on an NxM+2 allocation
13 /// @author Oliver Lange olange@u.washington.edu
14 
15 #ifndef INCLUDED_protocols_jd2_MPIMultiCommJobDistributor_hh
16 #define INCLUDED_protocols_jd2_MPIMultiCommJobDistributor_hh
17 
18 #ifdef USEMPI
19 #include <mpi.h> //keep this first
20 #endif
21 
22 // Unit headers
25 
26 // Package headers
28 #include <protocols/jd2/Job.fwd.hh>
29 
31 #include <core/pose/Pose.fwd.hh>
32 
33 // Utility headers
34 #include <core/types.hh>
35 
36 // C++ headers
37 #include <string>
38 
39 #include <utility/vector1.hh>
40 
41 
42 namespace protocols {
43 namespace jd2 {
44 
45 ///@details This JobDistributor is intended for JD2 controlled runs of multiple parallel simulations that use
46 /// multiple replicas: e.g., N trajectories of M replicas on N*M+2 processes. (2 processes for central JD2 and MPIFileBuf )
47 /// derived from MPIFileBufJobDistributor: two dedicated processes are used to handle JobDistribution and File-IO.
48 /// all other processes (higher rank ) are used for computation.
51 protected:
52  ///@brief ctor is protected; singleton pattern
54 
55  virtual void handle_interrupt() {}
56 
57 public:
58 
59  ///@brief dummy for master/slave version
60  virtual core::Size get_new_job_id();
61 
62  ///@brief overloaded to suppress message from higher-rank replicas
63  virtual void job_succeeded(core::pose::Pose & pose, core::Real run_time);
64 
65  ///@brief overloaded to suppress message from higher-rank replicas
66  virtual void job_failed( core::pose::Pose & pose, bool );
67 
68  #ifdef USEMPI
69  ///@brief return current communicator ( or MPI_COMM_WORLD ).
70  /// this inteface could be put into an abstract base derived directly from JobDistributor
71  /// JobDistributor->MPIJobDistributor->MPIXXXJobDistributor
72  /// but for now it is only used by MPIMultiCommJobDistributor...
73  /// access via utility function jd2::current_mpi_comm()
74  MPI_Comm const& current_mpi_comm();
75  #endif
76 
78  return sub_rank_;
79  }
80 
81  friend class JobDistributorFactory; //ctor access
82 
83 private:
84 
85  void setup_sub_communicators( core::Size sub_size );
86 
88 #ifdef USEMPI
89  utility::vector1< MPI_Comm > mpi_communicators_;
91  utility::vector1< int* > mpi_ranks_;
92 #endif /*USEMPI*/
93 
94  int sub_rank_;
96 
97 };
98 
99 }//jd2
100 }//protocols
101 
102 #endif //INCLUDED_protocols_jd2_MPIMultiCommJobDistributor_HH