From f1f1cf3eb13f014cf63a94dfa372eeb45c863a06 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Sun, 6 Apr 2014 15:54:02 -0700 Subject: Improvement in SOP balancing. --- src/base/abci/abcIf.c | 6 ++++-- src/map/if/ifDelay.c | 14 +++++++++----- src/map/if/ifMan.c | 27 +++++++++++---------------- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/src/base/abci/abcIf.c b/src/base/abci/abcIf.c index 8a52260a..3ddc9fe3 100644 --- a/src/base/abci/abcIf.c +++ b/src/base/abci/abcIf.c @@ -393,10 +393,12 @@ Hop_Obj_t * Abc_NodeBuildFromMiniInt( Hop_Man_t * pMan, Vec_Int_t * vAig, int nL } Hop_Obj_t * Abc_NodeBuildFromMini( Hop_Man_t * pMan, If_Man_t * p, If_Cut_t * pCut, int fUseDsd ) { + int Delay; if ( fUseDsd ) - If_CutDsdBalanceEval( p, pCut, p->vArray ); + Delay = If_CutDsdBalanceEval( p, pCut, p->vArray ); else - If_CutSopBalanceEval( p, pCut, p->vArray ); + Delay = If_CutSopBalanceEval( p, pCut, p->vArray ); + assert( Delay >= 0 ); return Abc_NodeBuildFromMiniInt( pMan, p->vArray, If_CutLeaveNum(pCut) ); } diff --git a/src/map/if/ifDelay.c b/src/map/if/ifDelay.c index 61b3e6f1..710941e6 100644 --- a/src/map/if/ifDelay.c +++ b/src/map/if/ifDelay.c @@ -26,6 +26,8 @@ ABC_NAMESPACE_IMPL_START /// DECLARATIONS /// //////////////////////////////////////////////////////////////////////// +#define IF_MAX_CUBES 70 + //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// @@ -525,12 +527,12 @@ static inline word If_LogPinDelaysMulti( word * pPinDels, int nFanins, int nSupp } int If_CutSopBalancePinDelaysInt( Vec_Int_t * vCover, int * pTimes, int nSuppAll, char * pPerm ) { - word pPinDelsAnd[IF_MAX_FUNC_LUTSIZE], pPinDelsOr[32]; + word pPinDelsAnd[IF_MAX_FUNC_LUTSIZE], pPinDelsOr[IF_MAX_CUBES]; int nCounterAnd, pCounterAnd[IF_MAX_FUNC_LUTSIZE]; - int nCounterOr, pCounterOr[32]; + int nCounterOr, pCounterOr[IF_MAX_CUBES]; int i, k, Entry, Literal, Delay = 0; word ResAnd, ResOr; - if ( Vec_IntSize(vCover) > 32 ) + if ( Vec_IntSize(vCover) > IF_MAX_CUBES ) return -1; nCounterOr = 0; Vec_IntForEachEntry( vCover, Entry, i ) @@ -589,9 +591,9 @@ int If_CutSopBalancePinDelays( If_Man_t * p, If_Cut_t * pCut, char * pPerm ) int If_CutSopBalanceEvalIntInt( Vec_Int_t * vCover, int * pTimes, Vec_Int_t * vAig, int * piRes, int nSuppAll, int * pArea ) { int nCounterAnd, pCounterAnd[IF_MAX_FUNC_LUTSIZE], pFaninLitsAnd[IF_MAX_FUNC_LUTSIZE]; - int nCounterOr, pCounterOr[32], pFaninLitsOr[32]; + int nCounterOr, pCounterOr[IF_MAX_CUBES], pFaninLitsOr[IF_MAX_CUBES]; int i, k, Entry, Literal, nLits, Delay = 0, iRes = 0; - if ( Vec_IntSize(vCover) > 32 ) + if ( Vec_IntSize(vCover) > IF_MAX_CUBES ) return -1; nCounterOr = 0; Vec_IntForEachEntry( vCover, Entry, i ) @@ -628,6 +630,8 @@ int If_CutSopBalanceEvalInt( Vec_Int_t * vCover, int nLeaves, int * pTimes, Vec_ if ( Vec_IntSize(vCover) == 0 ) return -1; Res = If_CutSopBalanceEvalIntInt( vCover, pTimes, vAig, &iRes, nLeaves, pArea ); + if ( Res == -1 ) + return -1; assert( vAig == NULL || Abc_Lit2Var(iRes) == nLeaves + Abc_Lit2Var(Vec_IntSize(vAig)) - 1 ); if ( vAig ) Vec_IntPush( vAig, Abc_LitIsCompl(iRes) ^ fCompl ); diff --git a/src/map/if/ifMan.c b/src/map/if/ifMan.c index 53eea1a7..9bda135f 100644 --- a/src/map/if/ifMan.c +++ b/src/map/if/ifMan.c @@ -32,8 +32,6 @@ static If_Obj_t * If_ManSetupObj( If_Man_t * p ); static void If_ManCutSetRecycle( If_Man_t * p, If_Set_t * pSet ) { pSet->pNext = p->pFreeList; p->pFreeList = pSet; } static If_Set_t * If_ManCutSetFetch( If_Man_t * p ) { If_Set_t * pTemp = p->pFreeList; p->pFreeList = p->pFreeList->pNext; return pTemp; } -extern abctime s_TimeComp[4]; - //////////////////////////////////////////////////////////////////////// /// FUNCTION DEFINITIONS /// //////////////////////////////////////////////////////////////////////// @@ -62,14 +60,13 @@ If_Man_t * If_ManStart( If_Par_t * pPars ) p->vCis = Vec_PtrAlloc( 100 ); p->vCos = Vec_PtrAlloc( 100 ); p->vObjs = Vec_PtrAlloc( 100 ); -// p->vMapped = Vec_PtrAlloc( 100 ); p->vTemp = Vec_PtrAlloc( 100 ); // prepare the memory manager if ( p->pPars->fTruth ) { for ( v = 0; v <= p->pPars->nLutSize; v++ ) p->nTruth6Words[v] = Abc_Truth6WordNum( v ); - for ( v = 6; v <= p->pPars->nLutSize; v++ ) + for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ ) p->vTtMem[v] = Vec_MemAllocForTT( v, pPars->fUseTtPerm ); for ( v = 0; v < 6; v++ ) p->vTtMem[v] = p->vTtMem[6]; @@ -77,20 +74,19 @@ If_Man_t * If_ManStart( If_Par_t * pPars ) { p->vCover = Vec_IntAlloc( 0 ); p->vArray = Vec_IntAlloc( 1000 ); - for ( v = 6; v <= p->pPars->nLutSize; v++ ) + for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ ) p->vTtIsops[v] = Vec_WecAlloc( 1000 ); - for ( v = 6; v <= p->pPars->nLutSize; v++ ) + for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ ) Vec_WecInit( p->vTtIsops[v], 2 ); for ( v = 0; v < 6; v++ ) p->vTtIsops[v] = p->vTtIsops[6]; } } p->nPermWords = p->pPars->fUsePerm? If_CutPermWords( p->pPars->nLutSize ) : 0; - p->nObjBytes = sizeof(If_Obj_t) + sizeof(int) * (p->pPars->nLutSize + p->nPermWords/* + p->nTruthWords*/); - p->nCutBytes = sizeof(If_Cut_t) + sizeof(int) * (p->pPars->nLutSize + p->nPermWords/* + p->nTruthWords*/); + p->nObjBytes = sizeof(If_Obj_t) + sizeof(int) * (p->pPars->nLutSize + p->nPermWords); + p->nCutBytes = sizeof(If_Cut_t) + sizeof(int) * (p->pPars->nLutSize + p->nPermWords); p->nSetBytes = sizeof(If_Set_t) + (sizeof(If_Cut_t *) + p->nCutBytes) * (p->pPars->nCutsMax + 1); p->pMemObj = Mem_FixedStart( p->nObjBytes ); -// p->pMemSet = Mem_FixedStart( p->nSetBytes ); // report expected memory usage if ( p->pPars->fVerbose ) Abc_Print( 1, "K = %d. Memory (bytes): Truth = %4d. Cut = %4d. Obj = %4d. Set = %4d. CutMin = %s\n", @@ -103,7 +99,7 @@ If_Man_t * If_ManStart( If_Par_t * pPars ) p->puTempW = p->pPars->fTruth? ABC_ALLOC( word, p->nTruth6Words[p->pPars->nLutSize] ) : NULL; if ( pPars->fUseDsd ) { - for ( v = 6; v <= p->pPars->nLutSize; v++ ) + for ( v = 6; v <= Abc_MaxInt(6,p->pPars->nLutSize); v++ ) { p->vTtDsds[v] = Vec_IntAlloc( 1000 ); Vec_IntPush( p->vTtDsds[v], 0 ); @@ -151,7 +147,6 @@ void If_ManRestart( If_Man_t * p ) Vec_PtrClear( p->vCis ); Vec_PtrClear( p->vCos ); Vec_PtrClear( p->vObjs ); -// Vec_PtrClear( p->vMapped ); Vec_PtrClear( p->vTemp ); Mem_FixedRestart( p->pMemObj ); // create the constant node @@ -182,9 +177,9 @@ void If_ManStop( If_Man_t * p ) if ( p->pPars->fVerbose && p->pPars->fTruth ) { int nUnique = 0, nMemTotal = 0; - for ( i = 6; i <= p->pPars->nLutSize; i++ ) + for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ ) nUnique += Vec_MemEntryNum(p->vTtMem[i]); - for ( i = 6; i <= p->pPars->nLutSize; i++ ) + for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ ) nMemTotal += (int)Vec_MemMemory(p->vTtMem[i]); printf( "Unique truth tables = %d Memory = %.2f MB ", nUnique, 1.0 * nMemTotal / (1<<20) ); Abc_PrintTime( 1, "Time", p->timeCache[4] ); @@ -233,11 +228,11 @@ void If_ManStop( If_Man_t * p ) Vec_StrFreeP( &p->vPairPerms ); if ( p->vPairHash ) Hash_IntManStop( p->vPairHash ); - for ( i = 6; i <= p->pPars->nLutSize; i++ ) + for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ ) Vec_MemHashFree( p->vTtMem[i] ); - for ( i = 6; i <= p->pPars->nLutSize; i++ ) + for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ ) Vec_MemFreeP( &p->vTtMem[i] ); - for ( i = 6; i <= p->pPars->nLutSize; i++ ) + for ( i = 6; i <= Abc_MaxInt(6,p->pPars->nLutSize); i++ ) Vec_WecFreeP( &p->vTtIsops[i] ); Mem_FixedStop( p->pMemObj, 0 ); ABC_FREE( p->pMemCi ); -- cgit v1.2.3