66 p->pId2Part =
ABC_FALLOC(
int, Gia_ManObjNum(pGia) );
67 p->vFront = Vec_IntAlloc( 100 );
70 Vec_IntPush(
p->pvParts + i, Gia_ObjId(pGia, pObj) );
71 p->pId2Part[Gia_ObjId(pGia, pObj)] = i;
72 Vec_IntPush(
p->vFront, Gia_ObjId(pGia, pObj) );
74 p->nParts = Gia_ManPoNum(pGia);
80 Vec_IntFree(
p->vFront );
81 for ( i = 0; i < Gia_ManPoNum(
p->pGia); i++ )
87static inline void Opa_ManPrint(
Opa_Man_t *
p )
90 printf(
"Groups:\n" );
91 for ( i = 0; i < Gia_ManPoNum(
p->pGia); i++ )
93 if (
p->pvParts[i].nSize == 0 )
95 printf(
"%3d : ", i );
96 for ( k = 0; k <
p->pvParts[i].nSize; k++ )
97 printf(
"%d ",
p->pvParts[i].pArray[k] );
101static inline void Opa_ManPrint2(
Opa_Man_t *
p )
105 printf(
"Groups %d: ",
p->nParts );
106 for ( i = 0; i < Gia_ManPoNum(
p->pGia); i++ )
108 if (
p->pvParts[i].nSize == 0 )
113 Count += Gia_ObjIsPo(
p->pGia, pObj);
114 printf(
"%d ", Count );
132 int iObj = Gia_ObjId(
p->pGia, pObj);
133 int iFanin = Gia_ObjId(
p->pGia, pFanin);
136 assert(
p->pId2Part[ iObj ] >= 0 );
137 if (
p->pId2Part[ iFanin ] == -1 )
139 p->pId2Part[ iFanin ] =
p->pId2Part[ iObj ];
140 Vec_IntPush(
p->pvParts +
p->pId2Part[ iObj ], iFanin );
141 assert( Gia_ObjIsCi(pFanin) || Gia_ObjIsAnd(pFanin) );
142 if ( Gia_ObjIsAnd(pFanin) )
143 Vec_IntPush(
p->vFront, iFanin );
144 else if ( Gia_ObjIsRo(
p->pGia, pFanin) )
146 pFanin = Gia_ObjRoToRi(
p->pGia, pFanin);
147 iFanin = Gia_ObjId(
p->pGia, pFanin);
148 assert(
p->pId2Part[ iFanin ] == -1 );
149 p->pId2Part[ iFanin ] =
p->pId2Part[ iObj ];
150 Vec_IntPush(
p->pvParts +
p->pId2Part[ iObj ], iFanin );
151 Vec_IntPush(
p->vFront, iFanin );
154 else if (
p->pId2Part[ iObj ] !=
p->pId2Part[ iFanin ] )
156 Vec_Int_t * vPartObj =
p->pvParts +
p->pId2Part[ iObj ];
157 Vec_Int_t * vPartFan =
p->pvParts +
p->pId2Part[ iFanin ];
161 assert( Vec_IntSize(vPartObj) > 0 );
164 Vec_IntPush( vPartFan, iTemp );
165 p->pId2Part[ iTemp ] =
p->pId2Part[ iFanin ];
167 Vec_IntShrink( vPartObj, 0 );
175 int i, Limit, Count = 0;
177 p = Opa_ManStart( pGia );
178 Limit = Vec_IntSize(
p->vFront);
184 printf(
"%6d : %6d -> %6d\n", ++Count, i,
p->nParts );
185 Limit = Vec_IntSize(
p->vFront);
190 if ( Gia_ObjIsAnd(pObj) )
195 else if ( Gia_ObjIsCo(pObj) )
200 if (
p->nParts == 1 )
224 if ( Gia_ObjIsTravIdCurrent(
p, pObj) )
226 Gia_ObjSetTravIdCurrent(
p, pObj);
227 if ( Gia_ObjIsAnd(pObj) )
234 else if ( Gia_ObjIsCo(pObj) )
239 else if ( Gia_ObjIsRo(
p, pObj) )
240 Vec_IntPush( vRoots, Gia_ObjId(
p, Gia_ObjRoToRi(
p, pObj)) );
241 else if ( Gia_ObjIsPi(
p, pObj) )
244 return (
int)(Vec_IntSize(vRoots) > nLimit);
252 pObj = Gia_ManPo(
p, iOut );
253 vRoots = Vec_IntAlloc( 100 );
254 Vec_IntPush( vRoots, Gia_ObjId(
p, pObj) );
257 Gia_ObjSetTravIdCurrent(
p, Gia_ManConst0(
p) );
261 RetValue = Vec_IntSize( vRoots ) - 1;
262 Vec_IntFree( vRoots );
282 int i, RetValue, iOut;
284 vRoots = Vec_IntAlloc( 100 );
287 pObj = Gia_ManPo(
p, iOut );
288 Vec_IntPush( vRoots, Gia_ObjId(
p, pObj) );
292 Gia_ObjSetTravIdCurrent(
p, Gia_ManConst0(
p) );
296 RetValue = Vec_IntSize( vRoots ) - Vec_IntSize(vOuts);
297 Vec_IntFree( vRoots );
345 int i, j, Count, * pPerm, Limit;
361 vCount = Vec_IntAllocArray(
p->pRefs, Gia_ManObjNum(
p) );
p->pRefs = NULL;
364 vPivots = Vec_IntAlloc( 100 );
365 vWeights = Vec_IntAlloc( 100 );
368 if ( Count < 2 )
continue;
369 if ( fOnlyCis && !Gia_ObjIsCi(Gia_ManObj(
p, i)) )
371 Vec_IntPush( vPivots, i );
372 Vec_IntPush( vWeights, Count );
374 Vec_IntFree( vCount );
377 printf(
"Selected %d pivots with more than one fanout (out of %d CIs and ANDs).\n", Vec_IntSize(vWeights), Gia_ManCiNum(
p) + Gia_ManAndNum(
p) );
382 for ( i = 0; i < Vec_IntSize(vWeights); i++ )
385 ABC_SWAP(
int, vPivots->pArray[i], vPivots->pArray[j] );
386 ABC_SWAP(
int, vWeights->pArray[i], vWeights->pArray[j] );
389 if ( SelectShift == 0 )
393 Vec_Int_t * vTemp = Vec_IntStartNatural( Vec_IntSize(vWeights) );
394 pPerm = Vec_IntReleaseArray( vTemp );
395 Vec_IntFree( vTemp );
399 Limit = Abc_MinInt( 64, Vec_IntSize(vWeights) );
400 vResult = Vec_IntAlloc( Limit );
401 for ( i = 0; i < Limit; i++ )
403 j = (i + SelectShift) % Vec_IntSize(vWeights);
405 printf(
"%2d : Pivot =%7d Fanout =%7d\n", j, Vec_IntEntry(vPivots, pPerm[j]), Vec_IntEntry(vWeights, pPerm[j]) );
406 Vec_IntPush( vResult, Vec_IntEntry(vPivots, pPerm[j]) );
409 Vec_IntFree( vPivots );
410 Vec_IntFree( vWeights );
431 int i, fChange = 1, Counter;
438 printf(
"Signature propagation: " );
439 vSigns = Vec_WrdStart( Gia_ManObjNum(
p) );
448 *Vec_WrdEntryP( vSigns, i ) |= ( (
word)1 << pObj->
Value );
450 if ( Gia_ObjIsAnd(pObj) )
451 *Vec_WrdEntryP( vSigns, i ) |= Vec_WrdEntry(vSigns, Gia_ObjFaninId0(pObj, i)) | Vec_WrdEntry(vSigns, Gia_ObjFaninId1(pObj, i));
452 else if ( Gia_ObjIsCo(pObj) )
453 *Vec_WrdEntryP( vSigns, i ) |= Vec_WrdEntry(vSigns, Gia_ObjFaninId0(pObj, i));
458 word Value = Vec_WrdEntry(vSigns, Gia_ObjId(
p, pObj));
459 *Vec_WrdEntryP( vSigns, Gia_ObjId(
p, pObj) ) |= Vec_WrdEntry(vSigns, Gia_ObjId(
p, pObjRi));
460 if ( Value != Vec_WrdEntry(vSigns, Gia_ObjId(
p, pObj)) )
461 fChange = 1, Counter++;
464 printf(
"%d ", Counter );
491 vSignsPo = Vec_WrdAlloc( Gia_ManPoNum(
p) );
493 Vec_WrdPush( vSignsPo, Vec_WrdEntry(vSigns, Gia_ObjId(
p, pObj)) );
495 vPriority = Hsh_WrdManHashArray( vSignsPo, 1 );
496 Vec_WrdFree( vSignsPo );
497 vClasses = Vec_WecCreateClasses( vPriority );
498 Vec_IntFree( vPriority );
499 vBins = (
Vec_Ptr_t *)Vec_WecConvertToVecPtr( vClasses );
500 Vec_WecFree( vClasses );
504 printf(
"Computed %d partitions:\n", Vec_PtrSize(vBins) );
506 printf(
"Listing partitions with more than 100 outputs:\n" );
509 assert( Vec_IntSize(vBin) > 0 );
510 if ( fVerbose || Vec_IntSize(vBin) > 100 )
512 int PoNum = Vec_IntEntry( vBin, 0 );
514 word Sign = Vec_WrdEntry( vSigns, Gia_ObjId(
p, pObj) );
519 printf(
"PO =%7d ", Vec_IntSize(vBin) );
565 Vec_IntFree( vPivots );
567 Vec_WrdFree( vSigns );
570 vPart = Vec_VecEntryInt( (
Vec_Vec_t *)vParts, 0 );
575 *pvPosEquivs = vParts;
576 printf(
"The algorithm divided %d POs into %d partitions. ", Gia_ManPoNum(
p), Vec_PtrSize(vParts) );
577 Abc_PrintTime( 1,
"Time", Abc_Clock() - clk );
#define ABC_SWAP(Type, a, b)
#define ABC_FALLOC(type, num)
int * Abc_QuickSortCost(int *pCosts, int nSize, int fDecrease)
#define ABC_INFINITY
MACRO DEFINITIONS ///.
#define ABC_CALLOC(type, num)
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
void Opa_ManMoveOne(Opa_Man_t *p, Gia_Obj_t *pObj, Gia_Obj_t *pFanin)
Gia_Man_t * Gia_ManFindPoPartition(Gia_Man_t *p, int SelectShift, int fOnlyCis, int fSetLargest, int fVerbose, Vec_Ptr_t **pvPosEquivs)
int Gia_ManConeMark(Gia_Man_t *p, int iOut, int Limit)
int Gia_ManCountFlops(Gia_Man_t *p, Vec_Int_t *vOuts)
Gia_Man_t * Gia_ManFindPoPartition2(Gia_Man_t *p, int iStartNum, int nDelta, int nOutsMin, int nOutsMax, int fSetLargest, int fVerbose, Vec_Ptr_t **pvPosEquivs)
typedefABC_NAMESPACE_IMPL_START struct Opa_Man_t_ Opa_Man_t
DECLARATIONS ///.
Vec_Ptr_t * Gia_ManHashOutputs(Gia_Man_t *p, Vec_Wrd_t *vSigns, int fVerbose)
Vec_Wrd_t * Gia_ManDeriveSigns(Gia_Man_t *p, Vec_Int_t *vPivots, int fVerbose)
Vec_Int_t * Gia_ManFindPivots(Gia_Man_t *p, int SelectShift, int fOnlyCis, int fVerbose)
int Gia_ManConeMark_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vRoots, int nLimit)
void Opa_ManPerform(Gia_Man_t *pGia)
Gia_Man_t * Gia_ManFindPoPartition3(Gia_Man_t *p, int iOut, int nDelta, int nOutsMin, int nOutsMax, int fVerbose, Vec_Ptr_t **pvPosEquivs)
#define Gia_ManForEachPo(p, pObj, i)
struct Gia_Obj_t_ Gia_Obj_t
void Gia_ManFillValue(Gia_Man_t *p)
struct Gia_Man_t_ Gia_Man_t
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
Gia_Man_t * Gia_ManDupCones(Gia_Man_t *p, int *pPos, int nPos, int fTrimPis)
void Gia_ManCreateRefs(Gia_Man_t *p)
void Gia_ManIncrementTravId(Gia_Man_t *p)
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
#define Gia_ManForEachRiRo(p, pObjRi, pObjRo, i)
unsigned Gia_ManRandom(int fReset)
FUNCTION DEFINITIONS ///.
void Extra_PrintBinary(FILE *pFile, unsigned Sign[], int nBits)
unsigned __int64 word
DECLARATIONS ///.
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Wec_t_ Vec_Wec_t
INCLUDES ///.
typedefABC_NAMESPACE_HEADER_START struct Vec_Wrd_t_ Vec_Wrd_t
INCLUDES ///.