Skip to content

Commit

Permalink
Merge pull request #1199 from veg/develop
Browse files Browse the repository at this point in the history
2.5.17 rc
  • Loading branch information
spond authored Aug 19, 2020
2 parents 50926ae + 329ae58 commit 2c7f0fd
Show file tree
Hide file tree
Showing 8 changed files with 368 additions and 157 deletions.
2 changes: 1 addition & 1 deletion src/core/global_things.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ namespace hy_global {
kErrorStringDatasetRefIndexError ("Dataset index reference out of range"),
kErrorStringMatrixExportError ("Export matrix called with a non-polynomial matrix argument"),
kErrorStringNullOperand ("Attempting to operate on an undefined value; this is probably the result of an earlier 'soft' error condition"),
kHyPhyVersion = _String ("2.5.16"),
kHyPhyVersion = _String ("2.5.17"),

kNoneToken = "None",
kNullToken = "null",
Expand Down
2 changes: 2 additions & 0 deletions src/core/hbl_env.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,8 @@ _String const
// but rather set the last_fileio_exception variable to the value of the exception
status_bar_update_string ("STATUS_BAR_STATUS_STRING"),
// used to set the progress message displayed to the user
tolerate_numerical_errors ("TOLERATE_NUMERICAL_ERRORS"),
// if set, numerical errors that would cause termination are instead trated as warnings
try_numeric_sequence_match ("TRY_NUMERIC_SEQUENCE_MATCH"),
// try matching sequences by 0 (or 1) based index, if matching by name fails
true_const ("TRUE"),
Expand Down
3 changes: 2 additions & 1 deletion src/core/include/hbl_env.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ namespace hy_env {
try_numeric_sequence_match,
short_mpi_return,
kSCFGCorpus,
verbosity_level_string
verbosity_level_string,
tolerate_numerical_errors;

;

Expand Down
100 changes: 91 additions & 9 deletions src/core/likefunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5289,6 +5289,7 @@ long _LikelihoodFunction::Bracket (long index, hyFloat& left, hyFloat& middle
}

while (1) {


while (middle-leftStep <= lowerBound) {
if (verbosity_level > 100) {
Expand Down Expand Up @@ -5330,7 +5331,7 @@ long _LikelihoodFunction::Bracket (long index, hyFloat& left, hyFloat& middle
}
return -2;
} else {
middle=MIN(lowerBound+initialStep*.1,upperBound-rightStep);
middle=lowerBound+2.*leftStep;
first = false;
}
}
Expand Down Expand Up @@ -5374,7 +5375,7 @@ long _LikelihoodFunction::Bracket (long index, hyFloat& left, hyFloat& middle
}
return -2;
} else {
middle=MAX(upperBound-initialStep*.1,lowerBound+leftStep);
middle=MAX(upperBound-2.*rightStep,lowerBound+leftStep);
first = false;
}
}
Expand Down Expand Up @@ -8371,7 +8372,9 @@ hyFloat _LikelihoodFunction::ComputeBlock (long index, hyFloat* siteRes, long c
#endif

hyFloat* thread_results = (hyFloat*) alloca (sizeof(hyFloat)*np);

/*if (likeFuncEvalCallCount==11035) {
printf ("REGULAR overallScalingFactors = %ld\n", overallScalingFactors[0]);
}*/
#ifdef _OPENMP
#if _OPENMP>=201511
#pragma omp parallel for default(shared) schedule(monotonic:guided,1) private(blockID) proc_bind(spread) num_threads (np) if (np>1)
Expand Down Expand Up @@ -8399,6 +8402,42 @@ hyFloat _LikelihoodFunction::ComputeBlock (long index, hyFloat* siteRes, long c
branchIndex,
branchIndex >= 0 ? branchValues->list_data: nil);
}

/*if (likeFuncEvalCallCount == 68700) {

NLToConsole();
BufferToConsole(df->GetColumn (1141));
NLToConsole();
NLToConsole();
BufferToConsole(df->GetColumn (1140));
NLToConsole();
NLToConsole();
BufferToConsole(df->GetColumn (1142));
NLToConsole();

blockID = 0;
long bl = BlockLength (0);
hyFloat * site_results = new hyFloat [bl];
t->ComputeTreeBlockByBranch (*sl,
*branches,
tcc,
df,
inc,
conditionalTerminalNodeStateFlag[index],
ssf,
(_Vector*)conditionalTerminalNodeLikelihoodCaches(index),
overallScalingFactors.list_data[index],
blockID * sitesPerP,
(1+blockID) * sitesPerP,
catID,
site_results,
scc,
branchIndex,
branchIndex >= 0 ? branchValues->list_data: nil);
for (long k = 0; k < bl; k++) {
fprintf (stderr, "REGULAR,%ld,%15.12lg\n", k, site_results[k]);
}
}*/


if (np > 1) {
Expand Down Expand Up @@ -8441,6 +8480,10 @@ hyFloat _LikelihoodFunction::ComputeBlock (long index, hyFloat* siteRes, long c
branchIndex >= 0 ? branchValues->list_data: nil);
}*/


/*if (likeFuncEvalCallCount == 11035) {
printf ("\n\nREGULAR compute result %15.12lg %ld %15.12lg %15.12lg\n", sum, overallScalingFactors.list_data[index], _logLFScaler * overallScalingFactors.list_data[index], sum - _logLFScaler * overallScalingFactors.list_data[index]);
}*/
sum -= _logLFScaler * overallScalingFactors.list_data[index];


Expand All @@ -8460,6 +8503,11 @@ hyFloat _LikelihoodFunction::ComputeBlock (long index, hyFloat* siteRes, long c
/*for (unsigned long p_id = 0; p_id < indexInd.lLength; p_id++) {
printf ("%ld %s = %15.12g\n", p_id, GetIthIndependentVar(p_id)->GetName()->sData, (*parameterValuesAndRanges)(p_id,0));
}*/

/*if (likeFuncEvalCallCount==11035) {
printf ("BEFORE CONSTRUCT CACHE overallScalingFactors = %ld\n", overallScalingFactors[0]);
}*/

#ifdef _OPENMP
#if _OPENMP>=201511
#pragma omp parallel for default(shared) schedule(monotonic:guided,1) private(blockID) proc_bind(spread) num_threads (np) if (np>1)
Expand All @@ -8483,6 +8531,10 @@ hyFloat _LikelihoodFunction::ComputeBlock (long index, hyFloat* siteRes, long c

// check results

/*if (likeFuncEvalCallCount==11035) {
printf ("AFTER CONSTRUCT CACHE overallScalingFactors = %ld\n", overallScalingFactors[0]);
}*/

if (sum > -INFINITY) {
hyFloat checksum = t->ComputeLLWithBranchCache (*sl,
doCachedComp,
Expand All @@ -8493,6 +8545,24 @@ hyFloat _LikelihoodFunction::ComputeBlock (long index, hyFloat* siteRes, long c
catID,
siteRes)
- _logLFScaler * overallScalingFactors.list_data[index];

/*if (likeFuncEvalCallCount == 68700) {
blockID = 0;
long bl = BlockLength (0);
hyFloat * site_results = new hyFloat [bl];
t->ComputeLLWithBranchCache (*sl,
doCachedComp,
bc,
df,
0,
df->GetPatternCount (),
catID,
site_results);
for (long k = 0; k < bl; k++) {
fprintf (stderr, "CACHE,%ld,%15.12lg\n", k, site_results[k]);
}
}*/


if (fabs ((checksum-sum)/sum) > 1.e-10 * df->GetPatternCount ()) {
/*hyFloat check2 = t->ComputeTreeBlockByBranch (*sl,
Expand All @@ -8512,13 +8582,25 @@ hyFloat _LikelihoodFunction::ComputeBlock (long index, hyFloat* siteRes, long c
branchIndex,
branchIndex >= 0 ? branchValues->list_data: nil);*/

_String* node_name = GetIthTree (index)->GetNodeFromFlatIndex(doCachedComp)->GetName();

_TerminateAndDump (_String("Internal error in ComputeBranchCache (branch ") & *node_name &
+ " ) reversible model cached likelihood = "& _String (checksum, "%20.16g") & ", directly computed likelihood = " & _String (sum, "%20.16g") &
+ ". This is most likely because a non-reversible model was incorrectly auto-detected (or specified by the model file in environment variables).");
_String* node_name = GetIthTree (index)->GetNodeFromFlatIndex(doCachedComp)->GetName(),
err_msg = _String("Internal error in ComputeBranchCache (branch ") & *node_name &
+ ", eval #" & likeFuncEvalCallCount &" ) reversible model cached likelihood = "& _String (checksum, "%20.16g") & ", directly computed likelihood = " & _String (sum, "%20.16g") &
+ ". This is most likely because a non-reversible model was incorrectly auto-detected (or specified by the model file in environment variables; for smaller errors, this could be due to numerical instability of calculations for larger alignments).";



if (hy_env::EnvVariableTrue(hy_env::tolerate_numerical_errors)) {
NLToConsole();
BufferToConsole("***WARNING***\n");
StringToConsole(err_msg);
NLToConsole();
} else {
_TerminateAndDump (err_msg);
return -INFINITY;
}

return -INFINITY;


}
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/matrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2035,7 +2035,7 @@ bool _Matrix::IsReversible(_Matrix* freqs) {
}
return true;
}
} catch (const _String reason) {
} catch (const _String& reason) {
ReportWarning (_String ("Reversibility checks failed: ") & reason);
return false;
}
Expand Down
Loading

1 comment on commit 2c7f0fd

@kjlevitz
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Benchmark.js Benchmark'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 2.

Benchmark suite Current: 2c7f0fd Previous: 329ae58 Ratio
BGM.wbf Infinity secs/op (±0.000000%) null secs/op (±0.000000%) Infinity
aBSREL.wbf Infinity secs/op (±0.000000%) null secs/op (±0.000000%) Infinity
aBSREL-MH.wbf Infinity secs/op (±0.000000%) null secs/op (±0.000000%) Infinity

This comment was automatically generated by workflow using github-action-benchmark.

CC: @klevitz

Please sign in to comment.