Commit 74c8d35f by Alan Mishchenko

Updates to delay optimization project.

parent 6e1df46c
...@@ -2775,6 +2775,10 @@ SOURCE=.\src\opt\sbd\sbdLut.c ...@@ -2775,6 +2775,10 @@ SOURCE=.\src\opt\sbd\sbdLut.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=.\src\opt\sbd\sbdPath.c
# End Source File
# Begin Source File
SOURCE=.\src\opt\sbd\sbdSat.c SOURCE=.\src\opt\sbd\sbdSat.c
# End Source File # End Source File
# Begin Source File # Begin Source File
......
...@@ -41010,7 +41010,7 @@ int Abc_CommandAbc9Mfsd( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -41010,7 +41010,7 @@ int Abc_CommandAbc9Mfsd( Abc_Frame_t * pAbc, int argc, char ** argv )
Sbd_Par_t Pars, * pPars = &Pars; Sbd_Par_t Pars, * pPars = &Pars;
Sbd_ParSetDefault( pPars ); Sbd_ParSetDefault( pPars );
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "KSNPWFMCacvwh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "KSNPWFMCmcdpvwh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
...@@ -41102,11 +41102,17 @@ int Abc_CommandAbc9Mfsd( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -41102,11 +41102,17 @@ int Abc_CommandAbc9Mfsd( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pPars->nBTLimit < 0 ) if ( pPars->nBTLimit < 0 )
goto usage; goto usage;
break; break;
case 'a': case 'm':
pPars->fArea ^= 1; pPars->fMapping ^= 1;
break; break;
case 'c': case 'c':
pPars->fCover ^= 1; pPars->fMoreCuts ^= 1;
break;
case 'd':
pPars->fFindDivs ^= 1;
break;
case 'p':
pPars->fUsePath ^= 1;
break; break;
case 'v': case 'v':
pPars->fVerbose ^= 1; pPars->fVerbose ^= 1;
...@@ -41122,25 +41128,22 @@ int Abc_CommandAbc9Mfsd( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -41122,25 +41128,22 @@ int Abc_CommandAbc9Mfsd( Abc_Frame_t * pAbc, int argc, char ** argv )
} }
if ( pAbc->pGia == NULL ) if ( pAbc->pGia == NULL )
{ {
Abc_Print( -1, "Abc_CommandAbc9Mfs(): There is no AIG.\n" ); Abc_Print( -1, "Abc_CommandAbc9Mfsd(): There is no AIG.\n" );
return 0; return 0;
} }
if ( Gia_ManBufNum(pAbc->pGia) ) if ( Gia_ManBufNum(pAbc->pGia) )
{ {
Abc_Print( -1, "Abc_CommandAbc9Mfs(): This command does not work with barrier buffers.\n" ); Abc_Print( -1, "Abc_CommandAbc9Mfsd(): This command does not work with barrier buffers.\n" );
return 1; return 1;
} }
if ( Gia_ManHasMapping(pAbc->pGia) ) if ( Gia_ManHasMapping(pAbc->pGia) )
{ Abc_Print( 1, "The current AIG has mapping, which can be used to determine critical path if \"-p\" is selected.\n" );
Abc_Print( -1, "Abc_CommandAbc9Mfs(): The current AIG has mapping (run &st to unmap).\n" );
return 0;
}
pTemp = Sbd_NtkPerform( pAbc->pGia, pPars ); pTemp = Sbd_NtkPerform( pAbc->pGia, pPars );
Abc_FrameUpdateGia( pAbc, pTemp ); Abc_FrameUpdateGia( pAbc, pTemp );
return 0; return 0;
usage: usage:
Abc_Print( -2, "usage: &mfsd [-KSNPWFMC <num>] [-acvwh]\n" ); Abc_Print( -2, "usage: &mfsd [-KSNPWFMC <num>] [-mcdpvwh]\n" );
Abc_Print( -2, "\t performs SAT-based delay-oriented AIG optimization\n" ); Abc_Print( -2, "\t performs SAT-based delay-oriented AIG optimization\n" );
Abc_Print( -2, "\t-K <num> : the LUT size for delay minimization (2 <= num <= 6) [default = %d]\n", pPars->nLutSize ); Abc_Print( -2, "\t-K <num> : the LUT size for delay minimization (2 <= num <= 6) [default = %d]\n", pPars->nLutSize );
Abc_Print( -2, "\t-S <num> : the LUT structure size (1 <= num <= 2) [default = %d]\n", pPars->nLutNum ); Abc_Print( -2, "\t-S <num> : the LUT structure size (1 <= num <= 2) [default = %d]\n", pPars->nLutNum );
...@@ -41150,8 +41153,10 @@ usage: ...@@ -41150,8 +41153,10 @@ usage:
Abc_Print( -2, "\t-F <num> : the max number of fanouts to skip (1 <= num) [default = %d]\n", pPars->nTfoFanMax ); Abc_Print( -2, "\t-F <num> : the max number of fanouts to skip (1 <= num) [default = %d]\n", pPars->nTfoFanMax );
Abc_Print( -2, "\t-M <num> : the max node count of windows to consider (0 = no limit) [default = %d]\n", pPars->nWinSizeMax ); Abc_Print( -2, "\t-M <num> : the max node count of windows to consider (0 = no limit) [default = %d]\n", pPars->nWinSizeMax );
Abc_Print( -2, "\t-C <num> : the max number of conflicts in one SAT run (0 = no limit) [default = %d]\n", pPars->nBTLimit ); Abc_Print( -2, "\t-C <num> : the max number of conflicts in one SAT run (0 = no limit) [default = %d]\n", pPars->nBTLimit );
Abc_Print( -2, "\t-a : toggle minimizing area or area+edges [default = %s]\n", pPars->fArea? "area": "area+edges" ); Abc_Print( -2, "\t-m : toggle generating delay-oriented mapping [default = %s]\n", pPars->fMapping? "area": "area+edges" );
Abc_Print( -2, "\t-c : toggle using complete slow covering procedure [default = %s]\n", pPars->fCover? "yes": "no" ); Abc_Print( -2, "\t-c : toggle using several cuts at each node [default = %s]\n", pPars->fMoreCuts? "yes": "no" );
Abc_Print( -2, "\t-d : toggle additional search for good divisors [default = %s]\n", pPars->fFindDivs? "yes": "no" );
Abc_Print( -2, "\t-p : toggle optimizing critical path only [default = %s]\n", pPars->fUsePath? "yes": "no" );
Abc_Print( -2, "\t-v : toggle printing optimization summary [default = %s]\n", pPars->fVerbose? "yes": "no" ); Abc_Print( -2, "\t-v : toggle printing optimization summary [default = %s]\n", pPars->fVerbose? "yes": "no" );
Abc_Print( -2, "\t-w : toggle printing detailed stats for each node [default = %s]\n", pPars->fVeryVerbose? "yes": "no" ); Abc_Print( -2, "\t-w : toggle printing detailed stats for each node [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n"); Abc_Print( -2, "\t-h : print the command usage\n");
...@@ -4,5 +4,6 @@ SRC += src/opt/sbd/sbd.c \ ...@@ -4,5 +4,6 @@ SRC += src/opt/sbd/sbd.c \
src/opt/sbd/sbdCut.c \ src/opt/sbd/sbdCut.c \
src/opt/sbd/sbdCut2.c \ src/opt/sbd/sbdCut2.c \
src/opt/sbd/sbdLut.c \ src/opt/sbd/sbdLut.c \
src/opt/sbd/sbdPath.c \
src/opt/sbd/sbdSat.c \ src/opt/sbd/sbdSat.c \
src/opt/sbd/sbdWin.c src/opt/sbd/sbdWin.c
...@@ -47,6 +47,10 @@ struct Sbd_Par_t_ ...@@ -47,6 +47,10 @@ struct Sbd_Par_t_
int nWinSizeMax; // maximum window size (windowing) int nWinSizeMax; // maximum window size (windowing)
int nBTLimit; // maximum number of SAT conflicts int nBTLimit; // maximum number of SAT conflicts
int nWords; // simulation word count int nWords; // simulation word count
int fMapping; // generate mapping
int fMoreCuts; // use several cuts
int fFindDivs; // perform divisor search
int fUsePath; // optimize only critical path
int fArea; // area-oriented optimization int fArea; // area-oriented optimization
int fCover; // use complete cover procedure int fCover; // use complete cover procedure
int fVerbose; // verbose flag int fVerbose; // verbose flag
......
...@@ -65,10 +65,11 @@ struct Sbd_Sto_t_ ...@@ -65,10 +65,11 @@ struct Sbd_Sto_t_
Sbd_Cut_t * ppCuts[SBD_MAX_CUTNUM]; // temporary cut pointers Sbd_Cut_t * ppCuts[SBD_MAX_CUTNUM]; // temporary cut pointers
int nCutsR; // the number of cuts int nCutsR; // the number of cuts
int Pivot; // current object int Pivot; // current object
double CutCount[4]; // cut counters int iCutBest; // best-delay cut
int nCutsSpec; // special cuts int nCutsSpec; // special cuts
int nCutsOver; // overflow cuts int nCutsOver; // overflow cuts
int DelayMin; // minimum delay int DelayMin; // minimum delay
double CutCount[4]; // cut counters
abctime clkStart; // starting time abctime clkStart; // starting time
}; };
...@@ -540,6 +541,7 @@ static inline void Sbd_StoComputeDelay( Sbd_Sto_t * p, int iObj, Sbd_Cut_t ** pC ...@@ -540,6 +541,7 @@ static inline void Sbd_StoComputeDelay( Sbd_Sto_t * p, int iObj, Sbd_Cut_t ** pC
{ {
int i, v, Delay, DelayMin = ABC_INFINITY; int i, v, Delay, DelayMin = ABC_INFINITY;
assert( nCuts > 0 ); assert( nCuts > 0 );
p->iCutBest = -1;
for ( i = 0; i < nCuts; i++ ) for ( i = 0; i < nCuts; i++ )
{ {
if ( (int)pCuts[i]->nLeaves > p->nLutSize ) if ( (int)pCuts[i]->nLeaves > p->nLutSize )
...@@ -547,8 +549,16 @@ static inline void Sbd_StoComputeDelay( Sbd_Sto_t * p, int iObj, Sbd_Cut_t ** pC ...@@ -547,8 +549,16 @@ static inline void Sbd_StoComputeDelay( Sbd_Sto_t * p, int iObj, Sbd_Cut_t ** pC
Delay = 0; Delay = 0;
for ( v = 0; v < (int)pCuts[i]->nLeaves; v++ ) for ( v = 0; v < (int)pCuts[i]->nLeaves; v++ )
Delay = Abc_MaxInt( Delay, Vec_IntEntry(p->vDelays, pCuts[i]->pLeaves[v]) ); Delay = Abc_MaxInt( Delay, Vec_IntEntry(p->vDelays, pCuts[i]->pLeaves[v]) );
DelayMin = Abc_MinInt( DelayMin, Delay ); //DelayMin = Abc_MinInt( DelayMin, Delay );
if ( DelayMin > Delay )
{
DelayMin = Delay;
p->iCutBest = i;
}
else if ( DelayMin == Delay && p->iCutBest >= 0 && pCuts[p->iCutBest]->nLeaves > pCuts[i]->nLeaves )
p->iCutBest = i;
} }
assert( p->iCutBest >= 0 );
assert( DelayMin < ABC_INFINITY ); assert( DelayMin < ABC_INFINITY );
DelayMin = (nCuts > 1 || pCuts[0]->nLeaves > 1) ? DelayMin + 1 : DelayMin; DelayMin = (nCuts > 1 || pCuts[0]->nLeaves > 1) ? DelayMin + 1 : DelayMin;
Vec_IntWriteEntry( p->vDelays, iObj, DelayMin ); Vec_IntWriteEntry( p->vDelays, iObj, DelayMin );
...@@ -725,6 +735,14 @@ int Sbd_StoComputeCutsNode( Sbd_Sto_t * p, int iObj ) ...@@ -725,6 +735,14 @@ int Sbd_StoComputeCutsNode( Sbd_Sto_t * p, int iObj )
Sbd_StoMergeCuts( p, iObj ); Sbd_StoMergeCuts( p, iObj );
return Vec_IntEntry( p->vDelays, iObj ); return Vec_IntEntry( p->vDelays, iObj );
} }
void Sbd_StoSaveBestDelayCut( Sbd_Sto_t * p, int iObj, int * pCut )
{
Sbd_Cut_t * pCutBest = p->ppCuts[p->iCutBest]; int i;
assert( iObj == p->Pivot );
pCut[0] = pCutBest->nLeaves;
for ( i = 0; i < (int)pCutBest->nLeaves; i++ )
pCut[i+1] = pCutBest->pLeaves[i];
}
int Sbd_StoObjRefs( Sbd_Sto_t * p, int iObj ) int Sbd_StoObjRefs( Sbd_Sto_t * p, int iObj )
{ {
return Vec_IntEntry(p->vRefs, iObj); return Vec_IntEntry(p->vRefs, iObj);
......
...@@ -92,6 +92,7 @@ extern void Sbd_StoComputeCutsConst0( Sbd_Sto_t * p, int iObj ); ...@@ -92,6 +92,7 @@ extern void Sbd_StoComputeCutsConst0( Sbd_Sto_t * p, int iObj );
extern void Sbd_StoComputeCutsObj( Sbd_Sto_t * p, int iObj, int Delay, int Level ); extern void Sbd_StoComputeCutsObj( Sbd_Sto_t * p, int iObj, int Delay, int Level );
extern void Sbd_StoComputeCutsCi( Sbd_Sto_t * p, int iObj, int Delay, int Level ); extern void Sbd_StoComputeCutsCi( Sbd_Sto_t * p, int iObj, int Delay, int Level );
extern int Sbd_StoComputeCutsNode( Sbd_Sto_t * p, int iObj ); extern int Sbd_StoComputeCutsNode( Sbd_Sto_t * p, int iObj );
extern void Sbd_StoSaveBestDelayCut( Sbd_Sto_t * p, int iObj, int * pCut );
extern int Sbd_StoObjBestCut( Sbd_Sto_t * p, int iObj, int nSize, int * pLeaves ); extern int Sbd_StoObjBestCut( Sbd_Sto_t * p, int iObj, int nSize, int * pLeaves );
/*=== sbdCut2.c ==========================================================*/ /*=== sbdCut2.c ==========================================================*/
extern Sbd_Srv_t * Sbd_ManCutServerStart( Gia_Man_t * pGia, Vec_Int_t * vMirrors, extern Sbd_Srv_t * Sbd_ManCutServerStart( Gia_Man_t * pGia, Vec_Int_t * vMirrors,
...@@ -104,6 +105,8 @@ extern word Sbd_ManSolve( sat_solver * pSat, int PivotVar, int FreeVar, ...@@ -104,6 +105,8 @@ extern word Sbd_ManSolve( sat_solver * pSat, int PivotVar, int FreeVar,
extern sat_solver * Sbd_ManSatSolver( sat_solver * pSat, Gia_Man_t * p, Vec_Int_t * vMirrors, int Pivot, Vec_Int_t * vWinObjs, Vec_Int_t * vObj2Var, Vec_Int_t * vTfo, Vec_Int_t * vRoots, int fQbf ); extern sat_solver * Sbd_ManSatSolver( sat_solver * pSat, Gia_Man_t * p, Vec_Int_t * vMirrors, int Pivot, Vec_Int_t * vWinObjs, Vec_Int_t * vObj2Var, Vec_Int_t * vTfo, Vec_Int_t * vRoots, int fQbf );
extern int Sbd_ManCollectConstants( sat_solver * pSat, int nCareMints[2], int PivotVar, word * pVarSims[], Vec_Int_t * vInds ); extern int Sbd_ManCollectConstants( sat_solver * pSat, int nCareMints[2], int PivotVar, word * pVarSims[], Vec_Int_t * vInds );
extern int Sbd_ManCollectConstantsNew( sat_solver * pSat, Vec_Int_t * vDivVars, int nConsts, int PivotVar, word * pOnset, word * pOffset ); extern int Sbd_ManCollectConstantsNew( sat_solver * pSat, Vec_Int_t * vDivVars, int nConsts, int PivotVar, word * pOnset, word * pOffset );
/*=== sbdPath.c ==========================================================*/
extern Vec_Bit_t * Sbc_ManCriticalPath( Gia_Man_t * p );
/*=== sbdQbf.c ==========================================================*/ /*=== sbdQbf.c ==========================================================*/
extern int Sbd_ProblemSolve( extern int Sbd_ProblemSolve(
Gia_Man_t * p, Vec_Int_t * vMirrors, Gia_Man_t * p, Vec_Int_t * vMirrors,
......
/**CFile****************************************************************
FileName [sbdPath.c]
SystemName [ABC: Logic synthesis and verification system.]
PackageName [SAT-based optimization using internal don't-cares.]
Synopsis [Critical path.]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - June 20, 2005.]
Revision [$Id: sbdPath.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
***********************************************************************/
#include "sbdInt.h"
ABC_NAMESPACE_IMPL_START
////////////////////////////////////////////////////////////////////////
/// DECLARATIONS ///
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/// FUNCTION DEFINITIONS ///
////////////////////////////////////////////////////////////////////////
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
int Sbc_ManAddInternalToPath_rec( Gia_Man_t * p, int iObj, Vec_Bit_t * vPath )
{
Gia_Obj_t * pObj;
int k, iFan, Value = 0;
if ( Gia_ObjIsTravIdCurrentId(p, iObj) )
return Vec_BitEntry(vPath, iObj);
Gia_ObjSetTravIdCurrentId(p, iObj);
pObj = Gia_ManObj( p, iObj );
if ( Gia_ObjIsCi(pObj) )
return 0;
assert( Gia_ObjIsAnd(pObj) );
Gia_LutForEachFanin( p, iObj, iFan, k )
Value |= Sbc_ManAddInternalToPath_rec( p, iFan, vPath );
if ( Value )
Vec_BitWriteEntry( vPath, iObj, 1 );
return Value;
}
void Sbc_ManAddInternalToPath( Gia_Man_t * p, Vec_Bit_t * vPath )
{
int iObj;
Gia_ManForEachLut( p, iObj )
{
if ( !Vec_BitEntry(vPath, iObj) )
continue;
Gia_ManIncrementTravId( p );
Sbc_ManAddInternalToPath_rec( p, iObj, vPath );
}
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Sbc_ManCriticalPath_rec( Gia_Man_t * p, int * pLevels, int iObj, int LevelFan, Vec_Bit_t * vPath )
{
Gia_Obj_t * pObj; int k, iFan;
if ( Gia_ObjIsTravIdCurrentId(p, iObj) )
return;
Gia_ObjSetTravIdCurrentId(p, iObj);
pObj = Gia_ManObj( p, iObj );
if ( Gia_ObjIsCi(pObj) )
return;
assert( Gia_ObjIsAnd(pObj) );
Vec_BitWriteEntry( vPath, iObj, 1 );
Gia_LutForEachFanin( p, iObj, iFan, k )
if ( pLevels[iFan] == LevelFan )
Sbc_ManCriticalPath_rec( p, pLevels, iFan, LevelFan-1, vPath );
}
Vec_Bit_t * Sbc_ManCriticalPath( Gia_Man_t * p )
{
int * pLevels = NULL, k, iDriver;
int nLevels = p->pManTime ? Gia_ManLutLevelWithBoxes(p) : Gia_ManLutLevel(p, &pLevels);
Vec_Bit_t * vPath = Vec_BitStart( Gia_ManObjNum(p) );
if ( p->pManTime )
pLevels = Vec_IntArray( p->vLevels );
Gia_ManIncrementTravId( p );
Gia_ManForEachCoDriverId( p, iDriver, k )
if ( pLevels[iDriver] == nLevels && iDriver )
Sbc_ManCriticalPath_rec( p, pLevels, iDriver, nLevels-1, vPath );
if ( !p->pManTime )
ABC_FREE( pLevels );
Sbc_ManAddInternalToPath( p, vPath );
return vPath;
}
////////////////////////////////////////////////////////////////////////
/// END OF FILE ///
////////////////////////////////////////////////////////////////////////
ABC_NAMESPACE_IMPL_END
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment