diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2014-06-20 17:51:35 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2014-06-20 17:51:35 -0700 |
commit | 1e76ebdf3beee8bfd47d433f203c1aa7e998b179 (patch) | |
tree | f04e7730f024524b9e50a3d3d76c6c7654662319 /src/aig | |
parent | e5c031c5ae2b53bc2093cf84da352754a11e8882 (diff) | |
download | abc-1e76ebdf3beee8bfd47d433f203c1aa7e998b179.tar.gz abc-1e76ebdf3beee8bfd47d433f203c1aa7e998b179.tar.bz2 abc-1e76ebdf3beee8bfd47d433f203c1aa7e998b179.zip |
New tools for profiling verification miters.
Diffstat (limited to 'src/aig')
-rw-r--r-- | src/aig/gia/gia.h | 3 | ||||
-rw-r--r-- | src/aig/gia/giaDup.c | 90 | ||||
-rw-r--r-- | src/aig/gia/giaMan.c | 39 | ||||
-rw-r--r-- | src/aig/gia/giaSwitch.c | 21 |
4 files changed, 148 insertions, 5 deletions
diff --git a/src/aig/gia/gia.h b/src/aig/gia/gia.h index 8872ef83..f7e27a08 100644 --- a/src/aig/gia/gia.h +++ b/src/aig/gia/gia.h @@ -198,6 +198,7 @@ struct Gps_Par_t_ int fNpn; int fLutProf; int fMuxXor; + int fMiter; char * pDumpFile; }; @@ -1154,6 +1155,7 @@ extern double Gia_ManMemory( Gia_Man_t * p ); extern void Gia_ManPrintStats( Gia_Man_t * p, Gps_Par_t * pPars ); extern void Gia_ManPrintStatsShort( Gia_Man_t * p ); extern void Gia_ManPrintMiterStatus( Gia_Man_t * p ); +extern void Gia_ManPrintStatsMiter( Gia_Man_t * p, int fVerbose ); extern void Gia_ManSetRegNum( Gia_Man_t * p, int nRegs ); extern void Gia_ManReportImprovement( Gia_Man_t * p, Gia_Man_t * pNew ); extern void Gia_ManPrintNpnClasses( Gia_Man_t * p ); @@ -1244,6 +1246,7 @@ extern int Gia_SweeperRun( Gia_Man_t * p, Vec_Int_t * vProbeIds, extern float Gia_ManEvaluateSwitching( Gia_Man_t * p ); extern float Gia_ManComputeSwitching( Gia_Man_t * p, int nFrames, int nPref, int fProbOne ); extern Vec_Int_t * Gia_ManComputeSwitchProbs( Gia_Man_t * pGia, int nFrames, int nPref, int fProbOne ); +extern Vec_Flt_t * Gia_ManPrintOutputProb( Gia_Man_t * p ); /*=== giaTim.c ===========================================================*/ extern Gia_Man_t * Gia_ManDupNormalize( Gia_Man_t * p ); extern Gia_Man_t * Gia_ManDupUnnormalize( Gia_Man_t * p ); diff --git a/src/aig/gia/giaDup.c b/src/aig/gia/giaDup.c index 747e68b1..86d8039f 100644 --- a/src/aig/gia/giaDup.c +++ b/src/aig/gia/giaDup.c @@ -2760,15 +2760,15 @@ Gia_Man_t * Gia_ManDupSliced( Gia_Man_t * p, int nSuppMax ) SeeAlso [] ***********************************************************************/ -void Gia_ManDupWithConstrCollectAnd_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vSuper ) +void Gia_ManDupWithConstrCollectAnd_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vSuper, int fFirst ) { - if ( Gia_IsComplement(pObj) || !Gia_ObjIsAnd(pObj) ) + if ( (Gia_IsComplement(pObj) || !Gia_ObjIsAnd(pObj)) && !fFirst ) { Vec_IntPushUnique( vSuper, Gia_ObjToLit(p, pObj) ); return; } - Gia_ManDupWithConstrCollectAnd_rec( p, Gia_ObjChild0(pObj), vSuper ); - Gia_ManDupWithConstrCollectAnd_rec( p, Gia_ObjChild1(pObj), vSuper ); + Gia_ManDupWithConstrCollectAnd_rec( p, Gia_ObjChild0(pObj), vSuper, 0 ); + Gia_ManDupWithConstrCollectAnd_rec( p, Gia_ObjChild1(pObj), vSuper, 0 ); } Gia_Man_t * Gia_ManDupWithConstr( Gia_Man_t * p ) { @@ -2785,7 +2785,7 @@ Gia_Man_t * Gia_ManDupWithConstr( Gia_Man_t * p ) return NULL; } vSuper = Vec_IntAlloc( 100 ); - Gia_ManDupWithConstrCollectAnd_rec( p, Gia_ObjChild0(pObj), vSuper ); + Gia_ManDupWithConstrCollectAnd_rec( p, Gia_ObjChild0(pObj), vSuper, 1 ); assert( Vec_IntSize(vSuper) > 1 ); // find the highest level Gia_ManLevelNum( p ); @@ -2830,6 +2830,86 @@ Gia_Man_t * Gia_ManDupWithConstr( Gia_Man_t * p ) } +/**Function************************************************************* + + Synopsis [Compares two objects by their distance.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Gia_ManSortByValue( Gia_Obj_t ** pp1, Gia_Obj_t ** pp2 ) +{ + int Diff = Gia_Regular(*pp1)->Value - Gia_Regular(*pp2)->Value; + if ( Diff < 0 ) + return -1; + if ( Diff > 0 ) + return 1; + return 0; +} + +/**Function************************************************************* + + Synopsis [Decomposes the miter outputs.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Gia_Man_t * Gia_ManDupDemiter( Gia_Man_t * p, int fVerbose ) +{ + Vec_Int_t * vSuper; + Vec_Ptr_t * vSuperPtr; + Gia_Man_t * pNew, * pTemp; + Gia_Obj_t * pObj, * pObjPo; + int i, iLit; + assert( Gia_ManPoNum(p) == 1 ); + // decompose + pObjPo = Gia_ManPo( p, 0 ); + vSuper = Vec_IntAlloc( 100 ); + Gia_ManDupWithConstrCollectAnd_rec( p, Gia_ObjFanin0(pObjPo), vSuper, 1 ); + assert( Vec_IntSize(vSuper) > 1 ); + // report the result + printf( "The miter is %s-decomposable into %d parts.\n", Gia_ObjFaninC0(pObjPo) ? "OR":"AND", Vec_IntSize(vSuper) ); + // create levels + Gia_ManLevelNum( p ); + Vec_IntForEachEntry( vSuper, iLit, i ) + Gia_ManObj(p, Abc_Lit2Var(iLit))->Value = Gia_ObjLevelId(p, Abc_Lit2Var(iLit)); + // create pointer array + vSuperPtr = Vec_PtrAlloc( Vec_IntSize(vSuper) ); + Vec_IntForEachEntry( vSuper, iLit, i ) + Vec_PtrPush( vSuperPtr, Gia_Lit2Obj(p, iLit) ); + Vec_PtrSort( vSuperPtr, (int (*)(void))Gia_ManSortByValue ); + // create new manager + pNew = Gia_ManStart( Gia_ManObjNum(p) ); + pNew->pName = Abc_UtilStrsav( p->pName ); + pNew->pSpec = Abc_UtilStrsav( p->pSpec ); + Gia_ManConst0(p)->Value = 0; + Gia_ManHashAlloc( pNew ); + Gia_ManForEachCi( p, pObj, i ) + pObj->Value = Gia_ManAppendCi( pNew ); + Gia_ManForEachAnd( p, pObj, i ) + pObj->Value = Gia_ManHashAnd( pNew, Gia_ObjFanin0Copy(pObj), Gia_ObjFanin1Copy(pObj) ); + // create the outputs + Vec_PtrForEachEntry( Gia_Obj_t *, vSuperPtr, pObj, i ) + Gia_ManAppendCo( pNew, Gia_ObjLitCopy(p, Gia_Obj2Lit(p, pObj)) ^ Gia_ObjFaninC0(pObjPo) ); + Gia_ManForEachRi( p, pObj, i ) + Gia_ManAppendCo( pNew, Gia_ObjFanin0Copy(pObj) ); + Gia_ManSetRegNum( pNew, Gia_ManRegNum(p) ); + // rehash + pNew = Gia_ManCleanup( pTemp = pNew ); + Gia_ManStop( pTemp ); + Vec_IntFree( vSuper ); + Vec_PtrFree( vSuperPtr ); + return pNew; +} + //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// diff --git a/src/aig/gia/giaMan.c b/src/aig/gia/giaMan.c index f1470287..a0880837 100644 --- a/src/aig/gia/giaMan.c +++ b/src/aig/gia/giaMan.c @@ -385,6 +385,11 @@ void Gia_ManPrintChoiceStats( Gia_Man_t * p ) void Gia_ManPrintStats( Gia_Man_t * p, Gps_Par_t * pPars ) { extern float Gia_ManLevelAve( Gia_Man_t * p ); + if ( pPars->fMiter ) + { + Gia_ManPrintStatsMiter( p, 0 ); + return; + } #ifdef WIN32 SetConsoleTextAttribute( GetStdHandle(STD_OUTPUT_HANDLE), 15 ); // bright if ( p->pName ) @@ -548,6 +553,40 @@ void Gia_ManPrintMiterStatus( Gia_Man_t * p ) /**Function************************************************************* + Synopsis [Statistics of the miter.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +void Gia_ManPrintStatsMiter( Gia_Man_t * p, int fVerbose ) +{ + Gia_Obj_t * pObj; + Vec_Flt_t * vProb; + int i, iObjId; + Gia_ManLevelNum( p ); + Gia_ManCreateRefs( p ); + vProb = Gia_ManPrintOutputProb( p ); + printf( "Statistics for each outputs of the miter:\n" ); + Gia_ManForEachPo( p, pObj, i ) + { + iObjId = Gia_ObjId(p, pObj); + printf( "%4d : ", i ); + printf( "Level = %5d ", Gia_ObjLevelId(p, iObjId) ); + printf( "Supp = %5d ", Gia_ManSuppSize(p, &iObjId, 1) ); + printf( "Cone = %5d ", Gia_ManConeSize(p, &iObjId, 1) ); + printf( "Mffc = %5d ", Gia_NodeMffcSize(p, Gia_ObjFanin0(pObj)) ); + printf( "Prob = %8.4f ", Vec_FltEntry(vProb, iObjId) ); + printf( "\n" ); + } + Vec_FltFree( vProb ); +} + +/**Function************************************************************* + Synopsis [Prints stats for the AIG.] Description [] diff --git a/src/aig/gia/giaSwitch.c b/src/aig/gia/giaSwitch.c index a7b63864..e5b1eb22 100644 --- a/src/aig/gia/giaSwitch.c +++ b/src/aig/gia/giaSwitch.c @@ -777,6 +777,27 @@ float Gia_ManComputeSwitching( Gia_Man_t * p, int nFrames, int nPref, int fProbO return SwitchTotal; } +/**Function************************************************************* + + Synopsis [Determine probability of being 1 at the outputs.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +Vec_Flt_t * Gia_ManPrintOutputProb( Gia_Man_t * p ) +{ + Vec_Flt_t * vSimData; + Gia_Man_t * pDfs = Gia_ManDup( p ); + assert( Gia_ManObjNum(pDfs) == Gia_ManObjNum(p) ); + vSimData = (Vec_Flt_t *)Gia_ManComputeSwitchProbs( pDfs, (Gia_ManRegNum(p) ? 16 : 1), 0, 1 ); + Gia_ManStop( pDfs ); + return vSimData; +} + //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// |