3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-23 17:15:31 +00:00

working on parallel solver

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2017-10-10 16:35:05 -07:00
commit 1a6f8c2fad
25 changed files with 320 additions and 126 deletions

View file

@ -29,7 +29,7 @@ public:
static const unsigned long long zero = 0ull;
static const unsigned long long one = 1ull;
};
COMPILE_TIME_ASSERT(sizeof(unsigned long long) == 8);
static_assert(sizeof(unsigned long long) == 8, "");
template <> class approx_set_traits<unsigned> {
public:
@ -37,7 +37,7 @@ public:
static const unsigned zero = 0;
static const unsigned one = 1;
};
COMPILE_TIME_ASSERT(sizeof(unsigned) == 4);
static_assert(sizeof(unsigned) == 4, "unsigned are 4 bytes");
template<typename T, typename T2U_Proc, typename R=unsigned long long>
class approx_set_tpl : private T2U_Proc {

View file

@ -24,7 +24,7 @@ Revision History:
#include "util/vector.h"
#include "util/memory_manager.h"
COMPILE_TIME_ASSERT(sizeof(unsigned) == 4);
static_assert(sizeof(unsigned) == 4, "unsigned are 4 bytes");
#define BV_DEFAULT_CAPACITY 2
class bit_vector {

View file

@ -90,7 +90,6 @@ bool is_debug_enabled(const char * tag);
exit(-1); \
}
#define COMPILE_TIME_ASSERT(expr) static_assert(expr, "")
void finalize_debug();
/*

View file

@ -97,7 +97,7 @@ public:
}
};
COMPILE_TIME_ASSERT(sizeof(uint64) == sizeof(double));
static_assert(sizeof(uint64) == sizeof(double), "");
#endif /* DOUBLE_MANAGER_H_ */

View file

@ -182,6 +182,23 @@ unsigned long long memory::get_max_used_memory() {
return r;
}
#if defined(_WINDOWS)
#include "Windows.h"
#endif
unsigned long long memory::get_max_memory_size() {
#if defined(_WINDOWS)
MEMORYSTATUSEX statex;
statex.dwLength = sizeof (statex);
GlobalMemoryStatusEx (&statex);
return statex.ullTotalPhys;
#else
NOT_IMPLEMENTED_YET();
// two GB
return 1 << 31;
#endif
}
unsigned long long memory::get_allocation_count() {
return g_memory_alloc_count;
}

View file

@ -67,6 +67,7 @@ public:
static unsigned long long get_allocation_size();
static unsigned long long get_max_used_memory();
static unsigned long long get_allocation_count();
static unsigned long long get_max_memory_size();
// temporary hack to avoid out-of-memory crash in z3.exe
static void exit_when_out_of_memory(bool flag, char const * msg);
};

View file

