Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
WUQueueBuffer.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/WUQueueBuffer.hh
11 /// @brief memory aware structure that links irecv and isend
12 /// with their mpi::request status, so buffers are maintained until messages are sent/recvd
13 /// @author Ken Jung
14 
15 #ifndef INCLUDED_protocols_wum2_WUQueueBuffer_hh
16 #define INCLUDED_protocols_wum2_WUQueueBuffer_hh
17 
18 
19 #ifdef USEBOOSTMPI
20 // this is useless without mpi
21 #include <boost/mpi.hpp>
22 
25 #include <boost/tuple/tuple.hpp>
26 #include <boost/cstdint.hpp>
27 #include <list>
28 #include <vector>
29 
30 namespace protocols {
31 namespace wum2 {
32 
33 class WUQueueBuffer {
34 
35 
36  public:
37  typedef boost::tuple< boost::uint64_t, boost::mpi::request, boost::shared_ptr< std::vector< WorkUnitSP > > > mem_req_data_tuple;
38  typedef std::list< mem_req_data_tuple>::reverse_iterator riterator;
39  typedef std::list< mem_req_data_tuple>::iterator iterator;
40 
41  WUQueueBuffer():current_mem_(0){}
42  ~WUQueueBuffer(){}
43 
44  boost::uint64_t current_mem() { return current_mem_; }
45 
46  // allocates an entry in buffer for delayed linking to a mpi::request
47  // size isn't used in actually allocating the buffer, but used to track memory usage
48  // if buffer isn't linked to real mpi request, can have psuedo memory leak
49  riterator allocate_buffer( boost::uint64_t size );
50 
51  // pops off all requests that are completed
52  std::vector< WorkUnitSP > cleanup_reqs();
53 
54  private:
55  boost::uint64_t current_mem_;
56  std::list< mem_req_data_tuple> buffer_;
57 };
58 
59 }
60 }
61 
62 #endif
63 #endif
64