Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 21 additions & 17 deletions src/base/abci/abcOdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,9 @@ Odc_Man_t * Abc_NtkDontCareAlloc( int nVarsMax, int nLevels, int fVerbose, int f
***********************************************************************/
void Abc_NtkDontCareClear( Odc_Man_t * p )
{
abctime clk = Abc_Clock();
int fVerbose = p->fVerbose;
abctime clk;
ABC_TIME_START(fVerbose, clk);
// clean the structural hashing table
if ( Vec_IntSize(p->vUsedSpots) > p->nTableSize/3 ) // more than one third
memset( p->pTable, 0, sizeof(Odc_Lit_t) * p->nTableSize );
Expand All @@ -259,7 +261,7 @@ void Abc_NtkDontCareClear( Odc_Man_t * p )
// reset the root node
p->iRoot = 0xffff;

p->timeClean += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, p->timeClean, clk);
}

/**Function*************************************************************
Expand Down Expand Up @@ -1041,8 +1043,10 @@ int Abc_NtkDontCareSimulateBefore( Odc_Man_t * p, unsigned * puTruth )
***********************************************************************/
int Abc_NtkDontCareCompute( Odc_Man_t * p, Abc_Obj_t * pNode, Vec_Ptr_t * vLeaves, unsigned * puTruth )
{
int fVerbose = p->fVerbose;
int nMints, RetValue;
abctime clk, clkTotal = Abc_Clock();
abctime clk, clkTotal;
ABC_TIME_START(fVerbose, clkTotal);

p->nWins++;

Expand All @@ -1054,12 +1058,12 @@ int Abc_NtkDontCareCompute( Odc_Man_t * p, Abc_Obj_t * pNode, Vec_Ptr_t * vLeave
p->pNode = pNode;

// compute the window
clk = Abc_Clock();
ABC_TIME_START(fVerbose, clk);
RetValue = Abc_NtkDontCareWindow( p );
p->timeWin += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, p->timeWin, clk);
if ( !RetValue )
{
p->timeAbort += Abc_Clock() - clkTotal;
ABC_TIME_STOP(fVerbose, p->timeAbort, clkTotal);
Abc_InfoFill( puTruth, p->nWords );
p->nWinsEmpty++;
return 0;
Expand All @@ -1075,14 +1079,14 @@ p->timeAbort += Abc_Clock() - clkTotal;
}

// transfer the window into the AIG package
clk = Abc_Clock();
ABC_TIME_START(fVerbose, clk);
Abc_NtkDontCareTransfer( p );
p->timeMiter += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, p->timeMiter, clk);

// simulate to estimate the amount of don't-cares
clk = Abc_Clock();
ABC_TIME_START(fVerbose, clk);
nMints = Abc_NtkDontCareSimulateBefore( p, puTruth );
p->timeSim += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, p->timeSim, clk);
if ( p->fVeryVerbose )
{
printf( "AIG = %5d ", Odc_NodeNum(p) );
Expand All @@ -1092,7 +1096,7 @@ p->timeSim += Abc_Clock() - clk;
// if there is less then the given percentage of don't-cares, skip
if ( 100.0 * (p->nBits - nMints) / p->nBits < 1.0 * p->nPercCutoff )
{
p->timeAbort += Abc_Clock() - clkTotal;
ABC_TIME_STOP(fVerbose, p->timeAbort, clkTotal);
if ( p->fVeryVerbose )
printf( "Simulation cutoff.\n" );
Abc_InfoFill( puTruth, p->nWords );
Expand All @@ -1101,12 +1105,12 @@ p->timeAbort += Abc_Clock() - clkTotal;
}

// quantify external variables
clk = Abc_Clock();
ABC_TIME_START(fVerbose, clk);
RetValue = Abc_NtkDontCareQuantify( p );
p->timeQuant += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, p->timeQuant, clk);
if ( !RetValue )
{
p->timeAbort += Abc_Clock() - clkTotal;
ABC_TIME_STOP(fVerbose, p->timeAbort, clkTotal);
if ( p->fVeryVerbose )
printf( "=== Overflow! ===\n" );
Abc_InfoFill( puTruth, p->nWords );
Expand All @@ -1115,17 +1119,17 @@ p->timeAbort += Abc_Clock() - clkTotal;
}

