This PR refactors how the resource manager options are used. It moves options relevant for the resource manager into its own file (making the number of smt options a bit smaller) and uses the Options object directly instead of using the old static accessors.
proof_options.toml
prop_options.toml
quantifiers_options.toml
+ resource_manager_options.toml
sep_options.toml
sets_options.toml
smt_options.toml
bool getStatsEveryQuery() const;
bool getStrictParsing() const;
int getTearDownIncremental() const;
- unsigned long getCumulativeTimeLimit() const;
+ uint64_t getCumulativeTimeLimit() const;
bool getVersion() const;
const std::string& getForceLogicString() const;
int getVerbosity() const;
* Options::wasSetByUser<T> for different option types T.
*/
-#include "options.h"
-
#include <fstream>
#include <ostream>
#include <string>
#include "base/listener.h"
#include "base/modal_exception.h"
+#include "options.h"
#include "options/base_options.h"
#include "options/language.h"
#include "options/main_options.h"
#include "options/printer_modes.h"
#include "options/printer_options.h"
#include "options/quantifiers_options.h"
+#include "options/resource_manager_options.h"
#include "options/smt_options.h"
#include "options/uf_options.h"
return (*this)[options::tearDownIncremental];
}
-unsigned long Options::getCumulativeTimeLimit() const {
+uint64_t Options::getCumulativeTimeLimit() const
+{
return (*this)[options::cumulativeMillisecondLimit];
}
--- /dev/null
+id = "resource_manager"
+name = "Resource Manager options"
+header = "options/resource_manager_options.h"
+
+[[option]]
+ name = "cumulativeMillisecondLimit"
+ smt_name = "tlimit"
+ category = "common"
+ long = "tlimit=MS"
+ type = "uint64_t"
+ help = "set time limit in milliseconds of wall clock time"
+
+[[option]]
+ name = "perCallMillisecondLimit"
+ smt_name = "tlimit-per"
+ category = "common"
+ long = "tlimit-per=MS"
+ type = "uint64_t"
+ help = "set time limit per query in milliseconds"
+
+[[option]]
+ name = "cumulativeResourceLimit"
+ smt_name = "rlimit"
+ category = "common"
+ long = "rlimit=N"
+ type = "uint64_t"
+ help = "set resource limit"
+
+[[option]]
+ name = "perCallResourceLimit"
+ smt_name = "reproducible-resource-limit"
+ category = "common"
+ long = "rlimit-per=N"
+ type = "uint64_t"
+ help = "set resource limit per query"
+
+# --rweight is used to override the default of one particular resource weight.
+# It can be given multiple times to override multiple weights. When options are
+# parsed, the resource manager might now be created yet, and it is not clear
+# how an option handler would access it in a reasonable way. The option handler
+# thus merely puts the data in another option that holds a vector of strings.
+# This other option "resourceWeightHolder" has the sole purpose of storing
+# this data in a way so that the resource manager can access it in its
+# constructor.
+[[option]]
+ category = "expert"
+ long = "rweight=VAL=N"
+ type = "std::string"
+ handler = "setResourceWeight"
+ read_only = true
+ help = "set a single resource weight"
+
+[[option]]
+ name = "resourceWeightHolder"
+ category = "undocumented"
+ type = "std::vector<std::string>"
read_only = true
help = "set the diagnostic output channel of the solver"
-[[option]]
- name = "cumulativeMillisecondLimit"
- smt_name = "tlimit"
- category = "common"
- long = "tlimit=MS"
- type = "uint64_t"
- help = "set time limit in milliseconds of wall clock time"
-
-[[option]]
- name = "perCallMillisecondLimit"
- smt_name = "tlimit-per"
- category = "common"
- long = "tlimit-per=MS"
- type = "uint64_t"
- help = "set time limit per query in milliseconds"
-
-[[option]]
- name = "cumulativeResourceLimit"
- smt_name = "rlimit"
- category = "common"
- long = "rlimit=N"
- type = "uint64_t"
- help = "set resource limit"
-
-[[option]]
- name = "perCallResourceLimit"
- smt_name = "reproducible-resource-limit"
- category = "common"
- long = "rlimit-per=N"
- type = "uint64_t"
- help = "set resource limit per query"
-
-# --rweight is used to override the default of one particular resource weight.
-# It can be given multiple times to override multiple weights. When options are
-# parsed, the resource manager might now be created yet, and it is not clear
-# how an option handler would access it in a reasonable way. The option handler
-# thus merely puts the data in another option that holds a vector of strings.
-# This other option "resourceWeightHolder" has the sole purpose of storing
-# this data in a way so that the resource manager can access it in its
-# constructor.
-[[option]]
- smt_name = "resourceWeight"
- category = "expert"
- long = "rweight=VAL=N"
- type = "std::string"
- handler = "setResourceWeight"
- read_only = true
- help = "set a single resource weight"
-
-[[option]]
- name = "resourceWeightHolder"
- category = "undocumented"
- type = "std::vector<std::string>"
-
[[option]]
name = "forceNoLimitCpuWhileDump"
category = "regular"
read_only = true
help = "Cross-theory rewrites"
-
[[option]]
name = "solveBVAsInt"
category = "undocumented"
#include "options/option_exception.h"
#include "options/printer_options.h"
#include "options/proof_options.h"
+#include "options/resource_manager_options.h"
#include "options/smt_options.h"
#include "options/theory_options.h"
#include "printer/printer.h"
#include "base/output.h"
#include "options/option_exception.h"
#include "options/options.h"
-#include "options/smt_options.h"
+#include "options/resource_manager_options.h"
#include "util/statistics_registry.h"
using namespace std;
/*---------------------------------------------------------------------------*/
-ResourceManager::ResourceManager(StatisticsRegistry& stats, Options& options)
- : d_perCallTimer(),
+ResourceManager::ResourceManager(StatisticsRegistry& stats,
+ const Options& options)
+ : d_options(options),
+ d_perCallTimer(),
d_cumulativeTimeUsed(0),
d_cumulativeResourceUsed(0),
d_thisCallResourceUsed(0),
d_infidWeights.fill(1);
d_resourceWeights.fill(1);
- for (const auto& opt :
- options[cvc5::options::resourceWeightHolder__option_t()])
+ for (const auto& opt : d_options[options::resourceWeightHolder])
{
std::string name;
uint64_t weight;
uint64_t ResourceManager::getResourceRemaining() const
{
- if (options::cumulativeResourceLimit() <= d_cumulativeResourceUsed) return 0;
- return options::cumulativeResourceLimit() - d_cumulativeResourceUsed;
+ if (d_options[options::cumulativeResourceLimit] <= d_cumulativeResourceUsed)
+ return 0;
+ return d_options[options::cumulativeResourceLimit] - d_cumulativeResourceUsed;
}
void ResourceManager::spendResource(uint64_t amount)
void ResourceManager::beginCall()
{
- d_perCallTimer.set(options::perCallMillisecondLimit());
+ d_perCallTimer.set(d_options[options::perCallMillisecondLimit]);
d_thisCallResourceUsed = 0;
- if (options::cumulativeResourceLimit() > 0)
+ if (d_options[options::cumulativeResourceLimit] > 0)
{
// Compute remaining cumulative resource budget
d_thisCallResourceBudget =
- options::cumulativeResourceLimit() - d_cumulativeResourceUsed;
+ d_options[options::cumulativeResourceLimit] - d_cumulativeResourceUsed;
}
- if (options::perCallResourceLimit() > 0)
+ if (d_options[options::perCallResourceLimit] > 0)
{
// Check if per-call resource budget is even smaller
- if (options::perCallResourceLimit() < d_thisCallResourceBudget)
+ if (d_options[options::perCallResourceLimit] < d_thisCallResourceBudget)
{
- d_thisCallResourceBudget = options::perCallResourceLimit();
+ d_thisCallResourceBudget = d_options[options::perCallResourceLimit];
}
}
}
bool ResourceManager::limitOn() const
{
- return (options::cumulativeResourceLimit() > 0)
- || (options::perCallMillisecondLimit() > 0)
- || (options::perCallResourceLimit() > 0);
+ return (d_options[options::cumulativeResourceLimit] > 0)
+ || (d_options[options::perCallMillisecondLimit] > 0)
+ || (d_options[options::perCallResourceLimit] > 0);
}
bool ResourceManager::outOfResources() const
{
- if (options::perCallResourceLimit() > 0)
+ if (d_options[options::perCallResourceLimit] > 0)
{
// Check if per-call resources are exhausted
- if (d_thisCallResourceUsed >= options::perCallResourceLimit())
+ if (d_thisCallResourceUsed >= d_options[options::perCallResourceLimit])
{
return true;
}
}
- if (options::cumulativeResourceLimit() > 0)
+ if (d_options[options::cumulativeResourceLimit] > 0)
{
// Check if cumulative resources are exhausted
- if (d_cumulativeResourceUsed >= options::cumulativeResourceLimit())
+ if (d_cumulativeResourceUsed >= d_options[options::cumulativeResourceLimit])
{
return true;
}
bool ResourceManager::outOfTime() const
{
- if (options::perCallMillisecondLimit() == 0) return false;
+ if (d_options[options::perCallMillisecondLimit] == 0) return false;
return d_perCallTimer.expired();
}
{
public:
/** Construct a resource manager. */
- ResourceManager(StatisticsRegistry& statistics_registry, Options& options);
+ ResourceManager(StatisticsRegistry& statistics_registry,
+ const Options& options);
/** Default destructor. */
~ResourceManager();
/** Can not be copied. */
void registerListener(Listener* listener);
private:
+ const Options& d_options;
/** The per-call wall clock timer. */
WallClockTimer d_perCallTimer;