}
Command* DatatypeDeclarationCommand::exportTo(ExprManager* exprManager, ExprManagerMapCollection& variableMap) {
- throw ExportToUnsupportedException();
- // vector<DatatypeType> params;
- // transform(d_datatypes.begin(), d_datatypes.end(), back_inserter(params),
- // ExportTransformer(exprManager, variableMap));
- // DatatypeDeclarationCommand* c = new DatatypeDeclarationCommand(params);
- // return c;
+ throw ExportUnsupportedException
+ ("export of DatatypeDeclarationCommand unsupported");
}
Command* DatatypeDeclarationCommand::clone() const {
std::ostream& operator<<(std::ostream&, const CommandStatus&) throw() CVC4_PUBLIC;
std::ostream& operator<<(std::ostream&, const CommandStatus*) throw() CVC4_PUBLIC;
-class CVC4_PUBLIC ExportToUnsupportedException : public Exception {
-public:
- ExportToUnsupportedException() throw() :
- Exception("exportTo unsupported for command") {
- }
-};/* class ExportToUnsupportedException */
-
/** The status an SMT benchmark can have */
enum BenchmarkStatus {
/** Benchmark is satisfiable */
TypeNode exportTypeInternal(TypeNode n, NodeManager* from, NodeManager* to, ExprManagerMapCollection& vmap) {
Debug("export") << "type: " << n << std::endl;
- Assert(n.getKind() == kind::SORT_TYPE ||
- n.getMetaKind() != kind::metakind::PARAMETERIZED,
- "PARAMETERIZED-kinded types (other than SORT_KIND) not supported");
+ if(theory::kindToTheoryId(n.getKind()) == theory::THEORY_DATATYPES) {
+ throw ExportUnsupportedException
+ ("export of types belonging to theory of DATATYPES kinds unsupported");
+ }
+ if(n.getMetaKind() == kind::metakind::PARAMETERIZED &&
+ n.getKind() != kind::SORT_TYPE) {
+ throw ExportUnsupportedException
+ ("export of PARAMETERIZED-kinded types (other than SORT_KIND) not supported");
+ }
if(n.getKind() == kind::TYPE_CONSTANT) {
return to->mkTypeConst(n.getConst<TypeConstant>());
} else if(n.getKind() == kind::BITVECTOR_TYPE) {
return to->mkBitVectorType(n.getConst<BitVectorSize>());
+ } else if(n.getKind() == kind::SUBRANGE_TYPE) {
+ return to->mkSubrangeType(n.getSubrangeBounds());
}
Type from_t = from->toType(n);
Type& to_t = vmap.d_typeMap[from_t];
static Node exportConstant(TNode n, NodeManager* to);
Node exportInternal(TNode n, ExprManager* from, ExprManager* to, ExprManagerMapCollection& vmap) {
- if(n.isConst()) {
+ if(theory::kindToTheoryId(n.getKind()) == theory::THEORY_DATATYPES) {
+ throw ExportUnsupportedException
+ ("export of node belonging to theory of DATATYPES kinds unsupported");
+ }
+
+ if(n.getMetaKind() == metakind::CONSTANT) {
return exportConstant(n, NodeManager::fromExprManager(to));
} else if(n.isVar()) {
Expr from_e(from, new Node(n));
// a check that mkVar isn't called internally
NodeManagerScope nullScope(NULL);
- if(n.getKind() == kind::BOUND_VAR_LIST) {
+ if(n.getKind() == kind::BOUND_VAR_LIST || n.getKind() == kind::BOUND_VARIABLE) {
to_e = to->mkBoundVar(name, type);// FIXME thread safety
} else if(n.getKind() == kind::VARIABLE) {
to_e = to->mkVar(name, type);// FIXME thread safety
friend class ExprManager;
};/* class TypeCheckingException */
+/**
+ * Exception thrown in case of failure to export
+ */
+class CVC4_PUBLIC ExportUnsupportedException : public Exception {
+public:
+ ExportUnsupportedException() throw():
+ Exception("export unsupported") {
+ }
+ ExportUnsupportedException(const char* msg) throw():
+ Exception(msg) {
+ }
+};/* class DatatypeExportUnsupportedException */
+
std::ostream& operator<<(std::ostream& out,
const TypeCheckingException& e) CVC4_PUBLIC;
}
void Pickler::toPickle(Expr e, Pickle& p)
- throw(AssertionException, PicklingException) {
+ throw(PicklingException) {
Assert(NodeManager::fromExprManager(e.getExprManager()) == d_private->d_nm);
Assert(d_private->atDefaultState());
delete d_data;
}
+uint64_t MapPickler::variableFromMap(uint64_t x) const
+{
+ VarMap::const_iterator i = d_fromMap.find(x);
+ Assert(i != d_fromMap.end());
+ return i->second;
+}
+
}/* CVC4::expr::pickle namespace */
}/* CVC4::expr namespace */
}/* CVC4 namespace */
protected:
virtual uint64_t variableToMap(uint64_t x) const
- throw(AssertionException, PicklingException) {
+ throw(PicklingException) {
return x;
}
virtual uint64_t variableFromMap(uint64_t x) const {
*
* @return the pickle, which should be dispose()'d when you're done with it
*/
- void toPickle(Expr e, Pickle& p) throw(AssertionException, PicklingException);
+ void toPickle(Expr e, Pickle& p) throw(PicklingException);
/**
* Constructs a node from a Pickle.
protected:
virtual uint64_t variableToMap(uint64_t x) const
- throw(AssertionException, PicklingException) {
+ throw(PicklingException) {
VarMap::const_iterator i = d_toMap.find(x);
if(i != d_toMap.end()) {
return i->second;
}
}
- virtual uint64_t variableFromMap(uint64_t x) const {
- VarMap::const_iterator i = d_fromMap.find(x);
- Assert(i != d_fromMap.end());
- return i->second;
- }
+ virtual uint64_t variableFromMap(uint64_t x) const;
};/* class MapPickler */
}/* CVC4::expr::pickle namespace */
StatisticsRegistry d_stats;
public:
- // Note: though the options are not cached (instead a reference is
- // used), the portfolio command executer currently parses them
- // during initalization, creating thread-specific options and
- // storing them
CommandExecutor(ExprManager &exprMgr, Options &options);
- ~CommandExecutor() {}
-
/**
* Executes a command. Recursively handles if cmd is a command
* sequence. Eventually uses doCommandSingleton (which can be
d_lastWinner(0),
d_channelsOut(),
d_channelsIn(),
- d_ostringstreams()
+ d_ostringstreams(),
+ d_statLastWinner("portfolio::lastWinner")
{
- Assert(d_threadOptions.size() == d_numThreads);
+ assert(d_threadOptions.size() == d_numThreads);
+
+ d_statLastWinner.setData(d_lastWinner);
+ d_stats.registerStat_(&d_statLastWinner);
/* Duplication, Individualisation */
d_exprMgrs.push_back(&d_exprMgr);
d_smts.push_back(new SmtEngine(d_exprMgrs[i]));
}
- Assert(d_vmaps.size() == 0);
+ assert(d_vmaps.size() == 0);
for(unsigned i = 0; i < d_numThreads; ++i) {
d_vmaps.push_back(new ExprManagerMapCollection());
}
CommandExecutorPortfolio::~CommandExecutorPortfolio()
{
- Assert(d_seq != NULL);
+ assert(d_seq != NULL);
delete d_seq;
- Assert(d_smts.size() == d_numThreads);
+ assert(d_smts.size() == d_numThreads);
for(unsigned i = 1; i < d_numThreads; ++i) {
// the 0-th one is responsibility of parent class
- delete d_exprMgrs[i];
delete d_smts[i];
+ delete d_exprMgrs[i];
}
d_exprMgrs.clear();
d_smts.clear();
void CommandExecutorPortfolio::lemmaSharingInit()
{
/* Sharing channels */
- Assert(d_channelsIn.size() == 0);
- Assert(d_channelsOut.size() == 0);
+ assert(d_channelsIn.size() == 0);
+ assert(d_channelsOut.size() == 0);
if(d_numThreads == 1) {
// Disable sharing
/* Output to string stream */
if(d_options[options::verbosity] == 0
|| d_options[options::separateOutput]) {
- Assert(d_ostringstreams.size() == 0);
+ assert(d_ostringstreams.size() == 0);
for(unsigned i = 0; i < d_numThreads; ++i) {
d_ostringstreams.push_back(new ostringstream);
d_threadOptions[i].set(options::out, d_ostringstreams[i]);
+
+ // important even for muzzled builds (to get result output right)
+ *d_threadOptions[i][options::out]
+ << Expr::setlanguage(d_threadOptions[i][options::outputLanguage]);
}
}
}
void CommandExecutorPortfolio::lemmaSharingCleanup()
{
- Assert(d_numThreads == d_options[options::threads]);
+ assert(d_numThreads == d_options[options::threads]);
// Channel cleanup
- Assert(d_channelsIn.size() == d_numThreads);
- Assert(d_channelsOut.size() == d_numThreads);
+ assert(d_channelsIn.size() == d_numThreads);
+ assert(d_channelsOut.size() == d_numThreads);
for(unsigned i = 0; i < d_numThreads; ++i) {
delete d_channelsIn[i];
delete d_channelsOut[i];
// sstreams cleanup (if used)
if(d_ostringstreams.size() != 0) {
- Assert(d_ostringstreams.size() == d_numThreads);
+ assert(d_ostringstreams.size() == d_numThreads);
for(unsigned i = 0; i < d_numThreads; ++i) {
d_threadOptions[i].set(options::out, d_options[options::out]);
delete d_ostringstreams[i];
// mode = 1 : run a porfolio
// mode = 2 : run the last winner
- // if(dynamic_cast<CheckSatCommand*>(cmd) != NULL ||
- // dynamic_cast<QueryCommand*>(cmd) != NULL) {
- // mode = 1;
- // } else if(dynamic_cast<GetValueCommand*>(cmd) != NULL) {
- // mode = 2;
- // }
+ if(dynamic_cast<CheckSatCommand*>(cmd) != NULL ||
+ dynamic_cast<QueryCommand*>(cmd) != NULL) {
+ mode = 1;
+ } else if(dynamic_cast<GetValueCommand*>(cmd) != NULL) {
+ mode = 2;
+ }
if(mode == 0) {
d_seq->addCommand(cmd->clone());
*/
try {
seqs[i] = d_seq->exportTo(d_exprMgrs[i], *(d_vmaps[i]) );
- }catch(ExportToUnsupportedException& e){
+ }catch(ExportUnsupportedException& e){
return CommandExecutor::doCommandSingleton(cmd);
}
}
);
}
- Assert(d_channelsIn.size() == d_numThreads);
- Assert(d_channelsOut.size() == d_numThreads);
- Assert(d_smts.size() == d_numThreads);
+ assert(d_channelsIn.size() == d_numThreads);
+ assert(d_channelsOut.size() == d_numThreads);
+ assert(d_smts.size() == d_numThreads);
boost::function<void()>
smFn = boost::bind(sharingManager<ChannelFormat>,
d_numThreads,
// << std::endl;
if(d_ostringstreams.size() != 0) {
- Assert(d_numThreads == d_options[options::threads]);
- Assert(portfolioReturn.first >= 0);
- Assert(unsigned(portfolioReturn.first) < d_numThreads);
+ assert(d_numThreads == d_options[options::threads]);
+ assert(portfolioReturn.first >= 0);
+ assert(unsigned(portfolioReturn.first) < d_numThreads);
*d_options[options::out]
<< d_ostringstreams[portfolioReturn.first]->str();
cmd,
d_threadOptions[d_lastWinner][options::out]);
} else {
- Unreachable();
+ // Unreachable();
+ assert(false);
}
}/* CommandExecutorPortfolio::doCommandSingleton() */
}
void CommandExecutorPortfolio::flushStatistics(std::ostream& out) const {
- Assert(d_numThreads == d_exprMgrs.size() && d_exprMgrs.size() == d_smts.size());
+ assert(d_numThreads == d_exprMgrs.size() && d_exprMgrs.size() == d_smts.size());
for(size_t i = 0; i < d_numThreads; ++i) {
- string emTag = "ExprManager thread #"
+ string emTag = "thread#"
+ boost::lexical_cast<string>(d_threadOptions[i][options::thread_id]);
Statistics stats = d_exprMgrs[i]->getStatistics();
stats.setPrefix(emTag);
stats.flushInformation(out);
- string smtTag = "SmtEngine thread #"
+ string smtTag = "thread#"
+ boost::lexical_cast<string>(d_threadOptions[i][options::thread_id]);
stats = d_smts[i]->getStatistics();
stats.setPrefix(smtTag);
std::vector< SharedChannel<ChannelFormat>* > d_channelsIn;
std::vector<std::ostringstream*> d_ostringstreams;
+ // Stats
+ ReferenceStat<int> d_statLastWinner;
+
public:
CommandExecutorPortfolio(ExprManager &exprMgr,
Options &options,
** \brief Code relevant only for portfolio builds
**/
+#include <cassert>
#include <vector>
#include <unistd.h>
#include "options/options.h"
}
}
- Assert(numThreads >= 1); //do we need this?
+ assert(numThreads >= 1); //do we need this?
return threadOptions;
}
/* Alert if channel full, so that we increase sharingChannelSize
or decrease sharingBroadcastInterval */
- Assert(not channelsOut[t]->full());
+ assert(not channelsOut[t]->full());
T data = channelsOut[t]->pop();
for(unsigned t = 0; t < numThreads; ++t){
/* Alert if channel full, so that we increase sharingChannelSize
or decrease sharingBroadcastInterval */
- Assert(not channelsIn[t]->full());
+ assert(not channelsIn[t]->full());
while(!queues[t].empty() && !channelsIn[t]->full()){
Trace("sharing") << "sharing: pushing on channel " << t << std::endl;