Resource manager will be owned by SmtEngine in the future. This passes the resource manager cached by SmtEnginePrivate to the PropEngine created by SmtEngine instead of using the global pointer. It also makes a few preprocessing passes use the resource manager they already have access to and should use.
namespace CVC4 {
-DecisionEngine::DecisionEngine(context::Context* sc, context::UserContext* uc)
+DecisionEngine::DecisionEngine(context::Context* sc,
+ context::UserContext* uc,
+ ResourceManager* rm)
: d_enabledITEStrategy(nullptr),
d_needIteSkolemMap(),
d_relevancyStrategy(nullptr),
d_satContext(sc),
d_userContext(uc),
d_result(sc, SAT_VALUE_UNKNOWN),
- d_engineState(0)
+ d_engineState(0),
+ d_resourceManager(rm)
{
Trace("decision") << "Creating decision engine" << std::endl;
}
SatLiteral DecisionEngine::getNext(bool& stopSearch)
{
- NodeManager::currentResourceManager()->spendResource(
- ResourceManager::Resource::DecisionStep);
+ d_resourceManager->spendResource(ResourceManager::Resource::DecisionStep);
Assert(d_cnfStream != nullptr)
<< "Forgot to set cnfStream for decision engine?";
Assert(d_satSolver != nullptr)
// init/shutdown state
unsigned d_engineState; // 0=pre-init; 1=init,pre-shutdown; 2=shutdown
-public:
+ /** Pointer to resource manager for associated SmtEngine */
+ ResourceManager* d_resourceManager;
+
+ public:
// Necessary functions
/** Constructor */
- DecisionEngine(context::Context *sc, context::UserContext *uc);
+ DecisionEngine(context::Context* sc,
+ context::UserContext* uc,
+ ResourceManager* rm);
/** Destructor, currently does nothing */
~DecisionEngine() {
PreprocessingPassResult BoolToBV::applyInternal(
AssertionPipeline* assertionsToPreprocess)
{
- NodeManager::currentResourceManager()->spendResource(
- ResourceManager::Resource::PreprocessStep);
+ d_preprocContext->spendResource(ResourceManager::Resource::PreprocessStep);
size_t size = assertionsToPreprocess->size();
PreprocessingPassResult BVToBool::applyInternal(
AssertionPipeline* assertionsToPreprocess)
{
- NodeManager::currentResourceManager()->spendResource(
- ResourceManager::Resource::PreprocessStep);
+ d_preprocContext->spendResource(ResourceManager::Resource::PreprocessStep);
std::vector<Node> new_assertions;
liftBvToBool(assertionsToPreprocess->ref(), new_assertions);
for (unsigned i = 0; i < assertionsToPreprocess->size(); ++i)
d_removable(false) {
}
-TseitinCnfStream::TseitinCnfStream(SatSolver* satSolver, Registrar* registrar,
+TseitinCnfStream::TseitinCnfStream(SatSolver* satSolver,
+ Registrar* registrar,
context::Context* context,
- bool fullLitToNodeMap, std::string name)
- : CnfStream(satSolver, registrar, context, fullLitToNodeMap, name)
+ ResourceManager* rm,
+ bool fullLitToNodeMap,
+ std::string name)
+ : CnfStream(satSolver, registrar, context, fullLitToNodeMap, name),
+ d_resourceManager(rm)
{}
void CnfStream::assertClause(TNode node, SatClause& c) {
<< ", negated = " << (negated ? "true" : "false") << ")" << endl;
if (d_convertAndAssertCounter % ResourceManager::getFrequencyCount() == 0) {
- NodeManager::currentResourceManager()->spendResource(
- ResourceManager::Resource::CnfStep);
+ d_resourceManager->spendResource(ResourceManager::Resource::CnfStep);
d_convertAndAssertCounter = 0;
}
++d_convertAndAssertCounter;
* @param satSolver the sat solver to use
* @param registrar the entity that takes care of pre-registration of Nodes
* @param context the context that the CNF should respect.
+ * @param rm the resource manager of the CNF stream
* @param fullLitToNodeMap maintain a full SAT-literal-to-Node mapping,
* even for non-theory literals
*/
- TseitinCnfStream(SatSolver* satSolver, Registrar* registrar,
- context::Context* context, bool fullLitToNodeMap = false,
+ TseitinCnfStream(SatSolver* satSolver,
+ Registrar* registrar,
+ context::Context* context,
+ ResourceManager* rm,
+ bool fullLitToNodeMap = false,
std::string name = "");
/**
void ensureLiteral(TNode n, bool noPreregistration = false) override;
+ /** Pointer to resource manager for associated SmtEngine */
+ ResourceManager* d_resourceManager;
}; /* class TseitinCnfStream */
} /* CVC4::prop namespace */
PropEngine::PropEngine(TheoryEngine* te,
Context* satContext,
- UserContext* userContext)
+ UserContext* userContext,
+ ResourceManager* rm)
: d_inCheckSat(false),
d_theoryEngine(te),
d_context(satContext),
d_registrar(NULL),
d_cnfStream(NULL),
d_interrupted(false),
- d_resourceManager(NodeManager::currentResourceManager())
+ d_resourceManager(rm)
{
Debug("prop") << "Constructing the PropEngine" << endl;
- d_decisionEngine.reset(new DecisionEngine(satContext, userContext));
+ d_decisionEngine.reset(new DecisionEngine(satContext, userContext, rm));
d_decisionEngine->init(); // enable appropriate strategies
d_satSolver = SatSolverFactory::createDPLLMinisat(smtStatisticsRegistry());
d_registrar = new theory::TheoryRegistrar(d_theoryEngine);
d_cnfStream = new CVC4::prop::TseitinCnfStream(
- d_satSolver, d_registrar, userContext, true);
+ d_satSolver, d_registrar, userContext, rm, true);
d_theoryProxy = new TheoryProxy(
this, d_theoryEngine, d_decisionEngine.get(), d_context, d_cnfStream);
*/
PropEngine(TheoryEngine*,
context::Context* satContext,
- context::UserContext* userContext);
+ context::UserContext* userContext,
+ ResourceManager* rm);
/**
* Destructor.
* are unregistered by the obsolete PropEngine object before registered
* again by the new PropEngine object */
d_propEngine.reset(nullptr);
- d_propEngine.reset(
- new PropEngine(getTheoryEngine(), getContext(), getUserContext()));
+ d_propEngine.reset(new PropEngine(getTheoryEngine(),
+ getContext(),
+ getUserContext(),
+ d_private->getResourceManager()));
Trace("smt-debug") << "Setting up theory engine..." << std::endl;
d_theoryEngine->setPropEngine(getPropEngine());
* statistics are unregistered by the obsolete PropEngine object before
* registered again by the new PropEngine object */
d_propEngine.reset(nullptr);
- d_propEngine.reset(
- new PropEngine(getTheoryEngine(), getContext(), getUserContext()));
+ d_propEngine.reset(new PropEngine(getTheoryEngine(),
+ getContext(),
+ getUserContext(),
+ d_private->getResourceManager()));
d_theoryEngine->setPropEngine(getPropEngine());
}
default: Unreachable() << "Unknown SAT solver type";
}
d_satSolver.reset(solver);
- d_cnfStream.reset(
- new prop::TseitinCnfStream(d_satSolver.get(),
- d_bitblastingRegistrar.get(),
- d_nullContext.get(),
- options::proof(),
- "EagerBitblaster"));
+ ResourceManager* rm = NodeManager::currentResourceManager();
+ d_cnfStream.reset(new prop::TseitinCnfStream(d_satSolver.get(),
+ d_bitblastingRegistrar.get(),
+ d_nullContext.get(),
+ rm,
+ options::proof(),
+ "EagerBitblaster"));
}
EagerBitblaster::~EagerBitblaster() {}
d_satSolver.reset(
prop::SatSolverFactory::createMinisat(c, smtStatisticsRegistry(), name));
- d_cnfStream.reset(
- new prop::TseitinCnfStream(d_satSolver.get(),
- d_nullRegistrar.get(),
- d_nullContext.get(),
- options::proof(),
- "LazyBitblaster"));
+ ResourceManager* rm = NodeManager::currentResourceManager();
+ d_cnfStream.reset(new prop::TseitinCnfStream(d_satSolver.get(),
+ d_nullRegistrar.get(),
+ d_nullContext.get(),
+ rm,
+ options::proof(),
+ "LazyBitblaster"));
d_satSolverNotify.reset(
d_emptyNotify
// recreate sat solver
d_satSolver.reset(
prop::SatSolverFactory::createMinisat(d_ctx, smtStatisticsRegistry()));
+ ResourceManager* rm = NodeManager::currentResourceManager();
d_cnfStream.reset(new prop::TseitinCnfStream(
- d_satSolver.get(), d_nullRegistrar.get(), d_nullContext.get()));
+ d_satSolver.get(), d_nullRegistrar.get(), d_nullContext.get(), rm));
d_satSolverNotify.reset(
d_emptyNotify
? (prop::BVSatSolverNotify*)new MinisatEmptyNotify()
d_satSolver = new FakeSatSolver();
d_cnfContext = new context::Context();
d_cnfRegistrar = new theory::TheoryRegistrar(d_theoryEngine);
+ ResourceManager * rm = d_nodeManager->getResourceManager();
d_cnfStream = new CVC4::prop::TseitinCnfStream(
- d_satSolver, d_cnfRegistrar, d_cnfContext);
+ d_satSolver, d_cnfRegistrar, d_cnfContext, rm);
}
void tearDown() override