Skip to content

Commit c48a972

Browse files
Count number of solver calls in propt and prop_convt
Useful for logging statistics
1 parent d2f0dbe commit c48a972

File tree

6 files changed

+28
-0
lines changed

6 files changed

+28
-0
lines changed

src/solvers/prop/prop.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,11 @@ bvt propt::new_variables(std::size_t width)
2828

2929
propt::resultt propt::prop_solve()
3030
{
31+
++number_of_solver_calls;
3132
return do_prop_solve();
3233
}
34+
35+
std::size_t propt::get_number_of_solver_calls() const
36+
{
37+
return number_of_solver_calls;
38+
}

src/solvers/prop/prop.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,16 @@ class propt
117117
log.warning() << "CPU limit ignored (not implemented)" << messaget::eom;
118118
}
119119

120+
std::size_t get_number_of_solver_calls() const;
121+
120122
protected:
121123
virtual resultt do_prop_solve() = 0;
122124

123125
// to avoid a temporary for lcnf(...)
124126
bvt lcnf_bv;
125127

126128
messaget log;
129+
std::size_t number_of_solver_calls = 0;
127130
};
128131

129132
#endif // CPROVER_SOLVERS_PROP_PROP_H

src/solvers/prop/prop_conv.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,3 +512,8 @@ void prop_conv_solvert::print_assignment(std::ostream &out) const
512512
for(const auto &symbol : symbols)
513513
out << symbol.first << " = " << prop.l_get(symbol.second) << '\n';
514514
}
515+
516+
std::size_t prop_conv_solvert::get_number_of_solver_calls() const
517+
{
518+
return prop.get_number_of_solver_calls();
519+
}

src/solvers/prop/prop_conv.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ class prop_convt:public decision_proceduret
5555

5656
// Resource limits:
5757
virtual void set_time_limit_seconds(uint32_t) {}
58+
59+
/// Returns the number of incremental solver calls
60+
virtual std::size_t get_number_of_solver_calls() const = 0;
5861
};
5962

6063
//
@@ -122,6 +125,8 @@ class prop_conv_solvert:public prop_convt
122125
prop.set_time_limit_seconds(lim);
123126
}
124127

128+
std::size_t get_number_of_solver_calls() const override;
129+
125130
protected:
126131
virtual void post_process();
127132

src/solvers/smt2/smt2_conv.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4831,3 +4831,8 @@ exprt smt2_convt::substitute_let(
48314831

48324832
return expr;
48334833
}
4834+
4835+
std::size_t smt2_convt::get_number_of_solver_calls() const
4836+
{
4837+
return number_of_solver_calls;
4838+
}

src/solvers/smt2/smt2_conv.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ class smt2_convt:public prop_convt
135135
void convert_type(const typet &);
136136
void convert_literal(const literalt);
137137

138+
std::size_t get_number_of_solver_calls() const override;
139+
138140
protected:
139141
const namespacet &ns;
140142
std::ostream &out;
@@ -144,6 +146,8 @@ class smt2_convt:public prop_convt
144146
bvt assumptions;
145147
boolbv_widtht boolbv_width;
146148

149+
std::size_t number_of_solver_calls = 0;
150+
147151
void write_header();
148152
void write_footer(std::ostream &);
149153

0 commit comments

Comments
 (0)