Skip to content

Commit

Permalink
check that enough alignment patterns were assigned to each thread, an…
Browse files Browse the repository at this point in the history
…d issue a warning/error otherwise
  • Loading branch information
amkozlov committed Nov 28, 2017
1 parent 04b7f61 commit 8a3d6af
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/PartitionAssignment.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ struct PartitionAssignmentStats
{
PartitionAssignmentStats(const PartitionAssignmentList& part_assign)
{
total_sites = 0;
max_thread_sites = max_thread_parts = 0;
min_thread_sites = min_thread_parts = std::numeric_limits<size_t>::max();
for (auto pa: part_assign)
Expand All @@ -66,9 +67,11 @@ struct PartitionAssignmentStats
min_thread_parts = std::min(min_thread_parts, pa.num_parts());
max_thread_sites = std::max(max_thread_sites, pa.weight());
max_thread_parts = std::max(max_thread_parts, pa.num_parts());
total_sites += pa.weight();
}
}

size_t total_sites;
size_t min_thread_sites;
size_t min_thread_parts;
size_t max_thread_sites;
Expand Down
24 changes: 24 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,30 @@ void master_main(RaxmlInstance& instance, CheckpointManager& cm)
/* run load balancing algorithm */
balance_load(instance);

/* check that we have enough patterns per thread */
if (ParallelContext::master_rank() && ParallelContext::num_procs() > 1)
{
PartitionAssignmentStats stats(instance.proc_part_assign);
const size_t min_thread_pats = ParallelContext::num_threads() > 8 ? 500 : 150;
if (stats.min_thread_sites < min_thread_pats)
{
size_t opt_threads = trunc(stats.total_sites / (min_thread_pats*2)) + 1;
LOG_WARN << endl;
LOG_WARN << "WARNING: You are using too many threads (" << ParallelContext::num_threads() <<
") for your alignment with " << stats.total_sites << " unique patterns." << endl;
LOG_WARN << "NOTE: Please consider using " << opt_threads << " threads ('--threads " <<
opt_threads << "' option) for the optimal performance." << endl;
LOG_WARN << "NOTE: As a general rule-of-thumb, please assign at least 200-1000 "
"alignment patterns per thread." << endl;

if (stats.min_thread_sites < 50 && !instance.opts.force_mode)
throw runtime_error("Too few patterns per thread! "
"RAxML-NG will terminate now to avoid wasting resources.\n"
"NOTE: Please reduce the number of threads (see guidelines above).\n"
"NOTE: This check can be disabled with the '--force' option.");
}
}

/* generate bootstrap replicates */
generate_bootstraps(instance, cm.checkpoint());

Expand Down

0 comments on commit 8a3d6af

Please sign in to comment.