Fix portfolio command executor for changes from #2240. (#2294)
authorAina Niemetz <aina.niemetz@gmail.com>
Fri, 10 Aug 2018 23:45:27 +0000 (16:45 -0700)
committerGitHub <noreply@github.com>
Fri, 10 Aug 2018 23:45:27 +0000 (16:45 -0700)
src/main/command_executor_portfolio.cpp
src/main/command_executor_portfolio.h
src/main/driver_unified.cpp
src/main/portfolio_util.h
src/util/channel.h

index 0755311f3ff24e5c94f1a652564b4160e4f7915e..ba75d5ff7e230c6bbd2c3c7954044abeded9d8f1 100644 (file)
@@ -27,6 +27,7 @@
 #include <boost/thread/condition.hpp>
 #include <string>
 
+#include "api/cvc4cpp.h"
 #include "cvc4autoconfig.h"
 #include "expr/pickler.h"
 #include "main/main.h"
 #include "options/set_language.h"
 #include "smt/command.h"
 
-
 using namespace std;
 
 namespace CVC4 {
 namespace main {
 
-CommandExecutorPortfolio::CommandExecutorPortfolio(
-    ExprManager &exprMgr, Options &options, OptionsList& tOpts)
-    : CommandExecutor(exprMgr, options),
+CommandExecutorPortfolio::CommandExecutorPortfolio(api::Solver* solver,
+                                                   Options& options,
+                                                   OptionsList& tOpts)
+    : CommandExecutor(solver, options),
       d_numThreads(options.getThreads()),
       d_smts(),
       d_seq(new CommandSequence()),
@@ -64,19 +65,17 @@ CommandExecutorPortfolio::CommandExecutorPortfolio(
   d_stats.registerStat(&d_statWaitTime);
 
   /* Duplication, individualization */
-  d_exprMgrs.push_back(&d_exprMgr);
-  for(unsigned i = 1; i < d_numThreads; ++i) {
-    d_exprMgrs.push_back(new ExprManager(d_threadOptions[i]));
-  }
-
-  // Create the SmtEngine(s)
-  d_smts.push_back(d_smtEngine);
-  for(unsigned i = 1; i < d_numThreads; ++i) {
-    d_smts.push_back(new SmtEngine(d_exprMgrs[i]));
-  }
-
+  d_solvers.push_back(d_solver);
+  d_exprMgrs.push_back(d_solver->getExprManager());
+  d_smts.push_back(d_solver->getSmtEngine());
   assert(d_vmaps.size() == 0);
-  for(unsigned i = 0; i < d_numThreads; ++i) {
+  d_vmaps.push_back(new ExprManagerMapCollection());
+  for (unsigned i = 1; i < d_numThreads; ++i)
+  {
+    api::Solver* solver = new api::Solver(&d_threadOptions[i]);
+    d_solvers.push_back(solver);
+    d_exprMgrs.push_back(solver->getExprManager());
+    d_smts.push_back(solver->getSmtEngine());
     d_vmaps.push_back(new ExprManagerMapCollection());
   }
 }
@@ -87,12 +86,12 @@ CommandExecutorPortfolio::~CommandExecutorPortfolio()
   delete d_seq;
 
   assert(d_smts.size() == d_numThreads);
-  for(unsigned i = 1; i < d_numThreads; ++i) {
+  for (unsigned i = 1; i < d_numThreads; ++i)
+  {
     // the 0-th one is responsibility of parent class
-
-    delete d_smts[i];
-    delete d_exprMgrs[i];
+    delete d_solvers[i];
   }
+  d_solvers.clear();
   d_exprMgrs.clear();
   d_smts.clear();
 
index 39c577087e075f8a4d2f278ef41152465f58b392..fe4d356408fbe29a6d85a18a1def21031d5f51e6 100644 (file)
@@ -30,11 +30,16 @@ namespace CVC4 {
 
 class CommandSequence;
 
+namespace api {
+class Solver;
+}
+
 namespace main {
 
 class CommandExecutorPortfolio : public CommandExecutor {
+  // Solvers are created/deleted during initialization
+  std::vector<api::Solver*> d_solvers;
 
-  // These shall be created/deleted during initialization
   std::vector<ExprManager*> d_exprMgrs;
   const unsigned d_numThreads;   // Currently const, but designed so it is
                                  // not too hard to support this changing
@@ -55,18 +60,19 @@ class CommandExecutorPortfolio : public CommandExecutor {
   TimerStat d_statWaitTime;
 
 public:
 CommandExecutorPortfolio(ExprManager &exprMgr,
-                           Options &options,
-                           OptionsList& tOpts);
CommandExecutorPortfolio(api::Solver* solver,
+                          Options& options,
+                          OptionsList& tOpts);
 
 ~CommandExecutorPortfolio();
+ ~CommandExecutorPortfolio();
 
 std::string getSmtEngineStatus();
+ std::string getSmtEngineStatus();
 
 void flushStatistics(std::ostream& out) const;
void flushStatistics(std::ostream& out) const override;
 
 protected:
-  bool doCommandSingleton(Command* cmd);
+ bool doCommandSingleton(Command* cmd) override;
+
 private:
   CommandExecutorPortfolio();
   void lemmaSharingInit();
index c29212c4f6ee519bbe66ee13b525afb30e6b31da..390d83ebae2d047122b4a46d13649b99cb19fc35 100644 (file)
@@ -233,12 +233,12 @@ int runCvc4(int argc, char* argv[], Options& opts) {
   // pick appropriate one
   if (useParallelExecutor)
   {
-    solver.reset(&threadOpts[0]);
+    solver.reset(new api::Solver(&threadOpts[0]));
     pExecutor = new CommandExecutorPortfolio(solver.get(), opts, threadOpts);
   }
   else
   {
-    solver.reset(&opts);
+    solver.reset(new api::Solver(&opts));
     pExecutor = new CommandExecutor(solver.get(), opts);
   }
 # endif
index 6ebd97d3d5d6f2bccf4fcd77d4e5cebb7b164817..5b2152728281cd3e6682b15f7f13874c79b97e16 100644 (file)
@@ -49,7 +49,7 @@ public:
 
   ~PortfolioLemmaOutputChannel() {}
 
-  void notifyNewLemma(Expr lemma);
+  void notifyNewLemma(Expr lemma) override;
 };/* class PortfolioLemmaOutputChannel */
 
 class PortfolioLemmaInputChannel : public LemmaInputChannel {
@@ -67,8 +67,8 @@ public:
 
   ~PortfolioLemmaInputChannel() {}
 
-  bool hasNewLemma();
-  Expr getNewLemma();
+  bool hasNewLemma() override;
+  Expr getNewLemma() override;
 
 };/* class PortfolioLemmaInputChannel */
 
index 5a561041080cf09c9bb2bad7adceeed5ca245651..8587800c1096773c8e9998a1edbfee3cff313181 100644 (file)
@@ -74,8 +74,10 @@ public:
 
   explicit SynchronizedSharedChannel(size_type capacity) : m_unread(0), m_container(capacity) {}
 
-  bool push(param_type item){
-  // param_type represents the "best" way to pass a parameter of type value_type to a method
+  bool push(param_type item) override
+  {
+    // param_type represents the "best" way to pass a parameter of type
+    // value_type to a method
 
     boost::mutex::scoped_lock lock(m_mutex);
     m_not_full.wait(lock, boost::bind(&SynchronizedSharedChannel<value_type>::is_not_full, this));
@@ -86,7 +88,8 @@ public:
     return true;
   }//function definitions need to be moved to cpp
 
-  value_type pop(){
+  value_type pop() override
+  {
     value_type ret;
     boost::mutex::scoped_lock lock(m_mutex);
     m_not_empty.wait(lock, boost::bind(&SynchronizedSharedChannel<value_type>::is_not_empty, this));
@@ -96,11 +99,10 @@ public:
     return ret;
   }
 
+  bool empty() override { return not is_not_empty(); }
+  bool full() override { return not is_not_full(); }
 
-  bool empty() { return not is_not_empty(); }
-  bool full() { return not is_not_full(); }
-
-private:
+ private:
   SynchronizedSharedChannel(const SynchronizedSharedChannel&);              // Disabled copy constructor
   SynchronizedSharedChannel& operator = (const SynchronizedSharedChannel&); // Disabled assign operator