Commit 3b14c7b4 by Alan Mishchenko

Prepared &gla to try abstracting and proving concurrently.

parent 19c28cae
...@@ -129,6 +129,7 @@ static inline int Ga2_ObjFindOrAddLit( Ga2_Man_t * p, Gia_Obj_t * pObj, int f ) ...@@ -129,6 +129,7 @@ static inline int Ga2_ObjFindOrAddLit( Ga2_Man_t * p, Gia_Obj_t * pObj, int f )
// calling pthreads // calling pthreads
extern void Gia_Ga2ProveAbsracted( char * pFileName, int fVerbose ); extern void Gia_Ga2ProveAbsracted( char * pFileName, int fVerbose );
extern void Gia_Ga2ProveCancel( int fVerbose ); extern void Gia_Ga2ProveCancel( int fVerbose );
extern void Gia_Ga2ProveFinish( int fVerbose );
extern int Gia_Ga2ProveCheck( int fVerbose ); extern int Gia_Ga2ProveCheck( int fVerbose );
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
...@@ -1434,8 +1435,8 @@ void Ga2_GlaDumpAbsracted( Ga2_Man_t * p, int fVerbose ) ...@@ -1434,8 +1435,8 @@ void Ga2_GlaDumpAbsracted( Ga2_Man_t * p, int fVerbose )
if ( p->pPars->fDumpMabs ) if ( p->pPars->fDumpMabs )
{ {
pFileName = Ga2_GlaGetFileName(p, 0); pFileName = Ga2_GlaGetFileName(p, 0);
if ( fVerbose ) // if ( fVerbose )
Abc_Print( 1, "Dumping miter with abstraction map into file \"%s\"...\n", pFileName ); // Abc_Print( 1, "Dumping miter with abstraction map into file \"%s\"...\n", pFileName );
// dump abstraction map // dump abstraction map
Vec_IntFreeP( &p->pGia->vGateClasses ); Vec_IntFreeP( &p->pGia->vGateClasses );
p->pGia->vGateClasses = Ga2_ManAbsTranslate( p ); p->pGia->vGateClasses = Ga2_ManAbsTranslate( p );
...@@ -1446,8 +1447,8 @@ void Ga2_GlaDumpAbsracted( Ga2_Man_t * p, int fVerbose ) ...@@ -1446,8 +1447,8 @@ void Ga2_GlaDumpAbsracted( Ga2_Man_t * p, int fVerbose )
Vec_Int_t * vGateClasses; Vec_Int_t * vGateClasses;
Gia_Man_t * pAbs; Gia_Man_t * pAbs;
pFileName = Ga2_GlaGetFileName(p, 1); pFileName = Ga2_GlaGetFileName(p, 1);
if ( fVerbose ) // if ( fVerbose )
Abc_Print( 1, "Dumping abstracted model into file \"%s\"...\n", pFileName ); // Abc_Print( 1, "Dumping abstracted model into file \"%s\"...\n", pFileName );
// dump absracted model // dump absracted model
vGateClasses = Ga2_ManAbsTranslate( p ); vGateClasses = Ga2_ManAbsTranslate( p );
pAbs = Gia_ManDupAbsGates( p->pGia, vGateClasses ); pAbs = Gia_ManDupAbsGates( p->pGia, vGateClasses );
...@@ -1545,7 +1546,7 @@ int Ga2_ManPerform( Gia_Man_t * pAig, Gia_ParVta_t * pPars ) ...@@ -1545,7 +1546,7 @@ int Ga2_ManPerform( Gia_Man_t * pAig, Gia_ParVta_t * pPars )
Abc_Print( 1, "FrameMax = %d ConfMax = %d Timeout = %d RatioMin = %d %% RatioMax = %d %%\n", Abc_Print( 1, "FrameMax = %d ConfMax = %d Timeout = %d RatioMin = %d %% RatioMax = %d %%\n",
pPars->nFramesMax, pPars->nConfLimit, pPars->nTimeOut, pPars->nRatioMin, pPars->nRatioMax ); pPars->nFramesMax, pPars->nConfLimit, pPars->nTimeOut, pPars->nRatioMin, pPars->nRatioMax );
Abc_Print( 1, "LrnStart = %d LrnDelta = %d LrnRatio = %d %% Skip = %d SimpleCNF = %d Dump = %d\n", Abc_Print( 1, "LrnStart = %d LrnDelta = %d LrnRatio = %d %% Skip = %d SimpleCNF = %d Dump = %d\n",
pPars->nLearnedStart, pPars->nLearnedDelta, pPars->nLearnedPerce, pPars->fUseSkip, pPars->fUseSimple, pPars->fDumpVabs|pPars->fDumpMabs ); pPars->nLearnedStart, pPars->nLearnedDelta, pPars->nLearnedPerce, pPars->fUseSkip, pPars->fUseSimple, pPars->fDumpVabs|pPars->fDumpMabs|pPars->fCallProver );
if ( pPars->fDumpVabs || pPars->fDumpMabs ) if ( pPars->fDumpVabs || pPars->fDumpMabs )
Abc_Print( 1, "%s will be dumped into file \"%s\".\n", Abc_Print( 1, "%s will be dumped into file \"%s\".\n",
pPars->fDumpVabs ? "Abstracted model" : "Miter with abstraction map", pPars->fDumpVabs ? "Abstracted model" : "Miter with abstraction map",
...@@ -1810,6 +1811,10 @@ int Ga2_ManPerform( Gia_Man_t * pAig, Gia_ParVta_t * pPars ) ...@@ -1810,6 +1811,10 @@ int Ga2_ManPerform( Gia_Man_t * pAig, Gia_ParVta_t * pPars )
} }
finish: finish:
Prf_ManStopP( &p->pSat->pPrf2 ); Prf_ManStopP( &p->pSat->pPrf2 );
// cancel old one if it is proving
if ( iFrameTryProve >= 0 )
Gia_Ga2ProveCancel( pPars->fVerbose );
Gia_Ga2ProveFinish( pPars->fVerbose );
// analize the results // analize the results
if ( RetValue == 1 ) if ( RetValue == 1 )
Abc_Print( 1, "GLA completed %d frames and proved abstraction derived in frame %d. ", p->pPars->iFrameProved+1, iFrameTryProve ); Abc_Print( 1, "GLA completed %d frames and proved abstraction derived in frame %d. ", p->pPars->iFrameProved+1, iFrameTryProve );
......
...@@ -18,10 +18,11 @@ ...@@ -18,10 +18,11 @@
***********************************************************************/ ***********************************************************************/
#include "gia.h" #include "aig/ioa/ioa.h"
#include "proof/pdr/pdr.h"
// comment this out to disable pthreads // comment this out to disable pthreads
//#define ABC_USE_PTHREADS #define ABC_USE_PTHREADS
#ifdef ABC_USE_PTHREADS #ifdef ABC_USE_PTHREADS
...@@ -59,21 +60,110 @@ ABC_NAMESPACE_IMPL_START ...@@ -59,21 +60,110 @@ ABC_NAMESPACE_IMPL_START
void Gia_Ga2ProveAbsracted( char * pFileName, int fVerbose ) {} void Gia_Ga2ProveAbsracted( char * pFileName, int fVerbose ) {}
void Gia_Ga2ProveCancel( int fVerbose ) {} void Gia_Ga2ProveCancel( int fVerbose ) {}
void Gia_Ga2ProveFinish( int fVerbose ) {}
int Gia_Ga2ProveCheck( int fVerbose ) { return 0; } int Gia_Ga2ProveCheck( int fVerbose ) { return 0; }
#else // pthreads are used #else // pthreads are used
// information given to the thread
typedef struct Abs_Pair_t_
{
char * pFileName;
int fVerbose;
int RunId;
} Abs_Pair_t;
// the last valid thread
static int g_nRunIds = 0;
int Abs_CallBackToStop( int RunId ) { assert( RunId <= g_nRunIds ); return RunId < g_nRunIds; }
int Pdr_ManSolve_test( Aig_Man_t * pAig, Pdr_Par_t * pPars, Abc_Cex_t ** ppCex )
{
char * p = ABC_ALLOC( char, 111 );
while ( 1 )
{
if ( pPars->pFuncStop && pPars->pFuncStop(pPars->RunId) )
break;
}
ABC_FREE( p );
return -1;
}
static int g_fAbstractionProved = 0;
void * Abs_ProverThread( void * pArg )
{
Abs_Pair_t * pPair = (Abs_Pair_t *)pArg;
Pdr_Par_t Pars, * pPars = &Pars;
Aig_Man_t * pAig, * pTemp;
int RetValue;
pAig = Ioa_ReadAiger( pPair->pFileName, 0 );
if ( pAig == NULL )
Abc_Print( 1, "\nCannot open file \"%s\".\n", pPair->pFileName );
else
{
// synthesize abstraction
pAig = Aig_ManScl( pTemp = pAig, 1, 1, 0, -1, -1, 0, 0 );
Aig_ManStop( pTemp );
// call PDR
Pdr_ManSetDefaultParams( pPars );
pPars->fSilent = 1;
pPars->RunId = pPair->RunId;
pPars->pFuncStop = Abs_CallBackToStop;
RetValue = Pdr_ManSolve( pAig, pPars, NULL );
// RetValue = Pdr_ManSolve_test( pAig, pPars, NULL );
// update the result
g_fAbstractionProved = (RetValue == 1);
// free memory
Aig_ManStop( pAig );
// quit this thread
if ( pPair->fVerbose )
{
if ( RetValue == 1 )
Abc_Print( 1, "\nProved abstraction %d.\n", pPair->RunId );
else if ( RetValue == 0 )
Abc_Print( 1, "\nDisproved abstraction %d.\n", pPair->RunId );
else if ( RetValue == -1 )
Abc_Print( 1, "\nCancelled abstraction %d.\n", pPair->RunId );
else assert( 0 );
}
}
ABC_FREE( pPair->pFileName );
ABC_FREE( pPair );
// quit this thread
pthread_exit( NULL );
assert(0);
return NULL;
}
void Gia_Ga2ProveAbsracted( char * pFileName, int fVerbose ) void Gia_Ga2ProveAbsracted( char * pFileName, int fVerbose )
{ {
Abc_Print( 1, "Trying to prove abstraction.\n" ); Abs_Pair_t * pPair;
pthread_t ProverThread;
int RetValue;
assert( pFileName != NULL );
g_fAbstractionProved = 0;
// disable verbosity
fVerbose = 0;
// create thread
pPair = ABC_CALLOC( Abs_Pair_t, 1 );
pPair->pFileName = Abc_UtilStrsav( (void *)pFileName );
pPair->fVerbose = fVerbose;
pPair->RunId = ++g_nRunIds;
if ( fVerbose ) Abc_Print( 1, "\nTrying to prove abstraction %d.\n", pPair->RunId );
RetValue = pthread_create( &ProverThread, NULL, Abs_ProverThread, pPair );
assert( RetValue == 0 );
} }
void Gia_Ga2ProveCancel( int fVerbose ) void Gia_Ga2ProveCancel( int fVerbose )
{ {
Abc_Print( 1, "Canceling attempt to prove abstraction.\n" ); g_nRunIds++;
}
void Gia_Ga2ProveFinish( int fVerbose )
{
g_fAbstractionProved = 0;
} }
int Gia_Ga2ProveCheck( int fVerbose ) int Gia_Ga2ProveCheck( int fVerbose )
{ {
return 0; return g_fAbstractionProved;
} }
#endif #endif
......
...@@ -2577,6 +2577,8 @@ int Abc_NtkDarPdr( Abc_Ntk_t * pNtk, Pdr_Par_t * pPars, Abc_Cex_t ** ppCex ) ...@@ -2577,6 +2577,8 @@ int Abc_NtkDarPdr( Abc_Ntk_t * pNtk, Pdr_Par_t * pPars, Abc_Cex_t ** ppCex )
else else
RetValue = Pdr_ManSolve( pMan, pPars, ppCex ); RetValue = Pdr_ManSolve( pMan, pPars, ppCex );
// output the result // output the result
if ( !pPars->fSilent )
{
if ( RetValue == 1 ) if ( RetValue == 1 )
Abc_Print( 1, "Property proved. " ); Abc_Print( 1, "Property proved. " );
else if ( RetValue == 0 ) else if ( RetValue == 0 )
...@@ -2585,7 +2587,8 @@ int Abc_NtkDarPdr( Abc_Ntk_t * pNtk, Pdr_Par_t * pPars, Abc_Cex_t ** ppCex ) ...@@ -2585,7 +2587,8 @@ int Abc_NtkDarPdr( Abc_Ntk_t * pNtk, Pdr_Par_t * pPars, Abc_Cex_t ** ppCex )
Abc_Print( 1, "Property UNDECIDED. " ); Abc_Print( 1, "Property UNDECIDED. " );
else else
assert( 0 ); assert( 0 );
ABC_PRT( "Time", clock() - clk ); ABC_PRT( "Time", clock() - clk );
}
if ( *ppCex && !Saig_ManVerifyCex( pMan, *ppCex ) ) if ( *ppCex && !Saig_ManVerifyCex( pMan, *ppCex ) )
Abc_Print( 1, "Abc_NtkDarPdr(): Counter-example verification has FAILED.\n" ); Abc_Print( 1, "Abc_NtkDarPdr(): Counter-example verification has FAILED.\n" );
......
...@@ -51,9 +51,12 @@ struct Pdr_Par_t_ ...@@ -51,9 +51,12 @@ struct Pdr_Par_t_
int fDumpInv; // dump inductive invariant int fDumpInv; // dump inductive invariant
int fShortest; // forces bug traces to be shortest int fShortest; // forces bug traces to be shortest
int fSkipGeneral; // skips expensive generalization step int fSkipGeneral; // skips expensive generalization step
int fVerbose; // verbose output int fVerbose; // verbose output`
int fVeryVerbose; // very verbose output int fVeryVerbose; // very verbose output
int fSilent; // totally silent execution
int iFrame; // explored up to this frame int iFrame; // explored up to this frame
int RunId; // PDR id in this run
int(*pFuncStop)(int); // callback to terminate
}; };
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
...@@ -528,7 +528,9 @@ int Pdr_ManBlockCube( Pdr_Man_t * p, Pdr_Set_t * pCube ) ...@@ -528,7 +528,9 @@ int Pdr_ManBlockCube( Pdr_Man_t * p, Pdr_Set_t * pCube )
Pdr_QueuePush( p, pThis ); Pdr_QueuePush( p, pThis );
} }
// check the timeout // check termination
if ( p->pPars->pFuncStop && p->pPars->pFuncStop(p->pPars->RunId) )
return -1;
if ( p->timeToStop && clock() > p->timeToStop ) if ( p->timeToStop && clock() > p->timeToStop )
return -1; return -1;
} }
...@@ -565,7 +567,10 @@ int Pdr_ManSolveInt( Pdr_Man_t * p ) ...@@ -565,7 +567,10 @@ int Pdr_ManSolveInt( Pdr_Man_t * p )
{ {
if ( p->pPars->fVerbose ) if ( p->pPars->fVerbose )
Pdr_ManPrintProgress( p, 1, clock() - clkStart ); Pdr_ManPrintProgress( p, 1, clock() - clkStart );
if ( p->pPars->nConfLimit )
Abc_Print( 1, "Reached conflict limit (%d).\n", p->pPars->nConfLimit ); Abc_Print( 1, "Reached conflict limit (%d).\n", p->pPars->nConfLimit );
else if ( p->pPars->fVerbose )
Abc_Print( 1, "Computation cancelled by the callback.\n" );
p->pPars->iFrame = k; p->pPars->iFrame = k;
return -1; return -1;
} }
...@@ -576,7 +581,10 @@ int Pdr_ManSolveInt( Pdr_Man_t * p ) ...@@ -576,7 +581,10 @@ int Pdr_ManSolveInt( Pdr_Man_t * p )
{ {
if ( p->pPars->fVerbose ) if ( p->pPars->fVerbose )
Pdr_ManPrintProgress( p, 1, clock() - clkStart ); Pdr_ManPrintProgress( p, 1, clock() - clkStart );
if ( p->pPars->nConfLimit )
Abc_Print( 1, "Reached conflict limit (%d).\n", p->pPars->nConfLimit ); Abc_Print( 1, "Reached conflict limit (%d).\n", p->pPars->nConfLimit );
else if ( p->pPars->fVerbose )
Abc_Print( 1, "Computation cancelled by the callback.\n" );
p->pPars->iFrame = k; p->pPars->iFrame = k;
return -1; return -1;
} }
...@@ -615,6 +623,7 @@ int Pdr_ManSolveInt( Pdr_Man_t * p ) ...@@ -615,6 +623,7 @@ int Pdr_ManSolveInt( Pdr_Man_t * p )
{ {
if ( p->pPars->fVerbose ) if ( p->pPars->fVerbose )
Pdr_ManPrintProgress( p, 1, clock() - clkStart ); Pdr_ManPrintProgress( p, 1, clock() - clkStart );
if ( !p->pPars->fSilent )
Abc_Print( 1, "Reached conflict limit (%d).\n", p->pPars->nConfLimit ); Abc_Print( 1, "Reached conflict limit (%d).\n", p->pPars->nConfLimit );
p->pPars->iFrame = k; p->pPars->iFrame = k;
return -1; return -1;
...@@ -623,7 +632,9 @@ int Pdr_ManSolveInt( Pdr_Man_t * p ) ...@@ -623,7 +632,9 @@ int Pdr_ManSolveInt( Pdr_Man_t * p )
{ {
if ( p->pPars->fVerbose ) if ( p->pPars->fVerbose )
Pdr_ManPrintProgress( p, 1, clock() - clkStart ); Pdr_ManPrintProgress( p, 1, clock() - clkStart );
if ( !p->pPars->fSilent )
Pdr_ManReportInvariant( p ); Pdr_ManReportInvariant( p );
if ( !p->pPars->fSilent )
Pdr_ManVerifyInvariant( p ); Pdr_ManVerifyInvariant( p );
p->pPars->iFrame = k; p->pPars->iFrame = k;
return 1; // UNSAT return 1; // UNSAT
...@@ -633,7 +644,12 @@ int Pdr_ManSolveInt( Pdr_Man_t * p ) ...@@ -633,7 +644,12 @@ int Pdr_ManSolveInt( Pdr_Man_t * p )
// clkStart = clock(); // clkStart = clock();
} }
// check the timeout // check termination
if ( p->pPars->pFuncStop && p->pPars->pFuncStop(p->pPars->RunId) )
{
p->pPars->iFrame = k;
return -1;
}
if ( p->timeToStop && clock() > p->timeToStop ) if ( p->timeToStop && clock() > p->timeToStop )
{ {
if ( fPrintClauses ) if ( fPrintClauses )
...@@ -643,6 +659,7 @@ int Pdr_ManSolveInt( Pdr_Man_t * p ) ...@@ -643,6 +659,7 @@ int Pdr_ManSolveInt( Pdr_Man_t * p )
} }
if ( p->pPars->fVerbose ) if ( p->pPars->fVerbose )
Pdr_ManPrintProgress( p, 1, clock() - clkStart ); Pdr_ManPrintProgress( p, 1, clock() - clkStart );
if ( !p->pPars->fSilent )
Abc_Print( 1, "Reached timeout (%d seconds).\n", p->pPars->nTimeOut ); Abc_Print( 1, "Reached timeout (%d seconds).\n", p->pPars->nTimeOut );
p->pPars->iFrame = k; p->pPars->iFrame = k;
return -1; return -1;
...@@ -651,6 +668,7 @@ int Pdr_ManSolveInt( Pdr_Man_t * p ) ...@@ -651,6 +668,7 @@ int Pdr_ManSolveInt( Pdr_Man_t * p )
{ {
if ( p->pPars->fVerbose ) if ( p->pPars->fVerbose )
Pdr_ManPrintProgress( p, 1, clock() - clkStart ); Pdr_ManPrintProgress( p, 1, clock() - clkStart );
if ( !p->pPars->fSilent )
Abc_Print( 1, "Reached limit on the number of timeframes (%d).\n", p->pPars->nFrameMax ); Abc_Print( 1, "Reached limit on the number of timeframes (%d).\n", p->pPars->nFrameMax );
p->pPars->iFrame = k; p->pPars->iFrame = k;
return -1; return -1;
...@@ -677,6 +695,7 @@ int Pdr_ManSolve_( Aig_Man_t * pAig, Pdr_Par_t * pPars, Vec_Int_t ** pvPrioInit, ...@@ -677,6 +695,7 @@ int Pdr_ManSolve_( Aig_Man_t * pAig, Pdr_Par_t * pPars, Vec_Int_t ** pvPrioInit,
clock_t clk = clock(); clock_t clk = clock();
p = Pdr_ManStart( pAig, pPars, pvPrioInit? *pvPrioInit : NULL ); p = Pdr_ManStart( pAig, pPars, pvPrioInit? *pvPrioInit : NULL );
RetValue = Pdr_ManSolveInt( p ); RetValue = Pdr_ManSolveInt( p );
if ( ppCex )
*ppCex = RetValue ? NULL : Pdr_ManDeriveCex( p ); *ppCex = RetValue ? NULL : Pdr_ManDeriveCex( p );
if ( p->pPars->fDumpInv ) if ( p->pPars->fDumpInv )
Pdr_ManDumpClauses( p, (char *)"inv.pla", RetValue==1 ); Pdr_ManDumpClauses( p, (char *)"inv.pla", RetValue==1 );
......
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