Commit 75e60ab2 by Alan Mishchenko

Experiments with reachability.

parent c0c9fc84
...@@ -4163,11 +4163,11 @@ SOURCE=.\src\aig\llb\llb3Nonlin.c ...@@ -4163,11 +4163,11 @@ SOURCE=.\src\aig\llb\llb3Nonlin.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\aig\llb\llb4Image.c SOURCE=.\src\aig\llb\llb4Cluster.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\aig\llb\llb4Map.c SOURCE=.\src\aig\llb\llb4Image.c
# End Source File # End Source File
# Begin Source File # Begin Source File
......
...@@ -48,6 +48,7 @@ struct Llb_Mgr_t_ ...@@ -48,6 +48,7 @@ struct Llb_Mgr_t_
{ {
DdManager * dd; // working BDD manager DdManager * dd; // working BDD manager
Vec_Int_t * vVars2Q; // variables to quantify Vec_Int_t * vVars2Q; // variables to quantify
int nSizeMax; // maximum size of the cluster
// internal // internal
Llb_Prt_t ** pParts; // partitions Llb_Prt_t ** pParts; // partitions
Llb_Var_t ** pVars; // variables Llb_Var_t ** pVars; // variables
...@@ -263,7 +264,7 @@ int Llb_Nonlin4Quantify1( Llb_Mgr_t * p, Llb_Prt_t * pPart ) ...@@ -263,7 +264,7 @@ int Llb_Nonlin4Quantify1( Llb_Mgr_t * p, Llb_Prt_t * pPart )
int i, RetValue, nSizeNew; int i, RetValue, nSizeNew;
// create cube to be quantified // create cube to be quantified
bCube = Llb_Nonlin4CreateCube1( p, pPart ); Cudd_Ref( bCube ); bCube = Llb_Nonlin4CreateCube1( p, pPart ); Cudd_Ref( bCube );
assert( !Cudd_IsConstant(bCube) ); // assert( !Cudd_IsConstant(bCube) );
// derive new function // derive new function
pPart->bFunc = Cudd_bddExistAbstract( p->dd, bTemp = pPart->bFunc, bCube ); Cudd_Ref( pPart->bFunc ); pPart->bFunc = Cudd_bddExistAbstract( p->dd, bTemp = pPart->bFunc, bCube ); Cudd_Ref( pPart->bFunc );
Cudd_RecursiveDeref( p->dd, bTemp ); Cudd_RecursiveDeref( p->dd, bTemp );
...@@ -323,9 +324,13 @@ int Llb_Nonlin4Quantify2( Llb_Mgr_t * p, Llb_Prt_t * pPart1, Llb_Prt_t * pPart2 ...@@ -323,9 +324,13 @@ int Llb_Nonlin4Quantify2( Llb_Mgr_t * p, Llb_Prt_t * pPart1, Llb_Prt_t * pPart2
int i, RetValue, nSuppSize; int i, RetValue, nSuppSize;
int iPart1 = pPart1->iPart; int iPart1 = pPart1->iPart;
int iPart2 = pPart2->iPart; int iPart2 = pPart2->iPart;
int liveBeg, liveEnd;
// create cube to be quantified // create cube to be quantified
bCube = Llb_Nonlin4CreateCube2( p, pPart1, pPart2 ); Cudd_Ref( bCube ); bCube = Llb_Nonlin4CreateCube2( p, pPart1, pPart2 ); Cudd_Ref( bCube );
printf( "Quantifying " ); Extra_bddPrintSupport( p->dd, bCube ); printf( "\n" );
if ( fVerbose ) if ( fVerbose )
{ {
printf( "\n" ); printf( "\n" );
...@@ -334,7 +339,11 @@ Llb_Nonlin4Print( p ); ...@@ -334,7 +339,11 @@ Llb_Nonlin4Print( p );
printf( "Conjoining partitions %d and %d.\n", pPart1->iPart, pPart2->iPart ); printf( "Conjoining partitions %d and %d.\n", pPart1->iPart, pPart2->iPart );
Extra_bddPrintSupport( p->dd, bCube ); printf( "\n" ); Extra_bddPrintSupport( p->dd, bCube ); printf( "\n" );
} }
liveBeg = p->dd->keys - p->dd->dead;
bFunc = Cudd_bddAndAbstract( p->dd, pPart1->bFunc, pPart2->bFunc, bCube ); bFunc = Cudd_bddAndAbstract( p->dd, pPart1->bFunc, pPart2->bFunc, bCube );
liveEnd = p->dd->keys - p->dd->dead;
//printf( "%d ", liveEnd-liveBeg );
if ( bFunc == NULL ) if ( bFunc == NULL )
{ {
Cudd_RecursiveDeref( p->dd, bCube ); Cudd_RecursiveDeref( p->dd, bCube );
...@@ -343,6 +352,8 @@ Extra_bddPrintSupport( p->dd, bCube ); printf( "\n" ); ...@@ -343,6 +352,8 @@ Extra_bddPrintSupport( p->dd, bCube ); printf( "\n" );
Cudd_Ref( bFunc ); Cudd_Ref( bFunc );
Cudd_RecursiveDeref( p->dd, bCube ); Cudd_RecursiveDeref( p->dd, bCube );
printf( "Createing part %d ", p->iPartFree ); Extra_bddPrintSupport( p->dd, bFunc ); printf( "\n" );
// create new partition // create new partition
pTemp = p->pParts[p->iPartFree] = ABC_CALLOC( Llb_Prt_t, 1 ); pTemp = p->pParts[p->iPartFree] = ABC_CALLOC( Llb_Prt_t, 1 );
pTemp->iPart = p->iPartFree++; pTemp->iPart = p->iPartFree++;
...@@ -573,8 +584,15 @@ int Llb_Nonlin4NextPartitions( Llb_Mgr_t * p, Llb_Prt_t ** ppPart1, Llb_Prt_t ** ...@@ -573,8 +584,15 @@ int Llb_Nonlin4NextPartitions( Llb_Mgr_t * p, Llb_Prt_t ** ppPart1, Llb_Prt_t **
Llb_Nonlin4CheckVars( p ); Llb_Nonlin4CheckVars( p );
// find variable with minimum score // find variable with minimum score
Llb_MgrForEachVar( p, pVar, i ) Llb_MgrForEachVar( p, pVar, i )
{
if ( p->nSizeMax && pVar->nScore > p->nSizeMax )
continue;
// if ( pVarBest == NULL || Vec_IntSize(pVarBest->vParts) * pVarBest->nScore > Vec_IntSize(pVar->vParts) * pVar->nScore )
if ( pVarBest == NULL || pVarBest->nScore > pVar->nScore ) if ( pVarBest == NULL || pVarBest->nScore > pVar->nScore )
pVarBest = pVar; pVarBest = pVar;
// printf( "%d ", pVar->nScore );
}
//printf( "\n" );
if ( pVarBest == NULL ) if ( pVarBest == NULL )
return 0; return 0;
// find two partitions with minimum size // find two partitions with minimum size
...@@ -592,6 +610,10 @@ int Llb_Nonlin4NextPartitions( Llb_Mgr_t * p, Llb_Prt_t ** ppPart1, Llb_Prt_t ** ...@@ -592,6 +610,10 @@ int Llb_Nonlin4NextPartitions( Llb_Mgr_t * p, Llb_Prt_t ** ppPart1, Llb_Prt_t **
pPart2Best = pPart; pPart2Best = pPart;
} }
} }
printf( "Selecting %d and parts %d and %d\n", pVarBest->iVar, pPart1Best->nSize, pPart2Best->nSize );
Extra_bddPrintSupport( p->dd, pPart1Best->bFunc ); printf( "\n" );
Extra_bddPrintSupport( p->dd, pPart2Best->bFunc ); printf( "\n" );
*ppPart1 = pPart1Best; *ppPart1 = pPart1Best;
*ppPart2 = pPart2Best; *ppPart2 = pPart2Best;
return 1; return 1;
...@@ -661,13 +683,14 @@ void Llb_Nonlin4VerifyScores( Llb_Mgr_t * p ) ...@@ -661,13 +683,14 @@ void Llb_Nonlin4VerifyScores( Llb_Mgr_t * p )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
Llb_Mgr_t * Llb_Nonlin4Alloc( DdManager * dd, Vec_Ptr_t * vParts, DdNode * bCurrent, Vec_Int_t * vVars2Q ) Llb_Mgr_t * Llb_Nonlin4Alloc( DdManager * dd, Vec_Ptr_t * vParts, DdNode * bCurrent, Vec_Int_t * vVars2Q, int nSizeMax )
{ {
Llb_Mgr_t * p; Llb_Mgr_t * p;
DdNode * bFunc; DdNode * bFunc;
int i; int i;
p = ABC_CALLOC( Llb_Mgr_t, 1 ); p = ABC_CALLOC( Llb_Mgr_t, 1 );
p->dd = dd; p->dd = dd;
p->nSizeMax = nSizeMax;
p->vVars2Q = vVars2Q; p->vVars2Q = vVars2Q;
p->nVars = Cudd_ReadSize(dd); p->nVars = Cudd_ReadSize(dd);
p->iPartFree = Vec_PtrSize(vParts); p->iPartFree = Vec_PtrSize(vParts);
...@@ -678,7 +701,8 @@ Llb_Mgr_t * Llb_Nonlin4Alloc( DdManager * dd, Vec_Ptr_t * vParts, DdNode * bCurr ...@@ -678,7 +701,8 @@ Llb_Mgr_t * Llb_Nonlin4Alloc( DdManager * dd, Vec_Ptr_t * vParts, DdNode * bCurr
Vec_PtrForEachEntry( DdNode *, vParts, bFunc, i ) Vec_PtrForEachEntry( DdNode *, vParts, bFunc, i )
Llb_Nonlin4AddPartition( p, i, bFunc ); Llb_Nonlin4AddPartition( p, i, bFunc );
// add partition // add partition
Llb_Nonlin4AddPartition( p, p->iPartFree++, bCurrent ); if ( bCurrent )
Llb_Nonlin4AddPartition( p, p->iPartFree++, bCurrent );
return p; return p;
} }
...@@ -710,11 +734,11 @@ void Llb_Nonlin4Free( Llb_Mgr_t * p ) ...@@ -710,11 +734,11 @@ void Llb_Nonlin4Free( Llb_Mgr_t * p )
/**Function************************************************************* /**Function*************************************************************
Synopsis [Performs image computation.] Synopsis []
Description [Computes image of BDDs (vFuncs).] Description []
SideEffects [BDDs in vFuncs are derefed inside. The result is refed.] SideEffects []
SeeAlso [] SeeAlso []
...@@ -726,7 +750,7 @@ DdNode * Llb_Nonlin4Image( DdManager * dd, Vec_Ptr_t * vParts, DdNode * bCurrent ...@@ -726,7 +750,7 @@ DdNode * Llb_Nonlin4Image( DdManager * dd, Vec_Ptr_t * vParts, DdNode * bCurrent
DdNode * bFunc, * bTemp; DdNode * bFunc, * bTemp;
int i, nReorders; int i, nReorders;
// start the manager // start the manager
p = Llb_Nonlin4Alloc( dd, vParts, bCurrent, vVars2Q ); p = Llb_Nonlin4Alloc( dd, vParts, bCurrent, vVars2Q, 0 );
// remove singles // remove singles
Llb_MgrForEachPart( p, pPart, i ) Llb_MgrForEachPart( p, pPart, i )
if ( Llb_Nonlin4HasSingletonVars(p, pPart) ) if ( Llb_Nonlin4HasSingletonVars(p, pPart) )
...@@ -744,8 +768,8 @@ DdNode * Llb_Nonlin4Image( DdManager * dd, Vec_Ptr_t * vParts, DdNode * bCurrent ...@@ -744,8 +768,8 @@ DdNode * Llb_Nonlin4Image( DdManager * dd, Vec_Ptr_t * vParts, DdNode * bCurrent
} }
if ( nReorders < Cudd_ReadReorderings(dd) ) if ( nReorders < Cudd_ReadReorderings(dd) )
Llb_Nonlin4RecomputeScores( p ); Llb_Nonlin4RecomputeScores( p );
else // else
Llb_Nonlin4VerifyScores( p ); // Llb_Nonlin4VerifyScores( p );
} }
// load partitions // load partitions
bFunc = Cudd_ReadOne(p->dd); Cudd_Ref( bFunc ); bFunc = Cudd_ReadOne(p->dd); Cudd_Ref( bFunc );
...@@ -756,11 +780,70 @@ DdNode * Llb_Nonlin4Image( DdManager * dd, Vec_Ptr_t * vParts, DdNode * bCurrent ...@@ -756,11 +780,70 @@ DdNode * Llb_Nonlin4Image( DdManager * dd, Vec_Ptr_t * vParts, DdNode * bCurrent
} }
// nSuppMax = p->nSuppMax; // nSuppMax = p->nSuppMax;
Llb_Nonlin4Free( p ); Llb_Nonlin4Free( p );
//printf( "\n" );
// return // return
Cudd_Deref( bFunc ); Cudd_Deref( bFunc );
return bFunc; return bFunc;
} }
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Ptr_t * Llb_Nonlin4Group( DdManager * dd, Vec_Ptr_t * vParts, Vec_Int_t * vVars2Q, int nSizeMax )
{
Vec_Ptr_t * vGroups;
Llb_Prt_t * pPart, * pPart1, * pPart2;
Llb_Mgr_t * p;
int i, nReorders;
// start the manager
p = Llb_Nonlin4Alloc( dd, vParts, NULL, vVars2Q, nSizeMax );
// remove singles
Llb_MgrForEachPart( p, pPart, i )
if ( Llb_Nonlin4HasSingletonVars(p, pPart) )
Llb_Nonlin4Quantify1( p, pPart );
// compute scores
Llb_Nonlin4RecomputeScores( p );
// iteratively quantify variables
while ( Llb_Nonlin4NextPartitions(p, &pPart1, &pPart2) )
{
nReorders = Cudd_ReadReorderings(dd);
if ( !Llb_Nonlin4Quantify2( p, pPart1, pPart2 ) )
{
Llb_Nonlin4Free( p );
return NULL;
}
if ( nReorders < Cudd_ReadReorderings(dd) )
Llb_Nonlin4RecomputeScores( p );
else
Llb_Nonlin4VerifyScores( p );
}
// load partitions
vGroups = Vec_PtrAlloc( 1000 );
Llb_MgrForEachPart( p, pPart, i )
{
if ( Cudd_IsConstant(pPart->bFunc) )
{
assert( !Cudd_IsComplement(pPart->bFunc) );
continue;
}
Vec_PtrPush( vGroups, pPart->bFunc );
Cudd_Ref( pPart->bFunc );
printf( "Part %d ", pPart->iPart );
Extra_bddPrintSupport( p->dd, pPart->bFunc ); printf( "\n" );
}
Llb_Nonlin4Free( p );
return vGroups;
}
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// END OF FILE /// /// END OF FILE ///
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -255,6 +255,8 @@ void Llb_Nonlin4CreateOrderSmart_rec( Aig_Man_t * pAig, Aig_Obj_t * pObj, Vec_In ...@@ -255,6 +255,8 @@ void Llb_Nonlin4CreateOrderSmart_rec( Aig_Man_t * pAig, Aig_Obj_t * pObj, Vec_In
assert( Llb_MnxBddVar(vOrder, pObj) < 0 ); assert( Llb_MnxBddVar(vOrder, pObj) < 0 );
if ( Aig_ObjIsPi(pObj) ) if ( Aig_ObjIsPi(pObj) )
{ {
// if ( Saig_ObjIsLo(pAig, pObj) )
// Vec_IntWriteEntry( vOrder, Aig_ObjId(Saig_ObjLoToLi(pAig, pObj)), (*pCounter)++ );
Vec_IntWriteEntry( vOrder, Aig_ObjId(pObj), (*pCounter)++ ); Vec_IntWriteEntry( vOrder, Aig_ObjId(pObj), (*pCounter)++ );
return; return;
} }
...@@ -345,7 +347,11 @@ printf( "Techmapping added %d pivots.\n", Vec_IntSize(vNodes) ); ...@@ -345,7 +347,11 @@ printf( "Techmapping added %d pivots.\n", Vec_IntSize(vNodes) );
} }
Aig_ManForEachPi( pAig, pObj, i ) Aig_ManForEachPi( pAig, pObj, i )
if ( Llb_MnxBddVar(vOrder, pObj) < 0 ) if ( Llb_MnxBddVar(vOrder, pObj) < 0 )
{
// if ( Saig_ObjIsLo(pAig, pObj) )
// Vec_IntWriteEntry( vOrder, Aig_ObjId(Saig_ObjLoToLi(pAig, pObj)), Counter++ );
Vec_IntWriteEntry( vOrder, Aig_ObjId(pObj), Counter++ ); Vec_IntWriteEntry( vOrder, Aig_ObjId(pObj), Counter++ );
}
assert( Counter <= Aig_ManPiNum(pAig) + Aig_ManRegNum(pAig) + (vNodes?Vec_IntSize(vNodes):0) ); assert( Counter <= Aig_ManPiNum(pAig) + Aig_ManRegNum(pAig) + (vNodes?Vec_IntSize(vNodes):0) );
Aig_ManCleanMarkA( pAig ); Aig_ManCleanMarkA( pAig );
Vec_IntFreeP( &vNodes ); Vec_IntFreeP( &vNodes );
...@@ -701,6 +707,13 @@ int Llb_Nonlin4Reachability( Llb_Mnx_t * p ) ...@@ -701,6 +707,13 @@ int Llb_Nonlin4Reachability( Llb_Mnx_t * p )
Cudd_RecursiveDeref( p->dd, p->bNext ); p->bNext = NULL; Cudd_RecursiveDeref( p->dd, p->bNext ); p->bNext = NULL;
if ( Cudd_IsConstant(p->bCurrent) ) if ( Cudd_IsConstant(p->bCurrent) )
break; break;
/*
// reduce BDD size using constrain // Cudd_bddRestrict
p->bCurrent = Cudd_bddRestrict( p->dd, bAux = p->bCurrent, Cudd_Not(p->bReached) );
Cudd_Ref( p->bCurrent );
printf( "Before = %d. After = %d.\n", Cudd_DagSize(bAux), Cudd_DagSize(p->bCurrent) );
Cudd_RecursiveDeref( p->dd, bAux );
*/
// add to the reached set // add to the reached set
p->bReached = Cudd_bddOr( p->dd, bAux = p->bReached, p->bCurrent ); p->bReached = Cudd_bddOr( p->dd, bAux = p->bReached, p->bCurrent );
...@@ -715,14 +728,15 @@ int Llb_Nonlin4Reachability( Llb_Mnx_t * p ) ...@@ -715,14 +728,15 @@ int Llb_Nonlin4Reachability( Llb_Mnx_t * p )
Cudd_Ref( p->bReached ); Cudd_Ref( p->bReached );
Cudd_RecursiveDeref( p->dd, bAux ); Cudd_RecursiveDeref( p->dd, bAux );
// report the results // report the results
if ( p->pPars->fVerbose ) if ( p->pPars->fVerbose )
{ {
printf( "I =%5d : ", nIters ); printf( "I =%5d : ", nIters );
printf( "Fr =%7d ", nBddSizeFr ); printf( "Fr =%7d ", nBddSizeFr );
printf( "ImNs =%7d ", nBddSizeTo ); printf( "ImNs =%7d ", nBddSizeTo );
printf( "ImCs =%7d ", nBddSizeTo2 ); printf( "ImCs =%7d ", nBddSizeTo2 );
printf( "Rea =%7d ", Cudd_DagSize(p->bReached) ); printf( "Rea =%7d ", Cudd_DagSize(p->bReached) );
printf( "(%4d %4d) ", Cudd_ReadReorderings(p->dd), Cudd_ReadGarbageCollections(p->dd) ); printf( "(%4d %4d) ", Cudd_ReadReorderings(p->dd), Cudd_ReadGarbageCollections(p->dd) );
Abc_PrintTime( 1, "T", clock() - clkIter ); Abc_PrintTime( 1, "T", clock() - clkIter );
} }
......
...@@ -184,6 +184,7 @@ extern DdNode * Llb_NonlinComputeInitState( Aig_Man_t * pAig, DdManager * ...@@ -184,6 +184,7 @@ extern DdNode * Llb_NonlinComputeInitState( Aig_Man_t * pAig, DdManager *
/*=== llb4Image.c =======================================================*/ /*=== llb4Image.c =======================================================*/
extern DdNode * Llb_Nonlin4Image( DdManager * dd, Vec_Ptr_t * vParts, DdNode * bCurrent, Vec_Int_t * vVars2Q ); extern DdNode * Llb_Nonlin4Image( DdManager * dd, Vec_Ptr_t * vParts, DdNode * bCurrent, Vec_Int_t * vVars2Q );
extern Vec_Ptr_t * Llb_Nonlin4Group( DdManager * dd, Vec_Ptr_t * vParts, Vec_Int_t * vVars2Q, int nSizeMax );
/*=== llb4Map.c =========================================================*/ /*=== llb4Map.c =========================================================*/
//extern Vec_Int_t * Llb_AigMap( Aig_Man_t * pAig, int nLutSize, int nLutMin ); //extern Vec_Int_t * Llb_AigMap( Aig_Man_t * pAig, int nLutSize, int nLutMin );
/*=== llb4Nonlin.c ======================================================*/ /*=== llb4Nonlin.c ======================================================*/
......
...@@ -8522,21 +8522,24 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -8522,21 +8522,24 @@ int Abc_CommandTest( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes ); Abc_FrameReplaceCurrentNetwork( pAbc, pNtkRes );
} }
*/ */
/* /*
{ {
extern void Aig_ManTerSimulate( Aig_Man_t * pAig ); extern void Llb_Nonlin4Cluster( Aig_Man_t * pAig );
// extern void Aig_ManTerSimulate( Aig_Man_t * pAig );
extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters ); extern Aig_Man_t * Abc_NtkToDar( Abc_Ntk_t * pNtk, int fExors, int fRegisters );
Aig_Man_t * pAig = Abc_NtkToDar( pNtk, 0, 0 ); Aig_Man_t * pAig = Abc_NtkToDar( pNtk, 0, 0 );
Aig_ManTerSimulate( pAig ); // Aig_ManTerSimulate( pAig );
Llb_Nonlin4Cluster( pAig );
Aig_ManStop( pAig ); Aig_ManStop( pAig );
} }
*/ */
/*
{ {
extern void Ssm_ManExperiment( char * pFileIn, char * pFileOut ); // extern void Ssm_ManExperiment( char * pFileIn, char * pFileOut );
Ssm_ManExperiment( "m\\big1.ssim", "m\\big1_.ssim" ); // Ssm_ManExperiment( "m\\big1.ssim", "m\\big1_.ssim" );
} }
*/
return 0; return 0;
usage: usage:
Abc_Print( -2, "usage: test [-CKDN] [-vwh] <file_name>\n" ); Abc_Print( -2, "usage: test [-CKDN] [-vwh] <file_name>\n" );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment