├── makefile.in ├── LICENSE ├── src ├── hash_val.h ├── substitution_engine.h ├── parser.h ├── hash_val.cpp ├── polynomial_solver.h ├── nss.h ├── variable.h ├── substitution_engine.cpp ├── slicing.h ├── monomial.cpp ├── signal_statistics.h ├── monomial.h ├── aig.cpp ├── pac.h ├── parser.cpp ├── signal_statistics.cpp ├── polynomial_solver.cpp ├── aig.h ├── pac.cpp ├── polynomial.h ├── term.h ├── nss.cpp ├── elimination.h ├── term.cpp ├── substitution.h ├── amulet.cpp ├── polynomial.cpp ├── gate.cpp ├── gate.h └── slicing.cpp ├── configure.sh ├── README.md └── includes ├── LICENSE └── aiger.h /makefile.in: -------------------------------------------------------------------------------- 1 | CC=@CC@ 2 | CFLAGS=@CFLAGS@ 3 | DEP=@DEP@ 4 | 5 | BUILD_PATH=build/ 6 | SRC_PATH=src/ 7 | SRC := $(wildcard src/*.cpp) \ 8 | 9 | OBJECTS := $(SRC:$(SRC_PATH)%.cpp=$(BUILD_PATH)%.o) 10 | 11 | all: aiger amulet 12 | 13 | aiger: 14 | gcc -O3 -DNDEBUG -c includes/aiger.c -o includes/aiger.o 15 | 16 | $(BUILD_PATH)%.o: $(SRC_PATH)%.cpp 17 | $(CC) $(CFLAGS) $(INCLUDE) -c $< -o $@ 18 | 19 | amulet: $(OBJECTS) aiger 20 | $(CC) $(CFLAGS) -o $@ $(OBJECTS) includes/aiger.o -lgmp 21 | 22 | clean: 23 | rm -f amulet makefile includes/aiger.o \ 24 | rm -rf build/ 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Daniela Kaufmann 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/hash_val.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------*/ 2 | /*! \file hash_val.h 3 | \brief contains functions used to compute hash values for variables 4 | 5 | Part of AMulet2 : AIG Multiplier Verification Tool. 6 | Copyright(C) 2020, 2021 Daniela Kaufmann, Johannes Kepler University Linz 7 | */ 8 | /*------------------------------------------------------------------------*/ 9 | #ifndef AMULET2_SRC_HASH_VAL_H_ 10 | #define AMULET2_SRC_HASH_VAL_H_ 11 | /*------------------------------------------------------------------------*/ 12 | #include 13 | 14 | #include 15 | /*------------------------------------------------------------------------*/ 16 | 17 | 18 | /** 19 | Fills a 32-bit array with 64-bit random numbers 20 | */ 21 | void init_nonces(); 22 | 23 | /** 24 | Returns the 64-bit random number in our array of random numbers 25 | 26 | @param index size_t 27 | 28 | @return returns the random number stored in nonces[index] 29 | */ 30 | uint64_t get_nonces_entry(size_t index); 31 | 32 | /** 33 | Computes the hash value for the given string 34 | 35 | @param str a const std::string 36 | 37 | @return a uint64_t computed hash value for the input string 38 | */ 39 | uint64_t hash_string(const std::string& str); 40 | 41 | #endif // AMULET2_SRC_HASH_VAL_H_ 42 | -------------------------------------------------------------------------------- /src/substitution_engine.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------*/ 2 | /*! \file substitution_engine.h 3 | \brief contains the substitution engine 4 | 5 | Part of AMulet2 : AIG Multiplier Verification Tool. 6 | Copyright(C) 2020, 2021 Daniela Kaufmann, Johannes Kepler University Linz 7 | */ 8 | /*------------------------------------------------------------------------*/ 9 | #ifndef AMULET2_SRC_SUBSTITUTION_ENGINE_H_ 10 | #define AMULET2_SRC_SUBSTITUTION_ENGINE_H_ 11 | /*------------------------------------------------------------------------*/ 12 | #include "substitution.h" 13 | /*------------------------------------------------------------------------*/ 14 | /** 15 | Initializes the internal gate structure, with necessary informations 16 | for substitution. 17 | Uses the AIG module 18 | */ 19 | void init_gate_substitution(); 20 | 21 | /** 22 | Calls the substitution routine. 23 | We first detect the GP adder, then generate the equivalent miter 24 | and print the CNF miter and the rewritten AIG to the output files. 25 | 26 | @param out_f1 name of first output file 27 | @param out_f2 name of second output file 28 | 29 | @returns boolean whether substitution happened (1) or original is returned (0) 30 | */ 31 | bool substitution(const char * out_f1, const char * out_f2); 32 | 33 | 34 | #endif // AMULET2_SRC_SUBSTITUTION_ENGINE_H_ 35 | -------------------------------------------------------------------------------- /src/parser.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------*/ 2 | /*! \file parser.h 3 | \brief contains functions necessary to parse the AIG 4 | 5 | Part of AMulet2 : AIG Multiplier Verification Tool. 6 | Copyright(C) 2020, 2021 Daniela Kaufmann, Johannes Kepler University Linz 7 | */ 8 | /*------------------------------------------------------------------------*/ 9 | #ifndef AMULET2_SRC_PARSER_H_ 10 | #define AMULET2_SRC_PARSER_H_ 11 | /*------------------------------------------------------------------------*/ 12 | #include "aig.h" 13 | /*------------------------------------------------------------------------*/ 14 | /** 15 | Checks whether 'model' contains an aiger node with 16 | output lhs and inputs rhs0 and rhs1. 17 | 18 | @param lhs unsigned integer 19 | @param rhs0 unsigned integer 20 | @param rhs1 unsigned integer 21 | 22 | @return True if 'model' contains such an aiger node 23 | */ 24 | bool match_and(unsigned lhs, unsigned rhs0, unsigned rhs1); 25 | 26 | /** 27 | Identifies whether the input vectors are separated or interleaved. 28 | */ 29 | void determine_input_order(); 30 | 31 | /** 32 | Checks whether the input AIG fullfills our requirements. 33 | */ 34 | void init_aiger_with_checks(); 35 | 36 | /** 37 | Reads the input aiger given in the file called input_name to the aiger 'model' 38 | using the parserer function of aiger.h 39 | 40 | @param input_name char * ame of input file 41 | */ 42 | void parse_aig(const char * input_name); 43 | 44 | 45 | #endif // AMULET2_SRC_PARSER_H_ 46 | -------------------------------------------------------------------------------- /src/hash_val.cpp: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------*/ 2 | /*! \file hash_val.cpp 3 | \brief contains functions used to compute hash values for variables 4 | 5 | Part of AMulet2 : AIG Multiplier Verification Tool. 6 | Copyright(C) 2020, 2021 Daniela Kaufmann, Johannes Kepler University Linz 7 | */ 8 | /*------------------------------------------------------------------------*/ 9 | #include 10 | 11 | #include "hash_val.h" 12 | /*------------------------------------------------------------------------*/ 13 | // Local variables 14 | 15 | // / array used to hold 64-bit random numbers 16 | uint64_t nonces[32]; 17 | 18 | // / number of random numbers 19 | const size_t num_nonces = sizeof nonces / sizeof nonces[0]; 20 | 21 | std::random_device rd; 22 | std::mt19937_64 gen(42); 23 | std::uniform_int_distribution dis; 24 | /*------------------------------------------------------------------------*/ 25 | 26 | 27 | void init_nonces() { 28 | for (size_t i = 0; i < num_nonces; i++) 29 | nonces[i] = dis(gen) | 1; 30 | } 31 | 32 | /*------------------------------------------------------------------------*/ 33 | 34 | uint64_t get_nonces_entry(size_t index) { 35 | assert(index < 32); 36 | return nonces[index]; 37 | } 38 | 39 | /*------------------------------------------------------------------------*/ 40 | 41 | uint64_t hash_string(const std::string& str) { 42 | uint64_t res = 0; 43 | size_t i = 0; 44 | for (std::string::const_iterator it = str.cbegin(); it != str.cend(); ++it) { 45 | res += *it; 46 | res *= nonces[i++]; 47 | if (i == num_nonces) i = 0; 48 | } 49 | return res; 50 | } 51 | -------------------------------------------------------------------------------- /src/polynomial_solver.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------*/ 2 | /*! \file polynomial_solver.h 3 | \brief contains the polynomial solving routine 4 | 5 | Part of AMulet2 : AIG Multiplier Verification Tool. 6 | Copyright(C) 2020, 2021 Daniela Kaufmann, Johannes Kepler University Linz 7 | */ 8 | /*------------------------------------------------------------------------*/ 9 | #ifndef AMULET2_SRC_POLYNOMIAL_SOLVER_H_ 10 | #define AMULET2_SRC_POLYNOMIAL_SOLVER_H_ 11 | /*------------------------------------------------------------------------*/ 12 | #include "elimination.h" 13 | /*------------------------------------------------------------------------*/ 14 | // / If final remainder is not equal to zero a counter example is generated and 15 | // / printed to file .wit, default is true, can be turned of 16 | // using command line input 17 | extern bool gen_witness; 18 | /*------------------------------------------------------------------------*/ 19 | 20 | /** 21 | Initializes the internal gate structure, with necessary informations 22 | for verification. 23 | Uses the AIG module 24 | */ 25 | void init_gates_verify(); 26 | 27 | /** 28 | Calls the preprocessing, slicing, reduction routines 29 | If certify is true, files need to be provided to store the proof. 30 | 31 | @param inp_f name of input file 32 | @param out_f1 name of first output file 33 | @param out_f2 name of second output file 34 | @param out_f3 name of third output file 35 | @param certify true when modus -certify is used 36 | 37 | @returns boolean whether circuit is correct (1) or incorrect (0) 38 | */ 39 | bool verify(const char * inp_f = 0, 40 | const char * out_f1 = 0, 41 | const char * out_f2 = 0, 42 | const char * out_f3 = 0, 43 | bool certify = 0); 44 | 45 | 46 | #endif // AMULET2_SRC_POLYNOMIAL_SOLVER_H_ 47 | -------------------------------------------------------------------------------- /src/nss.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------*/ 2 | /*! \file nss.h 3 | \brief contains functions necessary to generate Nullstellensatz proofs 4 | 5 | Part of AMulet2 : AIG Multiplier Verification Tool. 6 | Copyright(C) 2020, 2021 Daniela Kaufmann, Johannes Kepler University Linz 7 | */ 8 | /*------------------------------------------------------------------------*/ 9 | #ifndef AMULET2_SRC_NSS_H_ 10 | #define AMULET2_SRC_NSS_H_ 11 | /*------------------------------------------------------------------------*/ 12 | #include "gate.h" 13 | /*------------------------------------------------------------------------*/ 14 | /** 15 | Prints the specification polynomial to the file 16 | 17 | @param file output file 18 | */ 19 | void print_spec_poly(FILE * file); 20 | /** 21 | Prints the circuit poly to the file(without indices) 22 | 23 | @param file output file 24 | */ 25 | void print_circuit_poly_nss(FILE * file); 26 | 27 | /** 28 | Prints the cofactors of the circuit polynomials 29 | 30 | @param file output file for cofactors 31 | */ 32 | void print_cofactors_poly_nss(FILE * file); 33 | 34 | 35 | /** 36 | Adding an ancestor polynomial to the ancestors of n 37 | 38 | @param n Gate* to which ancestor is added 39 | @param anc Gate* to Ancestor gate 40 | @param fac Polynomial* definng ancestor polynomial 41 | @param depth true if function is called internally(default = 0) 42 | */ 43 | void add_ancestors( 44 | Gate * n, Gate * anc, const Polynomial * fac, bool internal = 0); 45 | 46 | /** 47 | Updates the cofactor of the modulo polynomial 48 | 49 | @param fac Polynomial* which is added to the cofactor of the modpoly 50 | */ 51 | void add_fac_mod(const Polynomial * fac); 52 | 53 | /** 54 | Updates the cofactor of the gate n 55 | 56 | @param n Gate* for which the cofactor is updated 57 | @param fac Polynomial* which is added to the cofactor of n 58 | */ 59 | void add_fac(Gate * n, const Polynomial * fac); 60 | 61 | #endif // AMULET2_SRC_NSS_H_ 62 | -------------------------------------------------------------------------------- /src/variable.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------*/ 2 | /*! \file variable.h 3 | \brief contains the class Var 4 | 5 | Part of AMulet2 : AIG Multiplier Verification Tool. 6 | Copyright(C) 2020, 2021 Daniela Kaufmann, Johannes Kepler University Linz 7 | */ 8 | /*------------------------------------------------------------------------*/ 9 | #ifndef AMULET2_SRC_VARIABLE_H_ 10 | #define AMULET2_SRC_VARIABLE_H_ 11 | /*------------------------------------------------------------------------*/ 12 | #include 13 | #include 14 | 15 | #include "hash_val.h" 16 | /*------------------------------------------------------------------------*/ 17 | 18 | /** \class Var 19 | represents a variable is assigned to a gate(see ) and is 20 | used to represent variables in terms, see 21 | */ 22 | 23 | class Var { 24 | // / name of variable 25 | const std::string name; 26 | 27 | // / Hash value of variables, used for storing terms 28 | int hash; 29 | 30 | // / Increasing value that indicates the order of the variable 31 | const int level; 32 | 33 | // / corresponding value used to relate AIG gates to Gate class 34 | const int num; 35 | 36 | public: 37 | /** Constructor 38 | 39 | @param name_ name 40 | @param level_ level 41 | @param num_ num, default is 0 42 | 43 | */ 44 | Var(std::string name_, int level_, int num_ = 0): 45 | name(name_), level(level_), num(num_) { 46 | hash = hash_string(name_); 47 | } 48 | 49 | /** Getter for member name, and converts string to char* 50 | 51 | @return const char * 52 | */ 53 | const char * get_name() const {return name.c_str();} 54 | 55 | /** Getter for member hash 56 | 57 | @return integer 58 | */ 59 | int get_hash() const {return hash;} 60 | 61 | /** Getter for member level 62 | 63 | @return integer 64 | */ 65 | int get_level() const {return level;} 66 | 67 | /** Getter for member num 68 | 69 | @return integer 70 | */ 71 | int get_num() const {return num;} 72 | }; 73 | 74 | 75 | #endif // AMULET2_SRC_VARIABLE_H_ 76 | -------------------------------------------------------------------------------- /src/substitution_engine.cpp: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------*/ 2 | /*! \file substitution_engine.cpp 3 | \brief contains the substitution engine 4 | 5 | Part of AMulet2 : AIG Multiplier Verification Tool. 6 | Copyright(C) 2020, 2021 Daniela Kaufmann, Johannes Kepler University Linz 7 | */ 8 | /*------------------------------------------------------------------------*/ 9 | #include "substitution_engine.h" 10 | 11 | /*------------------------------------------------------------------------*/ 12 | // ERROR CODES: 13 | static int err_write_file = 51; // error write to file 14 | static int err_write_aig = 52; // error write aig 15 | /*------------------------------------------------------------------------*/ 16 | void init_gate_substitution() { 17 | allocate_gates(); 18 | mark_aig_outputs(); 19 | set_parents_and_children(0); 20 | set_xor(); 21 | } 22 | 23 | /*------------------------------------------------------------------------*/ 24 | 25 | bool substitution(const char * out_f1, const char * out_f2) { 26 | assert(out_f1); 27 | assert(out_f2); 28 | 29 | FILE * f1; 30 | if (!(f1 = fopen(out_f1, "w"))) 31 | die(err_write_file, "can not write output to '%s'", out_f1); 32 | 33 | FILE *f2; 34 | if (!(f2 = fopen(out_f2, "w"))) 35 | die(err_write_aig, "can not write output to '%s'", out_f2); 36 | 37 | init_aig_substitution(); 38 | init_time = process_time(); 39 | 40 | bool res; 41 | 42 | if (identify_final_stage_adder() && build_adder_miter()) { 43 | res = 1; 44 | 45 | if (!miter_to_file(f1)) 46 | die(err_write_file, "failed to write miter to '%s'", out_f1); 47 | else 48 | msg("writing miter to %s", out_f1); 49 | 50 | generate_rewritten_aig(); 51 | 52 | if (!aiger_write_to_file(rewritten, aiger_binary_mode, f2)) 53 | die(err_write_aig, "failed to write rewritten aig to '%s'", out_f2); 54 | else 55 | msg("writing rewritten aig to '%s'", out_f2); 56 | 57 | 58 | } else { 59 | res = 0; 60 | 61 | if (!trivial_miter_to_file(f1)) 62 | die(err_write_file, "failed to write trivial miter to '%s'", out_f1); 63 | else 64 | msg("writing trivial miter to %s", out_f1); 65 | 66 | if (!write_model(f2)) 67 | die(err_write_aig, "failed to write original aig to '%s'", out_f2); 68 | else 69 | msg("writing original aig to '%s'", out_f2); 70 | } 71 | 72 | substitution_time = process_time(); 73 | 74 | fclose(f1); 75 | fclose(f2); 76 | reset_aig_substitution(); 77 | 78 | return res; 79 | } 80 | -------------------------------------------------------------------------------- /src/slicing.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------*/ 2 | /*! \file slicing.h 3 | \brief contains functions slice and order the gates 4 | 5 | Part of AMulet2 : AIG Multiplier Verification Tool. 6 | Copyright(C) 2020, 2021 Daniela Kaufmann, Johannes Kepler University Linz 7 | */ 8 | /*------------------------------------------------------------------------*/ 9 | #ifndef AMULET2_SRC_SLICING_H_ 10 | #define AMULET2_SRC_SLICING_H_ 11 | /*------------------------------------------------------------------------*/ 12 | #include 13 | #include 14 | 15 | #include "gate.h" 16 | /*------------------------------------------------------------------------*/ 17 | // / vector-list Gate* matrix to store slices 18 | extern std::vector> slices; 19 | /*------------------------------------------------------------------------*/ 20 | 21 | /** 22 | Allocates the memory for the slices 23 | and adds the output gate of each slice 24 | */ 25 | void init_slices(); 26 | 27 | /** 28 | Prints the polynomials in the slices to stdout 29 | */ 30 | void print_slices(); 31 | 32 | 33 | /** 34 | Returns the child that has the highest position in a slice 35 | 36 | @param n Gate* for parent 37 | 38 | @return Gate* 39 | */ 40 | const Gate * topological_largest_child(const Gate * n); 41 | 42 | /** 43 | Overall slicing routine based on xor gates, calls all other functions 44 | automatically 45 | */ 46 | bool slicing_xor(); 47 | 48 | /*------------------------------------------------------------------------*/ 49 | 50 | /** 51 | Mark the children of gate n to slice num, if not assigned otherwise. 52 | 53 | @param n Gate* 54 | @param num integer for slice index 55 | */ 56 | void input_cone(Gate * n, int num); 57 | 58 | /** 59 | Identify those gates that are input in bigger slices 60 | */ 61 | void find_carries(); 62 | 63 | /** 64 | Identifies whether polynomials use a booth pattern(as in the aoki benchmarks) 65 | 66 | @return True if booth pattern are found 67 | */ 68 | bool search_for_booth_pattern(); 69 | 70 | /** 71 | We repeatedly move gates to smaller slices. 72 | */ 73 | void merge_all(); 74 | 75 | /** 76 | We repeatedly move gates to bigger slices. 77 | */ 78 | void promote_all(); 79 | 80 | /** 81 | Fills the slices by adding the gates that are assigned to slices 82 | */ 83 | void fill_slices(); 84 | 85 | 86 | /** 87 | Undoes slicing attempt 88 | */ 89 | void clean_slices(); 90 | 91 | /** 92 | Overall slicing routine, that does not depend on xor-chains 93 | */ 94 | void slicing_non_xor(); 95 | 96 | #endif // AMULET2_SRC_SLICING_H_ 97 | -------------------------------------------------------------------------------- /src/monomial.cpp: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------*/ 2 | /*! \file monomial.cpp 3 | \brief contains the class Monomial and further functions to 4 | manipulate monomials 5 | 6 | Part of AMulet2 : AIG Multiplier Verification Tool. 7 | Copyright(C) 2020, 2021 Daniela Kaufmann, Johannes Kepler University Linz 8 | */ 9 | /*------------------------------------------------------------------------*/ 10 | #include "monomial.h" 11 | /*------------------------------------------------------------------------*/ 12 | 13 | Monomial::Monomial(mpz_t _c, Term * _t): ref(1) { 14 | mpz_init_set(coeff, _c); 15 | if (mpz_sgn(_c) == 0) term = 0; 16 | else term = _t; 17 | } 18 | 19 | /*------------------------------------------------------------------------*/ 20 | 21 | Monomial * Monomial::copy() { 22 | Monomial * m = this; 23 | if (!m) return 0; 24 | assert(ref > 0); 25 | 26 | ++ref; 27 | assert(ref); 28 | return this; 29 | } 30 | 31 | /*------------------------------------------------------------------------*/ 32 | 33 | Monomial::~Monomial() { 34 | assert(ref == 0); 35 | 36 | mpz_clear(coeff); 37 | deallocate_term(term); 38 | } 39 | 40 | /*------------------------------------------------------------------------*/ 41 | 42 | void Monomial::print(FILE * file, bool lm) const { 43 | int sign = mpz_sgn(coeff); 44 | if (!sign) return; 45 | else if (!lm && sign > 0) fputc_unlocked('+', file); 46 | 47 | if (term) { 48 | if (mpz_cmp_si(coeff, -1) == 0) { fputc_unlocked('-', file); 49 | } else if (mpz_cmp_si(coeff, 1) != 0) { 50 | mpz_out_str(file, 10, coeff); 51 | fputc_unlocked('*', file); 52 | } term->print(file); 53 | } 54 | else mpz_out_str(file, 10, coeff); 55 | } 56 | 57 | /*------------------------------------------------------------------------*/ 58 | 59 | Monomial * multiply_monomial(const Monomial * m1, const Monomial *m2) { 60 | assert(m1); 61 | assert(m2); 62 | 63 | mpz_t coeff; 64 | mpz_init(coeff); 65 | mpz_mul(coeff, m1->coeff, m2->coeff); 66 | 67 | Term * t; 68 | if (m1->get_term() && m2->get_term()) 69 | t = multiply_term(m1->get_term(), m2->get_term()); 70 | else if (m2->get_term()) t = m2->get_term_copy(); 71 | else if (m1->get_term()) t = m1->get_term_copy(); 72 | else 73 | t = 0; 74 | 75 | Monomial * mon = new Monomial(coeff, t); 76 | 77 | mpz_clear(coeff); 78 | return mon; 79 | } 80 | 81 | /*------------------------------------------------------------------------*/ 82 | 83 | void deallocate_monomial(Monomial * m) { 84 | assert(m->get_ref() > 0); 85 | if (m->dec_ref() > 0) return; 86 | 87 | delete(m); 88 | } 89 | -------------------------------------------------------------------------------- /src/signal_statistics.h: -------------------------------------------------------------------------------- 1 | /*------------------------------------------------------------------------*/ 2 | /*! \file signal_statistics.h 3 | \brief used to handle signals, messages and statistics 4 | 5 | Part of AMulet2 : AIG Multiplier Verification Tool. 6 | Copyright(C) 2020, 2021 Daniela Kaufmann, Johannes Kepler University Linz 7 | */ 8 | /*------------------------------------------------------------------------*/ 9 | #ifndef AMULET2_SRC_SIGNAL_STATISTICS_H_ 10 | #define AMULET2_SRC_SIGNAL_STATISTICS_H_ 11 | /*------------------------------------------------------------------------*/ 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include 18 | /*------------------------------------------------------------------------*/ 19 | extern void(*original_SIGINT_handler)(int); 20 | extern void(*original_SIGSEGV_handler)(int); 21 | extern void(*original_SIGABRT_handler)(int); 22 | extern void(*original_SIGTERM_handler)(int); 23 | 24 | /** 25 | Returns name of signal 26 | 27 | @param sig integer 28 | 29 | @return char * 30 | */ 31 | const char * signal_name(int sig); 32 | 33 | /** 34 | Initialize all signals 35 | */ 36 | void init_all_signal_handers(); 37 | 38 | 39 | /** 40 | Catch signal and prints corresponding message 41 | 42 | @param sig integer 43 | */ 44 | void catch_signal(int sig); 45 | 46 | /** 47 | Resets all signal handlers 48 | */ 49 | void reset_all_signal_handlers(); 50 | 51 | /*------------------------------------------------------------------------*/ 52 | // / Level of output verbosity, ranges from 0 to 4 53 | extern int verbose; 54 | 55 | /** 56 | Prints an error message to stderr and exits the program 57 | 58 | @param char* fmt message 59 | @param int error_code 60 | */ 61 | void die(int error_code, const char *fmt,...); 62 | 63 | /** 64 | Prints a message to stdout 65 | 66 | @param char* fmt message 67 | */ 68 | void msg(const char *fmt, ...); 69 | /*------------------------------------------------------------------------*/ 70 | 71 | // / Time measures used for verify/certify modus 72 | extern double init_time; // /< measure initializing time 73 | extern double slicing_elim_time; // /< measure time used to eliminate & slice 74 | extern double reduction_time; // /< measure time used to reduce 75 | extern double reset_time; // /< measure resetting time 76 | extern double substitution_time; // /< measure time used in substitution 77 | 78 | /** 79 | Determines max used memory 80 | */ 81 | size_t maximum_resident_set_size(); 82 | 83 | /** 84 | Determines the used process time 85 | */ 86 | double process_time(); 87 | 88 | /** 89 | Print statistics of maximum memory and used process time depending on 90 | selected modus 91 | 92 | @param modus integer 93 | */ 94 | void print_statistics(int modus); 95 | 96 | #endif // AMULET2_SRC_SIGNAL_STATISTICS_H_ 97 | -------------------------------------------------------------------------------- /configure.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | die () { 3 | echo "*** configure.sh: $*" 1>&2 4 | exit 1 5 | } 6 | usage () { 7 | cat < ... ] 9 | 10 | where