void Solver::increment_term_stats(Kind kind) const
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
d_stats->d_terms << kind;
}
void Solver::increment_vars_consts_stats(const Sort& sort, bool is_var) const
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
const TypeNode tn = sort.getTypeNode();
TypeConstant tc = tn.getKind() == cvc5::kind::TYPE_CONSTANT
void Solver::resetStatistics()
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
d_stats.reset(new APIStatistics{
d_slv->getStatisticsRegistry().registerHistogram<TypeConstant>(
*
* Interface to a public class that provides compile-time information
* about the cvc5 library.
+ *
+ * Eventually, the configuration methods will all be migrated to the
+ * cvc5::configuration namespace below. This is cleaner and avoids a gcc/10.1.0
+ * bug. See https://github.com/cvc5/cvc5/pull/7898 for details.
*/
#include "cvc5_public.h"
namespace cvc5 {
+namespace configuration {
+ static constexpr bool isStatisticsBuild()
+ {
+#ifdef CVC5_STATISTICS_ON
+ return true;
+#else
+ return false;
+#endif
+ }
+} // namespace configuration
+
/**
* Represents the (static) configuration of cvc5.
*/
static bool isDebugBuild();
- static constexpr bool isStatisticsBuild()
- {
-#ifdef CVC5_STATISTICS_ON
- return true;
-#else
- return false;
-#endif
- }
-
static bool isTracingBuild();
static bool isMuzzledBuild();
std::cout << std::endl;
print_config_cond("debug code", Configuration::isDebugBuild());
- print_config_cond("statistics", Configuration::isStatisticsBuild());
+ print_config_cond("statistics", configuration::isStatisticsBuild());
print_config_cond("tracing", Configuration::isTracingBuild());
print_config_cond("muzzled", Configuration::isMuzzledBuild());
print_config_cond("assertions", Configuration::isAssertionBuild());
void StatisticsRegistry::storeSnapshot()
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
d_lastSnapshot = std::make_unique<Snapshot>();
for (const auto& s : d_stats)
StatisticBaseValue* StatisticsRegistry::get(const std::string& name) const
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
auto it = d_stats.find(name);
if (it == d_stats.end()) return nullptr;
void StatisticsRegistry::print(std::ostream& os) const
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
for (const auto& s : d_stats)
{
void StatisticsRegistry::printSafe(int fd) const
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
for (const auto& s : d_stats)
{
}
void StatisticsRegistry::printDiff(std::ostream& os) const
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
if (!d_lastSnapshot)
{
template <typename Stat>
Stat registerStat(const std::string& name, bool expert)
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
auto it = d_stats.find(name);
if (it == d_stats.end())
AverageStat& AverageStat::operator<<(double v)
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
d_data->d_sum += v;
d_data->d_count++;
IntStat& IntStat::operator=(int64_t val)
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
d_data->d_value = val;
}
IntStat& IntStat::operator++()
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
d_data->d_value++;
}
IntStat& IntStat::operator++(int)
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
d_data->d_value++;
}
IntStat& IntStat::operator+=(int64_t val)
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
d_data->d_value += val;
}
void IntStat::maxAssign(int64_t val)
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
if (d_data->d_value < val)
{
void IntStat::minAssign(int64_t val)
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
if (d_data->d_value > val)
{
void TimerStat::start()
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
Assert(!d_data->d_running) << "timer is already running";
d_data->d_start = StatisticTimerValue::clock::now();
}
void TimerStat::stop()
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
Assert(d_data->d_running) << "timer is not running";
d_data->d_duration += StatisticTimerValue::clock::now() - d_data->d_start;
}
bool TimerStat::running() const
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
return d_data->d_running;
}
CodeTimer::CodeTimer(TimerStat& timer, bool allow_reentrant)
: d_timer(timer), d_reentrant(false)
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
if (!allow_reentrant || !(d_reentrant = d_timer.running()))
{
}
CodeTimer::~CodeTimer()
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
if (!d_reentrant)
{
/** Add the value `val` to the histogram */
HistogramStat& operator<<(Integral val)
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
d_data->add(val);
}
void set(const TT& t)
{
static_assert(std::is_same_v<T, TT>, "Incorrect type for ReferenceStat");
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
d_data->d_value = &t;
}
/** Commit the value currently pointed to and release it. */
void reset()
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
d_data->commit();
d_data->d_value = nullptr;
/** Copy the current value of the referenced object. */
~ReferenceStat()
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
d_data->commit();
}
/** Reset the reference to point to `t`. */
void set(const T& t)
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
d_data->d_value = &t;
}
/** Copy the current size of the referenced container. */
~SizeStat()
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
d_data->commit();
}
/** Set to `t` */
void set(const T& t)
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
d_data->d_value = t;
}
/** Set to `t` */
ValueStat<T>& operator=(const T& t)
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
set(t);
}
}
T get() const
{
- if constexpr (Configuration::isStatisticsBuild())
+ if constexpr (configuration::isStatisticsBuild())
{
return d_data->d_value;
}