diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2013-05-27 15:09:23 -0700 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2013-05-27 15:09:23 -0700 |
commit | 19c25fd6aab057b2373717f996fe538507c1b1e1 (patch) | |
tree | 7aa7cd7609a5de31d11b3455b6388fd9300c8d0f /src/opt/dau | |
parent | 94356f0d1fa8e671303299717f631ecf0ca2f17e (diff) | |
download | abc-19c25fd6aab057b2373717f996fe538507c1b1e1.tar.gz abc-19c25fd6aab057b2373717f996fe538507c1b1e1.tar.bz2 abc-19c25fd6aab057b2373717f996fe538507c1b1e1.zip |
Adding a wrapper around clock() for more accurate time counting in ABC.
Diffstat (limited to 'src/opt/dau')
-rw-r--r-- | src/opt/dau/dauDsd.c | 46 | ||||
-rw-r--r-- | src/opt/dau/dauMerge.c | 12 | ||||
-rw-r--r-- | src/opt/dau/dauTree.c | 60 |
3 files changed, 59 insertions, 59 deletions
diff --git a/src/opt/dau/dauDsd.c b/src/opt/dau/dauDsd.c index a6597d98..2aeeb958 100644 --- a/src/opt/dau/dauDsd.c +++ b/src/opt/dau/dauDsd.c @@ -949,7 +949,7 @@ struct Dau_Dsd_t_ char pOutput[DAU_MAX_STR]; // output stream }; -static clock_t s_Times[3] = {0}; +static abctime s_Times[3] = {0}; /**Function************************************************************* @@ -1155,7 +1155,7 @@ finish: } int Dau_Dsd6DecomposeSingleVar( Dau_Dsd_t * p, word * pTruth, int * pVars, int nVars ) { - clock_t clk = clock(); + abctime clk = Abc_Clock(); assert( nVars > 1 ); while ( 1 ) { @@ -1171,7 +1171,7 @@ int Dau_Dsd6DecomposeSingleVar( Dau_Dsd_t * p, word * pTruth, int * pVars, int n } if ( nVars == 1 ) Dau_DsdWriteVar( p, pVars[--nVars], (int)(pTruth[0] & 1) ); - s_Times[0] += clock() - clk; + s_Times[0] += Abc_Clock() - clk; return nVars; } static inline int Dau_Dsd6FindSupportOne( Dau_Dsd_t * p, word tCof0, word tCof1, int * pVars, int nVars, int v, int u ) @@ -1284,7 +1284,7 @@ finish: } int Dau_Dsd6DecomposeDoubleVars( Dau_Dsd_t * p, word * pTruth, int * pVars, int nVars ) { - clock_t clk = clock(); + abctime clk = Abc_Clock(); while ( 1 ) { int v, u, nVarsOld; @@ -1298,7 +1298,7 @@ int Dau_Dsd6DecomposeDoubleVars( Dau_Dsd_t * p, word * pTruth, int * pVars, int nVars = Dau_Dsd6DecomposeDoubleVarsOne( p, pTruth, pVars, nVars, v, u ); if ( nVars == 0 ) { - s_Times[1] += clock() - clk; + s_Times[1] += Abc_Clock() - clk; return 0; } if ( nVarsOld > nVars ) @@ -1310,7 +1310,7 @@ int Dau_Dsd6DecomposeDoubleVars( Dau_Dsd_t * p, word * pTruth, int * pVars, int if ( v == 0 ) // not found break; } - s_Times[1] += clock() - clk; + s_Times[1] += Abc_Clock() - clk; return nVars; } @@ -1382,7 +1382,7 @@ static inline int Dau_Dsd6DecomposeTripleVarsInner( Dau_Dsd_t * p, word * pTrut } int Dau_Dsd6DecomposeTripleVars( Dau_Dsd_t * p, word * pTruth, int * pVars, int nVars ) { - clock_t clk = clock(); + abctime clk = Abc_Clock(); while ( 1 ) { int v; @@ -1401,13 +1401,13 @@ int Dau_Dsd6DecomposeTripleVars( Dau_Dsd_t * p, word * pTruth, int * pVars, int continue; if ( nVarsNew == 0 ) { - s_Times[2] += clock() - clk; + s_Times[2] += Abc_Clock() - clk; return 0; } nVars = Dau_Dsd6DecomposeDoubleVars( p, pTruth, pVars, nVarsNew ); if ( nVars == 0 ) { - s_Times[2] += clock() - clk; + s_Times[2] += Abc_Clock() - clk; return 0; } break; @@ -1415,7 +1415,7 @@ int Dau_Dsd6DecomposeTripleVars( Dau_Dsd_t * p, word * pTruth, int * pVars, int } if ( v == -1 ) { - s_Times[2] += clock() - clk; + s_Times[2] += Abc_Clock() - clk; return nVars; } } @@ -1513,7 +1513,7 @@ finish: } int Dau_DsdDecomposeSingleVar( Dau_Dsd_t * p, word * pTruth, int * pVars, int nVars ) { - clock_t clk = clock(); + abctime clk = Abc_Clock(); assert( nVars > 1 ); while ( 1 ) { @@ -1529,7 +1529,7 @@ int Dau_DsdDecomposeSingleVar( Dau_Dsd_t * p, word * pTruth, int * pVars, int nV } if ( nVars == 1 ) Dau_DsdWriteVar( p, pVars[--nVars], (int)(pTruth[0] & 1) ); - s_Times[0] += clock() - clk; + s_Times[0] += Abc_Clock() - clk; return nVars; } @@ -1660,7 +1660,7 @@ finish: } int Dau_DsdDecomposeDoubleVars( Dau_Dsd_t * p, word * pTruth, int * pVars, int nVars ) { - clock_t clk = clock(); + abctime clk = Abc_Clock(); while ( 1 ) { int v, u, nVarsOld; @@ -1674,7 +1674,7 @@ int Dau_DsdDecomposeDoubleVars( Dau_Dsd_t * p, word * pTruth, int * pVars, int nVars = Dau_DsdDecomposeDoubleVarsOne( p, pTruth, pVars, nVars, v, u ); if ( nVars == 0 ) { - s_Times[1] += clock() - clk; + s_Times[1] += Abc_Clock() - clk; return 0; } if ( nVarsOld > nVars ) @@ -1686,7 +1686,7 @@ int Dau_DsdDecomposeDoubleVars( Dau_Dsd_t * p, word * pTruth, int * pVars, int if ( v == 0 ) // not found break; } - s_Times[1] += clock() - clk; + s_Times[1] += Abc_Clock() - clk; return nVars; } @@ -1775,7 +1775,7 @@ static inline int Dau_DsdDecomposeTripleVarsInner( Dau_Dsd_t * p, word * pTruth } int Dau_DsdDecomposeTripleVars( Dau_Dsd_t * p, word * pTruth, int * pVars, int nVars ) { - clock_t clk = clock(); + abctime clk = Abc_Clock(); while ( 1 ) { int v; @@ -1794,13 +1794,13 @@ int Dau_DsdDecomposeTripleVars( Dau_Dsd_t * p, word * pTruth, int * pVars, int continue; if ( nVarsNew == 0 ) { - s_Times[2] += clock() - clk; + s_Times[2] += Abc_Clock() - clk; return 0; } nVars = Dau_DsdDecomposeDoubleVars( p, pTruth, pVars, nVarsNew ); if ( nVars == 0 ) { - s_Times[2] += clock() - clk; + s_Times[2] += Abc_Clock() - clk; return 0; } break; @@ -1808,7 +1808,7 @@ int Dau_DsdDecomposeTripleVars( Dau_Dsd_t * p, word * pTruth, int * pVars, int } if ( v == -1 ) { - s_Times[2] += clock() - clk; + s_Times[2] += Abc_Clock() - clk; return nVars; } } @@ -1969,7 +1969,7 @@ void Dau_DsdTest555() char pRes[DAU_MAX_STR]; int nSizeNonDec; int i, Counter = 0; - clock_t clk = clock(), clkDec = 0, clk2; + abctime clk = Abc_Clock(), clkDec = 0, clk2; // return; while ( fgets( pBuffer, DAU_MAX_STR, pFile ) != NULL ) @@ -1989,9 +1989,9 @@ void Dau_DsdTest555() pTruth = Dau_DsdToTruth( pBuffer[0] == '*' ? pBuffer + 1 : pBuffer, nVars ); Abc_TtCopy( Tru[0], pTruth, nWords, 0 ); Abc_TtCopy( Tru[1], pTruth, nWords, 0 ); - clk2 = clock(); + clk2 = Abc_Clock(); nSizeNonDec = Dau_DsdDecompose( Tru[1], nVars, 0, 1, pRes ); - clkDec += clock() - clk2; + clkDec += Abc_Clock() - clk2; Dau_DsdNormalize( pRes ); // pStr2 = Dau_DsdPerform( t ); nSizeNonDec = 0; assert( nSizeNonDec == 0 ); @@ -2008,7 +2008,7 @@ void Dau_DsdTest555() } printf( "Finished trying %d decompositions. ", Counter ); Abc_PrintTime( 1, "Time", clkDec ); - Abc_PrintTime( 1, "Total", clock() - clk ); + Abc_PrintTime( 1, "Total", Abc_Clock() - clk ); Abc_PrintTime( 1, "Time1", s_Times[0] ); Abc_PrintTime( 1, "Time2", s_Times[1] ); diff --git a/src/opt/dau/dauMerge.c b/src/opt/dau/dauMerge.c index 08eaff73..fff2e523 100644 --- a/src/opt/dau/dauMerge.c +++ b/src/opt/dau/dauMerge.c @@ -571,7 +571,7 @@ void Dau_DsdRemoveBraces( char * pDsd, int * pMatches ) } -clock_t s_TimeComp[4] = {0}; +abctime s_TimeComp[4] = {0}; /**Function************************************************************* @@ -605,7 +605,7 @@ char * Dau_DsdMerge( char * pDsd0i, int * pPerm0, char * pDsd1i, int * pPerm1, i word * pTruth, * pt = NULL, * pt0 = NULL, * pt1 = NULL; word pParts[3][DAU_MAX_WORD]; int Status; - clock_t clk = clock(); + abctime clk = Abc_Clock(); Counter++; // create local copies Dau_DsdMergeCopy( pDsd0i, fCompl0, pDsd0 ); @@ -675,10 +675,10 @@ printf( "Normalized:\n" ); if ( fVerbose ) printf( "%s\n", pRes ); - s_TimeComp[0] += clock() - clk; + s_TimeComp[0] += Abc_Clock() - clk; return pRes; } -s_TimeComp[3] += clock() - clk; +s_TimeComp[3] += Abc_Clock() - clk; // create variable mapping nVarsTotal = Dau_DsdMergeCreateMaps( pVarPres, nVarsShared, pOld2New, pNew2Old ); // perform variable replacement @@ -761,9 +761,9 @@ printf( "%s\n", pRes ); } if ( Status == 0 ) - s_TimeComp[1] += clock() - clk; + s_TimeComp[1] += Abc_Clock() - clk; else - s_TimeComp[2] += clock() - clk; + s_TimeComp[2] += Abc_Clock() - clk; return pRes; } diff --git a/src/opt/dau/dauTree.c b/src/opt/dau/dauTree.c index dd62642b..e0ce4ac4 100644 --- a/src/opt/dau/dauTree.c +++ b/src/opt/dau/dauTree.c @@ -91,10 +91,10 @@ struct Dss_Man_t_ int nCacheHits[2]; int nCacheMisses[2]; int nCacheEntries[2]; - clock_t timeBeg; - clock_t timeDec; - clock_t timeLook; - clock_t timeEnd; + abctime timeBeg; + abctime timeDec; + abctime timeLook; + abctime timeEnd; }; static inline Dss_Obj_t * Dss_Regular( Dss_Obj_t * p ) { return (Dss_Obj_t *)((ABC_PTRUINT_T)(p) & ~01); } @@ -309,16 +309,16 @@ void Dau_DsdTest_() */ } -clock_t if_dec_time; +abctime if_dec_time; void Dau_DsdCheckStructOne( word * pTruth, int nVars, int nLeaves ) { extern Dss_Ntk_t * Dss_NtkCreate( char * pDsd, int nVars, word * pTruth ); extern void Dss_NtkFree( Dss_Ntk_t * p ); - static clock_t timeTt = 0; - static clock_t timeDsd = 0; - clock_t clkTt, clkDsd; + static abctime timeTt = 0; + static abctime timeDsd = 0; + abctime clkTt, clkDsd; char pDsd[1000]; word Truth[1024]; @@ -345,14 +345,14 @@ void Dau_DsdCheckStructOne( word * pTruth, int nVars, int nLeaves ) pNtk = Dss_NtkCreate( pDsd, 16, NULL ); // measure DSD runtime - clkDsd = clock(); + clkDsd = Abc_Clock(); Status = Dss_ObjCheck666( pNtk ); - timeDsd += clock() - clkDsd; + timeDsd += Abc_Clock() - clkDsd; Dss_NtkFree( pNtk ); // measure TT runtime - clkTt = clock(); + clkTt = Abc_Clock(); { #define CLU_VAR_MAX 16 @@ -381,7 +381,7 @@ void Dau_DsdCheckStructOne( word * pTruth, int nVars, int nLeaves ) } } - timeTt += clock() - clkTt; + timeTt += Abc_Clock() - clkTt; } #endif @@ -1087,7 +1087,7 @@ void Dss_ManPrint( char * pFileName, Dss_Man_t * p ) { Dss_Obj_t * pObj; int CountNonDsd = 0, CountNonDsdStr = 0; - int i, clk = clock(); + int i, clk = Abc_Clock(); FILE * pFile; pFile = pFileName ? fopen( pFileName, "wb" ) : stdout; if ( pFileName && pFile == NULL ) @@ -1110,7 +1110,7 @@ void Dss_ManPrint( char * pFileName, Dss_Man_t * p ) fprintf( pFile, "Cache hits = %8d %8d\n", p->nCacheHits[0], p->nCacheHits[1] ); fprintf( pFile, "Cache misses = %8d %8d\n", p->nCacheMisses[0], p->nCacheMisses[1] ); fprintf( pFile, "Cache entries = %8d %8d\n", p->nCacheEntries[0], p->nCacheEntries[1] ); - Abc_PrintTime( 1, "Time", clock() - clk ); + Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); // Dss_ManHashProfile( p ); // Dss_ManDump( p ); // return; @@ -1547,7 +1547,7 @@ int Dss_ManMerge( Dss_Man_t * p, int * iDsd, int * nFans, int ** pFans, unsigned Dss_Ent_t * pEnt, ** ppSpot; Dss_Fun_t * pFun; int i; - clock_t clk; + abctime clk; Counter++; if ( DAU_MAX_VAR < nKLutSize ) { @@ -1569,17 +1569,17 @@ Dss_ManPrintOne( stdout, p, iDsd[1], pFans[1] ); if ( iDsd[1] == 1 ) return iDsd[0]; // no overlap -clk = clock(); +clk = Abc_Clock(); assert( nFans[0] == Dss_VecLitSuppSize(p->vObjs, iDsd[0]) ); assert( nFans[1] == Dss_VecLitSuppSize(p->vObjs, iDsd[1]) ); assert( nFans[0] + nFans[1] <= nKLutSize + Dss_WordCountOnes(uSharedMask) ); // create map of shared variables pEnt = Dss_ManSharedMap( p, iDsd, nFans, pFans, uSharedMask ); -p->timeBeg += clock() - clk; +p->timeBeg += Abc_Clock() - clk; // check cache if ( p->pCache == NULL ) { -clk = clock(); +clk = Abc_Clock(); if ( uSharedMask == 0 ) pFun = Dss_ManOperationFun( p, iDsd, nFans[0] + nFans[1] ); else @@ -1588,14 +1588,14 @@ clk = clock(); return -1; assert( (int)pFun->nFans == Dss_VecLitSuppSize(p->vObjs, pFun->iDsd) ); assert( (int)pFun->nFans <= nKLutSize ); -p->timeDec += clock() - clk; +p->timeDec += Abc_Clock() - clk; } else { -clk = clock(); +clk = Abc_Clock(); ppSpot = Dss_ManCacheLookup( p, pEnt ); -p->timeLook += clock() - clk; -clk = clock(); +p->timeLook += Abc_Clock() - clk; +clk = Abc_Clock(); if ( *ppSpot == NULL ) { if ( uSharedMask == 0 ) @@ -1610,10 +1610,10 @@ clk = clock(); *ppSpot = Dss_ManCacheCreate( p, pEnt, pFun ); } pFun = (*ppSpot)->pFunc; -p->timeDec += clock() - clk; +p->timeDec += Abc_Clock() - clk; } -clk = clock(); +clk = Abc_Clock(); for ( i = 0; i < (int)pFun->nFans; i++ ) if ( pFun->pFans[i] < 2 * nFans[0] ) // first dec pPermRes[i] = (unsigned char)Dss_Lit2Lit( pFans[0], pFun->pFans[i] ); @@ -1636,7 +1636,7 @@ clk = clock(); for ( i = 0; i < (int)pFun->nFans; i++ ) pPermResInt[i] = pPermRes[i]; -p->timeEnd += clock() - clk; +p->timeEnd += Abc_Clock() - clk; if ( fVerbose ) { @@ -1698,7 +1698,7 @@ int Mpm_FuncCompute( Dss_Man_t * p, int iDsd0, int iDsd1, Vec_Str_t * vShared, i Dss_Fun_t * pFun; int iDsd[2] = { iDsd0, iDsd1 }; int i; - clock_t clk; + abctime clk; assert( iDsd0 <= iDsd1 ); if ( DAU_MAX_VAR < *pnLeaves ) @@ -1712,12 +1712,12 @@ int Mpm_FuncCompute( Dss_Man_t * p, int iDsd0, int iDsd1, Vec_Str_t * vShared, i Dss_ManPrintOne( stdout, p, iDsd1, NULL ); } -clk = clock(); +clk = Abc_Clock(); pEnt = Dss_ManSharedMapDerive( p, iDsd0, iDsd1, vShared ); ppSpot = Dss_ManCacheLookup( p, pEnt ); -p->timeLook += clock() - clk; +p->timeLook += Abc_Clock() - clk; -clk = clock(); +clk = Abc_Clock(); if ( *ppSpot == NULL ) { if ( Vec_StrSize(vShared) == 0 ) @@ -1732,7 +1732,7 @@ clk = clock(); *ppSpot = Dss_ManCacheCreate( p, pEnt, pFun ); } pFun = (*ppSpot)->pFunc; -p->timeDec += clock() - clk; +p->timeDec += Abc_Clock() - clk; *pnLeaves = (int)pFun->nFans; for ( i = 0; i < (int)pFun->nFans; i++ ) |