mirror of https://github.com/YosysHQ/abc.git
Adding timeout to twoexact and lutexact.
This commit is contained in:
parent
c76af92d19
commit
d798d61637
|
|
@ -8293,7 +8293,7 @@ int Abc_CommandTwoExact( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
Bmc_EsPar_t Pars, * pPars = &Pars;
|
||||
Bmc_EsParSetDefault( pPars );
|
||||
Extra_UtilGetoptReset();
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "INaogvh" ) ) != EOF )
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "INTaogvh" ) ) != EOF )
|
||||
{
|
||||
switch ( c )
|
||||
{
|
||||
|
|
@ -8319,6 +8319,17 @@ int Abc_CommandTwoExact( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
if ( pPars->nNodes < 0 )
|
||||
goto usage;
|
||||
break;
|
||||
case 'T':
|
||||
if ( globalUtilOptind >= argc )
|
||||
{
|
||||
Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
|
||||
goto usage;
|
||||
}
|
||||
pPars->RuntimeLim = atoi(argv[globalUtilOptind]);
|
||||
globalUtilOptind++;
|
||||
if ( pPars->RuntimeLim < 0 )
|
||||
goto usage;
|
||||
break;
|
||||
case 'a':
|
||||
pPars->fOnlyAnd ^= 1;
|
||||
break;
|
||||
|
|
@ -8366,10 +8377,11 @@ int Abc_CommandTwoExact( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
return 0;
|
||||
|
||||
usage:
|
||||
Abc_Print( -2, "usage: twoexact [-IN <num>] [-aogvh] <hex>\n" );
|
||||
Abc_Print( -2, "usage: twoexact [-INT <num>] [-aogvh] <hex>\n" );
|
||||
Abc_Print( -2, "\t exact synthesis of multi-input function using two-input gates\n" );
|
||||
Abc_Print( -2, "\t-I <num> : the number of input variables [default = %d]\n", pPars->nVars );
|
||||
Abc_Print( -2, "\t-N <num> : the number of MAJ3 nodes [default = %d]\n", pPars->nNodes );
|
||||
Abc_Print( -2, "\t-N <num> : the number of two-input nodes [default = %d]\n", pPars->nNodes );
|
||||
Abc_Print( -2, "\t-T <num> : the runtime limit in seconds [default = %d]\n", pPars->RuntimeLim );
|
||||
Abc_Print( -2, "\t-a : toggle using only AND-gates (without XOR-gates) [default = %s]\n", pPars->fOnlyAnd ? "yes" : "no" );
|
||||
Abc_Print( -2, "\t-o : toggle using additional optimizations [default = %s]\n", pPars->fFewerVars ? "yes" : "no" );
|
||||
Abc_Print( -2, "\t-g : toggle using Glucose 3.0 by Gilles Audemard and Laurent Simon [default = %s]\n", pPars->fGlucose ? "yes" : "no" );
|
||||
|
|
@ -8405,7 +8417,7 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
Bmc_EsPar_t Pars, * pPars = &Pars;
|
||||
Bmc_EsParSetDefault( pPars );
|
||||
Extra_UtilGetoptReset();
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "INKiaogvh" ) ) != EOF )
|
||||
while ( ( c = Extra_UtilGetopt( argc, argv, "INKTiaogvh" ) ) != EOF )
|
||||
{
|
||||
switch ( c )
|
||||
{
|
||||
|
|
@ -8442,6 +8454,17 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
if ( pPars->nLutSize < 0 )
|
||||
goto usage;
|
||||
break;
|
||||
case 'T':
|
||||
if ( globalUtilOptind >= argc )
|
||||
{
|
||||
Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
|
||||
goto usage;
|
||||
}
|
||||
pPars->RuntimeLim = atoi(argv[globalUtilOptind]);
|
||||
globalUtilOptind++;
|
||||
if ( pPars->RuntimeLim < 0 )
|
||||
goto usage;
|
||||
break;
|
||||
case 'i':
|
||||
pPars->fUseIncr ^= 1;
|
||||
break;
|
||||
|
|
@ -8497,11 +8520,12 @@ int Abc_CommandLutExact( Abc_Frame_t * pAbc, int argc, char ** argv )
|
|||
return 0;
|
||||
|
||||
usage:
|
||||
Abc_Print( -2, "usage: lutexact [-INK <num>] [-iaogvh] <hex>\n" );
|
||||
Abc_Print( -2, "usage: lutexact [-INKT <num>] [-iaogvh] <hex>\n" );
|
||||
Abc_Print( -2, "\t exact synthesis of I-input function using N K-input gates\n" );
|
||||
Abc_Print( -2, "\t-I <num> : the number of input variables [default = %d]\n", pPars->nVars );
|
||||
Abc_Print( -2, "\t-N <num> : the number of K-input nodes [default = %d]\n", pPars->nNodes );
|
||||
Abc_Print( -2, "\t-K <num> : the number of node fanins [default = %d]\n", pPars->nLutSize );
|
||||
Abc_Print( -2, "\t-T <num> : the runtime limit in seconds [default = %d]\n", pPars->RuntimeLim );
|
||||
Abc_Print( -2, "\t-i : toggle using incremental solving [default = %s]\n", pPars->fUseIncr ? "yes" : "no" );
|
||||
Abc_Print( -2, "\t-a : toggle using only AND-gates when K = 2 [default = %s]\n", pPars->fOnlyAnd ? "yes" : "no" );
|
||||
Abc_Print( -2, "\t-o : toggle using additional optimizations [default = %s]\n", pPars->fFewerVars ? "yes" : "no" );
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ struct Bmc_EsPar_t_
|
|||
int fOrderNodes;
|
||||
int fEnumSols;
|
||||
int fFewerVars;
|
||||
int RuntimeLim;
|
||||
int fVerbose;
|
||||
char * pTtStr;
|
||||
};
|
||||
|
|
@ -76,6 +77,7 @@ static inline void Bmc_EsParSetDefault( Bmc_EsPar_t * pPars )
|
|||
pPars->fOrderNodes = 0;
|
||||
pPars->fEnumSols = 0;
|
||||
pPars->fFewerVars = 0;
|
||||
pPars->RuntimeLim = 0;
|
||||
pPars->fVerbose = 1;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -500,6 +500,8 @@ Exa_Man_t * Exa_ManAlloc( Bmc_EsPar_t * pPars, word * pTruth )
|
|||
p->vInfo = Exa_ManTruthTables( p );
|
||||
p->pSat = bmcg_sat_solver_start();
|
||||
bmcg_sat_solver_set_nvars( p->pSat, p->iVar );
|
||||
if ( pPars->RuntimeLim )
|
||||
bmcg_sat_solver_set_runtime_limit( p->pSat, Abc_Clock() + pPars->RuntimeLim * CLOCKS_PER_SEC );
|
||||
return p;
|
||||
}
|
||||
void Exa_ManFree( Exa_Man_t * p )
|
||||
|
|
@ -828,6 +830,11 @@ void Exa_ManExactSynthesis( Bmc_EsPar_t * pPars )
|
|||
printf( "The problem has no solution.\n" );
|
||||
break;
|
||||
}
|
||||
if ( status == GLUCOSE_UNDEC )
|
||||
{
|
||||
printf( "The problem timed out after %d sec.\n", pPars->RuntimeLim );
|
||||
break;
|
||||
}
|
||||
iMint = Exa_ManEval( p );
|
||||
}
|
||||
if ( iMint == -1 )
|
||||
|
|
@ -971,6 +978,8 @@ static Exa3_Man_t * Exa3_ManAlloc( Bmc_EsPar_t * pPars, word * pTruth )
|
|||
p->vUsed3 = Vec_BitStart( (1 << p->pPars->nVars) * p->pPars->nNodes * p->nObjs * p->nObjs * p->nObjs );
|
||||
p->pSat = bmcg_sat_solver_start();
|
||||
bmcg_sat_solver_set_nvars( p->pSat, p->iVar );
|
||||
if ( pPars->RuntimeLim )
|
||||
bmcg_sat_solver_set_runtime_limit( p->pSat, Abc_Clock() + pPars->RuntimeLim * CLOCKS_PER_SEC );
|
||||
return p;
|
||||
}
|
||||
static void Exa3_ManFree( Exa3_Man_t * p )
|
||||
|
|
@ -1323,15 +1332,17 @@ void Exa3_ManExactSynthesis( Bmc_EsPar_t * pPars )
|
|||
status = bmcg_sat_solver_solve( p->pSat, NULL, 0 );
|
||||
if ( pPars->fVerbose && (!pPars->fUseIncr || i % 100 == 0) )
|
||||
Exa3_ManPrint( p, i, iMint, Abc_Clock() - clkTotal );
|
||||
if ( status == GLUCOSE_UNSAT )
|
||||
if ( status == GLUCOSE_UNSAT || status == GLUCOSE_UNDEC )
|
||||
break;
|
||||
iMint = Exa3_ManEval( p );
|
||||
}
|
||||
if ( pPars->fVerbose )
|
||||
if ( pPars->fVerbose && status != GLUCOSE_UNDEC )
|
||||
Exa3_ManPrint( p, i, iMint, Abc_Clock() - clkTotal );
|
||||
if ( iMint == -1 )
|
||||
Exa3_ManPrintSolution( p, fCompl );
|
||||
else
|
||||
else if ( status == GLUCOSE_UNDEC )
|
||||
printf( "The problem timed out after %d sec.\n", pPars->RuntimeLim );
|
||||
else
|
||||
printf( "The problem has no solution.\n" );
|
||||
printf( "Added = %d. Tried = %d. ", p->nUsed[1], p->nUsed[0] );
|
||||
Exa3_ManFree( p );
|
||||
|
|
|
|||
Loading…
Reference in New Issue