Skip to content

Commit c1937d1

Browse files
committed
Improvements to &sprove.
1 parent d5c1f2c commit c1937d1

File tree

1 file changed

+52
-13
lines changed

1 file changed

+52
-13
lines changed

src/proof/cec/cecProve.c

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ int Cec_GiaProveTest( Gia_Man_t * p, int nProcs, int nTimeOut, int nTimeOut2, in
6464

6565
#define PAR_THR_MAX 8
6666
#define PAR_ENGINE_UFAR 6
67+
#define PAR_ENGINE_SCORR1 7
68+
#define PAR_ENGINE_SCORR2 8
6769
struct Par_Share_t_
6870
{
6971
volatile int fSolved;
@@ -82,7 +84,25 @@ typedef struct Par_ThData_t_
8284
Wlc_Ntk_t * pWlc;
8385
Par_Share_t * pShare;
8486
} Par_ThData_t;
87+
typedef struct Cec_ScorrStop_t_
88+
{
89+
Par_Share_t * pShare;
90+
abctime TimeToStop;
91+
} Cec_ScorrStop_t;
8592
static volatile Par_Share_t * g_pUfarShare = NULL;
93+
static inline const char * Cec_SolveEngineName( int iEngine )
94+
{
95+
if ( iEngine == 0 ) return "rar";
96+
if ( iEngine == 1 ) return "bmc";
97+
if ( iEngine == 2 ) return "pdr";
98+
if ( iEngine == 3 ) return "bmc-glucose";
99+
if ( iEngine == 4 ) return "pdr-abs";
100+
if ( iEngine == 5 ) return "bmcg";
101+
if ( iEngine == PAR_ENGINE_UFAR ) return "ufar";
102+
if ( iEngine == PAR_ENGINE_SCORR1 ) return "scorr-new";
103+
if ( iEngine == PAR_ENGINE_SCORR2 ) return "scorr-old";
104+
return "unknown";
105+
}
86106
static inline void Cec_CopyGiaName( Gia_Man_t * pSrc, Gia_Man_t * pDst )
87107
{
88108
char * pName = pSrc->pName ? pSrc->pName : pSrc->pSpec;
@@ -108,6 +128,17 @@ static int Cec_SProveStopUfar( int RunId )
108128
(void)RunId;
109129
return g_pUfarShare && g_pUfarShare->fSolved != 0;
110130
}
131+
static int Cec_ScorrStop( void * pUser )
132+
{
133+
Cec_ScorrStop_t * p = (Cec_ScorrStop_t *)pUser;
134+
if ( p == NULL )
135+
return 0;
136+
if ( p->pShare && p->pShare->fSolved )
137+
return 1;
138+
if ( p->TimeToStop && Abc_Clock() >= p->TimeToStop )
139+
return 1;
140+
return 0;
141+
}
111142
static int Cec_SProveCallback( void * pUser, int fSolved, unsigned Result )
112143
{
113144
Par_ThData_t * pThData = (Par_ThData_t *)pUser;
@@ -273,21 +304,25 @@ int Cec_GiaProveOne( Gia_Man_t * p, int iEngine, int nTimeOut, int fVerbose, Par
273304
}
274305
return RetValue;
275306
}
276-
Gia_Man_t * Cec_GiaScorrOld( Gia_Man_t * p )
307+
Gia_Man_t * Cec_GiaScorrOld( Gia_Man_t * p, int nTimeOut, Par_Share_t * pShare )
277308
{
309+
Cec_ScorrStop_t Stop = { pShare, nTimeOut > 0 ? Abc_Clock() + (abctime)nTimeOut * CLOCKS_PER_SEC : 0 };
278310
if ( Gia_ManRegNum(p) == 0 )
279311
return Gia_ManDup( p );
280312
Ssw_Pars_t Pars, * pPars = &Pars;
281313
Ssw_ManSetDefaultParams( pPars );
314+
pPars->pFunc = (void *)Cec_ScorrStop;
315+
pPars->pData = (void *)&Stop;
282316
Aig_Man_t * pAig = Gia_ManToAigSimple( p );
283317
Aig_Man_t * pAig2 = Ssw_SignalCorrespondence( pAig, pPars );
284318
Gia_Man_t * pGia2 = Gia_ManFromAigSimple( pAig2 );
285319
Aig_ManStop( pAig2 );
286320
Aig_ManStop( pAig );
287321
return pGia2;
288322
}
289-
Gia_Man_t * Cec_GiaScorrNew( Gia_Man_t * p )
323+
Gia_Man_t * Cec_GiaScorrNew( Gia_Man_t * p, int nTimeOut, Par_Share_t * pShare )
290324
{
325+
Cec_ScorrStop_t Stop = { pShare, nTimeOut > 0 ? Abc_Clock() + (abctime)nTimeOut * CLOCKS_PER_SEC : 0 };
291326
if ( Gia_ManRegNum(p) == 0 )
292327
return Gia_ManDup( p );
293328
Cec_ParCor_t Pars, * pPars = &Pars;
@@ -296,6 +331,8 @@ Gia_Man_t * Cec_GiaScorrNew( Gia_Man_t * p )
296331
pPars->nLevelMax = 100;
297332
pPars->fVerbose = 0;
298333
pPars->fUseCSat = 1;
334+
pPars->pFunc = (void *)Cec_ScorrStop;
335+
pPars->pData = (void *)&Stop;
299336
return Cec_ManLSCorrespondence( p, pPars );
300337
}
301338

@@ -376,7 +413,7 @@ int Cec_GiaProveTest( Gia_Man_t * p, int nProcs, int nTimeOut, int nTimeOut2, in
376413
Par_ThData_t ThData[PAR_THR_MAX];
377414
pthread_t WorkerThread[PAR_THR_MAX];
378415
Par_Share_t Share;
379-
int i, nWorkers = nProcs + (fUseUif ? 1 : 0), RetValue = -1, RetEngine = -2;
416+
int i, nWorkers = nProcs + (fUseUif ? 1 : 0), RetValue = -1, RetEngine = -1;
380417
memset( &Share, 0, sizeof(Par_Share_t) );
381418
Abc_CexFreeP( &p->pCexComb );
382419
Abc_CexFreeP( &p->pCexSeq );
@@ -391,10 +428,10 @@ int Cec_GiaProveTest( Gia_Man_t * p, int nProcs, int nTimeOut, int nTimeOut2, in
391428
Cec_GiaInitThreads( ThData, nWorkers, p, nTimeOut, nTimeOut3, pWlc, fUseUif, fVerbose, WorkerThread, &Share );
392429

393430
// meanwhile, perform scorr
394-
Gia_Man_t * pScorr = Cec_GiaScorrNew( p );
431+
Gia_Man_t * pScorr = Cec_GiaScorrNew( p, nTimeOut, &Share );
395432
clkScorr = Abc_Clock() - clkTotal;
396433
if ( Gia_ManAndNum(pScorr) == 0 )
397-
RetValue = 1, RetEngine = -1;
434+
RetValue = 1, RetEngine = PAR_ENGINE_SCORR1;
398435

399436
RetValue = Cec_GiaWaitThreads( ThData, nWorkers, p, RetValue, &RetEngine );
400437
if ( RetValue == -1 )
@@ -406,15 +443,15 @@ int Cec_GiaProveTest( Gia_Man_t * p, int nProcs, int nTimeOut, int nTimeOut2, in
406443
}
407444
Cec_GiaInitThreads( ThData, nWorkers, pScorr, nTimeOut2, nTimeOut3, pWlc, fUseUif, fVerbose, NULL, &Share );
408445

409-
// meanwhile, perform scorr
410-
if ( Gia_ManAndNum(pScorr) < 100000 )
446+
RetValue = Cec_GiaWaitThreads( ThData, nWorkers, p, RetValue, &RetEngine );
447+
if ( RetValue == -1 && Gia_ManAndNum(pScorr) < 100000 )
411448
{
412-
Gia_Man_t * pScorr2 = Cec_GiaScorrOld( pScorr );
449+
// Run this reduction only when round-2 did not decide the problem.
450+
Gia_Man_t * pScorr2 = Cec_GiaScorrOld( pScorr, nTimeOut3, &Share );
413451
clkScorr2 = Abc_Clock() - clkStart;
414452
if ( Gia_ManAndNum(pScorr2) == 0 )
415-
RetValue = 1;
416-
417-
RetValue = Cec_GiaWaitThreads( ThData, nWorkers, p, RetValue, &RetEngine );
453+
RetValue = 1, RetEngine = PAR_ENGINE_SCORR2;
454+
418455
if ( RetValue == -1 )
419456
{
420457
if ( !fSilent && fVerbose ) {
@@ -440,11 +477,13 @@ int Cec_GiaProveTest( Gia_Man_t * p, int nProcs, int nTimeOut, int nTimeOut2, in
440477
if ( !fSilent )
441478
{
442479
char * pProbName = p->pSpec ? p->pSpec : Gia_ManName(p);
480+
if ( RetValue != -1 && RetEngine < 0 )
481+
RetEngine = PAR_ENGINE_SCORR1;
443482
printf( "Problem \"%s\" is ", pProbName ? pProbName : "(none)" );
444483
if ( RetValue == 0 )
445-
printf( "SATISFIABLE (solved by %d).", RetEngine );
484+
printf( "SATISFIABLE (solved by %s).", Cec_SolveEngineName(RetEngine) );
446485
else if ( RetValue == 1 )
447-
printf( "UNSATISFIABLE (solved by %d).", RetEngine );
486+
printf( "UNSATISFIABLE (solved by %s).", Cec_SolveEngineName(RetEngine) );
448487
else if ( RetValue == -1 )
449488
printf( "UNDECIDED." );
450489
else assert( 0 );

0 commit comments

Comments
 (0)