From 66cdd36d20afea221ac9af47866569a9bf038f30 Mon Sep 17 00:00:00 2001 From: aletempiac Date: Wed, 15 Nov 2023 19:03:29 +0100 Subject: [PATCH] Runtime improvements in decomposition --- src/acd/ac_decomposition.hpp | 4 ++-- src/acd/ac_wrapper.cpp | 4 ++-- src/acd/ac_wrapper.h | 1 + src/acd/kitty_operators.hpp | 38 +++++++++++++++++++++++++++++++++++- src/map/if/if.h | 2 +- 5 files changed, 43 insertions(+), 6 deletions(-) diff --git a/src/acd/ac_decomposition.hpp b/src/acd/ac_decomposition.hpp index 4f94bcba4..59fd00ada 100644 --- a/src/acd/ac_decomposition.hpp +++ b/src/acd/ac_decomposition.hpp @@ -134,8 +134,8 @@ public: /* add cost if not support reducing */ uint32_t additional_cost = ( num_vars - i > ps.lut_size ) ? 128 : 0; - /* check for feasible solution that improves the cost */ - if ( cost <= ( 1 << ( ps.lut_size - i ) ) && cost + additional_cost < best_cost ) + /* check for feasible solution that improves the cost */ /* TODO: remove limit on cost */ + if ( cost <= ( 1 << ( ps.lut_size - i ) ) && cost + additional_cost < best_cost && cost < 12 ) { best_tt = tt_p; permutations = perm; diff --git a/src/acd/ac_wrapper.cpp b/src/acd/ac_wrapper.cpp index b7cee0dd7..aabe8e86f 100644 --- a/src/acd/ac_wrapper.cpp +++ b/src/acd/ac_wrapper.cpp @@ -20,8 +20,8 @@ int acd_evaluate( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, ac_decomposition_stats st; ac_decomposition_impl acd( tt, nVars, ps, &st ); - acd.run( *pdelay ); - int val = acd.compute_decomposition(); + int val = acd.run( *pdelay ); + // int val = acd.compute_decomposition(); if ( val < 0 ) { diff --git a/src/acd/ac_wrapper.h b/src/acd/ac_wrapper.h index 522a60b86..cb22acf80 100644 --- a/src/acd/ac_wrapper.h +++ b/src/acd/ac_wrapper.h @@ -4,6 +4,7 @@ // #include "base/main/main.h" #include "misc/util/abc_global.h" +#include "map/if/if.h" // ABC_NAMESPACE_HEADER_START diff --git a/src/acd/kitty_operators.hpp b/src/acd/kitty_operators.hpp index cf973ebe0..68a24cf2e 100644 --- a/src/acd/kitty_operators.hpp +++ b/src/acd/kitty_operators.hpp @@ -78,7 +78,43 @@ inline void operator|=( dynamic_truth_table& first, const dynamic_truth_table& s template inline void operator|=( static_truth_table& first, const static_truth_table& second ) { - first = binary_or( first, second ); + // first = binary_or( first, second ); + /* runtime improved version */ + if constexpr ( NumVars <= 6 ) + { + first._bits |= second._bits; + first.mask_bits(); + } + else if constexpr ( NumVars == 7 ) + { + first._bits[0] |= second._bits[0]; + first._bits[1] |= second._bits[1]; + } + else if constexpr ( NumVars == 8 ) + { + first._bits[0] |= second._bits[0]; + first._bits[1] |= second._bits[1]; + first._bits[2] |= second._bits[2]; + first._bits[3] |= second._bits[3]; + } + else if constexpr ( NumVars == 9 ) + { + first._bits[0] |= second._bits[0]; + first._bits[1] |= second._bits[1]; + first._bits[2] |= second._bits[2]; + first._bits[3] |= second._bits[3]; + first._bits[4] |= second._bits[4]; + first._bits[5] |= second._bits[5]; + first._bits[6] |= second._bits[6]; + first._bits[7] |= second._bits[7]; + } + else + { + for ( uint32_t i = 0; i < first.num_blocks(); ++i ) + { + first._bits[i] |= second._bits[i]; + } + } } } // namespace kitty diff --git a/src/map/if/if.h b/src/map/if/if.h index 156e8679f..56f0bb7ed 100644 --- a/src/map/if/if.h +++ b/src/map/if/if.h @@ -40,7 +40,7 @@ #include "opt/dau/dau.h" #include "misc/vec/vecHash.h" #include "misc/vec/vecWec.h" -#include "ACD/ac_wrapper.h" +#include "acd/ac_wrapper.h" ABC_NAMESPACE_HEADER_START