3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-12 12:08:18 +00:00

move allocator to memory_manager and std_vector to vector

Signed-off-by: Nikolaj Bjorner <nbjorner@microsoft.com>
This commit is contained in:
Nikolaj Bjorner 2023-09-19 13:57:28 -07:00
parent c5cfd62e0a
commit 85db8163fa
4 changed files with 23 additions and 18 deletions

View file

@ -9,29 +9,18 @@
#include "math/lp/lp_settings.h" #include "math/lp/lp_settings.h"
#include "util/uint_set.h" #include "util/uint_set.h"
#include "math/lp/implied_bound.h" #include "math/lp/implied_bound.h"
#include <vector> #include "util/vector.h"
namespace lp { namespace lp {
template <typename T>
struct my_allocator {
using value_type = T;
T* allocate(std::size_t n) {
return static_cast<T*>(memory::allocate(n * sizeof(T)));
}
void deallocate(T* p, std::size_t n) {
memory::deallocate(p);
}
};
template <typename T> template <typename T>
class lp_bound_propagator { class lp_bound_propagator {
uint_set m_visited_rows; uint_set m_visited_rows;
// these maps map a column index to the corresponding index in ibounds // these maps map a column index to the corresponding index in ibounds
u_map<unsigned> m_improved_lower_bounds; u_map<unsigned> m_improved_lower_bounds;
u_map<unsigned> m_improved_upper_bounds; u_map<unsigned> m_improved_upper_bounds;
T& m_imp; T& m_imp;
std::vector<implied_bound, my_allocator<implied_bound>> m_ibounds; std_vector<implied_bound> m_ibounds;
map<mpq, unsigned, obj_hash<mpq>, default_eq<mpq>> m_val2fixed_row; map<mpq, unsigned, obj_hash<mpq>, default_eq<mpq>> m_val2fixed_row;
// works for rows of the form x + y + sum of fixed = 0 // works for rows of the form x + y + sum of fixed = 0
@ -119,10 +108,10 @@ private:
~reset_cheap_eq() { p.reset_cheap_eq_eh(); } ~reset_cheap_eq() { p.reset_cheap_eq_eh(); }
}; };
public: public:
lp_bound_propagator(T& imp) : m_imp(imp) {} lp_bound_propagator(T& imp) : m_imp(imp) {}
const std::vector<implied_bound, my_allocator<implied_bound>>& ibounds() const { return m_ibounds; } const std_vector<implied_bound>& ibounds() const { return m_ibounds; }
void init() { void init() {
m_improved_upper_bounds.reset(); m_improved_upper_bounds.reset();

View file

@ -16,7 +16,7 @@ private:
void monotonicity_lemma(monic const& m); void monotonicity_lemma(monic const& m);
void monotonicity_lemma_gt(const monic& m); void monotonicity_lemma_gt(const monic& m);
void monotonicity_lemma_lt(const monic& m); void monotonicity_lemma_lt(const monic& m);
std::vector<rational> get_sorted_key(const monic& rm) const; // std_vector<rational> get_sorted_key(const monic& rm) const;
vector<std::pair<rational, lpvar>> get_sorted_key_with_rvars(const monic& a) const; vector<std::pair<rational, lpvar>> get_sorted_key_with_rvars(const monic& a) const;
}; };
} }

View file

@ -128,6 +128,19 @@ void dealloc_svect(T * ptr) {
memory::deallocate(ptr); memory::deallocate(ptr);
} }
template <typename T>
struct std_allocator {
using value_type = T;
T* allocate(std::size_t n) {
return static_cast<T*>(memory::allocate(n * sizeof(T)));
}
void deallocate(T* p, std::size_t n) {
memory::deallocate(p);
}
};
struct mem_stat { struct mem_stat {
}; };

View file

@ -33,6 +33,7 @@ Revision History:
#include "util/memory_manager.h" #include "util/memory_manager.h"
#include "util/hash.h" #include "util/hash.h"
#include "util/z3_exception.h" #include "util/z3_exception.h"
#include <vector>
// disable warning for constant 'if' expressions. // disable warning for constant 'if' expressions.
// these are used heavily in templates. // these are used heavily in templates.
@ -40,6 +41,8 @@ Revision History:
#pragma warning(disable:4127) #pragma warning(disable:4127)
#endif #endif
template <typename T>
class std_vector : public std::vector<T, std_allocator<T>> {};
#if 0 #if 0