Skip to content

Commit 078debf

Browse files
committed
Adding print-out of LUT mapping stats.
1 parent d245305 commit 078debf

File tree

5 files changed

+71
-2
lines changed

5 files changed

+71
-2
lines changed

src/aig/gia/gia.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ struct Gps_Par_t_
270270
int fSkipMap;
271271
int fSlacks;
272272
int fNoColor;
273+
int fMapOutStats;
273274
char * pDumpFile;
274275
};
275276

@@ -1508,6 +1509,7 @@ extern int Gia_ManHashAndMulti( Gia_Man_t * p, Vec_Int_t * vLits
15081509
extern int Gia_ManHashAndMulti2( Gia_Man_t * p, Vec_Int_t * vLits );
15091510
extern int Gia_ManHashDualMiter( Gia_Man_t * p, Vec_Int_t * vOuts );
15101511
/*=== giaIf.c ===========================================================*/
1512+
extern void Gia_ManPrintOutputLutStats( Gia_Man_t * p );
15111513
extern void Gia_ManPrintMappingStats( Gia_Man_t * p, char * pDumpFile );
15121514
extern void Gia_ManPrintPackingStats( Gia_Man_t * p );
15131515
extern void Gia_ManPrintLutStats( Gia_Man_t * p );

src/aig/gia/giaIf.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -470,6 +470,65 @@ int Gia_ManCountDupLut( Gia_Man_t * p )
470470
return nCountDup + nCountPis;
471471
}
472472

473+
void Gia_ManCollectLuts_rec( Gia_Man_t * p, int iObj, Vec_Int_t * vLuts )
474+
{
475+
if ( Gia_ObjIsTravIdCurrentId( p, iObj ) || !Gia_ObjIsAnd(Gia_ManObj(p, iObj)) )
476+
return;
477+
Gia_ObjSetTravIdCurrentId( p, iObj );
478+
int k, iFan;
479+
Gia_LutForEachFanin( p, iObj, iFan, k )
480+
Gia_ManCollectLuts_rec( p, iFan, vLuts );
481+
Vec_IntPush( vLuts, iObj );
482+
}
483+
int Gia_ManCountLutLevels( Gia_Man_t * p, Vec_Int_t * vLuts, Vec_Int_t * vLevel )
484+
{
485+
int i, iObj, k, iFan, LevelMax = 0;
486+
Vec_IntForEachEntry( vLuts, iObj, i ) {
487+
int Level = 0;
488+
Gia_LutForEachFanin( p, iObj, iFan, k )
489+
Level = Abc_MaxInt( Level, Vec_IntEntry(vLevel, iFan) );
490+
Vec_IntWriteEntry( vLevel, iObj, Level+1 );
491+
LevelMax = Abc_MaxInt( LevelMax, Level+1 );
492+
}
493+
Vec_IntForEachEntry( vLuts, iObj, i )
494+
Vec_IntWriteEntry( vLevel, iObj, 0 );
495+
return LevelMax;
496+
}
497+
void Gia_ManPrintOutputLutStats( Gia_Man_t * p )
498+
{
499+
int Limit = 100000;
500+
int nLutSize = Gia_ManLutSizeMax(p);
501+
Vec_Int_t * vLuts = Vec_IntAlloc( 1000 );
502+
Vec_Int_t * vNodes = Vec_IntStart( Limit );
503+
Vec_Int_t * vLevels = Vec_IntStart( Limit );
504+
Vec_Int_t * vLevel = Vec_IntStart( Gia_ManObjNum(p) );
505+
int i, DriverId, Value, nTotalLuts = 0;
506+
Gia_ManForEachCoDriverId( p, DriverId, i ) {
507+
Vec_IntClear( vLuts );
508+
Gia_ManIncrementTravId(p);
509+
Gia_ManCollectLuts_rec( p, DriverId, vLuts );
510+
if ( Vec_IntSize(vLuts) < Limit )
511+
Vec_IntAddToEntry( vNodes, Vec_IntSize(vLuts), 1 );
512+
int Level = Gia_ManCountLutLevels( p, vLuts, vLevel );
513+
if ( Level < Limit )
514+
Vec_IntAddToEntry( vLevels, Level, 1 );
515+
nTotalLuts += Vec_IntSize(vLuts);
516+
}
517+
printf( "Level count statistics for %d AIG outputs:\n", Gia_ManCoNum(p) );
518+
Vec_IntForEachEntry( vLevels, Value, i )
519+
if ( Value )
520+
printf( " %2d level : Function count = %8d (%6.2f %%)\n", i, Value, 100.0*Value/Gia_ManCoNum(p) );
521+
printf( "LUT count statistics for %d AIG outputs:\n", Gia_ManCoNum(p) );
522+
Vec_IntForEachEntry( vNodes, Value, i )
523+
if ( Value )
524+
printf( " %2d LUT%d : Function count = %8d (%6.2f %%)\n", i, nLutSize, Value, 100.0*Value/Gia_ManCoNum(p) );
525+
printf( "Sum total of LUT counts for all outputs = %d. Shared LUT count = %d.\n", nTotalLuts, Gia_ManLutNum(p) );
526+
Vec_IntFree( vLuts );
527+
Vec_IntFree( vNodes );
528+
Vec_IntFree( vLevels );
529+
Vec_IntFree( vLevel );
530+
}
531+
473532
void Gia_ManPrintMappingStats( Gia_Man_t * p, char * pDumpFile )
474533
{
475534
int fDisable2Lut = 1;

src/aig/gia/giaMan.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,8 @@ void Gia_ManPrintStats( Gia_Man_t * p, Gps_Par_t * pPars )
640640
}
641641
if ( pPars && pPars->fSlacks )
642642
Gia_ManDfsSlacksPrint( p );
643+
if ( Gia_ManHasMapping(p) && pPars->fMapOutStats )
644+
Gia_ManPrintOutputLutStats( p );
643645
}
644646

