24 #ifdef ABC_USE_PTHREADS
27 #include "../lib/pthread.h"
41 #ifndef ABC_USE_PTHREADS
45 #else // pthreads are used
66 void Gia_ParComputeSignature(
Gia_Man_t * p,
int nWords )
69 word * pData, Sign = 0;
74 for ( i = 0; i < p->
iData; i++ )
91 void Gia_ParTestSimulateInit(
Gia_Man_t * p )
99 for ( i = 0; i < p->
iData; i++ )
103 void Gia_ParTestSimulateObj(
Gia_Man_t * p,
int Id )
106 word * pData, * pData0, * pData1;
116 for ( i = 0; i < p->
iData; i++ )
117 pData[i] = ~(pData0[i] | pData1[i]);
119 for ( i = 0; i < p->
iData; i++ )
120 pData[i] = ~pData0[i] & pData1[i];
125 for ( i = 0; i < p->
iData; i++ )
126 pData[i] = pData0[i] & ~pData1[i];
128 for ( i = 0; i < p->
iData; i++ )
129 pData[i] = pData0[i] & pData1[i];
137 for ( i = 0; i < p->
iData; i++ )
138 pData[i] = ~pData0[i];
140 for ( i = 0; i < p->
iData; i++ )
141 pData[i] = pData0[i];
149 for ( i = 0; i < p->
iData; i++ )
154 void Gia_ParTestSimulate(
Gia_Man_t * p,
int nWords )
160 Gia_ParTestSimulateInit( p );
162 Gia_ParTestSimulateObj( p, i );
208 #define PAR_THR_MAX 100
209 typedef struct Par_ThData_t_
215 void * Gia_ParWorkerThread(
void * pArg )
217 Par_ThData_t * pThData = (Par_ThData_t *)pArg;
218 volatile int * pPlace = &pThData->Status;
221 while ( *pPlace == 0 );
222 assert( pThData->Status == 1 );
223 if ( pThData->Id == -1 )
225 pthread_exit( NULL );
229 assert( pThData->Id >= 0 );
230 Gia_ParTestSimulateObj( pThData->p, pThData->Id );
236 void Gia_ParTestSimulate2(
Gia_Man_t * p,
int nWords,
int nProcs )
238 pthread_t WorkerThread[PAR_THR_MAX];
239 Par_ThData_t ThData[PAR_THR_MAX];
241 int i, k, iFan, status, nCountFanins;
242 assert( nProcs <= PAR_THR_MAX );
245 Gia_ParTestSimulateInit( p );
252 vFanins = Gia_ManCreateFaninCounts( p );
255 for ( i = 0; i < nProcs; i++ )
259 ThData[i].Status = 0;
260 status = pthread_create( WorkerThread + i, NULL, Gia_ParWorkerThread, (
void *)(ThData + i) );
assert( status == 0 );
262 while ( nCountFanins > 0 ||
Vec_IntSize(vStack) > 0 )
264 for ( i = 0; i < nProcs; i++ )
266 if ( ThData[i].Status )
268 assert( ThData[i].Status == 0 );
269 if ( ThData[i].Id >= 0 )
276 assert( nCountFanins > 0 );
284 ThData[i].Status = 1;
291 printf(
"%d -> %d ", k, iFan );
298 for ( i = 0; i < nProcs; i++ )
299 if ( ThData[i].Status )
304 for ( i = 0; i < nProcs; i++ )
306 assert( ThData[i].Status == 0 );
308 ThData[i].Status = 1;
329 void Gia_ParTest(
Gia_Man_t * p,
int nWords,
int nProcs )
332 printf(
"Trying with %d words and %d threads. ", nWords, nProcs );
333 printf(
"Memory usage = %.2f MB\n", (8.0*nWords*
Gia_ManObjNum(p))/(1<<20) );
336 Gia_ParTestSimulate( p, nWords );
340 Gia_ParTestSimulate2( p, nWords, nProcs );
348 #endif // pthreads are used
#define Gia_ManForEachCo(p, pObj, i)
static int Gia_ObjFaninC1(Gia_Obj_t *pObj)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
static void Abc_TtPrintHexRev(FILE *pFile, word *pTruth, int nVars)
static int Gia_ObjIsConst0(Gia_Obj_t *pObj)
#define Vec_IntForEachEntryReverse(vVec, pEntry, i)
static ABC_NAMESPACE_IMPL_START void Gia_ParTestAlloc(Gia_Man_t *p, int nWords)
DECLARATIONS ///.
#define ABC_ALLOC(type, num)
static abctime Abc_Clock()
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
static word * Gia_ParTestObj(Gia_Man_t *p, int Id)
for(p=first;p->value< newval;p=p->next)
unsigned Gia_ManRandom(int fReset)
FUNCTION DEFINITIONS ///.
#define Gia_ManForEachCi(p, pObj, i)
static void Abc_PrintTime(int level, const char *pStr, abctime time)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
void Gia_ManStaticFanoutStop(Gia_Man_t *p)
static int Vec_IntEntry(Vec_Int_t *p, int i)
unsigned __int64 word
DECLARATIONS ///.
#define ABC_NAMESPACE_IMPL_END
static void Gia_ParTestFree(Gia_Man_t *p)
void Gia_ManStaticFanoutStart(Gia_Man_t *p)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
#define Gia_ObjForEachFanoutStaticId(p, Id, FanId, i)
void Gia_ObjPrint(Gia_Man_t *p, Gia_Obj_t *pObj)
word Gia_ManRandomW(int fReset)
static int Gia_ObjIsCo(Gia_Obj_t *pObj)
#define ABC_NAMESPACE_IMPL_START
static int Vec_IntSize(Vec_Int_t *p)
static int Vec_IntSum(Vec_Int_t *p)
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
static int Gia_ObjFaninC0(Gia_Obj_t *pObj)
static void Vec_IntFree(Vec_Int_t *p)
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
static int Gia_ObjFaninId1(Gia_Obj_t *pObj, int ObjId)
static int Gia_ManObjNum(Gia_Man_t *p)
static int Gia_ObjFaninId0(Gia_Obj_t *pObj, int ObjId)