31#ifdef ABC_USE_PTHREADS
34#include "../lib/pthread.h"
52#ifndef ABC_USE_PTHREADS
54int Cec_GiaProveTest(
Gia_Man_t *
p,
int nProcs,
int nTimeOut,
int nTimeOut2,
int nTimeOut3,
int fVerbose,
int fVeryVerbose,
int fSilent ) {
return -1; }
73int Cec_GiaProveOne(
Gia_Man_t *
p,
int iEngine,
int nTimeOut,
int fVerbose )
79 printf(
"Calling engine %d with timeout %d sec.\n", iEngine, nTimeOut );
89 else if ( iEngine == 1 )
97 p->pCexSeq = pAig->pSeqModel; pAig->pSeqModel = NULL;
100 else if ( iEngine == 2 )
104 pPars->nTimeOut = nTimeOut;
108 p->pCexSeq = pAig->pSeqModel; pAig->pSeqModel = NULL;
111 else if ( iEngine == 3 )
120 p->pCexSeq = pAig->pSeqModel; pAig->pSeqModel = NULL;
123 else if ( iEngine == 4 )
128 pPars->nTimeOut = nTimeOut;
132 p->pCexSeq = pAig->pSeqModel; pAig->pSeqModel = NULL;
135 else if ( iEngine == 5 )
148 printf(
"Engine %d finished and %ssolved the problem. ", iEngine, RetValue != -1 ?
" " :
"not " );
149 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
187typedef struct Par_ThData_t_
196void * Cec_GiaProveWorkerThread(
void * pArg )
198 Par_ThData_t * pThData = (Par_ThData_t *)pArg;
199 volatile int * pPlace = &pThData->fWorking;
202 while ( *pPlace == 0 );
203 assert( pThData->fWorking );
204 if ( pThData->p == NULL )
206 pthread_exit( NULL );
210 pThData->Result = Cec_GiaProveOne( pThData->p, pThData->iEngine, pThData->nTimeOut, pThData->fVerbose );
211 pThData->fWorking = 0;
216void Cec_GiaInitThreads( Par_ThData_t * ThData,
int nProcs,
Gia_Man_t *
p,
int nTimeOut,
int fVerbose, pthread_t * WorkerThread )
220 for ( i = 0; i < nProcs; i++ )
223 ThData[i].iEngine = i;
224 ThData[i].nTimeOut = nTimeOut;
225 ThData[i].fWorking = 0;
226 ThData[i].Result = -1;
227 ThData[i].fVerbose = fVerbose;
230 status = pthread_create( WorkerThread + i, NULL,Cec_GiaProveWorkerThread, (
void *)(ThData + i) );
assert( status == 0 );
232 for ( i = 0; i < nProcs; i++ )
233 ThData[i].fWorking = 1;
235int Cec_GiaWaitThreads( Par_ThData_t * ThData,
int nProcs,
Gia_Man_t *
p,
int RetValue,
int * pRetEngine )
238 for ( i = 0; i < nProcs; i++ )
240 if ( RetValue == -1 && !ThData[i].fWorking && ThData[i].Result != -1 ) {
241 RetValue = ThData[i].Result;
243 if ( !
p->pCexSeq && ThData[i].p->pCexSeq )
246 if ( ThData[i].fWorking )
252int Cec_GiaProveTest(
Gia_Man_t *
p,
int nProcs,
int nTimeOut,
int nTimeOut2,
int nTimeOut3,
int fVerbose,
int fVeryVerbose,
int fSilent )
254 abctime clkScorr = 0, clkTotal = Abc_Clock();
257 int i, RetValue = -1, RetEngine = -2;
260 if ( !fSilent && fVerbose )
261 printf(
"Solving verification problem with the following parameters:\n" );
262 if ( !fSilent && fVerbose )
263 printf(
"Processes = %d TimeOut = %d sec Verbose = %d.\n", nProcs, nTimeOut, fVerbose );
266 assert( nProcs == 3 || nProcs == 5 );
267 Cec_GiaInitThreads( ThData, nProcs,
p, nTimeOut, fVerbose, WorkerThread );
271 clkScorr = Abc_Clock() - clkTotal;
272 if ( Gia_ManAndNum(pScorr) == 0 )
273 RetValue = 1, RetEngine = -1;
275 RetValue = Cec_GiaWaitThreads( ThData, nProcs,
p, RetValue, &RetEngine );
276 if ( RetValue == -1 )
278 abctime clkScorr2, clkStart = Abc_Clock();
279 if ( !fSilent && fVerbose ) {
280 printf(
"Reduced the miter from %d to %d nodes. ", Gia_ManAndNum(
p), Gia_ManAndNum(pScorr) );
281 Abc_PrintTime( 1,
"Time", clkScorr );
283 Cec_GiaInitThreads( ThData, nProcs, pScorr, nTimeOut2, fVerbose, NULL );
286 if ( Gia_ManAndNum(pScorr) < 100000 )
288 Gia_Man_t * pScorr2 = Cec_GiaScorrOld( pScorr );
289 clkScorr2 = Abc_Clock() - clkStart;
290 if ( Gia_ManAndNum(pScorr2) == 0 )
293 RetValue = Cec_GiaWaitThreads( ThData, nProcs,
p, RetValue, &RetEngine );
294 if ( RetValue == -1 )
296 if ( !fSilent && fVerbose ) {
297 printf(
"Reduced the miter from %d to %d nodes. ", Gia_ManAndNum(pScorr), Gia_ManAndNum(pScorr2) );
298 Abc_PrintTime( 1,
"Time", clkScorr2 );
300 Cec_GiaInitThreads( ThData, nProcs, pScorr2, nTimeOut3, fVerbose, NULL );
302 RetValue = Cec_GiaWaitThreads( ThData, nProcs,
p, RetValue, &RetEngine );
311 for ( i = 0; i < nProcs; i++ )
314 ThData[i].fWorking = 1;
318 printf(
"Problem \"%s\" is ",
p->pSpec );
320 printf(
"SATISFIABLE (solved by %d).", RetEngine );
321 else if ( RetValue == 1 )
322 printf(
"UNSATISFIABLE (solved by %d).", RetEngine );
323 else if ( RetValue == -1 )
324 printf(
"UNDECIDED." );
327 Abc_PrintTime( 1,
"Time", Abc_Clock() - clkTotal );
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
void Aig_ManStop(Aig_Man_t *p)
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
#define PAR_THR_MAX
DECLARATIONS ///.
void Saig_ParBmcSetDefaultParams(Saig_ParBmc_t *p)
int Saig_ManBmcScalable(Aig_Man_t *pAig, Saig_ParBmc_t *pPars)
struct Bmc_AndPar_t_ Bmc_AndPar_t
struct Saig_ParBmc_t_ Saig_ParBmc_t
int Cec_GiaProveTest(Gia_Man_t *p, int nProcs, int nTimeOut, int nTimeOut2, int nTimeOut3, int fVerbose, int fVeryVerbose, int fSilent)
int Bmcg_ManPerform(Gia_Man_t *pGia, Bmc_AndPar_t *pPars)
ABC_NAMESPACE_IMPL_START int Ssw_RarSimulateGia(Gia_Man_t *p, Ssw_RarPars_t *pPars)
DECLARATIONS ///.
void Cec_ManCorSetDefaultParams(Cec_ParCor_t *p)
Gia_Man_t * Cec_ManLSCorrespondence(Gia_Man_t *pAig, Cec_ParCor_t *pPars)
struct Cec_ParCor_t_ Cec_ParCor_t
Aig_Man_t * Gia_ManToAigSimple(Gia_Man_t *p)
Gia_Man_t * Gia_ManFromAigSimple(Aig_Man_t *p)
void Gia_ManStop(Gia_Man_t *p)
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
struct Gia_Man_t_ Gia_Man_t
void Pdr_ManSetDefaultParams(Pdr_Par_t *pPars)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Pdr_Par_t_ Pdr_Par_t
INCLUDES ///.
int Pdr_ManSolve(Aig_Man_t *p, Pdr_Par_t *pPars)
void Ssw_ManSetDefaultParams(Ssw_Pars_t *p)
DECLARATIONS ///.
void Ssw_RarSetDefaultParams(Ssw_RarPars_t *p)
FUNCTION DEFINITIONS ///.
struct Ssw_RarPars_t_ Ssw_RarPars_t
typedefABC_NAMESPACE_HEADER_START struct Ssw_Pars_t_ Ssw_Pars_t
INCLUDES ///.
Aig_Man_t * Ssw_SignalCorrespondence(Aig_Man_t *pAig, Ssw_Pars_t *pPars)
void Abc_CexFreeP(Abc_Cex_t **p)
Abc_Cex_t * Abc_CexDup(Abc_Cex_t *p, int nRegsNew)