From 8826ed6d4f2403c2ff71596cb5a16a8be0c60104 Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Fri, 14 Mar 2014 22:08:33 -0700 Subject: Experiments with simulation. --- src/map/if/ifTest.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) (limited to 'src/map/if/ifTest.c') diff --git a/src/map/if/ifTest.c b/src/map/if/ifTest.c index f8ac8423..bbadaca2 100644 --- a/src/map/if/ifTest.c +++ b/src/map/if/ifTest.c @@ -206,19 +206,16 @@ typedef struct Par_ThData_t_ int Id; int Status; } Par_ThData_t; -//pthread_mutex_t g_mutex = PTHREAD_MUTEX_INITIALIZER; void * Gia_ParWorkerThread( void * pArg ) { Par_ThData_t * pThData = (Par_ThData_t *)pArg; - unsigned Counter = 0; + volatile int * pPlace = &pThData->Status; while ( 1 ) { - while ( pThData->Status == 0 ) - printf( "" ); + while ( *pPlace == 0 ); assert( pThData->Status == 1 ); if ( pThData->Id == -1 ) { -// printf( "Stopped\n" ); fflush( stdout ); pthread_exit( NULL ); assert( 0 ); return NULL; @@ -227,7 +224,6 @@ void * Gia_ParWorkerThread( void * pArg ) Gia_ParTestSimulateObj( pThData->p, pThData->Id ); pThData->Status = 0; } - assert( Counter != 0 ); assert( 0 ); return NULL; } @@ -256,9 +252,8 @@ void Gia_ParTestSimulate2( Gia_Man_t * p, int nWords, int nProcs ) ThData[i].Id = -1; ThData[i].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++ ) { @@ -303,7 +298,6 @@ void Gia_ParTestSimulate2( Gia_Man_t * p, int nWords, int nProcs ) for ( i = 0; i < nProcs; i++ ) { assert( ThData[i].Status == 0 ); -// printf( "Stopping %d\n", i ); fflush( stdout ); ThData[i].Id = -1; ThData[i].Status = 1; } @@ -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 ) { 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) ); - - clk = Abc_Clock(); - Gia_ParTestSimulate2( p, nWords, nProcs ); - Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); clk = Abc_Clock(); 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 ); } //////////////////////////////////////////////////////////////////////// -- cgit v1.2.3