// get the truth table
clk = Abc_Clock();
ABC_TIME_START(fVerbose, clk);
Abc_NtkDontCareSimulateSetElem( p );
nMints = Abc_NtkDontCareSimulate( p, puTruth );
p->timeTruth += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, p->timeTruth, clk);
if ( p->fVeryVerbose )
{
printf( "AIG = %5d ", Odc_NodeNum(p) );
printf( "%6.2f %% ", 100.0 * (p->nBits - nMints) / p->nBits );
printf( "\n" );
}
p->timeTotal += Abc_Clock() - clkTotal;
ABC_TIME_STOP(fVerbose, p->timeTotal, clkTotal);
p->nWinsFinish++;
p->nTotalDcs += (int)(100.0 * (p->nBits - nMints) / p->nBits);
return nMints;
Expand Down
29 changes: 15 additions & 14 deletions src/base/abci/abcRefactor.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,9 @@ Dec_Graph_t * Abc_NodeRefactor( Abc_ManRef_t * p, Abc_Obj_t * pNode, Vec_Ptr_t *
Required = fUpdateLevel? Abc_ObjRequiredLevel(pNode) : ABC_INFINITY;

// get the function of the cut
clk = Abc_Clock();
ABC_TIME_START(fVerbose, clk);
pTruth = Abc_NodeConeTruth( p->vVars, p->vFuncs, nWordsMax, pNode, vFanins, p->vVisited );
p->timeTru += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, p->timeTru, clk);
if ( pTruth == NULL )
return NULL;

Expand All @@ -184,9 +184,9 @@ p->timeTru += Abc_Clock() - clk;
}

// get the factored form
clk = Abc_Clock();
ABC_TIME_START(fVerbose, clk);
pFForm = (Dec_Graph_t *)Kit_TruthToGraph( (unsigned *)pTruth, nVars, p->vMemory );
p->timeFact += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, p->timeFact, clk);

// mark the fanin boundary
// (can mark only essential fanins, belonging to bNodeFunc!)
Expand All @@ -203,9 +203,9 @@ p->timeFact += Abc_Clock() - clk;
}

// detect how many new nodes will be added (while taking into account reused nodes)
clk = Abc_Clock();
ABC_TIME_START(fVerbose, clk);
nNodesAdded = Dec_GraphToNetworkCount( pNode, pFForm, nNodesSaved, Required );
p->timeEval += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, p->timeEval, clk);
// quit if there is no improvement
//if ( nNodesAdded == -1 || (nNodesAdded == nNodesSaved && !fUseZeros) )
if ( nNodesAdded == -1 || nNodesSaved - nNodesAdded < nMinSaved )
Expand Down Expand Up @@ -335,9 +335,10 @@ int Abc_NtkRefactor( Abc_Ntk_t * pNtk, int nNodeSizeMax, int nMinSaved, int nCon
Dec_Graph_t * pFForm;
Vec_Ptr_t * vFanins;
Abc_Obj_t * pNode;
abctime clk, clkStart = Abc_Clock();
abctime clk, clkStart;
int i, nNodes, RetValue = 1;

ABC_TIME_START(fVerbose, clkStart);
assert( Abc_NtkIsStrash(pNtk) );
// cleanup the AIG
Abc_AigCleanup((Abc_Aig_t *)pNtk->pManFunc);
Expand Down Expand Up @@ -369,28 +370,28 @@ int Abc_NtkRefactor( Abc_Ntk_t * pNtk, int nNodeSizeMax, int nMinSaved, int nCon
if ( i >= nNodes )
break;
// compute a reconvergence-driven cut
clk = Abc_Clock();
ABC_TIME_START(fVerbose, clk);
vFanins = Abc_NodeFindCut( pManCut, pNode, fUseDcs );
pManRef->timeCut += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, pManRef->timeCut, clk);
// evaluate this cut
clk = Abc_Clock();
ABC_TIME_START(fVerbose, clk);
pFForm = Abc_NodeRefactor( pManRef, pNode, vFanins, nMinSaved, fUpdateLevel, fUseZeros, fUseDcs, fVerbose );
pManRef->timeRes += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, pManRef->timeRes, clk);
if ( pFForm == NULL )
continue;
// acceptable replacement found, update the graph
clk = Abc_Clock();
ABC_TIME_START(fVerbose, clk);
if ( !Dec_GraphUpdateNetwork( pNode, pFForm, fUpdateLevel, pManRef->nLastGain ) )
{
Dec_GraphFree( pFForm );
RetValue = -1;
break;
}
pManRef->timeNtk += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, pManRef->timeNtk, clk);
Dec_GraphFree( pFForm );
}
Extra_ProgressBarStop( pProgress );
pManRef->timeTotal = Abc_Clock() - clkStart;
ABC_TIME_STOP(fVerbose, pManRef->timeTotal, clkStart);
pManRef->nNodesEnd = Abc_NtkNodeNum(pNtk);

