Decisions on late arrival

This commit is contained in:
aletempiac 2023-11-16 18:53:02 +01:00
parent 548fd6afb2
commit 8aa57c5d54
5 changed files with 41 additions and 23 deletions

View File

@ -62,6 +62,9 @@ struct ac_decomposition_params
/*! \brief Perform decomposition if support reducing. */
bool support_reducing_only{ true };
/*! \brief If decomposition with delay profile fails, ignore it. */
bool try_no_late_arrival{ false };
};
/*! \brief Statistics for ac_decomposition */
@ -157,28 +160,43 @@ public:
}
}
if ( best_multiplicity == UINT32_MAX )
if ( best_multiplicity == UINT32_MAX && ( !ps.try_no_late_arrival || late_arriving == 0 ) )
return -1;
/* compute isets */
// std::vector<STT> isets = compute_isets( free_set_size );
/* try without the delay profile */
if ( best_multiplicity == UINT32_MAX && ps.try_no_late_arrival )
{
if ( ps.support_reducing_only )
{
start = std::max( 1u, num_vars - ps.lut_size );
}
// generate_support_minimization_encodings();
// solve_min_support_exact( isets, free_set_size );
for ( uint32_t i = start; i <= ps.lut_size - 1 && i <= 3; ++i )
{
/* TODO: add shared set */
auto evaluate_fn = [&]( STT const& tt ) { return column_multiplicity( tt, i ); };
auto [tt_p, perm, cost] = enumerate_iset_combinations_offset( i, 0, evaluate_fn );
/* unfeasible decomposition */
// if ( best_bound_sets.empty() )
// {
// return -1;
// }
/* additional 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 */ /* TODO: remove limit on cost */
if ( cost <= ( 1 << ( ps.lut_size - i ) ) && cost + additional_cost < best_cost && cost < 10 )
{
best_tt = tt_p;
permutations = perm;
best_multiplicity = cost;
best_cost = cost + additional_cost;
free_set_size = i;
}
}
}
if ( best_multiplicity == UINT32_MAX )
return -1;
pst->num_luts = ps.lut_size - free_set_size;
best_free_set = free_set_size;
/* TODO generate decomposition only when returning the result */
// dec_result = generate_decomposition( free_set_size );
/* TODO: change return value */
return 0;
}

View File

@ -4,7 +4,7 @@
// ABC_NAMESPACE_IMPL_START
int acd_evaluate( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned *cost )
int acd_evaluate( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned *cost, int try_no_late_arrival )
{
using namespace mockturtle;
@ -17,6 +17,7 @@ int acd_evaluate( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay,
ac_decomposition_params ps;
ps.lut_size = lutSize;
ps.try_no_late_arrival = static_cast<bool>( try_no_late_arrival );
ac_decomposition_stats st;
ac_decomposition_impl acd( tt, nVars, ps, &st );

View File

@ -12,7 +12,7 @@
extern "C" {
#endif
int acd_evaluate( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned *cost );
int acd_evaluate( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned *cost, int try_no_late_arrival );
int acd_decompose( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned char *decomposition );
#ifdef __cplusplus

View File

@ -700,7 +700,7 @@ extern int If_ManCountSpecialPos( If_Man_t * p );
extern void If_CutTraverse( If_Man_t * p, If_Obj_t * pRoot, If_Cut_t * pCut, Vec_Ptr_t * vNodes );
extern void If_ObjPrint( If_Obj_t * pObj );
extern int acd_evaluate( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned *cost );
extern int acd_evaluate( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned *cost, int try_no_late_arrival );
extern int acd_decompose( word * pTruth, unsigned nVars, int lutSize, unsigned *pdelay, unsigned char *decomposition );
ABC_NAMESPACE_HEADER_END

View File

@ -471,12 +471,13 @@ int If_AcdEval( If_Man_t * p, If_Cut_t * pCut, int best_delay )
}
/* remove from critical set */
if ( !use_late_arrival )
if ( !use_late_arrival && nLeafMax > LutSize / 2 )
{
uLeafMask = 0;
}
word *pTruth = If_CutTruthW( p, pCut );
int val = acd_evaluate( pTruth, pCut->nLeaves, LutSize, &uLeafMask, &cost );
int val = acd_evaluate( pTruth, pCut->nLeaves, LutSize, &uLeafMask, &cost, !use_late_arrival );
/* not feasible decomposition */
pCut->acdDelay = uLeafMask;
@ -507,10 +508,8 @@ int If_AcdReEval( If_Man_t * p, If_Cut_t * pCut )
}
// int LutSize = p->pPars->pLutStruct[0] - '0';
int LutSize = 6;
int i, leaf_delay;
int DelayMax = -1, nLeafMax = 0;
unsigned uLeafMask = 0;
int DelayMax = -1;
for ( i = 0; i < If_CutLeaveNum(pCut); i++ )
{
leaf_delay = If_ObjCutBest(If_CutLeaf(p, pCut, i))->Delay;