diff options
Diffstat (limited to 'src/aig/dar/darMan.c')
-rw-r--r-- | src/aig/dar/darMan.c | 189 |
1 files changed, 22 insertions, 167 deletions
diff --git a/src/aig/dar/darMan.c b/src/aig/dar/darMan.c index 52df8890..a209503a 100644 --- a/src/aig/dar/darMan.c +++ b/src/aig/dar/darMan.c @@ -18,7 +18,7 @@ ***********************************************************************/ -#include "dar.h" +#include "darInt.h" //////////////////////////////////////////////////////////////////////// /// DECLARATIONS /// @@ -30,48 +30,25 @@ /**Function************************************************************* - Synopsis [Starts the AIG manager.] + Synopsis [Starts the rewriting manager.] - Description [The argument of this procedure is a soft limit on the - the number of nodes, or 0 if the limit is unknown.] + Description [] SideEffects [] SeeAlso [] ***********************************************************************/ -Dar_Man_t * Dar_ManStart( int nNodesMax ) +Dar_Man_t * Dar_ManStart( Aig_Man_t * pAig, Dar_Par_t * pPars ) { Dar_Man_t * p; - int i; - if ( nNodesMax <= 0 ) - nNodesMax = 10007; // start the manager p = ALLOC( Dar_Man_t, 1 ); memset( p, 0, sizeof(Dar_Man_t) ); - // perform initializations - p->nTravIds = 1; - p->fCatchExor = 0; - // allocate arrays for nodes - p->vPis = Vec_PtrAlloc( 100 ); - p->vPos = Vec_PtrAlloc( 100 ); - p->vObjs = Vec_PtrAlloc( 1000 ); + p->pPars = pPars; + p->pAig = pAig; // prepare the internal memory manager - p->pMemObjs = Dar_MmFixedStart( sizeof(Dar_Obj_t), nNodesMax ); - p->pMemCuts = Dar_MmFlexStart(); - // prepare storage for cuts - p->nBaseCuts = DAR_CUT_BASE; - for ( i = 0; i < p->nBaseCuts; i++ ) - p->pBaseCuts[i] = p->BaseCuts + i; - // create the constant node - p->pConst1 = Dar_ManFetchMemory( p ); - p->pConst1->Type = DAR_AIG_CONST1; - p->pConst1->fPhase = 1; - p->nObjs[DAR_AIG_CONST1]++; - // start the table - p->nTableSize = nNodesMax; - p->pTable = ALLOC( Dar_Obj_t *, p->nTableSize ); - memset( p->pTable, 0, sizeof(Dar_Obj_t *) * p->nTableSize ); + p->pMemCuts = Aig_MmFixedStart( p->pPars->nCutsMax * sizeof(Dar_Cut_t), 512 ); // other data p->vLeavesBest = Vec_PtrAlloc( 4 ); return p; @@ -79,69 +56,7 @@ Dar_Man_t * Dar_ManStart( int nNodesMax ) /**Function************************************************************* - Synopsis [Duplicates the AIG manager.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -Dar_Man_t * Dar_ManStartFrom( Dar_Man_t * p ) -{ - Dar_Man_t * pNew; - Dar_Obj_t * pObj; - int i; - // create the new manager - pNew = Dar_ManStart( Dar_ManObjIdMax(p) + 1 ); - // create the PIs - Dar_ManConst1(p)->pData = Dar_ManConst1(pNew); - Dar_ManForEachPi( p, pObj, i ) - pObj->pData = Dar_ObjCreatePi(pNew); - return pNew; -} - -/**Function************************************************************* - - Synopsis [Duplicates the AIG manager.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -Dar_Man_t * Dar_ManDup( Dar_Man_t * p ) -{ - Dar_Man_t * pNew; - Dar_Obj_t * pObj; - int i; - // create the new manager - pNew = Dar_ManStart( Dar_ManObjIdMax(p) + 1 ); - // create the PIs - Dar_ManConst1(p)->pData = Dar_ManConst1(pNew); - Dar_ManForEachPi( p, pObj, i ) - pObj->pData = Dar_ObjCreatePi(pNew); - // duplicate internal nodes - Dar_ManForEachObj( p, pObj, i ) - if ( Dar_ObjIsBuf(pObj) ) - pObj->pData = Dar_ObjChild0Copy(pObj); - else if ( Dar_ObjIsNode(pObj) ) - pObj->pData = Dar_And( pNew, Dar_ObjChild0Copy(pObj), Dar_ObjChild1Copy(pObj) ); - // add the POs - Dar_ManForEachPo( p, pObj, i ) - Dar_ObjCreatePo( pNew, Dar_ObjChild0Copy(pObj) ); - // check the resulting network - if ( !Dar_ManCheck(pNew) ) - printf( "Dar_ManDup(): The check has failed.\n" ); - return pNew; -} - -/**Function************************************************************* - - Synopsis [Stops the AIG manager.] + Synopsis [Stops the rewriting manager.] Description [] @@ -152,57 +67,17 @@ Dar_Man_t * Dar_ManDup( Dar_Man_t * p ) ***********************************************************************/ void Dar_ManStop( Dar_Man_t * p ) { - Dar_Obj_t * pObj; - int i; - // make sure the nodes have clean marks - Dar_ManForEachObj( p, pObj, i ) - assert( !pObj->fMarkA && !pObj->fMarkB ); - // print time - if ( p->time1 ) { PRT( "time1", p->time1 ); } - if ( p->time2 ) { PRT( "time2", p->time2 ); } -// Dar_TableProfile( p ); - Dar_MmFixedStop( p->pMemObjs, 0 ); - Dar_MmFlexStop( p->pMemCuts, 0 ); - if ( p->vPis ) Vec_PtrFree( p->vPis ); - if ( p->vPos ) Vec_PtrFree( p->vPos ); - if ( p->vObjs ) Vec_PtrFree( p->vObjs ); - if ( p->vRequired ) Vec_IntFree( p->vRequired ); - if ( p->vLeavesBest ) Vec_PtrFree( p->vLeavesBest ); - free( p->pTable ); + if ( p->pPars->fVerbose ) + Dar_ManPrintStats( p ); + if ( p->pMemCuts ) + Aig_MmFixedStop( p->pMemCuts, 0 ); + if ( p->vLeavesBest ) + Vec_PtrFree( p->vLeavesBest ); free( p ); } /**Function************************************************************* - Synopsis [Returns the number of dangling nodes removed.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -int Dar_ManCleanup( Dar_Man_t * p ) -{ - Vec_Ptr_t * vObjs; - Dar_Obj_t * pNode; - int i, nNodesOld; - nNodesOld = Dar_ManNodeNum(p); - // collect roots of dangling nodes - vObjs = Vec_PtrAlloc( 100 ); - Dar_ManForEachObj( p, pNode, i ) - if ( Dar_ObjIsNode(pNode) && Dar_ObjRefs(pNode) == 0 ) - Vec_PtrPush( vObjs, pNode ); - // recursively remove dangling nodes - Vec_PtrForEachEntry( vObjs, pNode, i ) - Dar_ObjDelete_rec( p, pNode, 1 ); - Vec_PtrFree( vObjs ); - return nNodesOld - Dar_ManNodeNum(p); -} - -/**Function************************************************************* - Synopsis [Stops the AIG manager.] Description [] @@ -214,39 +89,18 @@ int Dar_ManCleanup( Dar_Man_t * p ) ***********************************************************************/ void Dar_ManPrintStats( Dar_Man_t * p ) { - printf( "PI/PO/Lat = %5d/%5d/%5d ", Dar_ManPiNum(p), Dar_ManPoNum(p), Dar_ManLatchNum(p) ); - printf( "A = %6d. ", Dar_ManAndNum(p) ); - if ( Dar_ManExorNum(p) ) - printf( "X = %5d. ", Dar_ManExorNum(p) ); - if ( Dar_ManBufNum(p) ) - printf( "B = %3d. ", Dar_ManBufNum(p) ); - printf( "Cre = %6d. ", p->nCreated ); - printf( "Del = %6d. ", p->nDeleted ); -// printf( "Lev = %3d. ", Dar_ManCountLevels(p) ); - printf( "\n" ); -} - -/**Function************************************************************* - - Synopsis [Stops the AIG manager.] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -void Dar_ManPrintRuntime( Dar_Man_t * p ) -{ int i, Gain; - printf( "Good cuts = %d. Bad cuts = %d. Cut mem = %d Mb\n", - p->nCutsGood, p->nCutsBad, p->nCutMemUsed ); + Gain = p->nNodesInit - Aig_ManNodeNum(p->pAig); + printf( "NodesBeg = %8d. NodesEnd = %8d. Gain = %6d. (%6.2f %%). Cut mem = %d Mb\n", + p->nNodesInit, Aig_ManNodeNum(p->pAig), Gain, 100.0*Gain/p->nNodesInit, p->nCutMemUsed ); + printf( "Cuts = %8d. Tried = %8d. Used = %8d. Bad = %5d. Skipped = %5d. Ave = %.2f.\n", + p->nCutsAll, p->nCutsTried, p->nCutsUsed, p->nCutsBad, p->nCutsSkipped, + (float)p->nCutsUsed/Aig_ManNodeNum(p->pAig) ); PRT( "Cuts ", p->timeCuts ); PRT( "Eval ", p->timeEval ); PRT( "Other ", p->timeOther ); PRT( "TOTAL ", p->timeTotal ); - Gain = p->nNodesInit - Dar_ManNodeNum(p); +/* for ( i = 0; i < 222; i++ ) { if ( p->ClassGains[i] == 0 && p->ClassTimes[i] == 0 ) @@ -257,6 +111,7 @@ void Dar_ManPrintRuntime( Dar_Man_t * p ) printf( "R = %7d ", p->ClassGains[i]? p->ClassSubgs[i]/p->ClassGains[i] : 9999999 ); PRTP( "T", p->ClassTimes[i], p->timeEval ); } +*/ } |