Commit 52015095 by Alan Mishchenko

Improvements to the new technology mapper.

parent 2a39b635
...@@ -241,6 +241,7 @@ struct Jf_Par_t_ ...@@ -241,6 +241,7 @@ struct Jf_Par_t_
int nRounds; int nRounds;
int DelayTarget; int DelayTarget;
int fAreaOnly; int fAreaOnly;
int fCoarsen;
int fVerbose; int fVerbose;
int fVeryVerbose; int fVeryVerbose;
int nLutSizeMax; int nLutSizeMax;
...@@ -1204,6 +1205,7 @@ extern Vec_Int_t * Gia_ManGetDangling( Gia_Man_t * p ); ...@@ -1204,6 +1205,7 @@ extern Vec_Int_t * Gia_ManGetDangling( Gia_Man_t * p );
extern void Gia_ObjPrint( Gia_Man_t * p, Gia_Obj_t * pObj ); extern void Gia_ObjPrint( Gia_Man_t * p, Gia_Obj_t * pObj );
extern void Gia_ManPrint( Gia_Man_t * p ); extern void Gia_ManPrint( Gia_Man_t * p );
extern void Gia_ManPrintCo( Gia_Man_t * p, Gia_Obj_t * pObj ); extern void Gia_ManPrintCo( Gia_Man_t * p, Gia_Obj_t * pObj );
extern void Gia_ManPrintCone( Gia_Man_t * p, Gia_Obj_t * pObj, int * pLeaves, int nLeaves, Vec_Int_t * vNodes );
extern void Gia_ManInvertConstraints( Gia_Man_t * pAig ); extern void Gia_ManInvertConstraints( Gia_Man_t * pAig );
extern void Gia_ManInvertPos( Gia_Man_t * pAig ); extern void Gia_ManInvertPos( Gia_Man_t * pAig );
extern int Gia_ManCompare( Gia_Man_t * p1, Gia_Man_t * p2 ); extern int Gia_ManCompare( Gia_Man_t * p1, Gia_Man_t * p2 );
......
...@@ -55,6 +55,7 @@ struct Jf_Man_t_ ...@@ -55,6 +55,7 @@ struct Jf_Man_t_
float (*pCutCmp) (Jf_Cut_t *, Jf_Cut_t *);// procedure to compare cuts float (*pCutCmp) (Jf_Cut_t *, Jf_Cut_t *);// procedure to compare cuts
abctime clkStart; // starting time abctime clkStart; // starting time
word CutCount[4]; // statistics word CutCount[4]; // statistics
int nCoarse; // coarse nodes
}; };
static inline int Jf_ObjCutH( Jf_Man_t * p, int i ) { return Vec_IntEntry(&p->vCuts, i); } static inline int Jf_ObjCutH( Jf_Man_t * p, int i ) { return Vec_IntEntry(&p->vCuts, i); }
...@@ -82,8 +83,9 @@ static inline float Jf_ObjRefs( Jf_Man_t * p, int i ) { return Vec_FltEntry( ...@@ -82,8 +83,9 @@ static inline float Jf_ObjRefs( Jf_Man_t * p, int i ) { return Vec_FltEntry(
SeeAlso [] SeeAlso []
***********************************************************************/ ***********************************************************************/
float * Jf_ManInitRefs( Gia_Man_t * p ) float * Jf_ManInitRefs( Jf_Man_t * pMan )
{ {
Gia_Man_t * p = pMan->pGia;
Gia_Obj_t * pObj, * pCtrl, * pData0, * pData1; Gia_Obj_t * pObj, * pCtrl, * pData0, * pData1;
float * pRes; int i; float * pRes; int i;
assert( p->pRefs == NULL ); assert( p->pRefs == NULL );
...@@ -104,6 +106,20 @@ float * Jf_ManInitRefs( Gia_Man_t * p ) ...@@ -104,6 +106,20 @@ float * Jf_ManInitRefs( Gia_Man_t * p )
} }
Gia_ManForEachCo( p, pObj, i ) Gia_ManForEachCo( p, pObj, i )
Gia_ObjRefFanin0Inc( p, pObj ); Gia_ObjRefFanin0Inc( p, pObj );
// mark XOR/MUX internal nodes, which are not used elsewhere
if ( pMan->pPars->fCoarsen )
{
pMan->nCoarse = 0;
Gia_ManForEachAnd( p, pObj, i )
{
if ( Gia_ObjIsBuf(pObj) || !Gia_ObjIsMuxType(pObj) )
continue;
if ( Gia_ObjRefNum(p, Gia_ObjFanin0(pObj)) == 1 )
Gia_ObjFanin0(pObj)->fMark0 = 1, pMan->nCoarse++;
if ( Gia_ObjRefNum(p, Gia_ObjFanin1(pObj)) == 1 )
Gia_ObjFanin1(pObj)->fMark0 = 1, pMan->nCoarse++;
}
}
// multiply by factor // multiply by factor
pRes = ABC_ALLOC( float, Gia_ManObjNum(p) ); pRes = ABC_ALLOC( float, Gia_ManObjNum(p) );
for ( i = 0; i < Gia_ManObjNum(p); i++ ) for ( i = 0; i < Gia_ManObjNum(p); i++ )
...@@ -136,7 +152,7 @@ Jf_Man_t * Jf_ManAlloc( Gia_Man_t * pGia, Jf_Par_t * pPars ) ...@@ -136,7 +152,7 @@ Jf_Man_t * Jf_ManAlloc( Gia_Man_t * pGia, Jf_Par_t * pPars )
Vec_IntFill( &p->vDep, Gia_ManObjNum(pGia), 0 ); Vec_IntFill( &p->vDep, Gia_ManObjNum(pGia), 0 );
Vec_FltFill( &p->vFlow, Gia_ManObjNum(pGia), 0 ); Vec_FltFill( &p->vFlow, Gia_ManObjNum(pGia), 0 );
p->vRefs.nCap = p->vRefs.nSize = Gia_ManObjNum(pGia); p->vRefs.nCap = p->vRefs.nSize = Gia_ManObjNum(pGia);
p->vRefs.pArray = Jf_ManInitRefs( pGia ); p->vRefs.pArray = Jf_ManInitRefs( p );
Vec_SetAlloc_( &p->pMem, 20 ); Vec_SetAlloc_( &p->pMem, 20 );
p->vTemp = Vec_IntAlloc( 1000 ); p->vTemp = Vec_IntAlloc( 1000 );
p->clkStart = Abc_Clock(); p->clkStart = Abc_Clock();
...@@ -144,6 +160,8 @@ Jf_Man_t * Jf_ManAlloc( Gia_Man_t * pGia, Jf_Par_t * pPars ) ...@@ -144,6 +160,8 @@ Jf_Man_t * Jf_ManAlloc( Gia_Man_t * pGia, Jf_Par_t * pPars )
} }
void Jf_ManFree( Jf_Man_t * p ) void Jf_ManFree( Jf_Man_t * p )
{ {
if ( p->pPars->fCoarsen )
Gia_ManCleanMark0( p->pGia );
ABC_FREE( p->pGia->pRefs ); ABC_FREE( p->pGia->pRefs );
ABC_FREE( p->vCuts.pArray ); ABC_FREE( p->vCuts.pArray );
ABC_FREE( p->vArr.pArray ); ABC_FREE( p->vArr.pArray );
...@@ -181,6 +199,13 @@ static inline void Jf_ObjCutPrint( int * pCuts ) ...@@ -181,6 +199,13 @@ static inline void Jf_ObjCutPrint( int * pCuts )
Jf_CutPrint( pCut ); Jf_CutPrint( pCut );
printf( "\n" ); printf( "\n" );
} }
static inline void Jf_ObjBestCutConePrint( Jf_Man_t * p, Gia_Obj_t * pObj )
{
int * pCut = Jf_ObjCutBest( p, Gia_ObjId(p->pGia, pObj) );
printf( "Best cut of node %d : ", Gia_ObjId(p->pGia, pObj) );
Jf_CutPrint( pCut );
Gia_ManPrintCone( p->pGia, pObj, pCut+1, pCut[0], p->vTemp );
}
static inline unsigned Jf_CutGetSign( int * pCut ) static inline unsigned Jf_CutGetSign( int * pCut )
{ {
unsigned Sign = 0; int i; unsigned Sign = 0; int i;
...@@ -506,6 +531,21 @@ void Jf_ObjComputeCuts( Jf_Man_t * p, Gia_Obj_t * pObj ) ...@@ -506,6 +531,21 @@ void Jf_ObjComputeCuts( Jf_Man_t * p, Gia_Obj_t * pObj )
c = Jf_ObjAddCutToStore( p, pSto, c, CutNum ); c = Jf_ObjAddCutToStore( p, pSto, c, CutNum );
assert( c <= CutNum ); assert( c <= CutNum );
} }
// fix the case when both fanins have no unit cuts
if ( c == 0 )
{
assert( !pObj->fMark0 );
assert( Gia_ObjFanin0(pObj)->fMark0 );
assert( Gia_ObjFanin1(pObj)->fMark0 );
Vec_IntClear( p->vTemp );
Vec_IntPushUnique( p->vTemp, Gia_ObjFaninId0p(p->pGia, Gia_ObjFanin0(pObj)) );
Vec_IntPushUnique( p->vTemp, Gia_ObjFaninId1p(p->pGia, Gia_ObjFanin0(pObj)) );
Vec_IntPushUnique( p->vTemp, Gia_ObjFaninId0p(p->pGia, Gia_ObjFanin1(pObj)) );
Vec_IntPushUnique( p->vTemp, Gia_ObjFaninId1p(p->pGia, Gia_ObjFanin1(pObj)) );
pSto[c]->pCut[0] = Vec_IntSize(p->vTemp);
memcpy( pSto[c]->pCut + 1, Vec_IntArray(p->vTemp), sizeof(int) * Vec_IntSize(p->vTemp) );
c++;
}
// Jf_ObjCheckPtrs( pSto, CutNum ); // Jf_ObjCheckPtrs( pSto, CutNum );
// Jf_ObjCheckStore( p, pSto, c, iObj ); // Jf_ObjCheckStore( p, pSto, c, iObj );
p->CutCount[3] += c; p->CutCount[3] += c;
...@@ -553,6 +593,8 @@ void Jf_ManComputeCuts( Jf_Man_t * p ) ...@@ -553,6 +593,8 @@ void Jf_ManComputeCuts( Jf_Man_t * p )
printf( "Gia = %.2f MB ", Gia_ManMemory(p->pGia) / (1<<20) ); printf( "Gia = %.2f MB ", Gia_ManMemory(p->pGia) / (1<<20) );
printf( "Man = %.2f MB ", 6.0 * sizeof(int) * Gia_ManObjNum(p->pGia) / (1<<20) ); printf( "Man = %.2f MB ", 6.0 * sizeof(int) * Gia_ManObjNum(p->pGia) / (1<<20) );
printf( "Cuts = %.2f MB", Vec_ReportMemory(&p->pMem) / (1<<20) ); printf( "Cuts = %.2f MB", Vec_ReportMemory(&p->pMem) / (1<<20) );
if ( p->nCoarse )
printf( " Coarse = %d (%.1f %%)", p->nCoarse, 100.0 * p->nCoarse / Gia_ManObjNum(p->pGia) );
printf( "\n" ); printf( "\n" );
} }
} }
...@@ -603,6 +645,7 @@ int Jf_ManComputeRefs( Jf_Man_t * p ) ...@@ -603,6 +645,7 @@ int Jf_ManComputeRefs( Jf_Man_t * p )
Gia_ObjRefInc( p->pGia, Gia_ObjFanin0(pObj) ); Gia_ObjRefInc( p->pGia, Gia_ObjFanin0(pObj) );
else if ( Gia_ObjIsAnd(pObj) && Gia_ObjRefNum(p->pGia, pObj) > 0 ) else if ( Gia_ObjIsAnd(pObj) && Gia_ObjRefNum(p->pGia, pObj) > 0 )
{ {
assert( !pObj->fMark0 );
Jf_CutRef( p, Jf_ObjCutBest(p, i) ); Jf_CutRef( p, Jf_ObjCutBest(p, i) );
p->pPars->Edge += Jf_ObjCutBest(p, i)[0]; p->pPars->Edge += Jf_ObjCutBest(p, i)[0];
p->pPars->Area++; p->pPars->Area++;
...@@ -654,7 +697,7 @@ void Jf_ManPropagateFlow( Jf_Man_t * p, int fEdge ) ...@@ -654,7 +697,7 @@ void Jf_ManPropagateFlow( Jf_Man_t * p, int fEdge )
Gia_ManForEachObj( p->pGia, pObj, i ) Gia_ManForEachObj( p->pGia, pObj, i )
if ( Gia_ObjIsBuf(pObj) ) if ( Gia_ObjIsBuf(pObj) )
Jf_ObjPropagateBuf( p, pObj, 0 ); Jf_ObjPropagateBuf( p, pObj, 0 );
else if ( Gia_ObjIsAnd(pObj) ) else if ( Gia_ObjIsAnd(pObj) && !pObj->fMark0 )
Jf_ObjComputeBestCut( p, pObj, fEdge, 0 ); Jf_ObjComputeBestCut( p, pObj, fEdge, 0 );
Jf_ManComputeRefs( p ); Jf_ManComputeRefs( p );
} }
...@@ -668,6 +711,7 @@ void Jf_ManPropagateEla( Jf_Man_t * p, int fEdge ) ...@@ -668,6 +711,7 @@ void Jf_ManPropagateEla( Jf_Man_t * p, int fEdge )
Jf_ObjPropagateBuf( p, pObj, 1 ); Jf_ObjPropagateBuf( p, pObj, 1 );
else if ( Gia_ObjIsAnd(pObj) && Gia_ObjRefNum(p->pGia, pObj) > 0 ) else if ( Gia_ObjIsAnd(pObj) && Gia_ObjRefNum(p->pGia, pObj) > 0 )
{ {
assert( !pObj->fMark0 );
CostBef = Jf_CutDeref_rec( p, Jf_ObjCutBest(p, i), fEdge, ABC_INFINITY ); CostBef = Jf_CutDeref_rec( p, Jf_ObjCutBest(p, i), fEdge, ABC_INFINITY );
Jf_ObjComputeBestCut( p, pObj, fEdge, 1 ); Jf_ObjComputeBestCut( p, pObj, fEdge, 1 );
CostAft = Jf_CutRef_rec( p, Jf_ObjCutBest(p, i), fEdge, ABC_INFINITY ); CostAft = Jf_CutRef_rec( p, Jf_ObjCutBest(p, i), fEdge, ABC_INFINITY );
...@@ -716,6 +760,7 @@ void Jf_ManSetDefaultPars( Jf_Par_t * pPars ) ...@@ -716,6 +760,7 @@ void Jf_ManSetDefaultPars( Jf_Par_t * pPars )
pPars->nRounds = 1; pPars->nRounds = 1;
pPars->DelayTarget = -1; pPars->DelayTarget = -1;
pPars->fAreaOnly = 1; pPars->fAreaOnly = 1;
pPars->fCoarsen = 1;
pPars->fVerbose = 0; pPars->fVerbose = 0;
pPars->fVeryVerbose = 0; pPars->fVeryVerbose = 0;
pPars->nLutSizeMax = JF_LEAF_MAX; pPars->nLutSizeMax = JF_LEAF_MAX;
......
...@@ -1138,6 +1138,10 @@ void Gia_ObjPrint( Gia_Man_t * p, Gia_Obj_t * pObj ) ...@@ -1138,6 +1138,10 @@ void Gia_ObjPrint( Gia_Man_t * p, Gia_Obj_t * pObj )
Gia_ObjFaninId1p(p, pObj), (Gia_ObjFaninC1(pObj)? "\'" : " ") ); Gia_ObjFaninId1p(p, pObj), (Gia_ObjFaninC1(pObj)? "\'" : " ") );
if ( p->pRefs ) if ( p->pRefs )
printf( " (refs = %3d)", Gia_ObjRefNum(p, pObj) ); printf( " (refs = %3d)", Gia_ObjRefNum(p, pObj) );
if ( pObj->fMark0 )
printf( " mark0" );
if ( pObj->fMark1 )
printf( " mark1" );
printf( "\n" ); printf( "\n" );
/* /*
if ( p->pRefs ) if ( p->pRefs )
...@@ -1189,6 +1193,26 @@ void Gia_ManPrintCo( Gia_Man_t * p, Gia_Obj_t * pObj ) ...@@ -1189,6 +1193,26 @@ void Gia_ManPrintCo( Gia_Man_t * p, Gia_Obj_t * pObj )
Gia_ManPrintCo_rec( p, Gia_ObjFanin0(pObj) ); Gia_ManPrintCo_rec( p, Gia_ObjFanin0(pObj) );
Gia_ObjPrint( p, pObj ); Gia_ObjPrint( p, pObj );
} }
void Gia_ManPrintCollect_rec( Gia_Man_t * p, Gia_Obj_t * pObj, Vec_Int_t * vNodes )
{
if ( Vec_IntFind(vNodes, Gia_ObjId(p, pObj)) >= 0 )
return;
assert( Gia_ObjIsAnd(pObj) );
Gia_ManPrintCollect_rec( p, Gia_ObjFanin0(pObj), vNodes );
Gia_ManPrintCollect_rec( p, Gia_ObjFanin1(pObj), vNodes );
Vec_IntPush( vNodes, Gia_ObjId(p, pObj) );
}
void Gia_ManPrintCone( Gia_Man_t * p, Gia_Obj_t * pObj, int * pLeaves, int nLeaves, Vec_Int_t * vNodes )
{
int i;
Vec_IntClear( vNodes );
for ( i = 0; i < nLeaves; i++ )
Vec_IntPush( vNodes, pLeaves[i] );
Gia_ManPrintCollect_rec( p, pObj, vNodes );
printf( "GIA logic cone for node %d:\n", Gia_ObjId(p, pObj) );
Gia_ManForEachObjVec( vNodes, p, pObj, i )
Gia_ObjPrint( p, pObj );
}
/**Function************************************************************* /**Function*************************************************************
......
...@@ -29825,7 +29825,7 @@ int Abc_CommandAbc9Jf( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -29825,7 +29825,7 @@ int Abc_CommandAbc9Jf( Abc_Frame_t * pAbc, int argc, char ** argv )
int c; int c;
Jf_ManSetDefaultPars( pPars ); Jf_ManSetDefaultPars( pPars );
Extra_UtilGetoptReset(); Extra_UtilGetoptReset();
while ( ( c = Extra_UtilGetopt( argc, argv, "KCRDavwh" ) ) != EOF ) while ( ( c = Extra_UtilGetopt( argc, argv, "KCRDacvwh" ) ) != EOF )
{ {
switch ( c ) switch ( c )
{ {
...@@ -29882,6 +29882,9 @@ int Abc_CommandAbc9Jf( Abc_Frame_t * pAbc, int argc, char ** argv ) ...@@ -29882,6 +29882,9 @@ int Abc_CommandAbc9Jf( Abc_Frame_t * pAbc, int argc, char ** argv )
case 'a': case 'a':
pPars->fAreaOnly ^= 1; pPars->fAreaOnly ^= 1;
break; break;
case 'c':
pPars->fCoarsen ^= 1;
break;
case 'v': case 'v':
pPars->fVerbose ^= 1; pPars->fVerbose ^= 1;
break; break;
...@@ -29907,13 +29910,14 @@ usage: ...@@ -29907,13 +29910,14 @@ usage:
sprintf(Buffer, "best possible" ); sprintf(Buffer, "best possible" );
else else
sprintf(Buffer, "%d", pPars->DelayTarget ); sprintf(Buffer, "%d", pPars->DelayTarget );
Abc_Print( -2, "usage: &jf [-KCRD num] [-avwh]\n" ); Abc_Print( -2, "usage: &jf [-KCRD num] [-acvwh]\n" );
Abc_Print( -2, "\t performs technology mapping of the network\n" ); Abc_Print( -2, "\t performs technology mapping of the network\n" );
Abc_Print( -2, "\t-K num : LUT size for the mapping (2 <= K <= %d) [default = %d]\n", pPars->nLutSizeMax, pPars->nLutSize ); Abc_Print( -2, "\t-K num : LUT size for the mapping (2 <= K <= %d) [default = %d]\n", pPars->nLutSizeMax, pPars->nLutSize );
Abc_Print( -2, "\t-C num : the max number of priority cuts (1 <= C <= %d) [default = %d]\n", pPars->nCutNumMax, pPars->nCutNum ); Abc_Print( -2, "\t-C num : the max number of priority cuts (1 <= C <= %d) [default = %d]\n", pPars->nCutNumMax, pPars->nCutNum );
Abc_Print( -2, "\t-R num : the number of mapping rounds [default = %d]\n", pPars->nRounds ); Abc_Print( -2, "\t-R num : the number of mapping rounds [default = %d]\n", pPars->nRounds );
Abc_Print( -2, "\t-D num : sets the delay constraint for the mapping [default = %s]\n", Buffer ); Abc_Print( -2, "\t-D num : sets the delay constraint for the mapping [default = %s]\n", Buffer );
Abc_Print( -2, "\t-a : toggles area-oriented mapping [default = %s]\n", pPars->fAreaOnly? "yes": "no" ); Abc_Print( -2, "\t-a : toggles area-oriented mapping [default = %s]\n", pPars->fAreaOnly? "yes": "no" );
Abc_Print( -2, "\t-c : toggles coarsening the subject graph [default = %s]\n", pPars->fCoarsen? "yes": "no" );
Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" ); Abc_Print( -2, "\t-v : toggles verbose output [default = %s]\n", pPars->fVerbose? "yes": "no" );
Abc_Print( -2, "\t-w : toggles very verbose output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" ); Abc_Print( -2, "\t-w : toggles very verbose output [default = %s]\n", pPars->fVeryVerbose? "yes": "no" );
Abc_Print( -2, "\t-h : prints the command usage\n"); Abc_Print( -2, "\t-h : prints the command usage\n");
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