// print statistics of the manager
Expand Down
60 changes: 30 additions & 30 deletions src/base/abci/abcResub.c
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,10 @@ int Abc_NtkResubstitute( Abc_Ntk_t * pNtk, int nCutMax, int nStepsMax, int nMinS
break;

// compute a reconvergence-driven cut
clk = Abc_Clock();
ABC_TIME_START(fVerbose, clk);
vLeaves = Abc_NodeFindCut( pManCut, pNode, 0 );
// vLeaves = Abc_CutFactorLarge( pNode, nCutMax );
pManRes->timeCut += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, pManRes->timeCut, clk);
/*
if ( fVerbose && vLeaves )
printf( "Node %6d : Leaves = %3d. Volume = %3d.\n", pNode->Id, Vec_PtrSize(vLeaves), Abc_CutVolumeCheck(pNode, vLeaves) );
Expand All @@ -224,18 +224,18 @@ pManRes->timeCut += Abc_Clock() - clk;
// get the don't-cares
if ( pManOdc )
{
clk = Abc_Clock();
ABC_TIME_START(fVerbose, clk);
Abc_NtkDontCareClear( pManOdc );
Abc_NtkDontCareCompute( pManOdc, pNode, vLeaves, pManRes->pCareSet );
pManRes->timeTruth += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, pManRes->timeTruth, clk);
}

// evaluate this cut
clk = Abc_Clock();
ABC_TIME_START(fVerbose, clk);
pFForm = Abc_ManResubEval( pManRes, pNode, vLeaves, nStepsMax, fUpdateLevel, fVerbose );
// Vec_PtrFree( vLeaves );
// Abc_ManResubCleanup( pManRes );
pManRes->timeRes += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, pManRes->timeRes, clk);
if ( pFForm == NULL )
continue;
if ( pManRes->nLastGain < nMinSaved )
Expand All @@ -254,9 +254,9 @@ pManRes->timeRes += Abc_Clock() - clk;
}
*/
// acceptable replacement found, update the graph
clk = Abc_Clock();
ABC_TIME_START(fVerbose, clk);
Dec_GraphUpdateNetwork( pNode, pFForm, fUpdateLevel, pManRes->nLastGain );
pManRes->timeNtk += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, pManRes->timeNtk, clk);
Dec_GraphFree( pFForm );
}
Extra_ProgressBarStop( pProgress );
Expand Down Expand Up @@ -1958,24 +1958,24 @@ Dec_Graph_t * Abc_ManResubEval( Abc_ManRes_t * p, Abc_Obj_t * pRoot, Vec_Ptr_t *
p->nLastGain = -1;

// collect the MFFC
clk = Abc_Clock();
ABC_TIME_START(fVerbose, clk);
p->nMffc = Abc_NodeMffcInside( pRoot, vLeaves, p->vTemp );
p->timeMffc += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, p->timeMffc, clk);
assert( p->nMffc > 0 );

// collect the divisor nodes
clk = Abc_Clock();
ABC_TIME_START(fVerbose, clk);
if ( !Abc_ManResubCollectDivs( p, pRoot, vLeaves, Required ) )
return NULL;
p->timeDiv += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, p->timeDiv, clk);