@ -73,7 +73,7 @@ mpf_manager::~mpf_manager() {
}
void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, int value) {
COMPILE_TIME_ASSERT(sizeof(int) == 4);
static_assert(sizeof(int) == 4, "assume integers are 4 bytes");
o.sign = false;
o.ebits = ebits;
@ -119,7 +119,7 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, mpf_rounding_mode
void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, double value) {
// double === mpf(11, 53)
COMPILE_TIME_ASSERT(sizeof(double) == 8);
static_assert(sizeof(double) == 8, "doubles are 8 bytes");
uint64 raw;
memcpy(&raw, &value, sizeof(double));
@ -155,7 +155,7 @@ void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, double value) {
void mpf_manager::set(mpf & o, unsigned ebits, unsigned sbits, float value) {
// single === mpf(8, 24)
COMPILE_TIME_ASSERT(sizeof(float) == 4);
static_assert(sizeof(float) == 4, "floats are 4 bytes");
unsigned int raw;
memcpy(&raw, &value, sizeof(float));

View file

@ -27,8 +27,8 @@ Revision History:
#include "util/bit_util.h"
#include "util/trace.h"
COMPILE_TIME_ASSERT(sizeof(mpn_digit) == sizeof(unsigned));
COMPILE_TIME_ASSERT(sizeof(unsigned) == 4);
static_assert(sizeof(mpn_digit) == sizeof(unsigned), "");
static_assert(sizeof(unsigned) == 4, "unsigned haven't changed size for a while");
// MIN_MSW is an shorthand for 0x8000..00, i.e., the minimal most significand word.
#define MIN_MSW (1u << (sizeof(unsigned) * 8 - 1))

View file

@ -24,7 +24,7 @@ Revision History:
#define max(a,b) (((a) > (b)) ? (a) : (b))
typedef uint64 mpn_double_digit;
COMPILE_TIME_ASSERT(sizeof(mpn_double_digit) == 2 * sizeof(mpn_digit));
static_assert(sizeof(mpn_double_digit) == 2 * sizeof(mpn_digit), "size alignment");
const mpn_digit mpn_manager::zero = 0;

View file

@ -558,14 +558,13 @@ void mpz_manager<SYNCH>::big_rem(mpz const & a, mpz const & b, mpz & c) {
template<bool SYNCH>
void mpz_manager<SYNCH>::gcd(mpz const & a, mpz const & b, mpz & c) {
if (is_small(a) && is_small(b)) {
static_assert(sizeof(a.m_val) == sizeof(int), "size mismatch");
if (is_small(a) && is_small(b) && a.m_val != INT_MIN && b.m_val != INT_MIN) {
int _a = a.m_val;
int _b = b.m_val;
if (_a < 0) _a = -_a;
if (_b < 0) _b = -_b;
unsigned r = u_gcd(_a, _b);
// Remark: r is (INT_MAX + 1)
// If a == b == INT_MIN
set(c, r);
}
else {
@ -725,7 +724,7 @@ void mpz_manager<SYNCH>::gcd(mpz const & a, mpz const & b, mpz & c) {
#ifdef LEHMER_GCD
// For now, it only works if sizeof(digit_t) == sizeof(unsigned)
COMPILE_TIME_ASSERT(sizeof(digit_t) == sizeof(unsigned));
static_assert(sizeof(digit_t) == sizeof(unsigned), "");
int64 a_hat, b_hat, A, B, C, D, T, q, a_sz, b_sz;
mpz a1, b1, t, r, tmp;
@ -1755,7 +1754,7 @@ void mpz_manager<SYNCH>::mul2k(mpz & a, unsigned k) {
}
#ifndef _MP_GMP
COMPILE_TIME_ASSERT(sizeof(digit_t) == 4 || sizeof(digit_t) == 8);
static_assert(sizeof(digit_t) == 4 || sizeof(digit_t) == 8, "");
#endif
template<bool SYNCH>
@ -1822,7 +1821,7 @@ unsigned mpz_manager<SYNCH>::log2(mpz const & a) {
if (is_small(a))
return ::log2((unsigned)a.m_val);
#ifndef _MP_GMP
COMPILE_TIME_ASSERT(sizeof(digit_t) == 8 || sizeof(digit_t) == 4);
static_assert(sizeof(digit_t) == 8 || sizeof(digit_t) == 4, "");
mpz_cell * c = a.m_ptr;
unsigned sz = c->m_size;
digit_t * ds = c->m_digits;
@ -1844,7 +1843,7 @@ unsigned mpz_manager<SYNCH>::mlog2(mpz const & a) {
if (is_small(a))
return ::log2((unsigned)-a.m_val);
#ifndef _MP_GMP
COMPILE_TIME_ASSERT(sizeof(digit_t) == 8 || sizeof(digit_t) == 4);
static_assert(sizeof(digit_t) == 8 || sizeof(digit_t) == 4, "");
mpz_cell * c = a.m_ptr;
unsigned sz = c->m_size;
digit_t * ds = c->m_digits;

View file

@ -22,7 +22,6 @@ Revision History:
#include "util/util.h"
#include "util/vector.h"
COMPILE_TIME_ASSERT(sizeof(unsigned) == 4);
class uint_set : unsigned_vector {

View file

@ -34,13 +34,13 @@ Revision History:
typedef unsigned long long uint64;
#endif
COMPILE_TIME_ASSERT(sizeof(uint64) == 8);
static_assert(sizeof(uint64) == 8, "64 bits please");
#ifndef int64
typedef long long int64;
#endif
COMPILE_TIME_ASSERT(sizeof(int64) == 8);
static_assert(sizeof(int64) == 8, "64 bits");
#ifndef INT64_MIN
#define INT64_MIN static_cast<int64>(0x8000000000000000ull)
@ -112,7 +112,7 @@ inline unsigned next_power_of_two(unsigned v) {
unsigned log2(unsigned v);
unsigned uint64_log2(uint64 v);
COMPILE_TIME_ASSERT(sizeof(unsigned) == 4);
static_assert(sizeof(unsigned) == 4, "unsigned are 32 bits");
// Return the number of 1 bits in v.
static inline unsigned get_num_1bits(unsigned v) {