Skip to content

Commit

Permalink
retire lib/abcresub and abc_index_list
Browse files Browse the repository at this point in the history
  • Loading branch information
lee30sonia committed Mar 4, 2024
1 parent 19953de commit 34fbc5b
Show file tree
Hide file tree
Showing 16 changed files with 214 additions and 3,775 deletions.
2 changes: 1 addition & 1 deletion include/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
add_library(mockturtle INTERFACE)
target_include_directories(mockturtle SYSTEM INTERFACE ${PROJECT_SOURCE_DIR}/include)
target_link_libraries(mockturtle INTERFACE kitty lorina parallel_hashmap percy json bill libabcesop abcresub)
target_link_libraries(mockturtle INTERFACE kitty lorina parallel_hashmap percy json bill libabcesop)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9)
target_link_libraries(mockturtle INTERFACE stdc++fs)
Expand Down
5 changes: 2 additions & 3 deletions include/mockturtle/algorithms/circuit_validator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,7 @@ class circuit_validator
template<class iterator_type, class index_list_type>
std::optional<bool> validate( node const& root, iterator_type divs_begin, iterator_type divs_end, index_list_type const& id_list, bool inverted = false )
{
static_assert( std::is_same_v<index_list_type, abc_index_list> ||
std::is_same_v<index_list_type, mig_index_list> ||
static_assert( std::is_same_v<index_list_type, mig_index_list> ||
std::is_same_v<index_list_type, xag_index_list<true>> ||
std::is_same_v<index_list_type, xag_index_list<false>> ||
std::is_same_v<index_list_type, muxig_index_list>, "Unknown type of index list" );
Expand Down Expand Up @@ -240,7 +239,7 @@ class circuit_validator
push();
}

if constexpr ( std::is_same_v<index_list_type, abc_index_list> || std::is_same_v<index_list_type, xag_index_list<true>> || std::is_same_v<index_list_type, xag_index_list<false>> )
if constexpr ( std::is_same_v<index_list_type, xag_index_list<true>> || std::is_same_v<index_list_type, xag_index_list<false>> )
{
id_list.foreach_gate( [&]( uint32_t id_lit0, uint32_t id_lit1 ) {
uint32_t const node_pos0 = id_lit0 >> 1;
Expand Down
127 changes: 0 additions & 127 deletions include/mockturtle/algorithms/resyn_engines/xag_resyn.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#include "../../utils/node_map.hpp"
#include "../../utils/stopwatch.hpp"

#include <abcresub/abcresub.hpp>
#include <fmt/format.h>
#include <kitty/kitty.hpp>

Expand Down Expand Up @@ -873,130 +872,4 @@ class xag_resyn_decompose
stats& st;
}; /* xag_resyn_decompose */

struct xag_resyn_abc_stats
{
};

template<class TT, class static_params = xag_resyn_static_params_default<TT>>
class xag_resyn_abc
{
public:
using stats = xag_resyn_abc_stats;
using index_list_t = large_xag_index_list;
using truth_table_t = TT;

explicit xag_resyn_abc( stats& st ) noexcept
: st( st ), counter( 0 )
{
static_assert( std::is_same_v<typename static_params::base_type, xag_resyn_static_params>, "Invalid static_params type" );
static_assert( !static_params::preserve_depth && static_params::uniform_div_cost, "Advanced resynthesis is not implemented for this solver" );
}

virtual ~xag_resyn_abc()
{
abcresub::Abc_ResubPrepareManager( 0 );
release();
}

template<class iterator_type, class truth_table_storage_type>
std::optional<index_list_t> operator()( TT const& target, TT const& care, iterator_type begin, iterator_type end, truth_table_storage_type const& tts, uint32_t max_size = std::numeric_limits<uint32_t>::max(), uint32_t max_level = std::numeric_limits<uint32_t>::max() )
{
(void)max_level;
num_divisors = std::distance( begin, end ) + 2;
num_blocks_per_truth_table = target.num_blocks();
abcresub::Abc_ResubPrepareManager( num_blocks_per_truth_table );
alloc();

add_divisor( ~target & care ); /* off-set */
add_divisor( target & care ); /* on-set */

while ( begin != end )
{
add_divisor( tts[*begin] );
++begin;
}

return compute_function( max_size );
}

protected:
void add_divisor( TT const& tt )
{
assert( tt.num_blocks() == num_blocks_per_truth_table );
for ( uint64_t i = 0ul; i < num_blocks_per_truth_table; ++i )
{
if constexpr ( std::is_same_v<TT, kitty::partial_truth_table> || std::is_same_v<TT, kitty::dynamic_truth_table> )
Vec_WrdPush( abc_tts, tt._bits[i] );
else // static_truth_table
Vec_WrdPush( abc_tts, tt._bits );
}
Vec_PtrPush( abc_divs, Vec_WrdEntryP( abc_tts, counter * num_blocks_per_truth_table ) );
++counter;
}

std::optional<index_list_t> compute_function( uint32_t num_inserts )
{
int nLimit = num_inserts > std::numeric_limits<int>::max() ? std::numeric_limits<int>::max() : num_inserts;
int* raw_list;
int size = abcresub::Abc_ResubComputeFunction(
/* ppDivs */ (void**)Vec_PtrArray( abc_divs ),
/* nDivs */ Vec_PtrSize( abc_divs ),
/* nWords */ num_blocks_per_truth_table,
/* nLimit */ nLimit,
/* nDivsMax */ static_params::max_binates,
/* iChoice */ 0, /* fUseXor */ int( static_params::use_xor ), /* fDebug */ 0, /* fVerbose */ 0,
/* ppArray */ &raw_list );

if ( size )
{
index_list_t xag_list;
xag_list.add_inputs( num_divisors - 2 );
for ( int i = 0; i < size - 1; i += 2 )
{
if ( raw_list[i] < raw_list[i + 1] )
xag_list.add_and( raw_list[i] - 2, raw_list[i + 1] - 2 );
else
xag_list.add_xor( raw_list[i] - 2, raw_list[i + 1] - 2 );
}
xag_list.add_output( raw_list[size - 1] < 2 ? raw_list[size - 1] : raw_list[size - 1] - 2 );
return xag_list;
}

return std::nullopt;
}

void dump( std::string const file = "dump.txt" ) const
{
abcresub::Abc_ResubDumpProblem( file.c_str(), (void**)Vec_PtrArray( abc_divs ), Vec_PtrSize( abc_divs ), num_blocks_per_truth_table );
}

void alloc()
{
assert( abc_tts == nullptr );
assert( abc_divs == nullptr );
abc_tts = abcresub::Vec_WrdAlloc( num_divisors * num_blocks_per_truth_table );
abc_divs = abcresub::Vec_PtrAlloc( num_divisors );
}

void release()
{
assert( abc_divs != nullptr );
assert( abc_tts != nullptr );
Vec_PtrFree( abc_divs );
Vec_WrdFree( abc_tts );
abc_divs = nullptr;
abc_tts = nullptr;
}

protected:
uint64_t num_divisors;
uint64_t num_blocks_per_truth_table;
uint64_t counter;

abcresub::Vec_Wrd_t* abc_tts{ nullptr };
abcresub::Vec_Ptr_t* abc_divs{ nullptr };

stats& st;
}; /* xag_resyn_abc */

} /* namespace mockturtle */
Loading

0 comments on commit 34fbc5b

Please sign in to comment.