From 19c25fd6aab057b2373717f996fe538507c1b1e1 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Mon, 27 May 2013 15:09:23 -0700 Subject: Adding a wrapper around clock() for more accurate time counting in ABC. --- src/opt/lpk/lpkAbcDec.c | 22 ++++++++++---------- src/opt/lpk/lpkCore.c | 54 ++++++++++++++++++++++++------------------------- src/opt/lpk/lpkInt.h | 26 ++++++++++++------------ 3 files changed, 51 insertions(+), 51 deletions(-) (limited to 'src/opt/lpk') diff --git a/src/opt/lpk/lpkAbcDec.c b/src/opt/lpk/lpkAbcDec.c index 731c37e6..b7d4ccb1 100644 --- a/src/opt/lpk/lpkAbcDec.c +++ b/src/opt/lpk/lpkAbcDec.c @@ -148,7 +148,7 @@ int Lpk_Decompose_rec( Lpk_Man_t * pMan, Lpk_Fun_t * p ) { Lpk_Res_t * pResMux, * pResDsd; Lpk_Fun_t * p2; - clock_t clk; + abctime clk; // is only called for non-trivial blocks assert( p->nLutK >= 3 && p->nLutK <= 6 ); @@ -165,15 +165,15 @@ int Lpk_Decompose_rec( Lpk_Man_t * pMan, Lpk_Fun_t * p ) Lpk_FunComputeCofSupps( p ); // check DSD decomposition -clk = clock(); +clk = Abc_Clock(); pResDsd = Lpk_DsdAnalize( pMan, p, pMan->pPars->nVarsShared ); -pMan->timeEvalDsdAn += clock() - clk; +pMan->timeEvalDsdAn += Abc_Clock() - clk; if ( pResDsd && (pResDsd->nBSVars == (int)p->nLutK || pResDsd->nBSVars == (int)p->nLutK - 1) && pResDsd->AreaEst <= (int)p->nAreaLim && pResDsd->DelayEst <= (int)p->nDelayLim ) { -clk = clock(); +clk = Abc_Clock(); p2 = Lpk_DsdSplit( pMan, p, pResDsd->pCofVars, pResDsd->nCofVars, pResDsd->BSVars ); -pMan->timeEvalDsdSp += clock() - clk; +pMan->timeEvalDsdSp += Abc_Clock() - clk; assert( p2->nVars <= (int)p->nLutK ); if ( p->nVars > p->nLutK && !Lpk_Decompose_rec( pMan, p ) ) return 0; @@ -181,9 +181,9 @@ pMan->timeEvalDsdSp += clock() - clk; } // check MUX decomposition -clk = clock(); +clk = Abc_Clock(); pResMux = Lpk_MuxAnalize( pMan, p ); -pMan->timeEvalMuxAn += clock() - clk; +pMan->timeEvalMuxAn += Abc_Clock() - clk; // pResMux = NULL; assert( !pResMux || (pResMux->DelayEst <= (int)p->nDelayLim && pResMux->AreaEst <= (int)p->nAreaLim) ); // accept MUX decomposition if it is "good" @@ -202,9 +202,9 @@ pMan->timeEvalMuxAn += clock() - clk; assert( pResMux == NULL || pResDsd == NULL ); if ( pResMux ) { -clk = clock(); +clk = Abc_Clock(); p2 = Lpk_MuxSplit( pMan, p, pResMux->Variable, pResMux->Polarity ); -pMan->timeEvalMuxSp += clock() - clk; +pMan->timeEvalMuxSp += Abc_Clock() - clk; if ( p2->nVars > p->nLutK && !Lpk_Decompose_rec( pMan, p2 ) ) return 0; if ( p->nVars > p->nLutK && !Lpk_Decompose_rec( pMan, p ) ) @@ -213,9 +213,9 @@ pMan->timeEvalMuxSp += clock() - clk; } if ( pResDsd ) { -clk = clock(); +clk = Abc_Clock(); p2 = Lpk_DsdSplit( pMan, p, pResDsd->pCofVars, pResDsd->nCofVars, pResDsd->BSVars ); -pMan->timeEvalDsdSp += clock() - clk; +pMan->timeEvalDsdSp += Abc_Clock() - clk; assert( p2->nVars <= (int)p->nLutK ); if ( p->nVars > p->nLutK && !Lpk_Decompose_rec( pMan, p ) ) return 0; diff --git a/src/opt/lpk/lpkCore.c b/src/opt/lpk/lpkCore.c index f060db9a..91e7c715 100644 --- a/src/opt/lpk/lpkCore.c +++ b/src/opt/lpk/lpkCore.c @@ -134,7 +134,7 @@ int Lpk_ExploreCut( Lpk_Man_t * p, Lpk_Cut_t * pCut, Kit_DsdNtk_t * pNtk ) If_Obj_t * pDriver, * ppLeaves[16]; Abc_Obj_t * pLeaf, * pObjNew; int nGain, i; - clock_t clk; + abctime clk; int nNodesBef; // int nOldShared; @@ -186,9 +186,9 @@ int Lpk_ExploreCut( Lpk_Man_t * p, Lpk_Cut_t * pCut, Kit_DsdNtk_t * pNtk ) // perform mapping p->pIfMan->pPars->fAreaOnly = 1; -clk = clock(); +clk = Abc_Clock(); If_ManPerformMappingComb( p->pIfMan ); -p->timeMap += clock() - clk; +p->timeMap += Abc_Clock() - clk; // compute the gain in area nGain = pCut->nNodes - pCut->nNodesDup - (int)p->pIfMan->AreaGlo; @@ -244,16 +244,16 @@ int Lpk_ResynthesizeNode( Lpk_Man_t * p ) Lpk_Cut_t * pCut; unsigned * pTruth; int i, k, nSuppSize, nCutNodes, RetValue; - clock_t clk; + abctime clk; // compute the cuts -clk = clock(); +clk = Abc_Clock(); if ( !Lpk_NodeCuts( p ) ) { -p->timeCuts += clock() - clk; +p->timeCuts += Abc_Clock() - clk; return 0; } -p->timeCuts += clock() - clk; +p->timeCuts += Abc_Clock() - clk; //return 0; @@ -283,10 +283,10 @@ p->timeCuts += clock() - clk; continue; // compute the truth table -clk = clock(); +clk = Abc_Clock(); pTruth = Lpk_CutTruth( p, pCut, 0 ); nSuppSize = Extra_TruthSupportSize(pTruth, pCut->nLeaves); -p->timeTruth += clock() - clk; +p->timeTruth += Abc_Clock() - clk; pDsdNtk = Kit_DsdDecompose( pTruth, pCut->nLeaves ); // Kit_DsdVerify( pDsdNtk, pTruth, pCut->nLeaves ); @@ -319,9 +319,9 @@ p->timeTruth += clock() - clk; } // update the network -clk = clock(); +clk = Abc_Clock(); RetValue = Lpk_ExploreCut( p, pCut, pDsdNtk ); -p->timeEval += clock() - clk; +p->timeEval += Abc_Clock() - clk; Kit_DsdNtkFree( pDsdNtk ); if ( RetValue ) break; @@ -374,18 +374,18 @@ int Lpk_ResynthesizeNodeNew( Lpk_Man_t * p ) unsigned * pTruth; int nNodesBef, nNodesAft, nCutNodes; int i, k; - clock_t clk; + abctime clk; int Required = Abc_ObjRequiredLevel(p->pObj); // CloudNode * pFun2;//, * pFun1; // compute the cuts -clk = clock(); +clk = Abc_Clock(); if ( !Lpk_NodeCuts( p ) ) { -p->timeCuts += clock() - clk; +p->timeCuts += Abc_Clock() - clk; return 0; } -p->timeCuts += clock() - clk; +p->timeCuts += Abc_Clock() - clk; if ( p->pPars->fVeryVerbose ) printf( "Node %5d : Mffc size = %5d. Cuts = %5d. Level = %2d. Req = %2d.\n", @@ -421,21 +421,21 @@ p->timeCuts += clock() - clk; Vec_PtrPush( p->vLeaves, Abc_NtkObj(p->pNtk, pCut->pLeaves[k]) ); // compute the truth table -clk = clock(); +clk = Abc_Clock(); pTruth = Lpk_CutTruth( p, pCut, 0 ); -p->timeTruth += clock() - clk; -clk = clock(); +p->timeTruth += Abc_Clock() - clk; +clk = Abc_Clock(); Lpk_ComputeSupports( p, pCut, pTruth ); -p->timeSupps += clock() - clk; -//clk = clock(); +p->timeSupps += Abc_Clock() - clk; +//clk = Abc_Clock(); // pFun1 = Lpk_CutTruthBdd( p, pCut ); -//p->timeTruth2 += clock() - clk; +//p->timeTruth2 += Abc_Clock() - clk; /* -clk = clock(); +clk = Abc_Clock(); Cloud_Restart( p->pDsdMan->dd ); pFun2 = Kit_TruthToCloud( p->pDsdMan->dd, pTruth, pCut->nLeaves ); RetValue = Kit_CreateCloud( p->pDsdMan->dd, pFun2, p->vBddNodes ); -p->timeTruth3 += clock() - clk; +p->timeTruth3 += Abc_Clock() - clk; */ // if ( pFun1 != pFun2 ) // printf( "Truth tables do not agree!\n" ); @@ -458,10 +458,10 @@ p->timeTruth3 += clock() - clk; // update the network nNodesBef = Abc_NtkNodeNum(p->pNtk); -clk = clock(); +clk = Abc_Clock(); pObjNew = Lpk_Decompose( p, p->pNtk, p->vLeaves, pTruth, p->puSupps, p->pPars->nLutSize, (int)pCut->nNodes - (int)pCut->nNodesDup - 1 + (int)(p->pPars->fZeroCost > 0), Required ); -p->timeEval += clock() - clk; +p->timeEval += Abc_Clock() - clk; nNodesAft = Abc_NtkNodeNum(p->pNtk); // perform replacement @@ -511,7 +511,7 @@ int Lpk_Resynthesize( Abc_Ntk_t * pNtk, Lpk_Par_t * pPars ) double Delta; // int * pnFanouts, nObjMax; int i, Iter, nNodes, nNodesPrev; - clock_t clk = clock(); + abctime clk = Abc_Clock(); assert( Abc_NtkIsLogic(pNtk) ); // sweep dangling nodes as a preprocessing step @@ -659,7 +659,7 @@ int Lpk_Resynthesize( Abc_Ntk_t * pNtk, Lpk_Par_t * pPars ) printf( " %d=%d", i, p->nBlocks[i] ); printf( "\n" ); - p->timeTotal = clock() - clk; + p->timeTotal = Abc_Clock() - clk; p->timeEval = p->timeEval - p->timeMap; p->timeOther = p->timeTotal - p->timeCuts - p->timeTruth - p->timeEval - p->timeMap; ABC_PRTP( "Cuts ", p->timeCuts, p->timeTotal ); diff --git a/src/opt/lpk/lpkInt.h b/src/opt/lpk/lpkInt.h index 053cfe96..841572c7 100644 --- a/src/opt/lpk/lpkInt.h +++ b/src/opt/lpk/lpkInt.h @@ -121,20 +121,20 @@ struct Lpk_Man_t_ // counter of non-DSD blocks int nBlocks[17]; // runtime - clock_t timeCuts; - clock_t timeTruth; - clock_t timeSupps; - clock_t timeTruth2; - clock_t timeTruth3; - clock_t timeEval; - clock_t timeMap; - clock_t timeOther; - clock_t timeTotal; + abctime timeCuts; + abctime timeTruth; + abctime timeSupps; + abctime timeTruth2; + abctime timeTruth3; + abctime timeEval; + abctime timeMap; + abctime timeOther; + abctime timeTotal; // runtime of eval - clock_t timeEvalMuxAn; - clock_t timeEvalMuxSp; - clock_t timeEvalDsdAn; - clock_t timeEvalDsdSp; + abctime timeEvalMuxAn; + abctime timeEvalMuxSp; + abctime timeEvalDsdAn; + abctime timeEvalDsdSp; }; -- cgit v1.2.3