Skip to content

Commit

Permalink
fixed the progress-display issue for PF
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaskf committed Mar 10, 2024
1 parent 792f030 commit 5598aed
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
22 changes: 14 additions & 8 deletions main/phylotesting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2193,6 +2193,8 @@ void testPartitionModel(Params &params, PhyloSuperTree* in_tree, ModelCheckpoint
}
size_t num_pairs = closest_pairs.size();
size_t compute_pairs = 0;
progress_display progress(num_pairs, "Calculating subsets");
progress.setProgressDisplay(true);

#ifdef _OPENMP
#pragma omp parallel for private(i) schedule(dynamic) if(!params.model_test_and_tree)
Expand Down Expand Up @@ -2278,13 +2280,14 @@ void testPartitionModel(Params &params, PhyloSuperTree* in_tree, ModelCheckpoint
// cout.width(11);
// cout << cur_pair.tree_len << " " << cur_pair.set_name;
if (num_model >= 10) {
double remain_time = max(total_num_model-num_model, (int64_t)0)*(getRealTime()-start_time)/num_model;
if (remain_time < 0.0)
remain_time = 0.0;
double finish_percent = (double) pair * 100.0 / num_pairs;
cout << " Finished subset " << pair << "/" << num_pairs << " " << finish_percent << " percent done";
cout << " " << convert_time(getRealTime()-start_time) << " ("
<< convert_time(remain_time) << " left) \r" << flush;
// double remain_time = max(total_num_model-num_model, (int64_t)0)*(getRealTime()-start_time)/num_model;
// if (remain_time < 0.0)
// remain_time = 0.0;
// double finish_percent = (double) pair * 100.0 / num_pairs;
// cout << " Finished subset " << pair << "/" << num_pairs << " " << finish_percent << " percent done";
// cout << " " << convert_time(getRealTime()-start_time) << " (" << convert_time(remain_time) << " left) \r" << flush;
progress += 1;
// progress.reportProgress(getRealTime(), getCPUTime(), false);
}
// cout << endl;

Expand All @@ -2296,7 +2299,10 @@ void testPartitionModel(Params &params, PhyloSuperTree* in_tree, ModelCheckpoint
}

// clear the message previous on this line
cout << blkStr << "\r" << flush;
// cout << blkStr << "\r" << flush;
progress.done();
progress.hide();
progress.setProgressDisplay(false);

if (better_pairs.size() > 0) {
ModelPairSet compatible_pairs;
Expand Down
5 changes: 3 additions & 2 deletions utils/progress.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,14 @@ void progress_display::reportProgress(double time, double cpu, bool newline) {
}
}

progress_display& progress_display::done() {
progress_display& progress_display::done(bool display) {
#if _OPENMP
#pragma omp critical (io)
#endif
workDone = totalWorkToDo;
isDone = true;
reportProgress(getRealTime(), getCPUTime(), true);
if (display)
reportProgress(getRealTime(), getCPUTime(), true);
return *this;
}

Expand Down
2 changes: 1 addition & 1 deletion utils/progress.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class progress_display {
progress_display& operator = (double workDoneNow);
progress_display& hide ();
progress_display& show ();
progress_display& done ();
progress_display& done (bool display = false);
void reportProgress(double time, double cpu, bool newline);
static void setProgressDisplay(bool displayIt);
static bool getProgressDisplay();
Expand Down

0 comments on commit 5598aed

Please sign in to comment.