38#ifdef ABC_USE_PTHREADS
41#include "../lib/pthread.h"
54extern int Abc_NtkFxPerform(
Abc_Ntk_t * pNtk,
int nNewNodesMax,
int nLitCountMax,
int fCanonDivs,
int fVerbose,
int fVeryVerbose );
119#ifdef ABC_USE_PTHREADS
124 pthread_mutex_t *
mutex;
131#ifdef ABC_USE_PTHREADS
133 pthread_mutex_lock(
p->mutex );
137#ifdef ABC_USE_PTHREADS
139 pthread_mutex_unlock(
p->mutex );
148 n = Gia_ManAndNum( pGia );
150 pNew =
Gia_ManTransductionTt( pGia, (
p->fMerge? 8: 7),
p->fMspf,
p->nSeed++, 0, 0, 0, 0,
p->pExdc,
p->fNewLine,
p->nVerbose > 0?
p->nVerbose - 1: 0 );
152 pNew =
Gia_ManTransductionBdd( pGia, (
p->fMerge? 8: 7),
p->fMspf,
p->nSeed++, 0, 0, 0, 0,
p->pExdc,
p->fNewLine,
p->nVerbose > 0?
p->nVerbose - 1: 0 );
155 if (
p->fRefactor ) {
167 printf(
"* ite %d : #nodes = %5d\n", i, Gia_ManAndNum( pGia ) );
169 }
while ( n > Gia_ManAndNum( pGia ) );
174 int i, n = Gia_ManAndNum(
p->pStart );
179 for ( i = 0; 1; i++ ) {
183 if ( n > Gia_ManAndNum( pGia ) ) {
184 n = Gia_ManAndNum( pGia );
192 if (
p->fZeroCostHop ) {
214 printf(
"* hop %d : #nodes = %5d\n", i, Gia_ManAndNum( pGia ) );
221 int i, n = Gia_ManAndNum(
p->pStart );
224 for ( i = 0; i <=
p->nRestarts; i++ ) {
225 p->nSeed = 1234 * (i +
p->nSeedBase);
227 if (
p->nRestarts &&
p->nVerbose )
228 printf(
"* res %2d : #nodes = %5d\n", i, Gia_ManAndNum( pNew ) );
229 if ( n > Gia_ManAndNum( pNew ) ) {
230 n = Gia_ManAndNum( pNew );
240#ifdef ABC_USE_PTHREADS
241void * Gia_ManTranStochWorkerThread(
void * pArg ) {
243 volatile int * pPlace = &
p->fWorking;
245 while ( *pPlace == 0 );
247 if (
p->pStart == NULL ) {
248 pthread_exit( NULL );
252 p->nSeed = 1234 * (
p->nIte +
p->nSeedBase);
261Gia_Man_t *
Gia_ManTranStoch(
Gia_Man_t * pGia,
int nRestarts,
int nHops,
int nSeedBase,
int fMspf,
int fMerge,
int fResetHop,
int fZeroCostHop,
int fRefactor,
int fTruth,
int fSingle,
int fOriginalOnly,
int fNewLine,
Gia_Man_t *
pExdc,
int nThreads,
int nVerbose ) {
278#ifdef ABC_USE_PTHREADS
282 vpStarts = Vec_PtrAlloc( 4 );
284 if ( !fOriginalOnly ) {
295 Vec_PtrPush( vpStarts, pNew );
298 pNew =
Gia_ManTtopt( pGia, Gia_ManCiNum( pGia ), Gia_ManCoNum( pGia ), 100 );
299 Vec_PtrPush( vpStarts, pNew );
313 Vec_PtrPush( vpStarts, pNew );
317 pBest = (
Gia_Man_t *)Vec_PtrEntry( vpStarts, 0 );
318 for ( i = 1; i < Vec_PtrSize( vpStarts ); i++ ) {
320 if ( Gia_ManAndNum(
pStart ) < Gia_ManAndNum( pBest ) ) {
328 Vec_PtrClear( vpStarts );
329 Vec_PtrPush( vpStarts, pBest );
333 if ( nThreads == 1 ) {
336 printf(
"*begin starting point %d: #nodes = %5d\n", i + j, Gia_ManAndNum(
pStart ) );
340 printf(
"*end starting point %d: #nodes = %5d\n", i + j, Gia_ManAndNum( pNew ) );
341 if ( Gia_ManAndNum( pBest ) > Gia_ManAndNum( pNew ) ) {
350#ifdef ABC_USE_PTHREADS
351 static pthread_mutex_t
mutex;
352 int k, status, nIte, fAssigned, fWorking;
354 pthread_t WorkerThread[100];
359 for ( i = 0; i < nThreads; i++ ) {
361 status = pthread_create( WorkerThread + i, NULL, Gia_ManTranStochWorkerThread, (
void *)(ThData + i) );
365 for ( nIte = 0; nIte <=
p->nRestarts; nIte++ ) {
367 while ( !fAssigned ) {
368 for ( i = 0; i < nThreads; i++ ) {
369 if ( ThData[i].fWorking )
371 if ( ThData[i].pRes != NULL ) {
373 printf(
"*sp %d res %4d : #nodes = %5d\n", ThData[i].nSp, ThData[i].nIte, Gia_ManAndNum( ThData[i].pRes ) );
374 if ( Gia_ManAndNum( pBest ) > Gia_ManAndNum( ThData[i].pRes ) ) {
376 pBest = ThData[i].pRes;
380 ThData[i].pRes = NULL;
382 ThData[i].nSp = j + k;
383 ThData[i].nIte = nIte;
385 ThData[i].fWorking = 1;
395 for ( i = 0; i < nThreads; i++ ) {
396 if( ThData[i].fWorking ) {
400 if ( ThData[i].pRes != NULL ) {
402 printf(
"*sp %d res %4d : #nodes = %5d\n", ThData[i].nSp, ThData[i].nIte, Gia_ManAndNum( ThData[i].pRes ) );
403 if ( Gia_ManAndNum( pBest ) > Gia_ManAndNum( ThData[i].pRes ) ) {
405 pBest = ThData[i].pRes;
409 ThData[i].pRes = NULL;
413 for ( i = 0; i < nThreads; i++ ) {
415 ThData[i].fWorking = 1;
418 printf(
"ERROR: pthread is off" );
424 printf(
"best: %d\n", Gia_ManAndNum( pBest ) );
425 Vec_PtrFree( vpStarts );
void Abc_NtkFxuFreeInfo(Fxu_Data_t *p)
void Abc_NtkSetDefaultFxParams(Fxu_Data_t *p)
FUNCTION DEFINITIONS ///.
ABC_DLL Abc_Ntk_t * Abc_NtkCollapse(Abc_Ntk_t *pNtk, int fBddSizeMax, int fDualRail, int fReorder, int fReverse, int fDumpOrder, int fVerbose)
DECLARATIONS ///.
struct Abc_Ntk_t_ Abc_Ntk_t
ABC_DLL int Abc_NtkToSop(Abc_Ntk_t *pNtk, int fMode, int nCubeLimit)
ABC_DLL Abc_Ntk_t * Abc_NtkStrash(Abc_Ntk_t *pNtk, int fAllNodes, int fCleanup, int fRecord)
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
#define ABC_INFINITY
MACRO DEFINITIONS ///.
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
Aig_Man_t * Aig_ManDupDfs(Aig_Man_t *p)
void Aig_ManStop(Aig_Man_t *p)
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
ABC_DLL void * Abc_FrameReadLibLut()
int Dar_ManRefactor(Aig_Man_t *pAig, Dar_RefPar_t *pPars)
struct Dar_RefPar_t_ Dar_RefPar_t
void Dar_ManDefaultRefParams(Dar_RefPar_t *pPars)
FUNCTION DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct FxuDataStruct Fxu_Data_t
INCLUDES ///.
Gia_Man_t * Gia_ManCompress2(Gia_Man_t *p, int fUpdateLevel, int fVerbose)
Gia_Man_t * Gia_ManFromAig(Aig_Man_t *p)
INCLUDES ///.
Aig_Man_t * Gia_ManToAig(Gia_Man_t *p, int fChoices)
void Gia_ManTranStochMfs2(Abc_Ntk_t *pNtk)
int Abc_NtkPerformMfs(Abc_Ntk_t *pNtk, Sfm_Par_t *pPars)
void Gia_ManTranStochLock(Gia_ManTranStochParam *p)
Gia_Man_t * Gia_ManTranStochOpt3(Gia_ManTranStochParam *p)
ABC_NAMESPACE_IMPL_START Abc_Ntk_t * Abc_NtkFromAigPhase(Aig_Man_t *pMan)
DECLARATIONS ///.
Gia_Man_t * Gia_ManTranStochOpt2(Gia_ManTranStochParam *p)
Abc_Ntk_t * Gia_ManTranStochIf(Abc_Ntk_t *pNtk)
Abc_Ntk_t * Gia_ManTranStochPut(Gia_Man_t *pGia)
void Gia_ManTranStochUnlock(Gia_ManTranStochParam *p)
Aig_Man_t * Abc_NtkToDar(Abc_Ntk_t *pNtk, int fExors, int fRegisters)
Gia_Man_t * Gia_ManTranStoch(Gia_Man_t *pGia, int nRestarts, int nHops, int nSeedBase, int fMspf, int fMerge, int fResetHop, int fZeroCostHop, int fRefactor, int fTruth, int fSingle, int fOriginalOnly, int fNewLine, Gia_Man_t *pExdc, int nThreads, int nVerbose)
Gia_Man_t * Gia_ManTranStochOpt1(Gia_ManTranStochParam *p, Gia_Man_t *pOld)
Gia_Man_t * Gia_ManTranStochGet(Abc_Ntk_t *pNtk)
void Gia_ManTranStochFx(Abc_Ntk_t *pNtk)
Gia_Man_t * Gia_ManTranStochRefactor(Gia_Man_t *pGia)
int Abc_NtkFxPerform(Abc_Ntk_t *pNtk, int nNewNodesMax, int nLitCountMax, int fCanonDivs, int fVerbose, int fVeryVerbose)
Abc_Ntk_t * Abc_NtkIf(Abc_Ntk_t *pNtk, If_Par_t *pPars)
void Gia_ManStop(Gia_Man_t *p)
Gia_Man_t * Gia_ManDup(Gia_Man_t *p)
struct Gia_Man_t_ Gia_Man_t
Gia_Man_t * Gia_ManTransductionTt(Gia_Man_t *pGia, int nType, int fMspf, int nRandom, int nSortType, int nPiShuffle, int nParameter, int fLevel, Gia_Man_t *pExdc, int fNewLine, int nVerbose)
Gia_Man_t * Gia_ManTransductionBdd(Gia_Man_t *pGia, int nType, int fMspf, int nRandom, int nSortType, int nPiShuffle, int nParameter, int fLevel, Gia_Man_t *pExdc, int fNewLine, int nVerbose)
Gia_Man_t * Gia_ManTtopt(Gia_Man_t *p, int nIns, int nOuts, int nRounds)
struct If_Par_t_ If_Par_t
struct If_LibLut_t_ If_LibLut_t
void If_ManSetDefaultPars(If_Par_t *pPars)
FUNCTION DECLARATIONS ///.
struct Sfm_Par_t_ Sfm_Par_t
void Sfm_ParSetDefault(Sfm_Par_t *pPars)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.