diff options
author | Liana Hadarean <lianah@cs.nyu.edu> | 2014-11-17 15:26:42 -0500 |
---|---|---|
committer | Morgan Deters <mdeters@cs.nyu.edu> | 2014-11-17 15:26:42 -0500 |
commit | 3ba7ed6b1b09739385ae2ffb77a5c7ccd18b40a5 (patch) | |
tree | 845ae47600ffff9c68fa654c0f78d3474e406beb /src/smt/options_handlers.h | |
parent | d8da3b13bc9df7750723cf3da38edc8cb6f67d3d (diff) |
Resource-limiting work.
Signed-off-by: Morgan Deters <mdeters@cs.nyu.edu>
Diffstat (limited to 'src/smt/options_handlers.h')
-rw-r--r-- | src/smt/options_handlers.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/src/smt/options_handlers.h b/src/smt/options_handlers.h index d02b88fd2..fc2b796d3 100644 --- a/src/smt/options_handlers.h +++ b/src/smt/options_handlers.h @@ -21,6 +21,7 @@ #include "cvc4autoconfig.h" #include "util/dump.h" +#include "util/resource_manager.h" #include "smt/modal_exception.h" #include "smt/smt_engine.h" #include "lib/strtok_r.h" @@ -452,6 +453,63 @@ inline void statsEnabledBuild(std::string option, bool value, SmtEngine* smt) th #endif /* CVC4_STATISTICS_ON */ } +inline unsigned long tlimitHandler(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { + unsigned long ms; + std::istringstream convert(optarg); + if (!(convert >> ms)) + throw OptionException("option `"+option+"` requires a number as an argument"); + + // make sure the resource is set if the option is updated + // if the smt engine is null the resource will be set in the + if (smt != NULL) { + ResourceManager* rm = NodeManager::fromExprManager(smt->getExprManager())->getResourceManager(); + rm->setTimeLimit(ms, true); + } + return ms; +} + +inline unsigned long tlimitPerHandler(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { + unsigned long ms; + + std::istringstream convert(optarg); + if (!(convert >> ms)) + throw OptionException("option `"+option+"` requires a number as an argument"); + + if (smt != NULL) { + ResourceManager* rm = NodeManager::fromExprManager(smt->getExprManager())->getResourceManager(); + rm->setTimeLimit(ms, false); + } + return ms; +} + +inline unsigned long rlimitHandler(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { + unsigned long ms; + + std::istringstream convert(optarg); + if (!(convert >> ms)) + throw OptionException("option `"+option+"` requires a number as an argument"); + + if (smt != NULL) { + ResourceManager* rm = NodeManager::fromExprManager(smt->getExprManager())->getResourceManager(); + rm->setResourceLimit(ms, true); + } + return ms; +} + +inline unsigned long rlimitPerHandler(std::string option, std::string optarg, SmtEngine* smt) throw(OptionException) { + unsigned long ms; + + std::istringstream convert(optarg); + if (!(convert >> ms)) + throw OptionException("option `"+option+"` requires a number as an argument"); + + if (smt != NULL) { + ResourceManager* rm = NodeManager::fromExprManager(smt->getExprManager())->getResourceManager(); + rm->setResourceLimit(ms, false); + } + return ms; +} + }/* CVC4::smt namespace */ }/* CVC4 namespace */ |