Skip to content

Commit

Permalink
Fix 'transposition growth' computation for older compilers
Browse files Browse the repository at this point in the history
The issue is probably due to some shenanigans with float-versus-double or converting size_t to
double including some rounding up. Either way, it may introduce undefined behaviour or be
interpreted multiple ways. This leads GCC 10 to unexpectedly abort repeated transposition.
  • Loading branch information
SSoelvsten committed Feb 12, 2024
1 parent 00b4df8 commit 34b13fc
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/adiar/internal/algorithms/quantify.h
Original file line number Diff line number Diff line change
Expand Up @@ -908,11 +908,11 @@ namespace adiar::internal
const size_t dd_size = dd.size();

// Do Partial Quantification as long as...
// 1. ... it stays smaller than 1+epsilon% of the input size.
const size_t transposition__size_threshold = static_cast<size_t>(
std::min<double>(std::numeric_limits<size_t>::max(),
ep.template get<exec_policy::quantify::transposition_growth>()
* static_cast<double>(dd_size)));
// 1. ... it stays smaller than 1+epsilon of the input size.
const size_t transposition__size_threshold =
(std::min(static_cast<double>(std::numeric_limits<size_t>::max() / 2u),
static_cast<double>(ep.template get<exec_policy::quantify::transposition_growth>())
* static_cast<double>(dd_size)));

// 2. ... it has not run more than the maximum number of iterations.
const size_t transposition__max_iterations =
Expand Down

0 comments on commit 34b13fc

Please sign in to comment.