Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
EndPoint.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/wum2/EndPoint.hh
11 /// @brief Non-MPI version of EndPoint
12 /// @details This class is required because SingleNode role needs to use an EndPoint that is not MPI dependent (ie just a wrapper for 2 queues)
13 /// @author Ken Jung
14 
15 #ifndef INCLUDED_protocols_wum2_EndPoint_hh
16 #define INCLUDED_protocols_wum2_EndPoint_hh
17 
18 
22 #include <boost/cstdint.hpp>
23 #include <boost/function.hpp>
24 
25 namespace protocols {
26 namespace wum2 {
27 
28 using namespace boost;
29 
30 struct StatusRequest;
31 struct StatusResponse;
32 
33 class EndPoint {
34 
35 public:
36  EndPoint( function < uint64_t () > role_available_mem );
37  virtual ~EndPoint(){}
38 
39  // real memory usage
40  virtual uint64_t current_mem() {
41  return inq_.current_mem() +
42  outq_.current_mem();
43  }
44 
45  WUQueue & inq() { return inq_; }
46  WUQueue & outq() { return outq_; }
47 
48  uint64_t max_outgoing_wu_mem() {
49  // for now, return whole queue size
50  return outq_.current_mem();
51  }
52 
53  // MPI derived class uses these
54  // this is easier than doing static casts to use MPI_EndPoint fxns
55  // non-void functions made pure virtual to avoid compiler warnings ~ Labonte
56  virtual void check_and_act_status_request( function< void ( StatusResponse & , int ) > /*functor*/ ) {}
57  virtual void check_and_act_clearcommand() {}
58  virtual void cleanup_reqs() {}
59  virtual bool has_open_status( int /*rank*/ ) = 0;
60  virtual void send_status_request( int /*rank*/ ){}
61  virtual void listen_wu_sendrecv( StatusResponse & /*r*/, int /*requesting_node*/ ){}
62  virtual bool initiate_wu_sendrecv( StatusResponse & /*r*/ ) = 0;
63  virtual void act_on_status_response( function<bool ( StatusResponse & r )> /*functor*/ ) {}
64 
65 protected:
66 
69 
70  function< uint64_t () > role_available_mem_;
71 
72 };
73 
75  int rank; // rank of node responding to statusrequest
76  uint64_t incoming_allocated; // how much memory is allocated for incoming wu
77  uint64_t outq_current_mem; // how much memory outgoing queue is using
78 #ifdef USEBOOSTSERIALIZE
79  template<class Archive>
80  void serialize(Archive & ar, const unsigned int version) {
81  ar & rank;
82  ar & incoming_allocated;
83  ar & outq_current_mem;
84  }
85 #endif
86 };
87 
88 struct StatusRequest {
89  int rank; // rank of node sending statusrequest
90  uint64_t max_outgoing_wu_mem; // the maximum amount of memory the outgoing wus will have
91 #ifdef USEBOOSTSERIALIZE
92  template<class Archive>
93  void serialize(Archive & ar, const unsigned int version) {
94  ar & rank;
95  ar & max_outgoing_wu_mem;
96  }
97 #endif
98 };
99 
100 } // wum2
101 } // protocols
102 
103 #endif