Commit b5e0b7d4 by Alan Mishchenko

Experiments with precomputation and matching.

parent 9df63f52
...@@ -5160,7 +5160,7 @@ int Abc_CommandMfs3( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -5160,7 +5160,7 @@ int Abc_CommandMfs3( Abc_Frame_t * pAbc, int argc, char ** argv )
// set defaults // set defaults
Sfm_ParSetDefault3( pPars ); Sfm_ParSetDefault3( pPars );
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "OIFXMLCNdaovwh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "OIFLHMCNdazovwh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
...@@ -5200,37 +5200,37 @@ int Abc_CommandMfs3( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -5200,37 +5200,37 @@ int Abc_CommandMfs3( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( pPars->nFanoutMax < 0 ) if ( pPars->nFanoutMax < 0 )
goto usage; goto usage;
break; break;
case 'X': case 'L':
if ( globalUtilOptind >= argc ) if ( globalUtilOptind >= argc )
{ {
Abc_Print( -1, "Command line switch \"-X\" should be followed by an integer.\n" ); Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" );
goto usage; goto usage;
} }
pPars->nMffcMax = atoi(argv[globalUtilOptind]); pPars->nMffcMin = atoi(argv[globalUtilOptind]);
globalUtilOptind++; globalUtilOptind++;
if ( pPars->nMffcMax < 0 ) if ( pPars->nMffcMin < 0 )
goto usage; goto usage;
break; break;
case 'M': case 'H':
if ( globalUtilOptind >= argc ) if ( globalUtilOptind >= argc )
{ {
Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" ); Abc_Print( -1, "Command line switch \"-H\" should be followed by an integer.\n" );
goto usage; goto usage;
} }
pPars->nWinSizeMax = atoi(argv[globalUtilOptind]); pPars->nMffcMax = atoi(argv[globalUtilOptind]);
globalUtilOptind++; globalUtilOptind++;
if ( pPars->nWinSizeMax < 0 ) if ( pPars->nMffcMax < 0 )
goto usage; goto usage;
break; break;
case 'L': case 'M':
if ( globalUtilOptind >= argc ) if ( globalUtilOptind >= argc )
{ {
Abc_Print( -1, "Command line switch \"-L\" should be followed by an integer.\n" ); Abc_Print( -1, "Command line switch \"-M\" should be followed by an integer.\n" );
goto usage; goto usage;
} }
pPars->nGrowthLevel = atoi(argv[globalUtilOptind]); pPars->nWinSizeMax = atoi(argv[globalUtilOptind]);
globalUtilOptind++; globalUtilOptind++;
if ( pPars->nGrowthLevel < -ABC_INFINITY || pPars->nGrowthLevel > ABC_INFINITY ) if ( pPars->nWinSizeMax < 0 )
goto usage; goto usage;
break; break;
case 'C': case 'C':
...@@ -5258,6 +5258,9 @@ int Abc_CommandMfs3( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -5258,6 +5258,9 @@ int Abc_CommandMfs3( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'a': case 'a':
pPars->fArea ^= 1; pPars->fArea ^= 1;
break; break;
case 'z':
pPars->fZeroCost ^= 1;
break;
case 'o': case 'o':
pPars->fRrOnly ^= 1; pPars->fRrOnly ^= 1;
break; break;
...@@ -5288,17 +5291,18 @@ int Abc_CommandMfs3( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -5288,17 +5291,18 @@ int Abc_CommandMfs3( Abc_Frame_t * pAbc, int argc, char ** argv )
return 0; return 0;
usage: usage:
Abc_Print( -2, "usage: mfs3 [-OIFXMLCN <num>] [-aovwh]\n" ); Abc_Print( -2, "usage: mfs3 [-OIFLHMCN <num>] [-azovwh]\n" );
Abc_Print( -2, "\t performs don't-care-based optimization of mapped networks\n" ); Abc_Print( -2, "\t performs don't-care-based optimization of mapped networks\n" );
Abc_Print( -2, "\t-O <num> : the number of levels in the TFO cone (0 <= num) [default = %d]\n", pPars->nTfoLevMax ); Abc_Print( -2, "\t-O <num> : the number of levels in the TFO cone (0 <= num) [default = %d]\n", pPars->nTfoLevMax );
Abc_Print( -2, "\t-I <num> : the number of levels in the TFI cone (1 <= num) [default = %d]\n", pPars->nTfiLevMax ); Abc_Print( -2, "\t-I <num> : the number of levels in the TFI cone (1 <= num) [default = %d]\n", pPars->nTfiLevMax );
Abc_Print( -2, "\t-F <num> : the max number of fanouts to skip (1 <= num) [default = %d]\n", pPars->nFanoutMax ); Abc_Print( -2, "\t-F <num> : the max number of fanouts to skip (1 <= num) [default = %d]\n", pPars->nFanoutMax );
Abc_Print( -2, "\t-X <num> : the max size of max fanout-free cone (MFFC) [default = %d]\n", pPars->nMffcMax ); Abc_Print( -2, "\t-L <num> : the min size of max fanout-free cone (MFFC) [default = %d]\n", pPars->nMffcMin );
Abc_Print( -2, "\t-H <num> : the max size of max fanout-free cone (MFFC) [default = %d]\n", pPars->nMffcMax );
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-L <num> : the max increase in node level after resynthesis (0 <= num) [default = %d]\n", pPars->nGrowthLevel );
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-N <num> : the max number of nodes to try (0 = all) [default = %d]\n", pPars->nNodesMax ); Abc_Print( -2, "\t-N <num> : the max number of nodes to try (0 = all) [default = %d]\n", pPars->nNodesMax );
Abc_Print( -2, "\t-a : toggle minimizing area or area+edges [default = %s]\n", pPars->fArea? "area": "area+edges" ); Abc_Print( -2, "\t-a : toggle minimizing area or area+edges [default = %s]\n", pPars->fArea? "area": "area+edges" );
Abc_Print( -2, "\t-z : toggle zero-cost replacements [default = %s]\n", pPars->fZeroCost? "yes": "no" );
Abc_Print( -2, "\t-o : toggle using old implementation for comparison [default = %s]\n", pPars->fRrOnly? "yes": "no" ); Abc_Print( -2, "\t-o : toggle using old implementation for comparison [default = %s]\n", pPars->fRrOnly? "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" );
...@@ -46,6 +46,7 @@ struct Sfm_Par_t_ ...@@ -46,6 +46,7 @@ struct Sfm_Par_t_
int nTfiLevMax; // the maximum fanin levels int nTfiLevMax; // the maximum fanin levels
int nFanoutMax; // the maximum number of fanouts int nFanoutMax; // the maximum number of fanouts
int nDepthMax; // the maximum depth to try int nDepthMax; // the maximum depth to try
int nMffcMin; // the minimum MFFC size
int nMffcMax; // the maximum MFFC size int nMffcMax; // the maximum MFFC size
int nWinSizeMax; // the maximum window size int nWinSizeMax; // the maximum window size
int nGrowthLevel; // the maximum allowed growth in level int nGrowthLevel; // the maximum allowed growth in level
...@@ -55,6 +56,7 @@ struct Sfm_Par_t_ ...@@ -55,6 +56,7 @@ struct Sfm_Par_t_
int fRrOnly; // perform redundance removal int fRrOnly; // perform redundance removal
int fArea; // performs optimization for area int fArea; // performs optimization for area
int fMoreEffort; // performs high-affort minimization int fMoreEffort; // performs high-affort minimization
int fZeroCost; // enable zero-cost replacement
int fVerbose; // enable basic stats int fVerbose; // enable basic stats
int fVeryVerbose; // enable detailed stats int fVeryVerbose; // enable detailed stats
}; };
......
...@@ -47,6 +47,7 @@ ABC_NAMESPACE_HEADER_START ...@@ -47,6 +47,7 @@ ABC_NAMESPACE_HEADER_START
#define SFM_SUPP_MAX 6 #define SFM_SUPP_MAX 6
#define SFM_WORD_MAX ((SFM_SUPP_MAX>6) ? (1<<(SFM_SUPP_MAX-6)) : 1) #define SFM_WORD_MAX ((SFM_SUPP_MAX>6) ? (1<<(SFM_SUPP_MAX-6)) : 1)
#define SFM_WIN_MAX 1000
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
/// BASIC TYPES /// /// BASIC TYPES ///
...@@ -193,7 +194,7 @@ extern int Sfm_LibFindComplInputGate( Vec_Wrd_t * vFuncs, int iGate, in ...@@ -193,7 +194,7 @@ extern int Sfm_LibFindComplInputGate( Vec_Wrd_t * vFuncs, int iGate, in
extern Sfm_Lib_t * Sfm_LibPrepare( int nVars, int fTwo, int fVerbose ); extern Sfm_Lib_t * Sfm_LibPrepare( int nVars, int fTwo, int fVerbose );
extern void Sfm_LibPrint( Sfm_Lib_t * p ); extern void Sfm_LibPrint( Sfm_Lib_t * p );
extern void Sfm_LibStop( Sfm_Lib_t * p ); extern void Sfm_LibStop( Sfm_Lib_t * p );
extern int Sfm_LibImplement( Sfm_Lib_t * p, word uTruth, int * pFanins, int nFanins, int AreaMffc, Vec_Int_t * vGates, Vec_Wec_t * vFanins ); extern int Sfm_LibImplement( Sfm_Lib_t * p, word uTruth, int * pFanins, int nFanins, int AreaMffc, Vec_Int_t * vGates, Vec_Wec_t * vFanins, int fZeroCost );
/*=== sfmNtk.c ==========================================================*/ /*=== sfmNtk.c ==========================================================*/
extern Sfm_Ntk_t * Sfm_ConstructNetwork( Vec_Wec_t * vFanins, int nPis, int nPos ); extern Sfm_Ntk_t * Sfm_ConstructNetwork( Vec_Wec_t * vFanins, int nPis, int nPos );
extern void Sfm_NtkPrepare( Sfm_Ntk_t * p ); extern void Sfm_NtkPrepare( Sfm_Ntk_t * p );
......
...@@ -428,7 +428,7 @@ void Sfm_LibTest( int nVars, int fTwo, int fVerbose ) ...@@ -428,7 +428,7 @@ void Sfm_LibTest( int nVars, int fTwo, int fVerbose )
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Sfm_LibImplement( Sfm_Lib_t * p, word uTruth, int * pFanins, int nFanins, int AreaMffc, Vec_Int_t * vGates, Vec_Wec_t * vFanins ) int Sfm_LibImplement( Sfm_Lib_t * p, word uTruth, int * pFanins, int nFanins, int AreaMffc, Vec_Int_t * vGates, Vec_Wec_t * vFanins, int fZeroCost )
{ {
Mio_Library_t * pLib = (Mio_Library_t *)Abc_FrameReadLibGen(); Mio_Library_t * pLib = (Mio_Library_t *)Abc_FrameReadLibGen();
Mio_Gate_t * pGate; Mio_Gate_t * pGate;
...@@ -460,7 +460,7 @@ int Sfm_LibImplement( Sfm_Lib_t * p, word uTruth, int * pFanins, int nFanins, in ...@@ -460,7 +460,7 @@ int Sfm_LibImplement( Sfm_Lib_t * p, word uTruth, int * pFanins, int nFanins, in
Sfm_LibForEachSuper( p, pObj, iFunc ) Sfm_LibForEachSuper( p, pObj, iFunc )
if ( !pObjMin || pObjMin->Area > pObj->Area ) if ( !pObjMin || pObjMin->Area > pObj->Area )
pObjMin = pObj; pObjMin = pObj;
if ( pObjMin == NULL || pObjMin->Area >= AreaMffc ) if ( pObjMin == NULL || (fZeroCost ? pObjMin->Area > AreaMffc : pObjMin->Area >= AreaMffc) )
return -1; return -1;
// get the gates // get the gates
pCellB = p->pCells + (int)pObjMin->pFansB[0]; pCellB = p->pCells + (int)pObjMin->pFansB[0];
......
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