diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2014-07-09 20:22:51 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2014-07-09 20:22:51 -0700 |
commit | c58b57e2b45943a0b015290c0fffb66c8a3e12a8 (patch) | |
tree | 4d6c14a3a67eca3cf09284f0032e026492882cfd /src/aig | |
parent | ea1e369fc296935ea7a9265a612e756d35086d5c (diff) | |
download | abc-c58b57e2b45943a0b015290c0fffb66c8a3e12a8.tar.gz abc-c58b57e2b45943a0b015290c0fffb66c8a3e12a8.tar.bz2 abc-c58b57e2b45943a0b015290c0fffb66c8a3e12a8.zip |
Improvements to profiling and printing statistics.
Diffstat (limited to 'src/aig')
-rw-r--r-- | src/aig/gia/giaCof.c | 106 | ||||
-rw-r--r-- | src/aig/gia/giaMuxes.c | 9 |
2 files changed, 98 insertions, 17 deletions
diff --git a/src/aig/gia/giaCof.c b/src/aig/gia/giaCof.c index 43cce6ac..c6ccb7d1 100644 --- a/src/aig/gia/giaCof.c +++ b/src/aig/gia/giaCof.c @@ -549,6 +549,48 @@ void Cof_ManPrintHighFanout( Cof_Man_t * p, int nNodes ) Vec_PtrFree( vNodes ); } + +/**Function************************************************************* + + Synopsis [Compute MFFC size of the node.] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +int Cof_NodeDeref_rec( Cof_Obj_t * pNode ) +{ + if ( pNode->nFanins == 0 ) + return 0; + if ( --pNode->nFanouts > 0 ) + return 0; + return 1 + Cof_NodeDeref_rec( Cof_ObjFanin(pNode, 0) ) + + Cof_NodeDeref_rec( Cof_ObjFanin(pNode, 1) ); +} +int Cof_NodeRef_rec( Cof_Obj_t * pNode ) +{ + if ( pNode->nFanins == 0 ) + return 0; + if ( pNode->nFanouts++ > 0 ) + return 0; + return 1 + Cof_NodeRef_rec( Cof_ObjFanin(pNode, 0) ) + + Cof_NodeRef_rec( Cof_ObjFanin(pNode, 1) ); +} +static inline int Cof_ObjMffcSize( Cof_Obj_t * pNode ) +{ + int Count1, Count2, nFanout; + nFanout = pNode->nFanouts; + pNode->nFanouts = 1; + Count1 = Cof_NodeDeref_rec( pNode ); + Count2 = Cof_NodeRef_rec( pNode ); + pNode->nFanouts = nFanout; + assert( Count1 == Count2 ); + return Count1; +} + /**Function************************************************************* Synopsis [Prints the distribution of fanins/fanouts in the network.] @@ -564,28 +606,33 @@ void Cof_ManPrintFanio( Cof_Man_t * p ) { char Buffer[100]; Cof_Obj_t * pNode; - Vec_Int_t * vFanins, * vFanouts; - int nFanins, nFanouts, nFaninsMax, nFanoutsMax, nFaninsAll, nFanoutsAll; - int i, k, nSizeMax; + Vec_Int_t * vFanins, * vFanouts, * vMffcs; + int nFanins, nFanouts, nMffcs, nFaninsMax, nFanoutsMax, nMffcsMax, nFaninsAll, nFanoutsAll, nMffcsAll; + int i, k, nSizeMax, nMffcNodes = 0; // determine the largest fanin and fanout - nFaninsMax = nFanoutsMax = 0; - nFaninsAll = nFanoutsAll = 0; + nFaninsMax = nFanoutsMax = nMffcsMax = 0; + nFaninsAll = nFanoutsAll = nMffcsAll = 0; Cof_ManForEachNode( p, pNode, i ) { if ( i == 0 ) continue; nFanins = Cof_ObjFaninNum(pNode); nFanouts = Cof_ObjFanoutNum(pNode); + nMffcs = pNode->nFanouts > 1 ? Cof_ObjMffcSize(pNode) : 0; nFaninsAll += nFanins; nFanoutsAll += nFanouts; - nFaninsMax = Abc_MaxInt( nFaninsMax, nFanins ); + nMffcsAll += nMffcs; + nFaninsMax = Abc_MaxInt( nFaninsMax, nFanins ); nFanoutsMax = Abc_MaxInt( nFanoutsMax, nFanouts ); + nMffcsMax = Abc_MaxInt( nMffcsMax, nMffcs ); } // allocate storage for fanin/fanout numbers nSizeMax = Abc_MaxInt( 10 * (Abc_Base10Log(nFaninsMax) + 1), 10 * (Abc_Base10Log(nFanoutsMax) + 1) ); + nSizeMax = Abc_MaxInt( 10 * (Abc_Base10Log(nMffcsMax) + 1), nSizeMax ); vFanins = Vec_IntStart( nSizeMax ); vFanouts = Vec_IntStart( nSizeMax ); + vMffcs = Vec_IntStart( nSizeMax ); // count the number of fanins and fanouts Cof_ManForEachNode( p, pNode, i ) @@ -593,7 +640,7 @@ void Cof_ManPrintFanio( Cof_Man_t * p ) if ( i == 0 ) continue; nFanins = Cof_ObjFaninNum(pNode); nFanouts = Cof_ObjFanoutNum(pNode); -// nFanouts = Cof_NodeMffcSize(pNode); + nMffcs = pNode->nFanouts > 1 ? Cof_ObjMffcSize(pNode) : 0; if ( nFanins < 10 ) Vec_IntAddToEntry( vFanins, nFanins, 1 ); @@ -624,13 +671,33 @@ void Cof_ManPrintFanio( Cof_Man_t * p ) Vec_IntAddToEntry( vFanouts, 50 + nFanouts/100000, 1 ); else if ( nFanouts < 10000000 ) Vec_IntAddToEntry( vFanouts, 60 + nFanouts/1000000, 1 ); + + if ( nMffcs == 0 ) + continue; + nMffcNodes++; + + if ( nMffcs < 10 ) + Vec_IntAddToEntry( vMffcs, nMffcs, 1 ); + else if ( nMffcs < 100 ) + Vec_IntAddToEntry( vMffcs, 10 + nMffcs/10, 1 ); + else if ( nMffcs < 1000 ) + Vec_IntAddToEntry( vMffcs, 20 + nMffcs/100, 1 ); + else if ( nMffcs < 10000 ) + Vec_IntAddToEntry( vMffcs, 30 + nMffcs/1000, 1 ); + else if ( nMffcs < 100000 ) + Vec_IntAddToEntry( vMffcs, 40 + nMffcs/10000, 1 ); + else if ( nMffcs < 1000000 ) + Vec_IntAddToEntry( vMffcs, 50 + nMffcs/100000, 1 ); + else if ( nMffcs < 10000000 ) + Vec_IntAddToEntry( vMffcs, 60 + nMffcs/1000000, 1 ); } - printf( "The distribution of fanins and fanouts in the network:\n" ); - printf( " Number Nodes with fanin Nodes with fanout\n" ); + printf( "The distribution of fanins, fanouts. and MFFCs in the network:\n" ); + printf( " Number Nodes with fanin Nodes with fanout Nodes with MFFC\n" ); + for ( k = 0; k < nSizeMax; k++ ) { - if ( vFanins->pArray[k] == 0 && vFanouts->pArray[k] == 0 ) + if ( vFanins->pArray[k] == 0 && vFanouts->pArray[k] == 0 && vMffcs->pArray[k] == 0 ) continue; if ( k < 10 ) printf( "%15d : ", k ); @@ -642,20 +709,27 @@ void Cof_ManPrintFanio( Cof_Man_t * p ) if ( vFanins->pArray[k] == 0 ) printf( " " ); else - printf( "%12d ", vFanins->pArray[k] ); + printf( "%11d ", vFanins->pArray[k] ); printf( " " ); if ( vFanouts->pArray[k] == 0 ) printf( " " ); else printf( "%12d ", vFanouts->pArray[k] ); + printf( " " ); + if ( vMffcs->pArray[k] == 0 ) + printf( " " ); + else + printf( " %12d ", vMffcs->pArray[k] ); printf( "\n" ); } Vec_IntFree( vFanins ); Vec_IntFree( vFanouts ); + Vec_IntFree( vMffcs ); - printf( "Fanins: Max = %d. Ave = %.2f. Fanouts: Max = %d. Ave = %.2f.\n", - nFaninsMax, 1.0*nFaninsAll/Cof_ManNodeNum(p), - nFanoutsMax, 1.0*nFanoutsAll/Cof_ManNodeNum(p) ); + printf( "Fanins: Max = %d. Ave = %.2f. Fanouts: Max = %d. Ave = %.2f. MFFCs: Max = %d. Ave = %.2f.\n", + nFaninsMax, 1.0*nFaninsAll /Cof_ManNodeNum(p), + nFanoutsMax, 1.0*nFanoutsAll/Cof_ManNodeNum(p), + nMffcsMax, 1.0*nMffcsAll /nMffcNodes ); } /**Function************************************************************* @@ -678,12 +752,16 @@ void Gia_ManPrintFanio( Gia_Man_t * pGia, int nNodes ) p->pLevels = ABC_CALLOC( int, p->nLevels ); Cof_ManPrintFanio( p ); + if ( nNodes > 0 ) + { Cof_ManResetTravId( p ); Gia_ManHashStart( pGia ); Cof_ManPrintHighFanout( p, nNodes ); Gia_ManHashStop( pGia ); ABC_PRMn( "Memory for logic network", 4*p->nObjData ); ABC_PRT( "Time", Abc_Clock() - clk ); + } + Cof_ManStop( p ); } diff --git a/src/aig/gia/giaMuxes.c b/src/aig/gia/giaMuxes.c index 96dda567..c0c3b18f 100644 --- a/src/aig/gia/giaMuxes.c +++ b/src/aig/gia/giaMuxes.c @@ -371,7 +371,7 @@ void Gia_MuxStructDump_rec( Gia_Man_t * p, int iObj, int fFirst, Vec_Str_t * vSt Vec_StrPush( vStr, ']' ); } } -void Gia_MuxStructDump( Gia_Man_t * p, int iObj, Vec_Str_t * vStr, int nDigitsNum, int nDigitsId ) +int Gia_MuxStructDump( Gia_Man_t * p, int iObj, Vec_Str_t * vStr, int nDigitsNum, int nDigitsId ) { int Count1, Count2; assert( Gia_ObjIsMuxId(p, iObj) ); @@ -382,6 +382,7 @@ void Gia_MuxStructDump( Gia_Man_t * p, int iObj, Vec_Str_t * vStr, int nDigitsNu Vec_StrPush( vStr, '\0' ); Count2 = Gia_MuxRef( p, iObj ); assert( Count1 == Count2 ); + return Count1; } /**Function************************************************************* @@ -530,7 +531,9 @@ void Gia_ManMuxProfiling( Gia_Man_t * p ) if ( Gia_ObjRefNumId(pNew, i) == 1 && Gia_ObjIsMuxId(pNew, Vec_IntEntry(vFans, i)) ) continue; // this node is the root of the MUX structure - create hash key - Gia_MuxStructDump( pNew, i, vStr, 3, nDigitsId ); + Counter = Gia_MuxStructDump( pNew, i, vStr, 3, nDigitsId ); + if ( Counter == 1 ) + continue; iStructId = Abc_NamStrFindOrAdd( pMan->pNames, Vec_StrArray(vStr), &fFound ); if ( !fFound ) Vec_WecPushLevel( pMan->vTops ); @@ -542,7 +545,7 @@ void Gia_ManMuxProfiling( Gia_Man_t * p ) printf( "MUX structure profile for AIG \"%s\":\n", p->pName ); printf( "Total MUXes = %d. Total trees = %d. Unique trees = %d. Memory = %.2f MB ", - Gia_ManMuxNum(pNew), Vec_WecSizeSize(pMan->vTops), Vec_WecSize(pMan->vTops), + Gia_ManMuxNum(pNew), Vec_WecSizeSize(pMan->vTops), Vec_WecSize(pMan->vTops)-1, 1.0*Abc_NamMemUsed(pMan->pNames)/(1<<20) ); Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); |