p->nTotalDivs += p->nDivs;
p->nTotalLeaves += p->nLeaves;

// simulate the nodes
clk = Abc_Clock();
ABC_TIME_START(fVerbose, clk);
Abc_ManResubSimulate( p->vDivs, p->nLeaves, p->vSims, p->nLeavesMax, p->nWords );
p->timeSim += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, p->timeSim, clk);

if ( p->pFile && Vec_PtrSize(vLeaves) != p->nLeavesMax && p->nProbs < (1 << p->Log2Probs) )
{
Expand Down Expand Up @@ -2003,7 +2003,7 @@ p->timeSim += Abc_Clock() - clk;
return NULL;
}

clk = Abc_Clock();
ABC_TIME_START(fVerbose, clk);
// consider constants
if ( (pGraph = Abc_ManResubQuit( p )) )
{
Expand All @@ -2015,14 +2015,14 @@ clk = Abc_Clock();
// consider equal nodes
if ( (pGraph = Abc_ManResubDivs0( p )) )
{
p->timeRes1 += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, p->timeRes1, clk);
p->nUsedNode0++;
p->nLastGain = p->nMffc;
return pGraph;
}
if ( nSteps == 0 || p->nMffc == 1 )
{
p->timeRes1 += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, p->timeRes1, clk);
return NULL;
}

Expand All @@ -2035,50 +2035,50 @@ p->timeRes1 += Abc_Clock() - clk;
// consider one node
if ( (pGraph = Abc_ManResubDivs1( p, Required )) )
{
p->timeRes1 += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, p->timeRes1, clk);
p->nLastGain = p->nMffc - 1;
return pGraph;
}
p->timeRes1 += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, p->timeRes1, clk);
if ( nSteps == 1 || p->nMffc == 2 )
return NULL;

clk = Abc_Clock();
ABC_TIME_START(fVerbose, clk);
// consider triples
if ( (pGraph = Abc_ManResubDivs12( p, Required )) )
{
p->timeRes2 += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, p->timeRes2, clk);
p->nLastGain = p->nMffc - 2;
return pGraph;
}
p->timeRes2 += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, p->timeRes2, clk);

// get the two level divisors
clk = Abc_Clock();
ABC_TIME_START(fVerbose, clk);
Abc_ManResubDivsD( p, Required );
p->timeResD += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, p->timeResD, clk);

// consider two nodes
clk = Abc_Clock();
ABC_TIME_START(fVerbose, clk);
if ( (pGraph = Abc_ManResubDivs2( p, Required )) )
{
p->timeRes2 += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, p->timeRes2, clk);
p->nLastGain = p->nMffc - 2;
return pGraph;
}
p->timeRes2 += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, p->timeRes2, clk);
if ( nSteps == 2 || p->nMffc == 3 )
return NULL;

// consider two nodes
clk = Abc_Clock();
ABC_TIME_START(fVerbose, clk);
if ( (pGraph = Abc_ManResubDivs3( p, Required )) )
{
p->timeRes3 += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, p->timeRes3, clk);
p->nLastGain = p->nMffc - 3;
return pGraph;
}
p->timeRes3 += Abc_Clock() - clk;
ABC_TIME_STOP(fVerbose, p->timeRes3, clk);
if ( nSteps == 3 || p->nLeavesMax == 4 )
return NULL;
return NULL;
Expand Down
9 changes: 9 additions & 0 deletions src/misc/util/abc_global.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,15 @@ static inline abctime Abc_ThreadClock()
#endif
}

// stopwatch timing for verbose statistics
#if defined(ABC_NO_TIMERS)
#define ABC_TIME_START(cond, clk) do { (void)(clk); } while (0)
#define ABC_TIME_STOP(cond, acc, clk) do { (void)(clk); } while (0)
#else
#define ABC_TIME_START(cond, clk) do { clk = (cond) ? Abc_Clock() : 0; } while (0)
#define ABC_TIME_STOP(cond, acc, clk) do { if (cond) acc += Abc_Clock() - clk; } while (0)
#endif

// misc printing procedures
enum Abc_VerbLevel
{
Expand Down
Loading
Loading