Skip to content

Commit 3795a20

Browse files
committed
Fixing sigFPE bug
1 parent b06e291 commit 3795a20

File tree

4 files changed

+12
-18
lines changed

4 files changed

+12
-18
lines changed

src/cl_predictors_abs.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,6 @@ class Solver;
4444

4545
struct ReduceCommonData
4646
{
47-
double safe_div(double a, double b) {
48-
if (b == 0) {
49-
assert(a == 0);
50-
return 0;
51-
}
52-
return a/b;
53-
}
54-
5547
double avg_props;
5648
//double avg_glue; CANNOT COUNT, ternary has no glue!
5749
double avg_uip;

src/constants.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ THE SOFTWARE.
2424

2525
#include <cstdint>
2626
#include <cstdlib>
27-
#include <cstdio>
2827
#include <iostream>
2928
#include <random>
3029
#include <ranges>
30+
#include <cassert>
3131

3232
using std::cerr;
3333
using std::exit;
@@ -244,3 +244,12 @@ inline uint32_t rnd_uint(std::mt19937_64& mtrand, const uint32_t maximum_inclusi
244244
/*cout << "set unsat CL ID here to " << (x) << endl;*/\
245245
/*assert(false);*/\
246246
} while (0)
247+
248+
249+
inline double safe_div(double a, double b) {
250+
if (b == 0) {
251+
assert(a == 0);
252+
return 0;
253+
}
254+
return a/b;
255+
}

src/matrixfinder.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,6 @@ bool MatrixFinder::find_matrices(bool& matrix_created)
185185
return solver->okay();
186186
}
187187

188-
static double safe_div(double a, double b) {
189-
if (b == 0) {
190-
assert(a == 0);
191-
return 0;
192-
}
193-
return a/b;
194-
}
195-
196188
uint32_t MatrixFinder::setup_matrices_attach_remaining_cls() {
197189
if (solver->conf.sampling_vars_set) {
198190
uint32_t size_at_least = (double)solver->conf.sampling_vars.size()*3;

src/oracle_use.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,8 @@ bool Solver::oracle_vivif(int fast, bool& backbone_found) {
278278
<< " T: " << std::setprecision(2) << (end_bin_tme - start_bin_time));
279279

280280
verb_print(1, "[oracle-vivif] cache usefulness: "
281-
<< std::setprecision(0) << std::fixed << (double)oracle.getStats().cache_useful/(double)oracle.getStats().total_cache_lookups*100.0 << "%"
281+
<< std::setprecision(0) << std::fixed <<
282+
safe_div(oracle.getStats().cache_useful, oracle.getStats().total_cache_lookups)*100.0 << "%"
282283
<< std::setprecision(2)
283284
<< " total T: " << std::setprecision(2) << (cpuTime() - start_vivif_time));
284285
return solver->okay();

0 commit comments

Comments
 (0)