Skip to content

Commit d5c1f2c

Browse files
committed
Adding callbacks to "scorr" and "&scorr".
1 parent ef54c1d commit d5c1f2c

File tree

6 files changed

+56
-14
lines changed

6 files changed

+56
-14
lines changed

src/proof/cec/cecCorr.c

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@
2222

2323
ABC_NAMESPACE_IMPL_START
2424

25+
static inline int Cec_ParCorShouldStop( Cec_ParCor_t * pPars )
26+
{
27+
if ( pPars == NULL || pPars->pFunc == NULL )
28+
return 0;
29+
return ((int (*)(void *))pPars->pFunc)( pPars->pData );
30+
}
31+
2532

2633
////////////////////////////////////////////////////////////////////////
2734
/// DECLARATIONS ///
@@ -808,6 +815,8 @@ void Cec_ManLSCorrespondenceBmc( Gia_Man_t * pAig, Cec_ParCor_t * pPars, int nPr
808815
fChanges = 1;
809816
for ( i = 0; fChanges && (!pPars->nLimitMax || i < pPars->nLimitMax); i++ )
810817
{
818+
if ( Cec_ParCorShouldStop( pPars ) )
819+
break;
811820
abctime clkBmc = Abc_Clock();
812821
fChanges = 0;
813822
pSrm = Gia_ManCorrSpecReduceInit( pAig, pPars->nFrames, nPrefs, !pPars->fLatchCorr, &vOutputs, pPars->fUseRings );
@@ -836,6 +845,8 @@ void Cec_ManLSCorrespondenceBmc( Gia_Man_t * pAig, Cec_ParCor_t * pPars, int nPr
836845
Vec_StrFree( vStatus );
837846
Gia_ManStop( pSrm );
838847
Vec_IntFree( vOutputs );
848+
if ( Cec_ParCorShouldStop( pPars ) )
849+
break;
839850
}
840851
Cec_ManSimStop( pSim );
841852
}
@@ -975,10 +986,10 @@ int Cec_ManLSCorrespondenceClasses( Gia_Man_t * pAig, Cec_ParCor_t * pPars )
975986
// check the base case
976987
if ( fRunBmcFirst && (!pPars->fLatchCorr || pPars->nFrames > 1) )
977988
Cec_ManLSCorrespondenceBmc( pAig, pPars, 0 );
978-
if ( pPars->pFunc )
989+
if ( Cec_ParCorShouldStop( pPars ) )
979990
{
980-
((int (*)(void *))pPars->pFunc)( pPars->pData );
981-
((int (*)(void *))pPars->pFunc)( pPars->pData );
991+
Cec_ManSimStop( pSim );
992+
return 1;
982993
}
983994
if ( pPars->nStepsMax == 0 )
984995
{
@@ -989,6 +1000,11 @@ int Cec_ManLSCorrespondenceClasses( Gia_Man_t * pAig, Cec_ParCor_t * pPars )
9891000
// perform refinement of equivalence classes
9901001
for ( r = 0; r < nIterMax; r++ )
9911002
{
1003+
if ( Cec_ParCorShouldStop( pPars ) )
1004+
{
1005+
Cec_ManSimStop( pSim );
1006+
return 1;
1007+
}
9921008
if ( pPars->nStepsMax == r )
9931009
{
9941010
Cec_ManSimStop( pSim );
@@ -1036,8 +1052,11 @@ int Cec_ManLSCorrespondenceClasses( Gia_Man_t * pAig, Cec_ParCor_t * pPars )
10361052
Vec_StrFree( vStatus );
10371053
Vec_IntFree( vOutputs );
10381054
//Gia_ManEquivPrintClasses( pAig, 1, 0 );
1039-
if ( pPars->pFunc )
1040-
((int (*)(void *))pPars->pFunc)( pPars->pData );
1055+
if ( Cec_ParCorShouldStop( pPars ) )
1056+
{
1057+
Cec_ManSimStop( pSim );
1058+
return 1;
1059+
}
10411060
// quit if const is no longer there
10421061
if ( pPars->fStopWhenGone && Gia_ManPoNum(pAig) == 1 && !Gia_ObjIsConst( pAig, Gia_ObjFaninId0p(pAig, Gia_ManPo(pAig, 0)) ) )
10431062
{
@@ -1448,4 +1467,3 @@ Gia_Man_t * Gia_ManDupStopsTest( Gia_Man_t * p )
14481467

14491468

14501469
ABC_NAMESPACE_IMPL_END
1451-

src/proof/ssw/sswConstr.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,8 @@ clk = Abc_Clock();
512512
p->fRefined = 0;
513513
for ( f = 0; f < p->pPars->nFramesK; f++ )
514514
{
515+
if ( Ssw_ManCallbackStop(p) )
516+
break;
515517
// map constants and PIs
516518
Ssw_ObjSetFrame( p, Aig_ManConst1(p->pAig), f, Aig_ManConst1(p->pFrames) );
517519
Saig_ManForEachPi( p->pAig, pObj, i )
@@ -540,10 +542,14 @@ clk = Abc_Clock();
540542
// sweep internal nodes
541543
Aig_ManForEachNode( p->pAig, pObj, i )
542544
{
545+
if ( Ssw_ManCallbackStop(p) )
546+
break;
543547
pObjNew = Aig_And( p->pFrames, Ssw_ObjChild0Fra(p, pObj, f), Ssw_ObjChild1Fra(p, pObj, f) );
544548
Ssw_ObjSetFrame( p, pObj, f, pObjNew );
545549
p->fRefined |= Ssw_ManSweepNodeConstr( p, pObj, f, 1 );
546550
}
551+
if ( i < Aig_ManObjNumMax(p->pAig) )
552+
break;
547553
// quit if this is the last timeframe
548554
if ( f == p->pPars->nFramesK - 1 )
549555
break;
@@ -692,6 +698,8 @@ p->timeReduce += Abc_Clock() - clk;
692698
pProgress = Bar_ProgressStart( stdout, Aig_ManObjNumMax(p->pAig) );
693699
Aig_ManForEachObj( p->pAig, pObj, i )
694700
{
701+
if ( Ssw_ManCallbackStop(p) )
702+
break;
695703
if ( p->pPars->fVerbose )
696704
Bar_ProgressUpdate( pProgress, i, NULL );
697705
if ( Saig_ObjIsLo(p->pAig, pObj) )

src/proof/ssw/sswCore.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ Aig_Man_t * Ssw_SignalCorrespondenceRefine( Ssw_Man_t * p )
238238
Aig_Man_t * pAigNew;
239239
int RetValue, nIter = -1, nPrev[4] = {0};
240240
abctime clk, clkTotal = Abc_Clock();
241+
abctime nTimeToStop = p->pPars->TimeLimit > 0 ? clkTotal + (abctime)p->pPars->TimeLimit * CLOCKS_PER_SEC : 0;
241242
// get the starting stats
242243
p->nLitsBeg = Ssw_ClassesLitNum( p->ppClasses );
243244
p->nNodesBeg = Aig_ManNodeNum(p->pAig);
@@ -251,6 +252,8 @@ Aig_Man_t * Ssw_SignalCorrespondenceRefine( Ssw_Man_t * p )
251252
if ( !p->pPars->fLatchCorr || p->pPars->nFramesK > 1 )
252253
{
253254
p->pMSat = Ssw_SatStart( 0 );
255+
if ( nTimeToStop )
256+
sat_solver_set_runtime_limit( p->pMSat->pSat, nTimeToStop );
254257
if ( p->pPars->fConstrs )
255258
Ssw_ManSweepBmcConstr( p );
256259
else
@@ -276,11 +279,8 @@ Aig_Man_t * Ssw_SignalCorrespondenceRefine( Ssw_Man_t * p )
276279
Aig_ManStop( pSRed );
277280
}
278281
*/
279-
if ( p->pPars->pFunc )
280-
{
281-
((int (*)(void *))p->pPars->pFunc)( p->pPars->pData );
282-
((int (*)(void *))p->pPars->pFunc)( p->pPars->pData );
283-
}
282+
if ( Ssw_ManCallbackStop(p) || Ssw_ManCallbackStop(p) )
283+
goto finalize;
284284
if ( p->pPars->nStepsMax == 0 )
285285
{
286286
Abc_Print( 1, "Stopped signal correspondence after BMC.\n" );
@@ -290,6 +290,8 @@ Aig_Man_t * Ssw_SignalCorrespondenceRefine( Ssw_Man_t * p )
290290
nSatProof = nSatCallsSat = nRecycles = nSatFailsReal = nUniques = 0;
291291
for ( nIter = 0; ; nIter++ )
292292
{
293+
if ( nTimeToStop && Abc_Clock() >= nTimeToStop )
294+
goto finalize;
293295
if ( p->pPars->nStepsMax == nIter )
294296
{
295297
Abc_Print( 1, "Stopped signal correspondence after %d refiment iterations.\n", nIter );
@@ -306,9 +308,13 @@ Aig_Man_t * Ssw_SignalCorrespondenceRefine( Ssw_Man_t * p )
306308
Abc_Print( 1, "If the miter is SAT, the reduced result is incorrect.\n" );
307309
break;
308310
}
311+
if ( Ssw_ManCallbackStop(p) )
312+
goto finalize;
309313

310314
clk = Abc_Clock();
311315
p->pMSat = Ssw_SatStart( 0 );
316+
if ( nTimeToStop )
317+
sat_solver_set_runtime_limit( p->pMSat->pSat, nTimeToStop );
312318
if ( p->pPars->fLatchCorrOpt )
313319
{
314320
RetValue = Ssw_ManSweepLatch( p );
@@ -379,8 +385,8 @@ clk = Abc_Clock();
379385
Ssw_ManCleanup( p );
380386
if ( !RetValue )
381387
break;
382-
if ( p->pPars->pFunc )
383-
((int (*)(void *))p->pPars->pFunc)( p->pPars->pData );
388+
if ( Ssw_ManCallbackStop(p) )
389+
goto finalize;
384390
if ( p->pPars->nLimitMax )
385391
{
386392
int nCur = Ssw_ClassesCand1Num(p->ppClasses);

src/proof/ssw/sswDyn.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,8 @@ p->timeReduce += Abc_Clock() - clk;
407407
p->iNodeStart = 0;
408408
Aig_ManForEachObj( p->pAig, pObj, i )
409409
{
410+
if ( Ssw_ManCallbackStop(p) )
411+
break;
410412
if ( p->iNodeStart == 0 )
411413
p->iNodeStart = i;
412414
if ( p->pPars->fVerbose )

src/proof/ssw/sswInt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ static inline void Ssw_ObjSetFrame_( Ssw_Frm_t * p, Aig_Obj_t * pObj, int
190190

191191
static inline Aig_Obj_t * Ssw_ObjChild0Fra_( Ssw_Frm_t * p, Aig_Obj_t * pObj, int i ) { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin0(pObj)? Aig_NotCond(Ssw_ObjFrame_(p, Aig_ObjFanin0(pObj), i), Aig_ObjFaninC0(pObj)) : NULL; }
192192
static inline Aig_Obj_t * Ssw_ObjChild1Fra_( Ssw_Frm_t * p, Aig_Obj_t * pObj, int i ) { assert( !Aig_IsComplement(pObj) ); return Aig_ObjFanin1(pObj)? Aig_NotCond(Ssw_ObjFrame_(p, Aig_ObjFanin1(pObj), i), Aig_ObjFaninC1(pObj)) : NULL; }
193+
static inline int Ssw_ManCallbackStop( Ssw_Man_t * p ) { return (p && p->pPars && p->pPars->pFunc) ? ((int (*)(void *))p->pPars->pFunc)( p->pPars->pData ) : 0; }
193194

194195
////////////////////////////////////////////////////////////////////////
195196
/// FUNCTION DECLARATIONS ///
@@ -299,4 +300,3 @@ ABC_NAMESPACE_HEADER_END
299300
////////////////////////////////////////////////////////////////////////
300301
/// END OF FILE ///
301302
////////////////////////////////////////////////////////////////////////
302-

src/proof/ssw/sswSweep.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ clk = Abc_Clock();
288288
pProgress = Bar_ProgressStart( stdout, Aig_ManObjNumMax(p->pAig) * p->pPars->nFramesK );
289289
for ( f = 0; f < p->pPars->nFramesK; f++ )
290290
{
291+
if ( Ssw_ManCallbackStop(p) )
292+
break;
291293
// map constants and PIs
292294
Ssw_ObjSetFrame( p, Aig_ManConst1(p->pAig), f, Aig_ManConst1(p->pFrames) );
293295
Saig_ManForEachPi( p->pAig, pObj, i )
@@ -298,12 +300,16 @@ clk = Abc_Clock();
298300
// sweep internal nodes
299301
Aig_ManForEachNode( p->pAig, pObj, i )
300302
{
303+
if ( Ssw_ManCallbackStop(p) )
304+
break;
301305
if ( p->pPars->fVerbose )
302306
Bar_ProgressUpdate( pProgress, Aig_ManObjNumMax(p->pAig) * f + i, NULL );
303307
pObjNew = Aig_And( p->pFrames, Ssw_ObjChild0Fra(p, pObj, f), Ssw_ObjChild1Fra(p, pObj, f) );
304308
Ssw_ObjSetFrame( p, pObj, f, pObjNew );
305309
p->fRefined |= Ssw_ManSweepNode( p, pObj, f, 1, NULL );
306310
}
311+
if ( i < Aig_ManObjNumMax(p->pAig) )
312+
break;
307313
// quit if this is the last timeframe
308314
if ( f == p->pPars->nFramesK - 1 )
309315
break;
@@ -415,6 +421,8 @@ p->timeReduce += Abc_Clock() - clk;
415421
vObjPairs = (p->pPars->fEquivDump || p->pPars->fEquivDump2)? Vec_IntAlloc(1000) : NULL;
416422
Aig_ManForEachObj( p->pAig, pObj, i )
417423
{
424+
if ( Ssw_ManCallbackStop(p) )
425+
break;
418426
if ( p->pPars->fVerbose )
419427
Bar_ProgressUpdate( pProgress, i, NULL );
420428
if ( Saig_ObjIsLo(p->pAig, pObj) )

0 commit comments

Comments
 (0)