43 #define GIA_PLACE_SIZE 0x7fff
127 #define Emb_ManForEachObj( p, pObj, i ) \
128 for ( i = 0; (i < p->nObjData) && (pObj = Emb_ManObj(p,i)); i += Emb_ObjSize(pObj) )
129 #define Emb_ManForEachNode( p, pObj, i ) \
130 for ( i = 0; (i < p->nObjData) && (pObj = Emb_ManObj(p,i)); i += Emb_ObjSize(pObj) ) if ( Emb_ObjIsTerm(pObj) ) {} else
131 #define Emb_ManForEachObjVec( vVec, p, pObj, i ) \
132 for ( i = 0; (i < Vec_IntSize(vVec)) && ((pObj) = Emb_ManObj(p, Vec_IntEntry(vVec,i))); i++ )
133 #define Emb_ObjForEachFanin( pObj, pNext, i ) \
134 for ( i = 0; (i < (int)pObj->nFanins) && (pNext = Emb_ObjFanin(pObj,i)); i++ )
135 #define Emb_ObjForEachFanout( pObj, pNext, i ) \
136 for ( i = 0; (i < (int)pObj->nFanouts) && (pNext = Emb_ObjFanout(pObj,i)); i++ )
177 int i, nNodes, hHandle = 0;
202 pObj->
Value = hHandle;
218 pObj->
Value = hHandle;
237 pObj->
Value = hHandle;
258 printf(
"Emb_ManStartSimple(): Fatal error in internal representation.\n" );
476 pObj->
Value = Counter++;
497 Gia_Obj_t * pObj, * pObjRi, * pObjRo, * pFanin;
499 int nObjs, nFanios, nNodes = 0;
500 int i, k, hHandle = 0;
528 pObj->
Value = hHandle;
552 pObj->
Value = hHandle;
574 pObj->
Value = hHandle;
596 printf(
"Emb_ManStart(): Fatal error in internal representation.\n" );
633 printf(
"mem =%5.2f MB", 4.0*p->
nObjData/(1<<20) );
680 int nFanins, nFanouts, nFaninsMax, nFanoutsMax, nFaninsAll, nFanoutsAll;
684 nFaninsMax = nFanoutsMax = 0;
685 nFaninsAll = nFanoutsAll = 0;
688 if ( i == 0 )
continue;
691 nFaninsAll += nFanins;
692 nFanoutsAll += nFanouts;
693 nFaninsMax =
Abc_MaxInt( nFaninsMax, nFanins );
694 nFanoutsMax =
Abc_MaxInt( nFanoutsMax, nFanouts );
705 if ( i == 0 )
continue;
711 else if ( nFanins < 100 )
713 else if ( nFanins < 1000 )
715 else if ( nFanins < 10000 )
717 else if ( nFanins < 100000 )
719 else if ( nFanins < 1000000 )
721 else if ( nFanins < 10000000 )
726 else if ( nFanouts < 100 )
728 else if ( nFanouts < 1000 )
730 else if ( nFanouts < 10000 )
732 else if ( nFanouts < 100000 )
734 else if ( nFanouts < 1000000 )
736 else if ( nFanouts < 10000000 )
740 printf(
"The distribution of fanins and fanouts in the network:\n" );
741 printf(
" Number Nodes with fanin Nodes with fanout\n" );
742 for ( k = 0; k < nSizeMax; k++ )
744 if ( vFanins->pArray[k] == 0 && vFanouts->pArray[k] == 0 )
747 printf(
"%15d : ", k );
750 sprintf( Buffer,
"%d - %d", (
int)pow((
double)10, k/10) * (k%10), (
int)pow((
double)10, k/10) * (k%10+1) - 1 );
751 printf(
"%15s : ", Buffer );
753 if ( vFanins->pArray[k] == 0 )
756 printf(
"%12d ", vFanins->pArray[k] );
758 if ( vFanouts->pArray[k] == 0 )
761 printf(
"%12d ", vFanouts->pArray[k] );
767 printf(
"Fanins: Max = %d. Ave = %.2f. Fanouts: Max = %d. Ave = %.2f.\n",
787 int i, k, d, nVisited = 0;
817 vTemp = vThis; vThis = vNext; vNext = vTemp;
848 printf(
"From inputs: " );
849 for ( i = 0; i < nAttempts; i++ )
859 printf(
"%d ", Dist );
864 printf(
"From outputs: " );
865 for ( i = 0; i < nAttempts; i++ )
873 printf(
"%d ", Dist );
878 printf(
"From nodes: " );
879 for ( i = 0; i < nAttempts; i++ )
888 printf(
"%d ", Dist );
958 vTemp = vThis; vThis = vNext; vNext = vTemp;
1077 pFile = fopen(
"1.g",
"w" );
1085 fprintf( pFile,
"%d %d\n", pThis->
Value, pNext->
Value );
1141 for ( d = 0; d < nDims; d++ )
1145 if ( d+1 == nReached )
1173 float ** pMatr = (
float **)
ABC_ALLOC(
char,
sizeof(
float *) * nDims +
sizeof(float) * nDims * nDims );
1174 pMatr[0] = (
float *)(pMatr + nDims);
1175 for ( i = 1; i < nDims; i++ )
1176 pMatr[i] = pMatr[i-1] + nDims;
1198 for ( d = 0; d < nDims; d++ )
1203 for ( v = 0; v < p->
nObjs; v++ )
1208 for ( v = 0; v < p->
nObjs; v++ )
1219 for ( i = 0; i < nDims; i++ )
1223 for ( k = 0; k < nDims; k++ )
1227 for ( v = 0; v < p->
nObjs; v++ )
1228 pRow[k] += pOne[v]*pTwo[v];
1247 for ( i = 0; i < nDims; i++ )
1266 for ( i = 0; i < nDims; i++ )
1267 Norm += pVec[i] * pVec[i];
1268 Norm = pow( Norm, 0.5 );
1269 for ( i = 0; i < nDims; i++ )
1288 for ( i = 0; i < nDims; i++ )
1289 Res += pVec0[i] * pVec1[i];
1307 for ( i = 0; i < nDims; i++ )
1308 pVecDest[i] = pVecSour[i];
1325 for ( k = 0; k < nDims; k++ )
1343 for ( k = 0; k < nDims; k++ )
1360 float * pVecUiHat, * pVecUi;
1363 pVecUiHat = p->
pEigen[nSols];
1364 for ( i = 0; i < nSols; i++ )
1373 for ( j = 0; j < i; j++ )
1404 for ( i = 0; i < nDims; i++ )
1407 for ( j = 0; j < nSols; j++ )
1410 for ( k = 0; k < p->
nObjs; k++ )
1411 pY[k] += pX[k] * p->
pEigen[j][i];
1429 float * pY0, * pY1, Max0, Max1, Min0, Min1, Str0, Str1;
1430 int * pPerm0, * pPerm1;
1438 for ( k = 0; k < p->
nObjs; k++ )
1445 for ( k = 0; k < p->
nObjs; k++ )
1446 pY0[k] = (pY0[k] != 0.0) ? ((pY0[k] - Min0) * Str0) : 0.0;
1452 for ( k = 0; k < p->
nObjs; k++ )
1459 for ( k = 0; k < p->
nObjs; k++ )
1460 pY1[k] = (pY1[k] != 0.0) ? ((pY1[k] - Min1) * Str1) : 0.0;
1468 for ( k = 0; k < p->
nObjs; k++ )
1491 double Result = 0.0;
1493 int i, k, iMinX, iMaxX, iMinY, iMaxY;
1507 Result += (iMaxX - iMinX) + (iMaxY - iMinY);
1527 double CostThis, CostPrev;
1528 float * pEdgeX, * pEdgeY;
1529 float * pVertX, * pVertY;
1531 int * pPermX, * pPermY;
1532 int i, k, Iter, iMinX, iMaxX, iMinY, iMaxY;
1542 for ( Iter = 0; Iter < nIters; Iter++ )
1557 pEdgeX[pThis->
Value] = 0.5 * (iMaxX + iMinX);
1558 pEdgeY[pThis->
Value] = 0.5 * (iMaxY + iMinY);
1559 CostThis += (iMaxX - iMinX) + (iMaxY - iMinY);
1564 VertX = pEdgeX[pThis->
Value];
1565 VertY = pEdgeY[pThis->
Value];
1568 VertX += pEdgeX[pNext->
Value];
1569 VertY += pEdgeY[pNext->
Value];
1577 for ( k = 0; k < p->
nObjs; k++ )
1587 printf(
"%2d : HPWL = %e ", Iter+1, CostThis );
1613 for ( i = 0; i < nSols; i++ )
1616 for ( k = 0; k < p->
nObjs; k++ )
1617 printf(
"%4d ", (
int)(100 * pSol[k]) );
1641 char * pBuffer, ** ppRows;
1642 int i, k, placeX, placeY;
1645 pBuffer =
ABC_CALLOC(
char, nRows * (nCols+1) );
1647 for ( i = 0; i < nRows; i++ )
1648 ppRows[i] = pBuffer + i*(nCols+1);
1654 assert( placeX < nCols && placeY < nRows );
1655 ppRows[placeY][placeX] = 1;
1659 for ( i = 0; i < nRows; i++ )
1662 for ( k = 0; k <= nCols; k++ )
1664 if ( ppRows[i][k] && !fStart )
1670 if ( !ppRows[i][k] && fStart )
1699 char * pDirectory =
"";
1707 printf(
"Emb_ManDumpGnuplot(): Placement is not available.\n" );
1711 pFile = fopen( Buffer,
"w" );
1712 fprintf( pFile,
"# This Gnuplot file was produced by ABC on %s\n",
Ioa_TimeStamp() );
1713 fprintf( pFile,
"\n" );
1714 fprintf( pFile,
"set nokey\n" );
1715 fprintf( pFile,
"\n" );
1719 fprintf( pFile,
"set terminal gif font \'arial\' 10 size 800,600 xffffff x000000 x000000 x000000\n" );
1721 fprintf( pFile,
"\n" );
1723 fprintf( pFile,
"set title \"%s : PI = %d PO = %d FF = %d Node = %d Obj = %d HPWL = %.2e\\n",
1725 fprintf( pFile,
"(image generated by ABC and Gnuplot on %s)\"",
Ioa_TimeStamp() );
1726 fprintf( pFile,
"font \"Times, 12\"\n" );
1727 fprintf( pFile,
"\n" );
1728 fprintf( pFile,
"plot [:] '-' w l\n" );
1729 fprintf( pFile,
"\n" );
1732 int begX, begY, endX, endY;
1740 fprintf( pFile,
"%5d %5d\n", begX, begY );
1741 fprintf( pFile,
"%5d %5d\n", endX, endY );
1742 fprintf( pFile,
"\n" );
1757 fprintf( pFile,
"\n" );
1761 fprintf( pFile,
"EOF\n" );
1762 fprintf( pFile,
"\n" );
1765 fprintf( pFile,
"pause -1 \"Close window\"\n" );
1766 fprintf( pFile,
"reset\n" );
1767 fprintf( pFile,
"\n" );
1771 fprintf( pFile,
"# pause -1 \"Close window\"\n" );
1772 fprintf( pFile,
"# reset\n" );
1773 fprintf( pFile,
"\n" );
1806 printf(
"Clustered: " );
1824 ABC_PRT(
"Setup ", clkSetup );
1861 for ( i = 0; i < p->
nObjs; i++ )
static void Emb_ObjSetTravIdCurrent(Emb_Man_t *p, Emb_Obj_t *pObj)
float ** Emb_ManMatrAlloc(int nDims)
void Gia_ManCreateRefs(Gia_Man_t *p)
void Emb_ManVecRandom(float *pVec, int nDims)
static Emb_Dat_t * Emb_ManVec(Emb_Man_t *p, int v)
static int Emb_ObjSize(Emb_Obj_t *pObj)
static int Emb_ManNodeNum(Emb_Man_t *p)
void Gia_ManSolveProblem(Gia_Man_t *pGia, Emb_Par_t *pPars)
void Emb_ManDerivePlacement(Emb_Man_t *p, int nSols)
void Emb_ManPlacementRefine(Emb_Man_t *p, int nIters, int fVerbose)
#define Gia_ManForEachCo(p, pObj, i)
static int Emb_ManCoNum(Emb_Man_t *p)
int Emb_ManComputeDistance_old(Emb_Man_t *p, Emb_Obj_t *pPivot)
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
void Emb_ManVecMultiply(float **pMatr, float *pVec, int nDims, float *pRes)
static int Emb_ObjFanoutNum(Emb_Obj_t *pObj)
static Gia_Obj_t * Gia_Regular(Gia_Obj_t *p)
void Emb_ManStop(Emb_Man_t *p)
Emb_Obj_t * Emb_ManPerformBfs(Emb_Man_t *p, Vec_Int_t *vThis, Vec_Int_t *vNext, Emb_Dat_t *pDist)
static int Emb_ObjIsCi(Emb_Obj_t *pObj)
Emb_Obj_t * Emb_ManFindDistances(Emb_Man_t *p, Vec_Int_t *vStart, Emb_Dat_t *pDist)
void Gia_ManGnuplotShow(char *pPlotFileName)
void Emb_ManCollectSuper(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vSuper, Vec_Int_t *vVisit)
static int Emb_ManPoNum(Emb_Man_t *p)
void Gia_ManCleanMark0(Gia_Man_t *p)
static int Gia_ObjIsConst0(Gia_Obj_t *pObj)
static int Gia_ObjValue(Gia_Obj_t *pObj)
void Gia_ManTestDistanceInternal(Emb_Man_t *p)
#define Emb_ObjForEachFanout(pObj, pNext, i)
static int Gia_ObjRefNum(Gia_Man_t *p, Gia_Obj_t *pObj)
static int Emb_ObjIsTravIdPrevious(Emb_Man_t *p, Emb_Obj_t *pObj)
static int Emb_ManPiNum(Emb_Man_t *p)
#define ABC_ALLOC(type, num)
static Emb_Obj_t * Emb_ManCi(Emb_Man_t *p, int i)
static abctime Abc_Clock()
static int Abc_MaxInt(int a, int b)
#define Gia_ManForEachCoDriver(p, pObj, i)
static int Emb_ManRegNum(Emb_Man_t *p)
static Gia_Obj_t * Gia_ManObj(Gia_Man_t *p, int v)
void Gia_ManCleanMark1(Gia_Man_t *p)
Emb_Man_t * Emb_ManStartSimple(Gia_Man_t *pGia)
void Emb_ManCleanTravId(Emb_Man_t *p)
void Emb_ManPrintStats(Emb_Man_t *p)
unsigned Gia_ManRandom(int fReset)
FUNCTION DEFINITIONS ///.
void Emb_ManCreateRefsSpecial(Gia_Man_t *p)
#define Gia_ManForEachCi(p, pObj, i)
#define Gia_ManForEachRiRo(p, pObjRi, pObjRo, i)
static int Gia_ManAndNum(Gia_Man_t *p)
void Emb_ManCollectSuper_rec(Gia_Man_t *p, Gia_Obj_t *pObj, Vec_Int_t *vSuper, Vec_Int_t *vVisit)
static int Abc_MinInt(int a, int b)
void Emb_ManVecNormal(float *pVec, int nDims)
void Emb_ManPrintFanio(Emb_Man_t *p)
static Emb_Obj_t * Emb_ManCo(Emb_Man_t *p, int i)
static Vec_Int_t * Vec_IntStart(int nSize)
void Gia_ManCheckMark1(Gia_Man_t *p)
#define Emb_ObjForEachFanin(pObj, pNext, i)
unsigned short * pPlacement
static Gia_Obj_t * Gia_ObjFanin0(Gia_Obj_t *pObj)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
void Emb_ManTransformRefs(Gia_Man_t *p, int *pnObjs, int *pnFanios)
static int Emb_ManObjNum(Emb_Man_t *p)
static void Vec_IntAddToEntry(Vec_Int_t *p, int i, int Addition)
static int Gia_ObjIsRo(Gia_Man_t *p, Gia_Obj_t *pObj)
void Emb_ManDumpGnuplot(Emb_Man_t *p, char *pName, int fDumpLarge, int fShowImage)
#define Emb_ManForEachObj(p, pObj, i)
void Emb_ManPrintSolutions(Emb_Man_t *p, int nSols)
static int Gia_ObjIsRi(Gia_Man_t *p, Gia_Obj_t *pObj)
static int Vec_IntEntry(Vec_Int_t *p, int i)
static int Abc_Base10Log(unsigned n)
static int Gia_ObjRefInc(Gia_Man_t *p, Gia_Obj_t *pObj)
#define ABC_NAMESPACE_IMPL_END
static int Emb_ObjIsNode(Emb_Obj_t *pObj)
static void Emb_ObjSetTravIdPrevious(Emb_Man_t *p, Emb_Obj_t *pObj)
#define Gia_ManForEachAnd(p, pObj, i)
static void Vec_IntPush(Vec_Int_t *p, int Entry)
void Emb_ManComputeCovariance(Emb_Man_t *p, int nDims)
static int Gia_ObjId(Gia_Man_t *p, Gia_Obj_t *pObj)
void Gia_ManFillValue(Gia_Man_t *p)
static Emb_Obj_t * Emb_ManObj(Emb_Man_t *p, unsigned hHandle)
static void Emb_ObjSetTravId(Emb_Obj_t *pObj, int TravId)
#define Emb_ManForEachNode(p, pObj, i)
char * Gia_FileNameGenericAppend(char *pBase, char *pSuffix)
void Emb_ManComputeDimensions(Emb_Man_t *p, int nDims)
void Emb_DumpGraphIntoFile(Emb_Man_t *p)
#define Emb_ManForEachObjVec(vVec, p, pObj, i)
static int Gia_ObjIsCo(Gia_Obj_t *pObj)
static int Emb_ObjFaninNum(Emb_Obj_t *pObj)
static void Emb_ManResetTravId(Emb_Man_t *p)
#define Gia_ManForEachObjVec(vVec, p, pObj, i)
#define ABC_NAMESPACE_IMPL_START
static int Gia_ObjRefDec(Gia_Man_t *p, Gia_Obj_t *pObj)
int Gia_ObjIsMuxType(Gia_Obj_t *pNode)
static int Gia_ManCiNum(Gia_Man_t *p)
static int Emb_ObjIsCo(Emb_Obj_t *pObj)
static int Vec_IntSize(Vec_Int_t *p)
static void Emb_ManIncrementTravId(Emb_Man_t *p)
static Emb_Obj_t * Emb_ObjFanin(Emb_Obj_t *pObj, int i)
Gia_Obj_t * Gia_ObjRecognizeMux(Gia_Obj_t *pNode, Gia_Obj_t **ppNodeT, Gia_Obj_t **ppNodeE)
static float * Emb_ManSol(Emb_Man_t *p, int v)
static int Gia_ObjIsAnd(Gia_Obj_t *pObj)
void Emb_ManSetValue(Emb_Man_t *p)
double Emb_ManComputeHPWL(Emb_Man_t *p)
#define Gia_ManForEachObj(p, pObj, i)
MACRO DEFINITIONS ///.
static Gia_Obj_t * Gia_ManConst0(Gia_Man_t *p)
Emb_Obj_t * Emb_ManRandomVertex(Emb_Man_t *p)
void Gia_ManTestDistance(Gia_Man_t *pGia)
void Emb_ManVecOrthogonolizeOne(float *pEigen, float *pVecI, int nDims, float *pVecRes)
#define ABC_CALLOC(type, num)
Emb_Man_t * Emb_ManStart(Gia_Man_t *pGia)
static Gia_Obj_t * Gia_ObjFanin1(Gia_Obj_t *pObj)
void Emb_ObjAddFanin(Emb_Obj_t *pObj, Emb_Obj_t *pFanin)
FUNCTION DEFINITIONS ///.
#define ABC_INFINITY
MACRO DEFINITIONS ///.
int * Gia_SortFloats(float *pArray, int *pPerm, int nSize)
static int Emb_ManCiNum(Emb_Man_t *p)
#define GIA_PLACE_SIZE
DECLARATIONS ///.
Vec_Int_t * Emb_ManConnectedComponents(Emb_Man_t *p)
Vec_Int_t * Emb_ManDumpGnuplotPrepare(Emb_Man_t *p)
void Emb_ManComputeSolutions(Emb_Man_t *p, int nDims, int nSols)
static void Vec_IntFree(Vec_Int_t *p)
struct Emb_Obj_t_ Emb_Obj_t
static void Vec_IntClear(Vec_Int_t *p)
static int Gia_ObjIsCi(Gia_Obj_t *pObj)
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
void Emb_ManVecCopyOne(float *pVecDest, float *pVecSour, int nDims)
static int Emb_ObjIsTerm(Emb_Obj_t *pObj)
float Emb_ManVecMultiplyOne(float *pVec0, float *pVec1, int nDims)
static int Gia_ManObjNum(Gia_Man_t *p)
void Emb_ManComputeEigenvectors(Emb_Man_t *p, int nDims, int nSols)
static int Gia_ManCoNum(Gia_Man_t *p)
static int Emb_ObjIsTravIdCurrent(Emb_Man_t *p, Emb_Obj_t *pObj)
static Emb_Obj_t * Emb_ObjFanout(Emb_Obj_t *pObj, int i)
static int Gia_ManRegNum(Gia_Man_t *p)