Improvements to DSD balancing.

This commit is contained in:
Alan Mishchenko 2014-08-27 12:23:31 -07:00
parent 66d9a80b3d
commit 9c154cfe61
6 changed files with 109 additions and 43 deletions

View File

@ -444,10 +444,10 @@ void Gia_ManPrintMappingStats( Gia_Man_t * p, char * pDumpFile )
SetConsoleTextAttribute( hConsole, 12 ); // red
Abc_Print( 1, "lev =%5d ", LevelMax );
Abc_Print( 1, "(%.2f) ", (float)Ave / Gia_ManCoNum(p) );
SetConsoleTextAttribute( hConsole, 7 ); // normal
// Abc_Print( 1, "over =%5.1f %% ", 100.0 * Gia_ManComputeOverlap(p) / Gia_ManAndNum(p) );
if ( p->pManTime && Tim_ManBoxNum((Tim_Man_t *)p->pManTime) )
Abc_Print( 1, "levB =%5d ", Gia_ManLutLevelWithBoxes(p) );
SetConsoleTextAttribute( hConsole, 7 ); // normal
Abc_Print( 1, "mem =%5.2f MB", 4.0*(Gia_ManObjNum(p) + 2*nLuts + nFanins)/(1<<20) );
Abc_Print( 1, "\n" );
}
@ -459,7 +459,7 @@ void Gia_ManPrintMappingStats( Gia_Man_t * p, char * pDumpFile )
Abc_Print( 1, "%s(%.2f)%s ", "\033[1;31m", (float)Ave / Gia_ManCoNum(p), "\033[0m" );
// Abc_Print( 1, "over =%5.1f %% ", 100.0 * Gia_ManComputeOverlap(p) / Gia_ManAndNum(p) );
if ( p->pManTime && Tim_ManBoxNum((Tim_Man_t *)p->pManTime) )
Abc_Print( 1, "levB =%5d ", Gia_ManLutLevelWithBoxes(p) );
Abc_Print( 1, "%slevB =%5d%s ", "\033[1;31m", Gia_ManLutLevelWithBoxes(p), "\033[0m" );
Abc_Print( 1, "mem =%5.2f MB", 4.0*(Gia_ManObjNum(p) + 2*nLuts + nFanins)/(1<<20) );
Abc_Print( 1, "\n" );
#endif
@ -1831,11 +1831,11 @@ Gia_Man_t * Gia_ManPerformDsdBalance( Gia_Man_t * p, int nLutSize, int nCutNum,
pPars->fCutMin = 1;
pPars->fTruth = 1;
pPars->fExpRed = 0;
if ( Abc_FrameReadManDsd() == NULL )
Abc_FrameSetManDsd( If_DsdManAlloc(pPars->nLutSize, 0) );
if ( Abc_FrameReadManDsd2() == NULL )
Abc_FrameSetManDsd2( If_DsdManAlloc(pPars->nLutSize, 0) );
// perform mapping
pIfMan = Gia_ManToIf( p, pPars );
pIfMan->pIfDsdMan = (If_DsdMan_t *)Abc_FrameReadManDsd();
pIfMan->pIfDsdMan = (If_DsdMan_t *)Abc_FrameReadManDsd2();
if ( pPars->fDsdBalance )
If_DsdManAllocIsops( pIfMan->pIfDsdMan, pPars->nLutSize );
If_ManPerformMapping( pIfMan );

View File

@ -428,7 +428,7 @@ void Gia_ManPrintStats( Gia_Man_t * p, Gps_Par_t * pPars )
if ( Gia_ManHasChoices(p) )
Abc_Print( 1, " ch =%5d", Gia_ManChoiceNum(p) );
if ( p->pManTime )
Abc_Print( 1, " box =%d", Tim_ManBoxNum((Tim_Man_t *)p->pManTime) );
Abc_Print( 1, " box = %d", Tim_ManBoxNum((Tim_Man_t *)p->pManTime) );
if ( pPars && pPars->fMuxXor )
printf( "\nXOR/MUX " ), Gia_ManPrintMuxStats( p );
if ( pPars && pPars->fSwitch )

View File

@ -15662,26 +15662,21 @@ int Abc_CommandDsdSave( Abc_Frame_t * pAbc, int argc, char ** argv )
char * FileName;
char ** pArgvNew;
int nArgcNew;
int c;
int c, fSecond = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "bh" ) ) != EOF )
{
switch ( c )
{
case 'b':
fSecond ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
if ( !Abc_FrameReadManDsd() )
{
Abc_Print( -1, "The DSD manager is not started.\n" );
return 1;
}
pArgvNew = argv + globalUtilOptind;
nArgcNew = argc - globalUtilOptind;
if ( nArgcNew != 1 )
@ -15691,12 +15686,30 @@ int Abc_CommandDsdSave( Abc_Frame_t * pAbc, int argc, char ** argv )
}
// get the input file name
FileName = (nArgcNew == 1) ? pArgvNew[0] : NULL;
If_DsdManSave( (If_DsdMan_t *)Abc_FrameReadManDsd(), FileName );
if ( fSecond )
{
if ( !Abc_FrameReadManDsd2() )
{
Abc_Print( -1, "The DSD manager is not started.\n" );
return 1;
}
If_DsdManSave( (If_DsdMan_t *)Abc_FrameReadManDsd2(), FileName );
}
else
{
if ( !Abc_FrameReadManDsd() )
{
Abc_Print( -1, "The DSD manager is not started.\n" );
return 1;
}
If_DsdManSave( (If_DsdMan_t *)Abc_FrameReadManDsd(), FileName );
}
return 0;
usage:
Abc_Print( -2, "usage: dsd_save [-h] <file>\n" );
Abc_Print( -2, "usage: dsd_save [-bh] <file>\n" );
Abc_Print( -2, "\t saves DSD manager into a file\n");
Abc_Print( -2, "\t-b : toggles processing second manager [default = %s]\n", fSecond? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n");
Abc_Print( -2, "\t<file> : (optional) file name to write\n");
return 1;
@ -15717,14 +15730,17 @@ int Abc_CommandDsdLoad( Abc_Frame_t * pAbc, int argc, char ** argv )
{
char * FileName, * pTemp;
char ** pArgvNew;
int c, nArgcNew;
int c, nArgcNew, fSecond = 0;
FILE * pFile;
If_DsdMan_t * pDsdMan;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "bh" ) ) != EOF )
{
switch ( c )
{
case 'b':
fSecond ^= 1;
break;
case 'h':
goto usage;
default:
@ -15753,16 +15769,28 @@ int Abc_CommandDsdLoad( Abc_Frame_t * pAbc, int argc, char ** argv )
return 1;
}
fclose( pFile );
Abc_FrameSetManDsd( NULL );
pDsdMan = If_DsdManLoad(FileName);
if ( pDsdMan == NULL )
return 1;
Abc_FrameSetManDsd( pDsdMan );
if ( fSecond )
{
Abc_FrameSetManDsd2( NULL );
pDsdMan = If_DsdManLoad(FileName);
if ( pDsdMan == NULL )
return 1;
Abc_FrameSetManDsd2( pDsdMan );
}
else
{
Abc_FrameSetManDsd( NULL );
pDsdMan = If_DsdManLoad(FileName);
if ( pDsdMan == NULL )
return 1;
Abc_FrameSetManDsd( pDsdMan );
}
return 0;
usage:
Abc_Print( -2, "usage: dsd_load [-h] <file>\n" );
Abc_Print( -2, "usage: dsd_load [-bh] <file>\n" );
Abc_Print( -2, "\t loads DSD manager from file\n");
Abc_Print( -2, "\t-b : toggles processing second manager [default = %s]\n", fSecond? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n");
Abc_Print( -2, "\t<file> : file name to read\n");
return 1;
@ -15781,30 +15809,46 @@ usage:
***********************************************************************/
int Abc_CommandDsdFree( Abc_Frame_t * pAbc, int argc, char ** argv )
{
int c;
int c, fSecond = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "h" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "bh" ) ) != EOF )
{
switch ( c )
{
case 'b':
fSecond ^= 1;
break;
case 'h':
goto usage;
default:
goto usage;
}
}
if ( !Abc_FrameReadManDsd() )
if ( fSecond )
{
Abc_Print( 1, "The DSD manager is not started.\n" );
return 0;
if ( !Abc_FrameReadManDsd2() )
{
Abc_Print( 1, "The DSD manager is not started.\n" );
return 0;
}
Abc_FrameSetManDsd2( NULL );
}
else
{
if ( !Abc_FrameReadManDsd() )
{
Abc_Print( 1, "The DSD manager is not started.\n" );
return 0;
}
Abc_FrameSetManDsd( NULL );
}
Abc_FrameSetManDsd( NULL );
return 0;
usage:
Abc_Print( -2, "usage: dsd_ps [-h]\n" );
Abc_Print( -2, "\t deletes DSD manager\n" );
Abc_Print( -2, "\t-h : print the command usage\n");
Abc_Print( -2, "usage: dsd_free [-bh]\n" );
Abc_Print( -2, "\t deletes DSD manager\n" );
Abc_Print( -2, "\t-b : toggles processing second manager [default = %s]\n", fSecond? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
@ -15821,9 +15865,9 @@ usage:
***********************************************************************/
int Abc_CommandDsdPs( Abc_Frame_t * pAbc, int argc, char ** argv )
{
int c, Number = 0, Support = 0, fOccurs = 0, fTtDump = 0, fVerbose = 0;
int c, Number = 0, Support = 0, fOccurs = 0, fTtDump = 0, fSecond = 0, fVerbose = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "NSotvh" ) ) != EOF )
while ( ( c = Extra_UtilGetopt( argc, argv, "NSotbvh" ) ) != EOF )
{
switch ( c )
{
@ -15855,6 +15899,9 @@ int Abc_CommandDsdPs( Abc_Frame_t * pAbc, int argc, char ** argv )
case 't':
fTtDump ^= 1;
break;
case 'b':
fSecond ^= 1;
break;
case 'v':
fVerbose ^= 1;
break;
@ -15864,21 +15911,34 @@ int Abc_CommandDsdPs( Abc_Frame_t * pAbc, int argc, char ** argv )
goto usage;
}
}
if ( !Abc_FrameReadManDsd() )
if ( fSecond )
{
Abc_Print( 1, "The DSD manager is not started.\n" );
return 0;
if ( !Abc_FrameReadManDsd2() )
{
Abc_Print( 1, "The DSD manager is not started.\n" );
return 0;
}
If_DsdManPrint( (If_DsdMan_t *)Abc_FrameReadManDsd2(), NULL, Number, Support, fOccurs, fTtDump, fVerbose );
}
else
{
if ( !Abc_FrameReadManDsd() )
{
Abc_Print( 1, "The DSD manager is not started.\n" );
return 0;
}
If_DsdManPrint( (If_DsdMan_t *)Abc_FrameReadManDsd(), NULL, Number, Support, fOccurs, fTtDump, fVerbose );
}
If_DsdManPrint( (If_DsdMan_t *)Abc_FrameReadManDsd(), NULL, Number, Support, fOccurs, fTtDump, fVerbose );
return 0;
usage:
Abc_Print( -2, "usage: dsd_ps [-NS num] [-ovh]\n" );
Abc_Print( -2, "usage: dsd_ps [-NS num] [-obvh]\n" );
Abc_Print( -2, "\t prints statistics of DSD manager\n" );
Abc_Print( -2, "\t-N num : show structures whose ID divides by N [default = %d]\n", Number );
Abc_Print( -2, "\t-S num : show structures whose support size is S [default = %d]\n", Support );
Abc_Print( -2, "\t-o : toggles printing occurence distribution [default = %s]\n", fOccurs? "yes": "no" );
Abc_Print( -2, "\t-t : toggles dumping truth tables [default = %s]\n", fTtDump? "yes": "no" );
Abc_Print( -2, "\t-b : toggles processing second manager [default = %s]\n", fSecond? "yes": "no" );
Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", fVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n");
return 1;

