Rosetta 3.5
Main Page
Related Pages
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Pages
src
protocols
jd2
MpiFileBuffer.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
// This file is part of the Rosetta software suite and is made available under license.
5
// The Rosetta software is developed by the contributing members of the Rosetta Commons consortium.
6
// (C) 199x-2009 Rosetta Commons participating institutions and developers.
7
// For more information, see http://www.rosettacommons.org/.
8
9
/// @file protocols/jd2/MpiFileBuffer.hh
10
/// @brief header file for MPISilentFileJobOutputter class, part of August 2008 job distributor as planned at RosettaCon08
11
/// @detail this outputter will send silentstructs via MPI to dedicated node that will collect all structures
12
/// @author Oliver Lange olange@u.washington.edu
13
14
15
#ifndef INCLUDED_protocols_jd2_MpiFileBuffer_hh
16
#define INCLUDED_protocols_jd2_MpiFileBuffer_hh
17
18
#ifdef USEMPI
19
#include <mpi.h>
20
#endif
21
22
// unit headers
23
#include <
protocols/jd2/MpiFileBuffer.fwd.hh
>
24
// AUTO-REMOVED #include <protocols/jd2/SingleFileBuffer.hh>
25
26
//project headers
27
#include <
core/types.hh
>
28
29
//utility headers
30
// AUTO-REMOVED #include <utility/vector1.hh>
31
//#include <utility/io/mpistream.hh>
32
33
//C++ headers
34
35
// AUTO-REMOVED #include <string>
36
#include <map>
37
#include <list>
38
39
#include <
protocols/jd2/SingleFileBuffer.fwd.hh
>
40
41
42
namespace
protocols {
43
namespace
jd2 {
44
45
class
MpiFileBuffer
{
//this has to be singleton...
46
typedef
std::map< std::string, core::Size >
Filenames
;
47
typedef
std::map< int, SingleFileBufferOP >
Buffers
;
48
typedef
std::pair< time_t, int >
TimeStampedChannel
;
49
typedef
std::map< int, time_t >
GarbageList
;
50
public
:
51
MpiFileBuffer
(
core::Size
file_buf_rank_ );
52
virtual
~MpiFileBuffer
();
53
//core::Size receive_line( std::string& line );
54
private
:
55
void
receive_str
(
core::Size
slave,
core::Size
size
,
std::string
& line );
56
void
open_channel
(
core::Size
slave,
std::string
const
&
filename
,
bool
append
,
core::Size
& status );
//status to ret
57
bool
is_open_channel
(
std::string
const
&
filename
);
58
void
store_to_channel
(
core::Size
slave,
core::Size
channel,
std::string
const
& line );
59
60
void
flush_channel
(
core::Size
slave,
core::Size
channel_id );
61
void
close_channel
(
core::Size
slave,
core::Size
channel_id );
62
void
block_file
(
core::Size
slave,
std::string
const
&
filename
);
//don't write to this file, and close-reopen_append streams
63
void
close_file
(
core::Size
channel );
64
bool
remote_close_file
(
std::string
const
&
filename
);
//this file is no longer used... close
65
//helper routine -- call when manually closing file or re-opening channel
66
void
clear_channel_from_garbage_collector
(
core::Size
channel );
67
68
public
:
69
void
release_file
(
std::string
filename
);
70
void
block_file
(
std::string
const
&
filename
);
71
bool
close_file
(
std::string
fname );
72
void
run
();
73
void
stop
();
74
void
set_SlaveCanOpenFile
(
bool
setting =
true
) {
75
bSlaveCanOpenFile_
= setting ;
76
}
77
void
garbage_collection
();
78
79
protected
:
80
virtual
SingleFileBufferOP
generate_new_channel
(
std::string
const
&
filename
,
core::Size
channel,
bool
append
,
core::Size
& status ) = 0;
81
private
:
82
core::Size
buffer_rank_
;
83
core::Size
my_rank_
;
84
Filenames
open_files_
;
85
Buffers
open_buffers_
;
86
core::Size
last_channel_
;
87
88
//if false slaves can only connect to already opened files.
89
// dormant files will never be closed...
90
bool
bSlaveCanOpenFile_
;
91
bool
bKeepFilesAlive_
;
//don't close files when no slaves want to write... probably speed up because not always reading from start
92
time_t
seconds_to_keep_files_alive_
;
93
bool
bStop_
;
94
GarbageList
garbage_collector_
;
95
time_t
last_garbage_collection_
;
96
std::list< std::string >
blocked_files_
;
97
};
98
99
100
class
WriteOut_MpiFileBuffer
:
public
MpiFileBuffer
{
101
public
:
102
WriteOut_MpiFileBuffer
(
core::Size
rank ) :
MpiFileBuffer
( rank ) { };
103
protected
:
104
virtual
SingleFileBufferOP
generate_new_channel
(
std::string
const
&
filename
,
core::Size
channel,
bool
append
,
core::Size
&status );
105
};
106
107
class
DebugOut_MpiFileBuffer
:
public
MpiFileBuffer
{
108
public
:
109
DebugOut_MpiFileBuffer
(
core::Size
rank ) :
MpiFileBuffer
( rank ) { };
110
protected
:
111
virtual
SingleFileBufferOP
generate_new_channel
(
std::string
const
&
filename
,
core::Size
channel,
bool
append
,
core::Size
&status );
112
};
113
114
}
115
}
116
117
#endif
Generated on Sat Jun 1 2013 11:54:55 for Rosetta 3.5 by
1.8.4