Commit eae04552 by Alan Mishchenko

Experiments with simulation.

parent 550b769d
...@@ -25315,7 +25315,7 @@ int Abc_CommandAbc9Show( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -25315,7 +25315,7 @@ int Abc_CommandAbc9Show( Abc_Frame_t * pAbc, int argc, char ** argv )
Abc_Print( -1, "Abc_CommandAbc9Show(): There is no AIG.\n" ); Abc_Print( -1, "Abc_CommandAbc9Show(): There is no AIG.\n" );
return 1; return 1;
} }
pMan = Gia_ManToAig( pAbc->pGia, 0 ); pMan = Gia_ManToAigSimple( pAbc->pGia );
Aig_ManShow( pMan, 0, NULL ); Aig_ManShow( pMan, 0, NULL );
Aig_ManStop( pMan ); Aig_ManStop( pMan );
return 0; return 0;
...@@ -57,6 +57,43 @@ static inline void Gia_ParTestFree( Gia_Man_t * p ) { ABC_FREE( ...@@ -57,6 +57,43 @@ static inline void Gia_ParTestFree( Gia_Man_t * p ) { ABC_FREE(
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
void Gia_ParComputeSignature( Gia_Man_t * p, int nWords )
{
Gia_Obj_t * pObj;
word * pData, Sign = 0;
int i, k;
Gia_ManForEachCo( p, pObj, k )
{
pData = Gia_ParTestObj( p, Gia_ObjId(p, pObj) );
for ( i = 0; i < p->iData; i++ )
Sign ^= pData[i];
}
Abc_TtPrintHexRev( stdout, &Sign, 6 );
}
/**Function*************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Gia_ParTestSimulateInit( Gia_Man_t * p )
{
Gia_Obj_t * pObj;
word * pData;
int i, k;
Gia_ManForEachCi( p, pObj, k )
{
pData = Gia_ParTestObj( p, Gia_ObjId(p, pObj) );
for ( i = 0; i < p->iData; i++ )
pData[i] = Gia_ManRandomW( 0 );
}
}
void Gia_ParTestSimulateObj( Gia_Man_t * p, int Id ) void Gia_ParTestSimulateObj( Gia_Man_t * p, int Id )
{ {
Gia_Obj_t * pObj = Gia_ManObj( p, Id ); Gia_Obj_t * pObj = Gia_ManObj( p, Id );
...@@ -99,9 +136,6 @@ void Gia_ParTestSimulateObj( Gia_Man_t * p, int Id ) ...@@ -99,9 +136,6 @@ void Gia_ParTestSimulateObj( Gia_Man_t * p, int Id )
} }
else if ( Gia_ObjIsCi(pObj) ) else if ( Gia_ObjIsCi(pObj) )
{ {
pData = Gia_ParTestObj( p, Id );
for ( i = 0; i < p->iData; i++ )
pData[i] = Gia_ManRandomW( 0 );
} }
else if ( Gia_ObjIsConst0(pObj) ) else if ( Gia_ObjIsConst0(pObj) )
{ {
...@@ -117,8 +151,10 @@ void Gia_ParTestSimulate( Gia_Man_t * p, int nWords ) ...@@ -117,8 +151,10 @@ void Gia_ParTestSimulate( Gia_Man_t * p, int nWords )
int i; int i;
Gia_ManRandom( 1 ); Gia_ManRandom( 1 );
Gia_ParTestAlloc( p, nWords ); Gia_ParTestAlloc( p, nWords );
Gia_ParTestSimulateInit( p );
Gia_ManForEachObj( p, pObj, i ) Gia_ManForEachObj( p, pObj, i )
Gia_ParTestSimulateObj( p, i ); Gia_ParTestSimulateObj( p, i );
Gia_ParComputeSignature( p, nWords ); printf( " " );
Gia_ParTestFree( p ); Gia_ParTestFree( p );
} }
...@@ -189,7 +225,6 @@ void * Gia_ParWorkerThread( void * pArg ) ...@@ -189,7 +225,6 @@ void * Gia_ParWorkerThread( void * pArg )
} }
assert( pThData->Id >= 0 ); assert( pThData->Id >= 0 );
Gia_ParTestSimulateObj( pThData->p, pThData->Id ); Gia_ParTestSimulateObj( pThData->p, pThData->Id );
// printf( "Simulated %d \n", pThData->Id ); fflush( stdout );
pThData->Status = 0; pThData->Status = 0;
} }
assert( Counter != 0 ); assert( Counter != 0 );
...@@ -204,10 +239,11 @@ void Gia_ParTestSimulate2( Gia_Man_t * p, int nWords, int nProcs ) ...@@ -204,10 +239,11 @@ void Gia_ParTestSimulate2( Gia_Man_t * p, int nWords, int nProcs )
int i, k, iFan, status, nCountFanins; int i, k, iFan, status, nCountFanins;
Gia_ManRandom( 1 ); Gia_ManRandom( 1 );
Gia_ParTestAlloc( p, nWords ); Gia_ParTestAlloc( p, nWords );
Gia_ParTestSimulateInit( p );
// start the stack // start the stack
vStack = Vec_IntAlloc( 1000 ); vStack = Vec_IntAlloc( 1000 );
for ( i = Vec_IntSize(p->vCis) - 1; i >= 0; i-- ) Vec_IntForEachEntryReverse( p->vCis, iFan, i )
Vec_IntPush( vStack, Vec_IntEntry(p->vCis, i) ); Vec_IntPush( vStack, iFan );
Vec_IntPush( vStack, 0 ); Vec_IntPush( vStack, 0 );
Gia_ManStaticFanoutStart( p ); Gia_ManStaticFanoutStart( p );
vFanins = Gia_ManCreateFaninCounts( p ); vFanins = Gia_ManCreateFaninCounts( p );
...@@ -266,6 +302,7 @@ void Gia_ParTestSimulate2( Gia_Man_t * p, int nWords, int nProcs ) ...@@ -266,6 +302,7 @@ 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 );
// printf( "Stopping %d\n", i ); fflush( stdout ); // printf( "Stopping %d\n", i ); fflush( stdout );
ThData[i].Id = -1; ThData[i].Id = -1;
ThData[i].Status = 1; ThData[i].Status = 1;
...@@ -273,6 +310,7 @@ void Gia_ParTestSimulate2( Gia_Man_t * p, int nWords, int nProcs ) ...@@ -273,6 +310,7 @@ void Gia_ParTestSimulate2( Gia_Man_t * p, int nWords, int nProcs )
Gia_ManStaticFanoutStop( p ); Gia_ManStaticFanoutStop( p );
Vec_IntFree( vStack ); Vec_IntFree( vStack );
Vec_IntFree( vFanins ); Vec_IntFree( vFanins );
Gia_ParComputeSignature( p, nWords ); printf( " " );
Gia_ParTestFree( p ); Gia_ParTestFree( p );
} }
...@@ -293,10 +331,10 @@ void Gia_ParTest( Gia_Man_t * p, int nWords, int nProcs ) ...@@ -293,10 +331,10 @@ void Gia_ParTest( Gia_Man_t * p, int nWords, int nProcs )
abctime clk = Abc_Clock(); abctime clk = Abc_Clock();
printf( "Trying with %d words and %d procs.\n", nWords, nProcs ); printf( "Trying with %d words and %d procs.\n", 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) );
Gia_ParTestSimulate( p, nWords ); Gia_ParTestSimulate2( p, nWords, nProcs );
Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); Abc_PrintTime( 1, "Time", Abc_Clock() - clk );
clk = Abc_Clock(); clk = Abc_Clock();
Gia_ParTestSimulate2( p, nWords, nProcs ); Gia_ParTestSimulate( p, nWords );
Abc_PrintTime( 1, "Time", Abc_Clock() - clk ); Abc_PrintTime( 1, "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