#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()),
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());
}
}
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();
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
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();
// 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
~PortfolioLemmaOutputChannel() {}
- void notifyNewLemma(Expr lemma);
+ void notifyNewLemma(Expr lemma) override;
};/* class PortfolioLemmaOutputChannel */
class PortfolioLemmaInputChannel : public LemmaInputChannel {
~PortfolioLemmaInputChannel() {}
- bool hasNewLemma();
- Expr getNewLemma();
+ bool hasNewLemma() override;
+ Expr getNewLemma() override;
};/* class PortfolioLemmaInputChannel */
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));
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));
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