Commit 32217230 by Alan Mishchenko

Performance improvement in &gla_refine.

parent 3bd0420b
...@@ -752,8 +752,7 @@ extern Gia_Man_t * Gia_ManChoiceMiter( Vec_Ptr_t * vGias ); ...@@ -752,8 +752,7 @@ extern Gia_Man_t * Gia_ManChoiceMiter( Vec_Ptr_t * vGias );
extern Gia_Man_t * Gia_ManDupWithConstraints( Gia_Man_t * p, Vec_Int_t * vPoTypes ); extern Gia_Man_t * Gia_ManDupWithConstraints( Gia_Man_t * p, Vec_Int_t * vPoTypes );
extern Gia_Man_t * Gia_ManDupAbsFlops( Gia_Man_t * p, Vec_Int_t * vFlopClasses ); extern Gia_Man_t * Gia_ManDupAbsFlops( Gia_Man_t * p, Vec_Int_t * vFlopClasses );
extern Gia_Man_t * Gia_ManDupAbsGates( Gia_Man_t * p, Vec_Int_t * vGateClasses ); extern Gia_Man_t * Gia_ManDupAbsGates( Gia_Man_t * p, Vec_Int_t * vGateClasses );
extern Vec_Int_t * Gia_GlaCollectAssigned( Gia_Man_t * p, Vec_Int_t * vGateClasses ); extern void Gia_ManGlaCollect( Gia_Man_t * p, Vec_Int_t * vGateClasses, Vec_Int_t ** pvPis, Vec_Int_t ** pvPPis, Vec_Int_t ** pvFlops, Vec_Int_t ** pvNodes );
extern void Gia_GlaCollectInputs( Gia_Man_t * p, Vec_Int_t * vGateClasses, Vec_Int_t ** pvPis, Vec_Int_t ** pvPPis );
extern Gia_Man_t * Gia_ManDupCones( Gia_Man_t * p, int * pPos, int nPos, int fTrimPis ); extern Gia_Man_t * Gia_ManDupCones( Gia_Man_t * p, int * pPos, int nPos, int fTrimPis );
/*=== giaEnable.c ==========================================================*/ /*=== giaEnable.c ==========================================================*/
extern void Gia_ManDetectSeqSignals( Gia_Man_t * p, int fSetReset, int fVerbose ); extern void Gia_ManDetectSeqSignals( Gia_Man_t * p, int fSetReset, int fVerbose );
......
...@@ -1664,6 +1664,83 @@ Gia_Man_t * Gia_ManDupAbsFlops( Gia_Man_t * p, Vec_Int_t * vFlopClasses ) ...@@ -1664,6 +1664,83 @@ Gia_Man_t * Gia_ManDupAbsFlops( Gia_Man_t * p, Vec_Int_t * vFlopClasses )
/**Function************************************************************* /**Function*************************************************************
Synopsis [Returns the array of neighbors.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Int_t * Gia_GlaCollectAssigned( Gia_Man_t * p, Vec_Int_t * vGateClasses )
{
Vec_Int_t * vAssigned;
Gia_Obj_t * pObj;
int i, Entry;
vAssigned = Vec_IntAlloc( 1000 );
Vec_IntForEachEntry( vGateClasses, Entry, i )
{
if ( Entry == 0 )
continue;
assert( Entry == 1 );
pObj = Gia_ManObj( p, i );
Vec_IntPush( vAssigned, Gia_ObjId(p, pObj) );
if ( Gia_ObjIsAnd(pObj) )
{
Vec_IntPush( vAssigned, Gia_ObjFaninId0p(p, pObj) );
Vec_IntPush( vAssigned, Gia_ObjFaninId1p(p, pObj) );
}
else if ( Gia_ObjIsRo(p, pObj) )
Vec_IntPush( vAssigned, Gia_ObjFaninId0p(p, Gia_ObjRoToRi(p, pObj)) );
else assert( Gia_ObjIsConst0(pObj) );
}
Vec_IntUniqify( vAssigned );
return vAssigned;
}
/**Function*************************************************************
Synopsis [Collects PIs and PPIs of the abstraction.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Gia_ManGlaCollect( Gia_Man_t * p, Vec_Int_t * vGateClasses, Vec_Int_t ** pvPis, Vec_Int_t ** pvPPis, Vec_Int_t ** pvFlops, Vec_Int_t ** pvNodes )
{
Vec_Int_t * vAssigned;
Gia_Obj_t * pObj;
int i;
assert( Gia_ManPoNum(p) == 1 );
assert( Vec_IntSize(vGateClasses) == Gia_ManObjNum(p) );
// create included objects and their fanins
vAssigned = Gia_GlaCollectAssigned( p, vGateClasses );
// create additional arrays
if ( pvPis ) *pvPis = Vec_IntAlloc( 100 );
if ( pvPPis ) *pvPPis = Vec_IntAlloc( 100 );
if ( pvFlops ) *pvFlops = Vec_IntAlloc( 100 );
if ( pvNodes ) *pvNodes = Vec_IntAlloc( 1000 );
Gia_ManForEachObjVec( vAssigned, p, pObj, i )
{
if ( Gia_ObjIsPi(p, pObj) )
{ if ( pvPis ) Vec_IntPush( *pvPis, Gia_ObjId(p,pObj) ); }
else if ( !Vec_IntEntry(vGateClasses, Gia_ObjId(p,pObj)) )
{ if ( pvPPis ) Vec_IntPush( *pvPPis, Gia_ObjId(p,pObj) ); }
else if ( Gia_ObjIsRo(p, pObj) )
{ if ( pvFlops ) Vec_IntPush( *pvFlops, Gia_ObjId(p,pObj) ); }
else if ( Gia_ObjIsAnd(pObj) )
{ if ( pvNodes ) Vec_IntPush( *pvNodes, Gia_ObjId(p,pObj) ); }
else assert( Gia_ObjIsConst0(pObj) );
}
Vec_IntFree( vAssigned );
}
/**Function*************************************************************
Synopsis [Duplicates the AIG manager recursively.] Synopsis [Duplicates the AIG manager recursively.]
Description [] Description []
...@@ -1697,33 +1774,15 @@ void Gia_ManDupAbsGates_rec( Gia_Man_t * pNew, Gia_Obj_t * pObj ) ...@@ -1697,33 +1774,15 @@ void Gia_ManDupAbsGates_rec( Gia_Man_t * pNew, Gia_Obj_t * pObj )
***********************************************************************/ ***********************************************************************/
Gia_Man_t * Gia_ManDupAbsGates( Gia_Man_t * p, Vec_Int_t * vGateClasses ) Gia_Man_t * Gia_ManDupAbsGates( Gia_Man_t * p, Vec_Int_t * vGateClasses )
{ {
Vec_Int_t * vAssigned, * vPis, * vPPis, * vFlops, * vNodes; Vec_Int_t * vPis, * vPPis, * vFlops, * vNodes;
Gia_Man_t * pNew, * pTemp; Gia_Man_t * pNew, * pTemp;
Gia_Obj_t * pObj, * pCopy; Gia_Obj_t * pObj, * pCopy;
int i;//, nFlops = 0; int i;//, nFlops = 0;
assert( Gia_ManPoNum(p) == 1 ); assert( Gia_ManPoNum(p) == 1 );
assert( Vec_IntSize(vGateClasses) == Gia_ManObjNum(p) ); assert( Vec_IntSize(vGateClasses) == Gia_ManObjNum(p) );
// create included objects and their fanins
vAssigned = Gia_GlaCollectAssigned( p, vGateClasses );
// create additional arrays // create additional arrays
vPis = Vec_IntAlloc( 1000 ); Gia_ManGlaCollect( p, vGateClasses, &vPis, &vPPis, &vFlops, &vNodes );
vPPis = Vec_IntAlloc( 1000 );
vFlops = Vec_IntAlloc( 1000 );
vNodes = Vec_IntAlloc( 1000 );
Gia_ManForEachObjVec( vAssigned, p, pObj, i )
{
if ( Gia_ObjIsPi(p, pObj) )
Vec_IntPush( vPis, Gia_ObjId(p,pObj) );
else if ( !Vec_IntEntry(vGateClasses, Gia_ObjId(p,pObj)) )
Vec_IntPush( vPPis, Gia_ObjId(p,pObj) );
else if ( Gia_ObjIsAnd(pObj) )
Vec_IntPush( vNodes, Gia_ObjId(p,pObj) );
else if ( Gia_ObjIsRo(p, pObj) )
Vec_IntPush( vFlops, Gia_ObjId(p,pObj) );
else assert( Gia_ObjIsConst0(pObj) );
}
// start the new manager // start the new manager
pNew = Gia_ManStart( 5000 ); pNew = Gia_ManStart( 5000 );
...@@ -1779,95 +1838,11 @@ Gia_Man_t * Gia_ManDupAbsGates( Gia_Man_t * p, Vec_Int_t * vGateClasses ) ...@@ -1779,95 +1838,11 @@ Gia_Man_t * Gia_ManDupAbsGates( Gia_Man_t * p, Vec_Int_t * vGateClasses )
Vec_IntFree( vPPis ); Vec_IntFree( vPPis );
Vec_IntFree( vFlops ); Vec_IntFree( vFlops );
Vec_IntFree( vNodes ); Vec_IntFree( vNodes );
Vec_IntFree( vAssigned );
return pNew; return pNew;
} }
/**Function************************************************************* /**Function*************************************************************
Synopsis [Collects PIs and PPIs of the abstraction.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
void Gia_GlaCollectInputs( Gia_Man_t * p, Vec_Int_t * vGateClasses, Vec_Int_t ** pvPis, Vec_Int_t ** pvPPis )
{
Vec_Int_t * vAssigned, * vPis, * vPPis;
Gia_Obj_t * pObj;
int i;
assert( Gia_ManPoNum(p) == 1 );
assert( Vec_IntSize(vGateClasses) == Gia_ManObjNum(p) );
// create included objects and their fanins
vAssigned = Gia_GlaCollectAssigned( p, vGateClasses );
// create additional arrays
vPis = Vec_IntAlloc( 1000 );
vPPis = Vec_IntAlloc( 1000 );
Gia_ManForEachObjVec( vAssigned, p, pObj, i )
{
if ( Gia_ObjIsPi(p, pObj) )
Vec_IntPush( vPis, Gia_ObjId(p,pObj) );
else if ( !Vec_IntEntry(vGateClasses, Gia_ObjId(p,pObj)) )
Vec_IntPush( vPPis, Gia_ObjId(p,pObj) );
else if ( Gia_ObjIsAnd(pObj) )
{}
else if ( Gia_ObjIsRo(p, pObj) )
{}
else assert( Gia_ObjIsConst0(pObj) );
}
Vec_IntFree( vAssigned );
if ( pvPis )
*pvPis = vPis;
else
Vec_IntFree( vPis );
if ( pvPPis )
*pvPPis = vPPis;
else
Vec_IntFree( vPPis );
}
/**Function*************************************************************
Synopsis [Returns the array of neighbors.]
Description []
SideEffects []
SeeAlso []
***********************************************************************/
Vec_Int_t * Gia_GlaCollectAssigned( Gia_Man_t * p, Vec_Int_t * vGateClasses )
{
Vec_Int_t * vAssigned;
Gia_Obj_t * pObj;
int i, Entry;
vAssigned = Vec_IntAlloc( 1000 );
Vec_IntForEachEntry( vGateClasses, Entry, i )
{
if ( Entry == 0 )
continue;
assert( Entry == 1 );
pObj = Gia_ManObj( p, i );
Vec_IntPush( vAssigned, Gia_ObjId(p, pObj) );
if ( Gia_ObjIsAnd(pObj) )
{
Vec_IntPush( vAssigned, Gia_ObjFaninId0p(p, pObj) );
Vec_IntPush( vAssigned, Gia_ObjFaninId1p(p, pObj) );
}
else if ( Gia_ObjIsRo(p, pObj) )
Vec_IntPush( vAssigned, Gia_ObjFaninId0p(p, Gia_ObjRoToRi(p, pObj)) );
else assert( Gia_ObjIsConst0(pObj) );
}
Vec_IntUniqify( vAssigned );
return vAssigned;
}
/**Function*************************************************************
Synopsis [Copy an AIG structure related to the selected POs.] Synopsis [Copy an AIG structure related to the selected POs.]
Description [] Description []
......
...@@ -200,10 +200,7 @@ void Gia_ManPrintFlopClasses( Gia_Man_t * p ) ...@@ -200,10 +200,7 @@ void Gia_ManPrintFlopClasses( Gia_Man_t * p )
***********************************************************************/ ***********************************************************************/
void Gia_ManPrintGateClasses( Gia_Man_t * p ) void Gia_ManPrintGateClasses( Gia_Man_t * p )
{ {
Vec_Int_t * vAssigned, * vPis, * vPPis, * vFlops, * vNodes; Vec_Int_t * vPis, * vPPis, * vFlops, * vNodes;
Gia_Obj_t * pObj;
int i;
if ( p->vGateClasses == NULL ) if ( p->vGateClasses == NULL )
return; return;
if ( Vec_IntSize(p->vGateClasses) != Gia_ManObjNum(p) ) if ( Vec_IntSize(p->vGateClasses) != Gia_ManObjNum(p) )
...@@ -211,38 +208,16 @@ void Gia_ManPrintGateClasses( Gia_Man_t * p ) ...@@ -211,38 +208,16 @@ void Gia_ManPrintGateClasses( Gia_Man_t * p )
printf( "Gia_ManPrintGateClasses(): The number of flop map entries differs from the number of flops.\n" ); printf( "Gia_ManPrintGateClasses(): The number of flop map entries differs from the number of flops.\n" );
return; return;
} }
// create included objects and their fanins
vAssigned = Gia_GlaCollectAssigned( p, p->vGateClasses );
// create additional arrays // create additional arrays
vPis = Vec_IntAlloc( 1000 ); Gia_ManGlaCollect( p, p->vGateClasses, &vPis, &vPPis, &vFlops, &vNodes );
vPPis = Vec_IntAlloc( 1000 );
vFlops = Vec_IntAlloc( 1000 );
vNodes = Vec_IntAlloc( 1000 );
Gia_ManForEachObjVec( vAssigned, p, pObj, i )
{
if ( Gia_ObjIsPi(p, pObj) )
Vec_IntPush( vPis, Gia_ObjId(p,pObj) );
else if ( !Vec_IntEntry(p->vGateClasses, Gia_ObjId(p,pObj)) )
Vec_IntPush( vPPis, Gia_ObjId(p,pObj) );
else if ( Gia_ObjIsAnd(pObj) )
Vec_IntPush( vNodes, Gia_ObjId(p,pObj) );
else if ( Gia_ObjIsRo(p, pObj) )
Vec_IntPush( vFlops, Gia_ObjId(p,pObj) );
else assert( Gia_ObjIsConst0(pObj) );
}
printf( "Gate-level abstraction: PI = %d PPI = %d FF = %d (%.2f %%) AND = %d (%.2f %%)\n", printf( "Gate-level abstraction: PI = %d PPI = %d FF = %d (%.2f %%) AND = %d (%.2f %%)\n",
Vec_IntSize(vPis), Vec_IntSize(vPPis), Vec_IntSize(vPis), Vec_IntSize(vPPis),
Vec_IntSize(vFlops), 100.0*Vec_IntSize(vFlops)/(Gia_ManRegNum(p)+1), Vec_IntSize(vFlops), 100.0*Vec_IntSize(vFlops)/(Gia_ManRegNum(p)+1),
Vec_IntSize(vNodes), 100.0*Vec_IntSize(vNodes)/(Gia_ManAndNum(p)+1) ); Vec_IntSize(vNodes), 100.0*Vec_IntSize(vNodes)/(Gia_ManAndNum(p)+1) );
Vec_IntFree( vPis ); Vec_IntFree( vPis );
Vec_IntFree( vPPis ); Vec_IntFree( vPPis );
Vec_IntFree( vFlops ); Vec_IntFree( vFlops );
Vec_IntFree( vNodes ); Vec_IntFree( vNodes );
Vec_IntFree( vAssigned );
} }
/**Function************************************************************* /**Function*************************************************************
......
...@@ -219,7 +219,7 @@ void Nwk_ManDeriveMinCut( Gia_Man_t * p, int fVerbose ) ...@@ -219,7 +219,7 @@ void Nwk_ManDeriveMinCut( Gia_Man_t * p, int fVerbose )
Gia_Obj_t * pObj; Gia_Obj_t * pObj;
int i, iObjId; int i, iObjId;
// get inputs // get inputs
Gia_GlaCollectInputs( p, p->vGateClasses, NULL, &vPPis ); Gia_ManGlaCollect( p, p->vGateClasses, NULL, &vPPis, NULL, NULL );
// collect nodes rechable from PPIs // collect nodes rechable from PPIs
vNodes = Vec_IntAlloc( 100 ); vNodes = Vec_IntAlloc( 100 );
vLeaves = Vec_IntAlloc( 100 ); vLeaves = Vec_IntAlloc( 100 );
......
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