645647
/**Function*************************************************************

src/base/abc/abcSop.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1131,6 +1131,8 @@ Vec_Ptr_t * Abc_SopFromTruthsHex( char * pTruth )
11311131
char * pToken = strtok( pCopy, " \r\n\t|" );
11321132
while ( pToken )
11331133
{
1134+
if ( pToken[0] == '0' && pToken[1] == 'x' )
1135+
pToken += 2;
11341136
if ( !Abc_SopCheckReadTruth( vRes, pToken, 1 ) )
11351137
break;
11361138
Vec_PtrPush( vRes, Abc_SopFromTruthHex(pToken) );

src/base/abci/abc.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34444,7 +34444,7 @@ int Abc_CommandAbc9Ps( Abc_Frame_t * pAbc, int argc, char ** argv )
3444434444
int c, fBest = 0;
3444534445
memset( pPars, 0, sizeof(Gps_Par_t) );
3444634446
Extra_UtilGetoptReset();
34447-
while ( ( c = Extra_UtilGetopt( argc, argv, "Dtpcnlmaszxbh" ) ) != EOF )
34447+
while ( ( c = Extra_UtilGetopt( argc, argv, "Dtpcnlmasozxbh" ) ) != EOF )
3444834448
{
3444934449
switch ( c )
3445034450
{
@@ -34472,6 +34472,9 @@ int Abc_CommandAbc9Ps( Abc_Frame_t * pAbc, int argc, char ** argv )
3447234472
case 's':
3447334473
pPars->fSlacks ^= 1;
3447434474
break;
34475+
case 'o':
34476+
pPars->fMapOutStats ^= 1;
34477+
break;
3447534478
case 'z':
3447634479
pPars->fSkipMap ^= 1;
3447734480
break;
@@ -34517,7 +34520,7 @@ int Abc_CommandAbc9Ps( Abc_Frame_t * pAbc, int argc, char ** argv )
3451734520
return 0;
3451834521

3451934522
usage:
34520-
Abc_Print( -2, "usage: &ps [-tpcnlmaszxbh] [-D file]\n" );
34523+
Abc_Print( -2, "usage: &ps [-tpcnlmasozxbh] [-D file]\n" );
3452134524
Abc_Print( -2, "\t prints stats of the current AIG\n" );
3452234525
Abc_Print( -2, "\t-t : toggle printing BMC tents [default = %s]\n", pPars->fTents? "yes": "no" );
3452334526
Abc_Print( -2, "\t-p : toggle printing switching activity [default = %s]\n", pPars->fSwitch? "yes": "no" );
@@ -34527,6 +34530,7 @@ int Abc_CommandAbc9Ps( Abc_Frame_t * pAbc, int argc, char ** argv )
3452734530
Abc_Print( -2, "\t-m : toggle printing MUX/XOR statistics [default = %s]\n", pPars->fMuxXor? "yes": "no" );
3452834531
Abc_Print( -2, "\t-a : toggle printing miter statistics [default = %s]\n", pPars->fMiter? "yes": "no" );
3452934532
Abc_Print( -2, "\t-s : toggle printing slack distribution [default = %s]\n", pPars->fSlacks? "yes": "no" );
34533+
Abc_Print( -2, "\t-o : toggle printing mapping output stats [default = %s]\n", pPars->fMapOutStats? "yes": "no" );
3453034534
Abc_Print( -2, "\t-z : skip mapping statistics even if mapped [default = %s]\n", pPars->fSkipMap? "yes": "no" );
3453134535
Abc_Print( -2, "\t-x : toggle using no color in the printout [default = %s]\n", pPars->fNoColor? "yes": "no" );
3453234536
Abc_Print( -2, "\t-b : toggle printing saved AIG statistics [default = %s]\n", fBest? "yes": "no" );

0 commit comments

Comments
 (0)