View File

@ -106,6 +106,7 @@ extern ABC_DLL void * Abc_FrameReadLibScl();
extern ABC_DLL void * Abc_FrameReadManDd();
extern ABC_DLL void * Abc_FrameReadManDec();
extern ABC_DLL void * Abc_FrameReadManDsd();
extern ABC_DLL void * Abc_FrameReadManDsd2();
extern ABC_DLL char * Abc_FrameReadFlag( char * pFlag );
extern ABC_DLL int Abc_FrameIsFlagEnabled( char * pFlag );
@ -140,6 +141,7 @@ extern ABC_DLL void Abc_FrameSetCex( Abc_Cex_t * pCex );
extern ABC_DLL void Abc_FrameSetNFrames( int nFrames );
extern ABC_DLL void Abc_FrameSetStatus( int Status );
extern ABC_DLL void Abc_FrameSetManDsd( void * pMan );
extern ABC_DLL void Abc_FrameSetManDsd2( void * pMan );
extern ABC_DLL int Abc_FrameCheckPoConst( Abc_Frame_t * p, int iPoNum );

View File

@ -60,6 +60,7 @@ void * Abc_FrameReadLibScl() { return s_GlobalFr
void * Abc_FrameReadManDd() { if ( s_GlobalFrame->dd == NULL ) s_GlobalFrame->dd = Cudd_Init( 0, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0 ); return s_GlobalFrame->dd; }
void * Abc_FrameReadManDec() { if ( s_GlobalFrame->pManDec == NULL ) s_GlobalFrame->pManDec = Dec_ManStart(); return s_GlobalFrame->pManDec; }
void * Abc_FrameReadManDsd() { return s_GlobalFrame->pManDsd; }
void * Abc_FrameReadManDsd2() { return s_GlobalFrame->pManDsd2; }
char * Abc_FrameReadFlag( char * pFlag ) { return Cmd_FlagReadByName( s_GlobalFrame, pFlag ); }
int Abc_FrameReadBmcFrames( Abc_Frame_t * p ) { return s_GlobalFrame->nFrames; }
@ -85,7 +86,8 @@ void Abc_FrameSetFlag( char * pFlag, char * pValue ) { Cmd_FlagUpdateVal
void Abc_FrameSetCex( Abc_Cex_t * pCex ) { ABC_FREE( s_GlobalFrame->pCex ); s_GlobalFrame->pCex = pCex; }
void Abc_FrameSetNFrames( int nFrames ) { ABC_FREE( s_GlobalFrame->pCex ); s_GlobalFrame->nFrames = nFrames; }
void Abc_FrameSetStatus( int Status ) { ABC_FREE( s_GlobalFrame->pCex ); s_GlobalFrame->Status = Status; }
void Abc_FrameSetManDsd( void * pMan ) { if (s_GlobalFrame->pManDsd && s_GlobalFrame->pManDsd != pMan) If_DsdManFree((If_DsdMan_t *)s_GlobalFrame->pManDsd, 0); s_GlobalFrame->pManDsd = pMan; }
void Abc_FrameSetManDsd( void * pMan ) { if (s_GlobalFrame->pManDsd && s_GlobalFrame->pManDsd != pMan) If_DsdManFree((If_DsdMan_t *)s_GlobalFrame->pManDsd, 0); s_GlobalFrame->pManDsd = pMan; }
void Abc_FrameSetManDsd2( void * pMan ) { if (s_GlobalFrame->pManDsd2 && s_GlobalFrame->pManDsd2 != pMan) If_DsdManFree((If_DsdMan_t *)s_GlobalFrame->pManDsd2, 0); s_GlobalFrame->pManDsd2 = pMan; }
int Abc_FrameIsBatchMode() { return s_GlobalFrame ? s_GlobalFrame->fBatchMode : 0; }
@ -195,6 +197,7 @@ void Abc_FrameDeallocate( Abc_Frame_t * p )
if ( p->pSave3 ) Aig_ManStop( (Aig_Man_t *)p->pSave3 );
if ( p->pSave4 ) Aig_ManStop( (Aig_Man_t *)p->pSave4 );
if ( p->pManDsd ) If_DsdManFree( (If_DsdMan_t *)p->pManDsd, 0 );
if ( p->pManDsd2 ) If_DsdManFree( (If_DsdMan_t *)p->pManDsd2, 0 );
if ( p->vPlugInComBinPairs )
{
char * pTemp;

View File

@ -85,6 +85,7 @@ struct Abc_Frame_t_
// decomposition package
void * pManDec; // decomposition manager
void * pManDsd; // decomposition manager
void * pManDsd2; // decomposition manager
DdManager * dd; // temporary BDD package
// libraries for mapping
void * pLibLut; // the current LUT library