1+ #include < errno.h>
2+ #include < signal.h>
13
24#include < mpi.h>
3- #include " main-all .hh"
5+ #include < fildesh/string .hh>
46
5- #include < errno.h >
7+ #include " main-all.hh "
68#include " mpidissem.hh"
79
810#include " namespace.hh"
@@ -50,7 +52,7 @@ handle_dissem_msg(MpiDissem::Tag tag,
5052}
5153
5254static
53- Bool
55+ bool
5456done_ck (void * dat)
5557{
5658 Table<uint> msg;
@@ -85,12 +87,10 @@ stabilization_search_init
8587 (SynthesisCtx& synctx,
8688 Xn::Sys& sys,
8789 LgTable<Xn::Sys>& systems,
88- lace::ofstream& log_ofile,
8990 AddConvergenceOpt& opt,
9091 const ProtoconFileOpt& infile_opt,
9192 const ProtoconOpt& exec_opt,
92- Table< Table<uint> >& act_layers
93- );
93+ Table< Table<uint> >& act_layers);
9494
9595static
9696 int
@@ -120,7 +120,6 @@ stabilization_search(vector<uint>& ret_actions,
120120
121121 DeclLegit ( good );
122122 AddConvergenceOpt opt (global_opt);
123- lace::ofstream log_ofile;
124123
125124 opt.sys_pcidx = PcIdx;
126125 opt.sys_npcs = NPcs;
@@ -129,12 +128,13 @@ stabilization_search(vector<uint>& ret_actions,
129128 LgTable<Xn::Sys> systems;
130129 SynthesisCtx synctx ( PcIdx, NPcs );
131130 synctx.conflicts = conflicts;
131+ std::ostream& log_out = synctx.log ;
132132
133133 Table< Table<uint> > act_layers;
134134
135135 DoLegitLine ( " Could not initialize." )
136136 stabilization_search_init
137- (synctx, sys, systems, log_ofile, opt, infile_opt, exec_opt, act_layers);
137+ (synctx, sys, systems, opt, infile_opt, exec_opt, act_layers);
138138
139139 PartialSynthesis& synlvl = synctx.base_partial ;
140140 synctx.done_ck_fn = done_ck;
@@ -147,7 +147,7 @@ stabilization_search(vector<uint>& ret_actions,
147147
148148 if (exec_opt.task == ProtoconOpt::VerifyTask)
149149 {
150- for (uint i = PcIdx; i < exec_opt.xfilepaths .sz (); i += NPcs) {
150+ for (uint i = PcIdx; i < exec_opt.xfilepaths .size (); i += NPcs) {
151151 if (synctx.done_ck ()) break ;
152152 multi_verify_stabilization
153153 (i, synctx, ret_actions,
@@ -160,7 +160,7 @@ stabilization_search(vector<uint>& ret_actions,
160160 for (uint conflict_idx = PcIdx; conflict_idx < flat_conflicts.sz (); conflict_idx += NPcs) {
161161 uint old_sz = flat_conflicts[conflict_idx].sz ();
162162 if (!synctx.done_ck () && old_sz > 1 ) {
163- *opt. log
163+ log_out
164164 << " pcidx:" << PcIdx
165165 << " conflict:" << conflict_idx << " /" << flat_conflicts.sz ()
166166 << " sz:" << old_sz
@@ -169,7 +169,7 @@ stabilization_search(vector<uint>& ret_actions,
169169 uint new_sz =
170170 synlvl.add_small_conflict_set (flat_conflicts[conflict_idx]);
171171
172- *opt. log
172+ log_out
173173 << " DONE: pcidx:" << PcIdx
174174 << " conflict:" << conflict_idx << " /" << flat_conflicts.sz ()
175175 << " old_sz:" << old_sz << " new_sz:" << new_sz
@@ -222,7 +222,7 @@ stabilization_search(vector<uint>& ret_actions,
222222 {}
223223 else if (found)
224224 {
225- *opt. log << " SOLUTION FOUND!" << std::endl;
225+ log_out << " SOLUTION FOUND!" << std::endl;
226226 bool count_solution = true ;
227227 if (opt.solution_as_conflict || global_opt.optimize_soln ) {
228228 FlatSet<uint> flat_actions ( actions );
@@ -234,10 +234,12 @@ stabilization_search(vector<uint>& ret_actions,
234234 }
235235 }
236236
237- if (global_opt.try_all && !!exec_opt.ofilepath && count_solution) {
238- lace::ofstream prot_out ((exec_opt.ofilepath + " ." + PcIdx + " ." + trial_idx).c_str ());
237+ if (global_opt.try_all && !exec_opt.ofilepath .empty () && count_solution) {
238+ fildesh::ostringstream oss;
239+ oss << exec_opt.ofilepath << " ." << PcIdx << " ." << trial_idx;
240+ fildesh::ofstream prot_out (oss.c_str ());
239241 oput_protocon_file (prot_out, sys, actions,
240- exec_opt.use_espresso ,
242+ exec_opt.maybe_espresso ,
241243 exec_opt.argline .c_str ());
242244 }
243245
@@ -257,11 +259,11 @@ stabilization_search(vector<uint>& ret_actions,
257259 set_term_flag (1 );
258260 }
259261
260- synctx.conflicts .oput_conflict_sizes (*opt. log );
262+ synctx.conflicts .oput_conflict_sizes (log_out );
261263
262264 for (std::ostream* ofile = &std::cerr;
263265 true ; // See end of loop.
264- ofile = opt. log )
266+ ofile = &log_out )
265267 {
266268 *ofile << " pcidx:" << PcIdx << " trial:" << trial_idx+1 ;
267269
@@ -276,7 +278,7 @@ stabilization_search(vector<uint>& ret_actions,
276278 *ofile << ' \n ' ;
277279 ofile->flush ();
278280
279- if (ofile == opt. log )
281+ if (ofile == &log_out )
280282 break ;
281283 }
282284
@@ -298,10 +300,10 @@ stabilization_search(vector<uint>& ret_actions,
298300
299301 mpi_dissem->finish ();
300302
301- if (!! exec_opt.conflicts_ofilepath ) {
303+ if (!exec_opt.conflicts_ofilepath . empty () ) {
302304 Table<uint> flattest_conflicts;
303- synctx.conflicts .oput_conflict_sizes (*opt. log );
304- opt. log -> flush ();
305+ synctx.conflicts .oput_conflict_sizes (log_out );
306+ log_out. flush ();
305307 if (PcIdx == 0 ) {
306308 synctx.conflicts .flush_new_conflicts ();
307309 for (uint source_idx = 1 ; source_idx < NPcs; ++source_idx) {
@@ -314,12 +316,13 @@ stabilization_search(vector<uint>& ret_actions,
314316 src_and_sz[0 ], MpiTag_Conflict, MPI_COMM_WORLD , &status);
315317 synctx.conflicts .add_conflicts (flattest_conflicts);
316318 synctx.conflicts .flush_new_conflicts ();
317- synctx.conflicts .oput_conflict_sizes (*opt. log );
318- opt. log -> flush ();
319+ synctx.conflicts .oput_conflict_sizes (log_out );
320+ log_out. flush ();
319321 }
320322
321323 synctx.conflicts .trim (global_opt.max_conflict_sz );
322- oput_conflicts (synctx.conflicts , exec_opt.conflicts_ofilepath );
324+ fildesh::ofstream conflict_out (exec_opt.conflicts_ofilepath .c_str ());
325+ conflict_out << synctx.conflicts ;
323326 }
324327 else {
325328 synctx.conflicts .flush_new_conflicts (flattest_conflicts);
@@ -369,7 +372,6 @@ int main(int argc, char** argv)
369372 int argi = 1 ;
370373 DeclLegit ( good );
371374 struct timespec begtime, endtime;
372- push_losefn_sysCx ((void (*) ()) MPI_Finalize);
373375 uint PcIdx = 0 ;
374376 uint NPcs = 1 ;
375377 MPI_Comm_rank (MPI_COMM_WORLD , (int *) &PcIdx);
@@ -393,10 +395,10 @@ int main(int argc, char** argv)
393395 stabilization_search (sys.actions , infile_opt, exec_opt, opt, PcIdx, NPcs);
394396 if (found_papc == (int )PcIdx) {
395397 DBog1 (" Solution found! (By PcIdx %u)" , PcIdx);
396- if (!exec_opt.ofilepath .empty_ck ())
398+ if (!exec_opt.ofilepath .empty ())
397399 {
398400 oput_protocon_file (exec_opt.ofilepath , sys,
399- exec_opt.use_espresso ,
401+ exec_opt.maybe_espresso ,
400402 exec_opt.argline .c_str ());
401403 }
402404 else {
@@ -434,7 +436,7 @@ END_NAMESPACE
434436
435437int main (int argc, char ** argv)
436438{
437- MPI_Init (&argc, &argv);
438- return PROTOCON_NAMESPACE::main (argc, argv);
439+ MPI_Init (&argc, &argv);
440+ int exstatus = PROTOCON_NAMESPACE::main (argc, argv);
441+ MPI_Finalize ();
439442}
440-
0 commit comments