Unverified Commit 9c2cac9e by alanminko Committed by GitHub

Merge pull request #230 from Yu-Utah/master

add orchestration function (local greedy); usage: orchestrate -h
parents 766f64e2 5bb7fb76
......@@ -163,6 +163,7 @@ static int Abc_CommandLutExact ( Abc_Frame_t * pAbc, int argc, cha
static int Abc_CommandAllExact ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandTestExact ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandMajGen ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandOrchestrate ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandLogic ( Abc_Frame_t * pAbc, int argc, char ** argv );
static int Abc_CommandComb ( Abc_Frame_t * pAbc, int argc, char ** argv );
......@@ -914,6 +915,7 @@ void Abc_Init( Abc_Frame_t * pAbc )
Cmd_CommandAdd( pAbc, "Synthesis", "varmin", Abc_CommandVarMin, 0 );
Cmd_CommandAdd( pAbc, "Synthesis", "faultclasses", Abc_CommandFaultClasses, 0 );
Cmd_CommandAdd( pAbc, "Synthesis", "exact", Abc_CommandExact, 1 );
Cmd_CommandAdd( pAbc, "Synthesis", "orchestrate", Abc_CommandOrchestrate, 1 );
Cmd_CommandAdd( pAbc, "Exact synthesis", "bms_start", Abc_CommandBmsStart, 0 );
Cmd_CommandAdd( pAbc, "Exact synthesis", "bms_stop", Abc_CommandBmsStop, 0 );
......@@ -7345,6 +7347,194 @@ usage:
return 1;
}
/**Function*************************************************************
Synopsis []
Description [Orchestration synthesis]
SideEffects []
SeeAlso []
***********************************************************************/
int Abc_CommandOrchestrate( Abc_Frame_t * pAbc, int argc, char ** argv )
{
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc), * pDup;
int c, RetValue;
int nNodeSizeMax;
int nConeSizeMax;
int fUpdateLevel;
int fUseZeros_rwr;
int fUseZeros_ref;
int fUseDcs;
int RS_CUT_MIN = 4;//rs option
int RS_CUT_MAX = 16;//rs option
int nCutsMax; //rs option
int nNodesMax; //rs option
int nLevelsOdc; //rs option
int fPrecompute; //rewrite option (not enabled)
int fPlaceEnable; //rewrite option (not enabled)
int fVerbose; //rewrite/rs/rf verbose
int fVeryVerbose; //very verbose option for all
size_t NtkSize;
extern void Rwr_Precompute();
//local greedy
extern int Abc_NtkOrchLocal( Abc_Ntk_t * pNtk, int fUseZeros_rwr, int fUseZeros_ref, int fPlaceEnable, int nCutsMax, int nNodesMax, int nLevelsOdc, int fUpdateLevel, int fVerbose, int fVeryVerbose, int nNodeSizeMax, int nConeSizeMax, int fUseDcs );
//priority orch
extern int Abc_NtkOchestration( Abc_Ntk_t * pNtk, Vec_Int_t **pGain_rwr, Vec_Int_t **pGain_res,Vec_Int_t **pGain_ref, int sOpsOrder, int fUseZeros_rwr, int fUseZeros_ref, int fPlaceEnable, int nCutsMax, int nNodesMax, int nLevelsOdc, int fUpdateLevel, int fVerbose, int fVeryVerbose, int nNodeSizeMax, int nConeSizeMax, int fUseDcs );
// set defaults
nNodeSizeMax = 10;
nConeSizeMax = 16;
fUpdateLevel = 1;
fUseZeros_rwr = 1;
fUseZeros_ref = 1;
fUseDcs = 0;
fVerbose = 0;
fVeryVerbose = 0;
fPlaceEnable = 0;
fPrecompute = 0;
nCutsMax = 8;
nNodesMax = 1;
nLevelsOdc = 0;
Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "KNFZzlvwh" ) ) != EOF )
{
switch ( c )
{
case 'K':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-K\" should be followed by an integer.\n" );
goto usage;
}
nCutsMax = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nCutsMax < 0 )
goto usage;
break;
case 'N':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-N\" should be followed by an integer.\n" );
goto usage;
}
nNodesMax = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nNodesMax < 0 )
goto usage;
break;
case 'F':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-F\" should be followed by an integer.\n" );
goto usage;
}
nLevelsOdc = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nLevelsOdc < 0 )
goto usage;
break;
case 'l':
fUpdateLevel ^= 1;
break;
case 'z':
fUseZeros_rwr ^= 1;
break;
case 'Z':
fUseZeros_ref ^= 1;
break;
case 'v':
fVerbose ^= 1;
break;
case 'w':
fVeryVerbose ^= 1;
break;
case 'h':
goto usage;
break;
}
}
if ( fPrecompute )
{
Rwr_Precompute();
return 0;
}
if ( pNtk == NULL )
{
Abc_Print( -1, "Empty network.\n" );
return 1;
}
if ( nCutsMax < RS_CUT_MIN || nCutsMax > RS_CUT_MAX )
{
Abc_Print( -1, "Can only compute cuts for %d <= K <= %d.\n", RS_CUT_MIN, RS_CUT_MAX );
return 1;
}
if ( !Abc_NtkIsStrash(pNtk) )
{
Abc_Print( -1, "This command can only be applied to an AIG (run \"strash\").\n" );
return 1;
}
if ( Abc_NtkGetChoiceNum(pNtk) )
{
Abc_Print( -1, "AIG resynthesis cannot be applied to AIGs with choice nodes.\n" );
return 1;
}
if ( nNodeSizeMax > 15 )
{
Abc_Print( -1, "The cone size cannot exceed 15.\n" );
return 1;
}
if ( fUseDcs && nNodeSizeMax >= nConeSizeMax )
{
Abc_Print( -1, "For don't-care to work, containing cone should be larger than collapsed node.\n" );
return 1;
}
// modify the current network
pDup = Abc_NtkDup( pNtk );
RetValue = Abc_NtkOrchLocal( pNtk, fUseZeros_rwr, fUseZeros_ref, fPlaceEnable, nCutsMax, nNodesMax, nLevelsOdc, fUpdateLevel, fVerbose, fVeryVerbose, nNodeSizeMax, nConeSizeMax, fUseDcs );
if ( RetValue == -1 )
{
Abc_FrameReplaceCurrentNetwork( pAbc, pDup );
printf( "An error occurred during computation. The original network is restored.\n" );
}
else
{
Abc_NtkDelete( pDup );
if ( RetValue == 0 )
{
Abc_Print( 0, "Ochestration (local greedy) has failed.\n" );
return 1;
}
}
return 0;
usage:
Abc_Print( -2, "usage: orchestrate [-KNFZzlvwh]\n" );
Abc_Print( -2, "\t performs technology-independent AIG synthesis using orchestration method (currently orchestrating rw/rf/rs)\n" );
Abc_Print( -2, "\t-K <num> : (resub)the max cut size (%d <= num <= %d) [default = %d]\n", RS_CUT_MIN, RS_CUT_MAX, nCutsMax );
Abc_Print( -2, "\t-N <num> : (resub)the max number of nodes to add (0 <= num <= 3) [default = %d]\n", nNodesMax );
Abc_Print( -2, "\t-F <num> : (resub)the number of fanout levels for ODC computation [default = %d]\n", nLevelsOdc );
Abc_Print( -2, "\t-l : (resub/rw/refactor)toggle preserving the number of levels [default = %s]\n", fUpdateLevel? "yes": "no" );
Abc_Print( -2, "\t-z : (rw)toggle using zero-cost replacements [default = %s]\n", fUseZeros_rwr? "yes": "no" );
Abc_Print( -2, "\t-Z : (refactor)toggle using zero-cost replacements [default = %s]\n", fUseZeros_ref? "yes": "no" );
Abc_Print( -2, "\t-v : (resub/rw/refactor)toggle verbose printout [default = %s]\n", fVerbose? "yes": "no" );
Abc_Print( -2, "\t-w : (resub/rw/refactor)toggle detailed verbose printout [default = %s]\n", fVeryVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : print the command usage\n");
return 1;
}
/**Function*************************************************************
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -41,6 +41,7 @@ SRC += src/base/abci/abc.c \
src/base/abci/abcNtbdd.c \
src/base/abci/abcNpn.c \
src/base/abci/abcNpnSave.c \
src/base/abci/abcOrchestration.c \
src/base/abci/abcOdc.c \
src/base/abci/abcOrder.c \
src/base/abci/abcPart.c \
......
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