Commit 8c7ca72e by Alan Mishchenko

Adding timeout to command 'ind'.

parent 184c5d4e
...@@ -131,7 +131,7 @@ extern Aig_Man_t * Saig_ManDupCones( Aig_Man_t * pAig, int * pPos, int nPo ...@@ -131,7 +131,7 @@ extern Aig_Man_t * Saig_ManDupCones( Aig_Man_t * pAig, int * pPos, int nPo
/*=== saigHaig.c ==========================================================*/ /*=== saigHaig.c ==========================================================*/
extern Aig_Man_t * Saig_ManHaigRecord( Aig_Man_t * p, int nIters, int nSteps, int fRetimingOnly, int fAddBugs, int fUseCnf, int fVerbose ); extern Aig_Man_t * Saig_ManHaigRecord( Aig_Man_t * p, int nIters, int nSteps, int fRetimingOnly, int fAddBugs, int fUseCnf, int fVerbose );
/*=== saigInd.c ==========================================================*/ /*=== saigInd.c ==========================================================*/
extern int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fUnique, int fUniqueAll, int fGetCex, int fVerbose, int fVeryVerbose ); extern int Saig_ManInduction( Aig_Man_t * p, int nTimeOut, int nFramesMax, int nConfMax, int fUnique, int fUniqueAll, int fGetCex, int fVerbose, int fVeryVerbose );
/*=== saigIoa.c ==========================================================*/ /*=== saigIoa.c ==========================================================*/
extern void Saig_ManDumpBlif( Aig_Man_t * p, char * pFileName ); extern void Saig_ManDumpBlif( Aig_Man_t * p, char * pFileName );
extern Aig_Man_t * Saig_ManReadBlif( char * pFileName ); extern Aig_Man_t * Saig_ManReadBlif( char * pFileName );
......
...@@ -142,7 +142,7 @@ void Saig_ManAddUniqueness( sat_solver * pSat, Vec_Int_t * vState, int nRegs, in ...@@ -142,7 +142,7 @@ void Saig_ManAddUniqueness( sat_solver * pSat, Vec_Int_t * vState, int nRegs, in
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fUnique, int fUniqueAll, int fGetCex, int fVerbose, int fVeryVerbose ) int Saig_ManInduction( Aig_Man_t * p, int nTimeOut, int nFramesMax, int nConfMax, int fUnique, int fUniqueAll, int fGetCex, int fVerbose, int fVeryVerbose )
{ {
sat_solver * pSat; sat_solver * pSat;
Aig_Man_t * pAigPart; Aig_Man_t * pAigPart;
...@@ -152,7 +152,7 @@ int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fUnique, ...@@ -152,7 +152,7 @@ int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fUnique,
Aig_Obj_t * pObjPi, * pObjPiCopy, * pObjPo; Aig_Obj_t * pObjPi, * pObjPiCopy, * pObjPo;
int i, k, f, Lits[2], status = -1, RetValue, nSatVarNum, nConfPrev; int i, k, f, Lits[2], status = -1, RetValue, nSatVarNum, nConfPrev;
int nOldSize, iReg, iLast, fAdded, nConstrs = 0, nClauses = 0; int nOldSize, iReg, iLast, fAdded, nConstrs = 0, nClauses = 0;
abctime clk; abctime clk, nTimeToStop = nTimeOut ? nTimeOut * CLOCKS_PER_SEC + Abc_Clock() : 0;
assert( fUnique == 0 || fUniqueAll == 0 ); assert( fUnique == 0 || fUniqueAll == 0 );
assert( Saig_ManPoNum(p) == 1 ); assert( Saig_ManPoNum(p) == 1 );
Aig_ManSetCioIds( p ); Aig_ManSetCioIds( p );
...@@ -168,6 +168,10 @@ int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fUnique, ...@@ -168,6 +168,10 @@ int Saig_ManInduction( Aig_Man_t * p, int nFramesMax, int nConfMax, int fUnique,
pSat = sat_solver_new(); pSat = sat_solver_new();
sat_solver_setnvars( pSat, 1000 ); sat_solver_setnvars( pSat, 1000 );
// set runtime limit
if ( nTimeToStop )
sat_solver_set_runtime_limit( pSat, nTimeToStop );
// iterate backward unrolling // iterate backward unrolling
RetValue = -1; RetValue = -1;
nSatVarNum = 0; nSatVarNum = 0;
...@@ -312,7 +316,7 @@ nextrun: ...@@ -312,7 +316,7 @@ nextrun:
} }
printf( "\n" ); printf( "\n" );
} }
if ( f == nFramesMax - 1 ) if ( nFramesMax && f == nFramesMax - 1 )
{ {
// derive counter-example // derive counter-example
assert( status == l_True ); assert( status == l_True );
...@@ -357,7 +361,9 @@ nextrun: ...@@ -357,7 +361,9 @@ nextrun:
} }
if ( fVerbose ) if ( fVerbose )
{ {
if ( status == l_Undef ) if ( nTimeToStop && Abc_Clock() >= nTimeToStop )
printf( "Timeout (%d sec) was reached during iteration %d.\n", nTimeOut, f+1 );
else if ( status == l_Undef )
printf( "Conflict limit (%d) was reached during iteration %d.\n", nConfMax, f+1 ); printf( "Conflict limit (%d) was reached during iteration %d.\n", nConfMax, f+1 );
else if ( fUnique || fUniqueAll ) else if ( fUnique || fUniqueAll )
printf( "Completed %d interations and added %d uniqueness constraints.\n", f+1, nConstrs ); printf( "Completed %d interations and added %d uniqueness constraints.\n", f+1, nConstrs );
......
...@@ -22492,6 +22492,7 @@ usage: ...@@ -22492,6 +22492,7 @@ usage:
int Abc_CommandInduction( Abc_Frame_t * pAbc, int argc, char ** argv ) int Abc_CommandInduction( Abc_Frame_t * pAbc, int argc, char ** argv )
{ {
Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc); Abc_Ntk_t * pNtk = Abc_FrameReadNtk(pAbc);
int nTimeOut;
int nFramesMax; int nFramesMax;
int nConfMax; int nConfMax;
int fUnique; int fUnique;
...@@ -22500,17 +22501,18 @@ int Abc_CommandInduction( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -22500,17 +22501,18 @@ int Abc_CommandInduction( Abc_Frame_t * pAbc, int argc, char ** argv )
int fVerbose; int fVerbose;
int fVeryVerbose; int fVeryVerbose;
int c; int c;
extern int Abc_NtkDarInduction( Abc_Ntk_t * pNtk, int nFramesMax, int nConfMax, int fUnique, int fUniqueAll, int fGetCex, int fVerbose, int fVeryVerbose ); extern int Abc_NtkDarInduction( Abc_Ntk_t * pNtk, int nTimeOut, int nFramesMax, int nConfMax, int fUnique, int fUniqueAll, int fGetCex, int fVerbose, int fVeryVerbose );
// set defaults // set defaults
nFramesMax = 100; nTimeOut = 0;
nConfMax = 1000; nFramesMax = 0;
nConfMax = 0;
fUnique = 0; fUnique = 0;
fUniqueAll = 0; fUniqueAll = 0;
fGetCex = 0; fGetCex = 0;
fVerbose = 0; fVerbose = 0;
fVeryVerbose = 0; fVeryVerbose = 0;
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "FCuaxvwh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "FCTuaxvwh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
...@@ -22536,6 +22538,17 @@ int Abc_CommandInduction( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -22536,6 +22538,17 @@ int Abc_CommandInduction( Abc_Frame_t * pAbc, int argc, char ** argv )
if ( nConfMax < 0 ) if ( nConfMax < 0 )
goto usage; goto usage;
break; break;
case 'T':
if ( globalUtilOptind >= argc )
{
Abc_Print( -1, "Command line switch \"-T\" should be followed by an integer.\n" );
goto usage;
}
nTimeOut = atoi(argv[globalUtilOptind]);
globalUtilOptind++;
if ( nTimeOut < 0 )
goto usage;
break;
case 'u': case 'u':
fUnique ^= 1; fUnique ^= 1;
break; break;
...@@ -22584,7 +22597,7 @@ int Abc_CommandInduction( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -22584,7 +22597,7 @@ int Abc_CommandInduction( Abc_Frame_t * pAbc, int argc, char ** argv )
} }
// modify the current network // modify the current network
pAbc->Status = Abc_NtkDarInduction( pNtk, nFramesMax, nConfMax, fUnique, fUniqueAll, fGetCex, fVerbose, fVeryVerbose ); pAbc->Status = Abc_NtkDarInduction( pNtk, nTimeOut, nFramesMax, nConfMax, fUnique, fUniqueAll, fGetCex, fVerbose, fVeryVerbose );
if ( fGetCex ) if ( fGetCex )
{ {
Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel ); Abc_FrameReplaceCex( pAbc, &pNtk->pSeqModel );
...@@ -22592,10 +22605,11 @@ int Abc_CommandInduction( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -22592,10 +22605,11 @@ int Abc_CommandInduction( Abc_Frame_t * pAbc, int argc, char ** argv )
} }
return 0; return 0;
usage: usage:
Abc_Print( -2, "usage: ind [-FC num] [-uaxvwh]\n" ); Abc_Print( -2, "usage: ind [-FCT num] [-uaxvwh]\n" );
Abc_Print( -2, "\t runs the inductive case of the K-step induction\n" ); Abc_Print( -2, "\t runs the inductive case of the K-step induction\n" );
Abc_Print( -2, "\t-F num : the max number of timeframes [default = %d]\n", nFramesMax ); Abc_Print( -2, "\t-F num : the max number of timeframes [default = %d]\n", nFramesMax );
Abc_Print( -2, "\t-C num : the max number of conflicts by SAT solver [default = %d]\n", nConfMax ); Abc_Print( -2, "\t-C num : the max number of conflicts by SAT solver [default = %d]\n", nConfMax );
Abc_Print( -2, "\t-T num : the limit on runtime per output in seconds [default = %d]\n", nTimeOut );
Abc_Print( -2, "\t-u : toggle adding uniqueness constraints on demand [default = %s]\n", fUnique? "yes": "no" ); Abc_Print( -2, "\t-u : toggle adding uniqueness constraints on demand [default = %s]\n", fUnique? "yes": "no" );
Abc_Print( -2, "\t-a : toggle adding uniqueness constraints always [default = %s]\n", fUniqueAll? "yes": "no" ); Abc_Print( -2, "\t-a : toggle adding uniqueness constraints always [default = %s]\n", fUniqueAll? "yes": "no" );
Abc_Print( -2, "\t-x : toggle returning CEX to induction for the top frame [default = %s]\n", fGetCex? "yes": "no" ); Abc_Print( -2, "\t-x : toggle returning CEX to induction for the top frame [default = %s]\n", fGetCex? "yes": "no" );
...@@ -3451,7 +3451,7 @@ Abc_Ntk_t * Abc_NtkDarTempor( Abc_Ntk_t * pNtk, int nFrames, int TimeOut, int nC ...@@ -3451,7 +3451,7 @@ Abc_Ntk_t * Abc_NtkDarTempor( Abc_Ntk_t * pNtk, int nFrames, int TimeOut, int nC
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
int Abc_NtkDarInduction( Abc_Ntk_t * pNtk, int nFramesMax, int nConfMax, int fUnique, int fUniqueAll, int fGetCex, int fVerbose, int fVeryVerbose ) int Abc_NtkDarInduction( Abc_Ntk_t * pNtk, int nTimeOut, int nFramesMax, int nConfMax, int fUnique, int fUniqueAll, int fGetCex, int fVerbose, int fVeryVerbose )
{ {
Aig_Man_t * pMan; Aig_Man_t * pMan;
abctime clkTotal = Abc_Clock(); abctime clkTotal = Abc_Clock();
...@@ -3459,7 +3459,7 @@ int Abc_NtkDarInduction( Abc_Ntk_t * pNtk, int nFramesMax, int nConfMax, int fUn ...@@ -3459,7 +3459,7 @@ int Abc_NtkDarInduction( Abc_Ntk_t * pNtk, int nFramesMax, int nConfMax, int fUn
pMan = Abc_NtkToDar( pNtk, 0, 1 ); pMan = Abc_NtkToDar( pNtk, 0, 1 );
if ( pMan == NULL ) if ( pMan == NULL )
return -1; return -1;
RetValue = Saig_ManInduction( pMan, nFramesMax, nConfMax, fUnique, fUniqueAll, fGetCex, fVerbose, fVeryVerbose ); RetValue = Saig_ManInduction( pMan, nTimeOut, nFramesMax, nConfMax, fUnique, fUniqueAll, fGetCex, fVerbose, fVeryVerbose );
if ( RetValue == 1 ) if ( RetValue == 1 )
{ {
Abc_Print( 1, "Networks are equivalent. " ); Abc_Print( 1, "Networks are equivalent. " );
......
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