Commit 8826ed6d by Alan Mishchenko

Experiments with simulation.

parent c7c3aa3f
...@@ -206,19 +206,16 @@ typedef struct Par_ThData_t_ ...@@ -206,19 +206,16 @@ typedef struct Par_ThData_t_
int Id; int Id;
int Status; int Status;
} Par_ThData_t; } Par_ThData_t;
//pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER;
void * Gia_ParWorkerThread( void * pArg ) void * Gia_ParWorkerThread( void * pArg )
{ {
Par_ThData_t * pThData = (Par_ThData_t *)pArg; Par_ThData_t * pThData = (Par_ThData_t *)pArg;
unsigned Counter = 0; volatile int * pPlace = &pThData->Status;
while ( 1 ) while ( 1 )
{ {
while ( pThData->Status == 0 ) while ( *pPlace == 0 );
printf( "" );
assert( pThData->Status == 1 ); assert( pThData->Status == 1 );
if ( pThData->Id == -1 ) if ( pThData->Id == -1 )
{ {
// printf( "Stopped\n" ); fflush( stdout );
pthread_exit( NULL ); pthread_exit( NULL );
assert( 0 ); assert( 0 );
return NULL; return NULL;
...@@ -227,7 +224,6 @@ void * Gia_ParWorkerThread( void * pArg ) ...@@ -227,7 +224,6 @@ void * Gia_ParWorkerThread( void * pArg )
Gia_ParTestSimulateObj( pThData->p, pThData->Id ); Gia_ParTestSimulateObj( pThData->p, pThData->Id );
pThData->Status = 0; pThData->Status = 0;
} }
assert( Counter != 0 );
assert( 0 ); assert( 0 );
return NULL; return NULL;
} }
...@@ -256,9 +252,8 @@ void Gia_ParTestSimulate2( Gia_Man_t * p, int nWords, int nProcs ) ...@@ -256,9 +252,8 @@ void Gia_ParTestSimulate2( Gia_Man_t * p, int nWords, int nProcs )
ThData[i].Id = -1; ThData[i].Id = -1;
ThData[i].Status = 0; ThData[i].Status = 0;
status = pthread_create( WorkerThread + i, NULL, Gia_ParWorkerThread, (void *)(ThData + i) ); assert( status == 0 ); status = pthread_create( WorkerThread + i, NULL, Gia_ParWorkerThread, (void *)(ThData + i) ); assert( status == 0 );
// printf( "Started %d\n", i ); fflush( stdout );
} }
while ( nCountFanins > 0 ) while ( nCountFanins > 0 || Vec_IntSize(vStack) > 0 )
{ {
for ( i = 0; i < nProcs; i++ ) for ( i = 0; i < nProcs; i++ )
{ {
...@@ -303,7 +298,6 @@ void Gia_ParTestSimulate2( Gia_Man_t * p, int nWords, int nProcs ) ...@@ -303,7 +298,6 @@ void Gia_ParTestSimulate2( Gia_Man_t * p, int nWords, int nProcs )
for ( i = 0; i < nProcs; i++ ) for ( i = 0; i < nProcs; i++ )
{ {
assert( ThData[i].Status == 0 ); assert( ThData[i].Status == 0 );
// printf( "Stopping %d\n", i ); fflush( stdout );
ThData[i].Id = -1; ThData[i].Id = -1;
ThData[i].Status = 1; ThData[i].Status = 1;
} }
...@@ -329,16 +323,16 @@ void Gia_ParTestSimulate2( Gia_Man_t * p, int nWords, int nProcs ) ...@@ -329,16 +323,16 @@ void Gia_ParTestSimulate2( Gia_Man_t * p, int nWords, int nProcs )
void Gia_ParTest( Gia_Man_t * p, int nWords, int nProcs ) void Gia_ParTest( Gia_Man_t * p, int nWords, int nProcs )
{ {
abctime clk; abctime clk;
printf( "Trying with %d words and %d threads.\n", nWords, nProcs ); printf( "Trying with %d words and %d threads. ", nWords, nProcs );
printf( "Memory usage = %.2f MB\n", (8.0*nWords*Gia_ManObjNum(p))/(1<<20) ); printf( "Memory usage = %.2f MB\n", (8.0*nWords*Gia_ManObjNum(p))/(1<<20) );
clk = Abc_Clock();
Gia_ParTestSimulate2( p, nWords, nProcs );
Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
clk = Abc_Clock(); clk = Abc_Clock();
Gia_ParTestSimulate( p, nWords ); Gia_ParTestSimulate( p, nWords );
Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); Abc_PrintTime( 1, "Regular time", Abc_Clock() - clk );
clk = Abc_Clock();
Gia_ParTestSimulate2( p, nWords, nProcs );
Abc_PrintTime( 1, "Special time", Abc_Clock() - clk );
} }
//////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment