mirror of
https://github.com/Z3Prover/z3
synced 2025-04-23 17:15:31 +00:00
env params
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
9bd4fd969a
commit
02e763bb6b
15 changed files with 133 additions and 80 deletions
36
src/util/env_params.cpp
Normal file
36
src/util/env_params.cpp
Normal file
|
@ -0,0 +1,36 @@
|
|||
/*++
|
||||
Copyright (c) 2011 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
env_params.cpp
|
||||
|
||||
Abstract:
|
||||
|
||||
Goodies for updating environment parameters.
|
||||
|
||||
Author:
|
||||
|
||||
Leonardo (leonardo) 2012-12-01
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
#include"env_params.h"
|
||||
#include"params.h"
|
||||
#include"gparams.h"
|
||||
#include"util.h"
|
||||
#include"memory_manager.h"
|
||||
|
||||
void env_params::updt_params() {
|
||||
params_ref p = gparams::get();
|
||||
set_verbosity_level(p.get_uint("verbose", 0));
|
||||
enable_warning_messages(p.get_bool("warning", true));
|
||||
memory::set_max_size(p.get_uint("memory_max_size", 0));
|
||||
}
|
||||
|
||||
void env_params::collect_param_descrs(param_descrs & d) {
|
||||
d.insert("verbose", CPK_UINT, "be verbose, where the value is the verbosity level", "0");
|
||||
d.insert("warning", CPK_BOOL, "enable/disable warning messages", "true");
|
||||
d.insert("memory_max_size", CPK_UINT, "set hard upper limit for memory consumption (in megabytes), if 0 then there is no bound.", "0");
|
||||
}
|
32
src/util/env_params.h
Normal file
32
src/util/env_params.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*++
|
||||
Copyright (c) 2011 Microsoft Corporation
|
||||
|
||||
Module Name:
|
||||
|
||||
env_params.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Goodies for updating environment parameters.
|
||||
|
||||
Author:
|
||||
|
||||
Leonardo (leonardo) 2012-12-01
|
||||
|
||||
Notes:
|
||||
|
||||
--*/
|
||||
#ifndef _ENV_PARAMS_H_
|
||||
#define _ENV_PARAMS_H_
|
||||
|
||||
class param_descrs;
|
||||
|
||||
struct env_params {
|
||||
static void updt_params();
|
||||
static void collect_param_descrs(param_descrs & p);
|
||||
/*
|
||||
REG_PARAMS('env_params::collect_param_descrs')
|
||||
*/
|
||||
};
|
||||
|
||||
#endif
|
|
@ -18,6 +18,7 @@ Notes:
|
|||
--*/
|
||||
#include"gparams.h"
|
||||
#include"dictionary.h"
|
||||
#include"trace.h"
|
||||
|
||||
extern void gparams_register_modules();
|
||||
|
||||
|
@ -291,6 +292,7 @@ public:
|
|||
|
||||
params_ref get() {
|
||||
params_ref result;
|
||||
TRACE("gparams", tout << "get() m_params: " << m_params << "\n";);
|
||||
#pragma omp critical (gparams)
|
||||
{
|
||||
result = m_params;
|
||||
|
@ -303,6 +305,7 @@ public:
|
|||
gparams::imp * gparams::g_imp = 0;
|
||||
|
||||
void gparams::set(char const * name, char const * value) {
|
||||
TRACE("gparams", tout << "setting [" << name << "] <- '" << value << "'\n";);
|
||||
SASSERT(g_imp != 0);
|
||||
g_imp->set(name, value);
|
||||
}
|
||||
|
@ -342,6 +345,7 @@ params_ref gparams::get_module(symbol const & module_name) {
|
|||
}
|
||||
|
||||
params_ref gparams::get() {
|
||||
TRACE("gparams", tout << "gparams::get()\n";);
|
||||
SASSERT(g_imp != 0);
|
||||
return g_imp->get();
|
||||
}
|
||||
|
@ -352,11 +356,13 @@ void gparams::display(std::ostream & out, unsigned indent, bool smt2_style) {
|
|||
}
|
||||
|
||||
void gparams::init() {
|
||||
TRACE("gparams", tout << "gparams::init()\n";);
|
||||
g_imp = alloc(imp);
|
||||
gparams_register_modules();
|
||||
}
|
||||
|
||||
void gparams::finalize() {
|
||||
TRACE("gparams", tout << "gparams::finalize()\n";);
|
||||
if (g_imp != 0) {
|
||||
dealloc(g_imp);
|
||||
g_imp = 0;
|
||||
|
|
|
@ -38,9 +38,9 @@ struct timeit::imp {
|
|||
~imp() {
|
||||
m_watch.stop();
|
||||
double end_memory = static_cast<double>(memory::get_allocation_size())/static_cast<double>(1024*1024);
|
||||
m_out << m_msg << ", time: " << std::fixed << std::setprecision(2) << m_watch.get_seconds()
|
||||
<< " secs, memory: (before " << std::fixed << std::setprecision(2) << m_start_memory
|
||||
<< ", after " << std::fixed << std::setprecision(2) << end_memory << ")"
|
||||
m_out << "(" << m_msg << " :time " << std::fixed << std::setprecision(2) << m_watch.get_seconds()
|
||||
<< " :before-memory " << std::fixed << std::setprecision(2) << m_start_memory
|
||||
<< " :after-memory " << std::fixed << std::setprecision(2) << end_memory << ")"
|
||||
<< std::endl;
|
||||
}
|
||||
};
|
||||
|
|
|
@ -29,11 +29,6 @@ unsigned get_verbosity_level() {
|
|||
return g_verbosity_level;
|
||||
}
|
||||
|
||||
void register_verbosity_level() {
|
||||
// PARAM-TODO
|
||||
// p.register_unsigned_param("VERBOSE", g_verbosity_level, "be verbose, where the value is the verbosity level", true);
|
||||
}
|
||||
|
||||
static std::ostream* g_verbose_stream = &std::cerr;
|
||||
|
||||
void set_verbose_stream(std::ostream& str) {
|
||||
|
|
|
@ -157,8 +157,6 @@ struct delete_proc {
|
|||
|
||||
void set_verbosity_level(unsigned lvl);
|
||||
unsigned get_verbosity_level();
|
||||
class ini_params;
|
||||
void register_verbosity_level(ini_params & p);
|
||||
std::ostream& verbose_stream();
|
||||
void set_verbose_stream(std::ostream& str);
|
||||
|
||||
|
|
|
@ -21,8 +21,6 @@ Revision History:
|
|||
#include<iostream>
|
||||
#include<stdarg.h>
|
||||
|
||||
class ini_params;
|
||||
|
||||
void send_warnings_to_stdout(bool flag);
|
||||
|
||||
void enable_warning_messages(bool flag);
|
||||
|
@ -33,8 +31,6 @@ void set_warning_stream(std::ostream* strm);
|
|||
|
||||
void warning_msg(const char * msg, ...);
|
||||
|
||||
void register_warning(ini_params & p);
|
||||
|
||||
void disable_error_msg_prefix();
|
||||
|
||||
void format2ostream(std::ostream& out, char const* fmt, va_list args);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue