14 #define TRDEBUG TR.Debug
40 #include <basic/options/keys/lh.OptionKeys.gen.hh>
41 #include <basic/options/option.hh>
45 #include <basic/Tracer.hh>
47 #include <ObjexxFCL/format.hh>
49 #include <ObjexxFCL/string.functions.hh>
51 #include <numeric/random/random.hh>
53 #ifndef _WIN32 // REQUIRED FOR WINDOWS
56 #include <utility/vector1.hh>
60 using namespace ObjexxFCL;
61 using namespace ObjexxFCL::fmt;
66 using namespace protocols::wum;
68 static basic::Tracer
TR(
"MPI.LHR.Emperor");
70 static numeric::random::RandomGenerator
RG(1248321);
74 MPI_LoopHashRefine_Emperor::set_defaults(){
75 using namespace basic::options;
76 using namespace basic::options::OptionKeys;
78 set_max_lib_size( option[ OptionKeys::lh::max_emperor_lib_size]() );
79 max_emperor_lib_round_ = option[ OptionKeys::lh::max_emperor_lib_round ]();
86 if( mpi_resume() !=
"" ){
87 TR <<
"Resuming job from IDENT: " << mpi_resume() << std::endl;
88 load_state( mpi_resume() );
92 set_mpi_feedback(
"add_n_replace" );
94 TR <<
"STARTLIB: " << std::endl;
99 MPI_LoopHashRefine_Emperor::go()
102 TR <<
"Init Master: " <<
mpi_rank() << std::endl;
105 TR <<
"Emperor Node: Waiting for data ..." << std::endl;
108 TRDEBUG <<
"Emperor: processing msgs.." << std::endl;
109 process_incoming_msgs();
111 TRDEBUG <<
"Emperor: process incoming" << std::endl;
112 process_inbound_wus();
114 TRDEBUG <<
"Emperor: process outbound" << std::endl;
115 process_outbound_wus();
118 process_incoming_msgs(
true );
126 MPI_LoopHashRefine_Emperor::process_inbound_wus(){
127 if( inbound().
size() > 0 ){
128 TR <<
"Processing inbound WUs on emperor .." << std::endl;
131 while( inbound().
size() > 0 )
134 runtime_assert( next_wu );
137 if ( structure_wu.get() == NULL ){
138 TR <<
"Cannot save structural data for WU: " << std::endl;
139 next_wu->print( TR );
145 if ( structure_wu->get_wu_type() ==
"resultpack" ){
146 TR <<
"Emperor: receivd structures: " << decoys.
size() << std::endl;
148 add_structures_to_library( decoys );
150 if ( structure_wu->get_wu_type() ==
"getnewstruct" ){
151 TR <<
"Emperor: received expired structures: " << decoys.
size() << std::endl;
153 if( decoys.
size() > 0 ){
154 add_structures_to_library( decoys );
156 TR <<
"Sending a new random structure to master:" << structure_wu->last_received_from() << std::endl;
158 send_random_library_struct( structure_wu->last_received_from(), (
core::Size) numeric::random::random_range(0,9999) );
159 TR <<
"Done." << std::endl;
162 TR.Error <<
"ERROR: Unknown workunit received. " << std::endl;
174 MPI_LoopHashRefine_Emperor::process_outbound_wus(){
181 using namespace basic::options;
182 using namespace basic::options::OptionKeys;
186 it != new_structs.
end(); ++it )
188 runtime_assert( *it );
193 if( max_emperor_lib_round_ > 0 ){
195 if( structure_round > max_emperor_lib_round_ )
continue;
199 runtime_assert( pss );
201 bool local_result = add_structure_to_library( *pss, add_algorithm );
202 result |= local_result;
206 dump_structures( new_structs,
false );