abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
abcPart.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [abcPart.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [Network and node package.]
8 
9  Synopsis [Output partitioning package.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - June 20, 2005.]
16 
17  Revision [$Id: abcPart.c,v 1.00 2005/06/20 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "base/abc/abc.h"
22 #include "base/main/main.h"
23 #include "base/cmd/cmd.h"
24 
26 
27 
28 ////////////////////////////////////////////////////////////////////////
29 /// DECLARATIONS ///
30 ////////////////////////////////////////////////////////////////////////
31 
32 typedef struct Supp_Man_t_ Supp_Man_t;
34 {
35  int nChunkSize; // the size of one chunk of memory (~1 MB)
36  int nStepSize; // the step size in saving memory (~64 bytes)
37  char * pFreeBuf; // the pointer to free memory
38  int nFreeSize; // the size of remaining free memory
39  Vec_Ptr_t * vMemory; // the memory allocated
40  Vec_Ptr_t * vFree; // the vector of free pieces of memory
41 };
42 
43 typedef struct Supp_One_t_ Supp_One_t;
45 {
46  int nRefs; // the number of references
47  int nOuts; // the number of outputs
48  int nOutsAlloc; // the array size
49  int pOuts[0]; // the array of outputs
50 };
51 
52 static inline int Supp_SizeType( int nSize, int nStepSize ) { return nSize / nStepSize + ((nSize % nStepSize) > 0); }
53 static inline char * Supp_OneNext( char * pPart ) { return *((char **)pPart); }
54 static inline void Supp_OneSetNext( char * pPart, char * pNext ) { *((char **)pPart) = pNext; }
55 
56 ////////////////////////////////////////////////////////////////////////
57 /// FUNCTION DEFINITIONS ///
58 ////////////////////////////////////////////////////////////////////////
59 
60 /**Function*************************************************************
61 
62  Synopsis [Start the memory manager.]
63 
64  Description []
65 
66  SideEffects []
67 
68  SeeAlso []
69 
70 ***********************************************************************/
71 Supp_Man_t * Supp_ManStart( int nChunkSize, int nStepSize )
72 {
73  Supp_Man_t * p;
74  p = ABC_ALLOC( Supp_Man_t, 1 );
75  memset( p, 0, sizeof(Supp_Man_t) );
76  p->nChunkSize = nChunkSize;
77  p->nStepSize = nStepSize;
78  p->vMemory = Vec_PtrAlloc( 1000 );
79  p->vFree = Vec_PtrAlloc( 1000 );
80  return p;
81 }
82 
83 /**Function*************************************************************
84 
85  Synopsis [Stops the memory manager.]
86 
87  Description []
88 
89  SideEffects []
90 
91  SeeAlso []
92 
93 ***********************************************************************/
95 {
96  void * pMemory;
97  int i;
98  Vec_PtrForEachEntry( void *, p->vMemory, pMemory, i )
99  ABC_FREE( pMemory );
100  Vec_PtrFree( p->vMemory );
101  Vec_PtrFree( p->vFree );
102  ABC_FREE( p );
103 }
104 
105 /**Function*************************************************************
106 
107  Synopsis [Fetches the memory entry of the given size.]
108 
109  Description []
110 
111  SideEffects []
112 
113  SeeAlso []
114 
115 ***********************************************************************/
116 char * Supp_ManFetch( Supp_Man_t * p, int nSize )
117 {
118  int Type, nSizeReal;
119  char * pMemory;
120  assert( nSize > 0 );
121  Type = Supp_SizeType( nSize, p->nStepSize );
122  Vec_PtrFillExtra( p->vFree, Type + 1, NULL );
123  if ( (pMemory = (char *)Vec_PtrEntry( p->vFree, Type )) )
124  {
125  Vec_PtrWriteEntry( p->vFree, Type, Supp_OneNext(pMemory) );
126  return pMemory;
127  }
128  nSizeReal = p->nStepSize * Type;
129  if ( p->nFreeSize < nSizeReal )
130  {
131  p->pFreeBuf = ABC_ALLOC( char, p->nChunkSize );
132  p->nFreeSize = p->nChunkSize;
133  Vec_PtrPush( p->vMemory, p->pFreeBuf );
134  }
135  assert( p->nFreeSize >= nSizeReal );
136  pMemory = p->pFreeBuf;
137  p->pFreeBuf += nSizeReal;
138  p->nFreeSize -= nSizeReal;
139  return pMemory;
140 }
141 
142 /**Function*************************************************************
143 
144  Synopsis [Recycles the memory entry of the given size.]
145 
146  Description []
147 
148  SideEffects []
149 
150  SeeAlso []
151 
152 ***********************************************************************/
153 void Supp_ManRecycle( Supp_Man_t * p, char * pMemory, int nSize )
154 {
155  int Type;
156  Type = Supp_SizeType( nSize, p->nStepSize );
157  Vec_PtrFillExtra( p->vFree, Type + 1, NULL );
158  Supp_OneSetNext( pMemory, (char *)Vec_PtrEntry(p->vFree, Type) );
159  Vec_PtrWriteEntry( p->vFree, Type, pMemory );
160 }
161 
162 /**Function*************************************************************
163 
164  Synopsis [Fetches the memory entry of the given size.]
165 
166  Description []
167 
168  SideEffects []
169 
170  SeeAlso []
171 
172 ***********************************************************************/
173 static inline Supp_One_t * Supp_ManFetchEntry( Supp_Man_t * p, int nWords, int nRefs )
174 {
175  Supp_One_t * pPart;
176  pPart = (Supp_One_t *)Supp_ManFetch( p, sizeof(Supp_One_t) + sizeof(int) * nWords );
177  pPart->nRefs = nRefs;
178  pPart->nOuts = 0;
179  pPart->nOutsAlloc = nWords;
180  return pPart;
181 }
182 
183 /**Function*************************************************************
184 
185  Synopsis [Recycles the memory entry of the given size.]
186 
187  Description []
188 
189  SideEffects []
190 
191  SeeAlso []
192 
193 ***********************************************************************/
194 static inline void Supp_ManRecycleEntry( Supp_Man_t * p, Supp_One_t * pEntry )
195 {
196  assert( pEntry->nOuts <= pEntry->nOutsAlloc );
197  assert( pEntry->nOuts >= pEntry->nOutsAlloc/2 );
198  Supp_ManRecycle( p, (char *)pEntry, sizeof(Supp_One_t) + sizeof(int) * pEntry->nOutsAlloc );
199 }
200 
201 /**Function*************************************************************
202 
203  Synopsis [Merges two entries.]
204 
205  Description []
206 
207  SideEffects []
208 
209  SeeAlso []
210 
211 ***********************************************************************/
213 {
214  Supp_One_t * p = Supp_ManFetchEntry( pMan, p1->nOuts + p2->nOuts, nRefs );
215  int * pBeg1 = p1->pOuts;
216  int * pBeg2 = p2->pOuts;
217  int * pBeg = p->pOuts;
218  int * pEnd1 = p1->pOuts + p1->nOuts;
219  int * pEnd2 = p2->pOuts + p2->nOuts;
220  while ( pBeg1 < pEnd1 && pBeg2 < pEnd2 )
221  {
222  if ( *pBeg1 == *pBeg2 )
223  *pBeg++ = *pBeg1++, pBeg2++;
224  else if ( *pBeg1 < *pBeg2 )
225  *pBeg++ = *pBeg1++;
226  else
227  *pBeg++ = *pBeg2++;
228  }
229  while ( pBeg1 < pEnd1 )
230  *pBeg++ = *pBeg1++;
231  while ( pBeg2 < pEnd2 )
232  *pBeg++ = *pBeg2++;
233  p->nOuts = pBeg - p->pOuts;
234  assert( p->nOuts <= p->nOutsAlloc );
235  assert( p->nOuts >= p1->nOuts );
236  assert( p->nOuts >= p2->nOuts );
237  return p;
238 }
239 
240 /**Function*************************************************************
241 
242  Synopsis [Tranfers the entry.]
243 
244  Description []
245 
246  SideEffects []
247 
248  SeeAlso []
249 
250 ***********************************************************************/
252 {
253  Vec_Int_t * vSupp;
254  int i;
255  vSupp = Vec_IntAlloc( p->nOuts );
256  for ( i = 0; i < p->nOuts; i++ )
257  Vec_IntPush( vSupp, p->pOuts[i] );
258  return vSupp;
259 }
260 
261 /**Function*************************************************************
262 
263  Synopsis [Computes supports of the POs in the multi-output AIG.]
264 
265  Description []
266 
267  SideEffects []
268 
269  SeeAlso []
270 
271 ***********************************************************************/
273 {
274  Vec_Ptr_t * vNodes;
275  Abc_Obj_t * pObj, * pNext;
276  int i, k;
277  assert( Abc_NtkIsStrash(pNtk) );
278  vNodes = Vec_PtrAlloc( Abc_NtkObjNum(pNtk) );
279  Abc_NtkIncrementTravId( pNtk );
280  // add the constant-1 nodes
281  pObj = Abc_AigConst1(pNtk);
282  Abc_NodeSetTravIdCurrent( pObj );
283  Vec_PtrPush( vNodes, pObj );
284  // add the CIs/nodes/COs in the topological order
285  Abc_NtkForEachNode( pNtk, pObj, i )
286  {
287  // check the fanins and add CIs
288  Abc_ObjForEachFanin( pObj, pNext, k )
289  if ( Abc_ObjIsCi(pNext) && !Abc_NodeIsTravIdCurrent(pNext) )
290  {
291  Abc_NodeSetTravIdCurrent( pNext );
292  Vec_PtrPush( vNodes, pNext );
293  }
294  // add the node
295  Vec_PtrPush( vNodes, pObj );
296  // check the fanouts and add COs
297  Abc_ObjForEachFanout( pObj, pNext, k )
298  if ( Abc_ObjIsCo(pNext) && !Abc_NodeIsTravIdCurrent(pNext) )
299  {
300  Abc_NodeSetTravIdCurrent( pNext );
301  Vec_PtrPush( vNodes, pNext );
302  }
303  }
304  return vNodes;
305 }
306 
307 /**Function*************************************************************
308 
309  Synopsis [Computes supports of the POs.]
310 
311  Description [Returns the ptr-vector of int-vectors.]
312 
313  SideEffects []
314 
315  SeeAlso []
316 
317 ***********************************************************************/
319 {
320  Vec_Ptr_t * vSupports;
321  Vec_Ptr_t * vNodes;
322  Vec_Int_t * vSupp;
323  Supp_Man_t * p;
324  Supp_One_t * pPart0, * pPart1;
325  Abc_Obj_t * pObj;
326  int i;
327  // set the number of PIs/POs
328  Abc_NtkForEachCi( pNtk, pObj, i )
329  pObj->pNext = (Abc_Obj_t *)(ABC_PTRINT_T)i;
330  Abc_NtkForEachCo( pNtk, pObj, i )
331  pObj->pNext = (Abc_Obj_t *)(ABC_PTRINT_T)i;
332  // start the support computation manager
333  p = Supp_ManStart( 1 << 20, 1 << 6 );
334  // consider objects in the topological order
335  vSupports = Vec_PtrAlloc( Abc_NtkCoNum(pNtk) );
336  Abc_NtkCleanCopy(pNtk);
337  // order the nodes so that the PIs and POs follow naturally
338  vNodes = Abc_NtkDfsNatural( pNtk );
339  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, i )
340  {
341  if ( Abc_ObjIsNode(pObj) )
342  {
343  pPart0 = (Supp_One_t *)Abc_ObjFanin0(pObj)->pCopy;
344  pPart1 = (Supp_One_t *)Abc_ObjFanin1(pObj)->pCopy;
345  pObj->pCopy = (Abc_Obj_t *)Supp_ManMergeEntry( p, pPart0, pPart1, Abc_ObjFanoutNum(pObj) );
346  assert( pPart0->nRefs > 0 );
347  if ( --pPart0->nRefs == 0 )
348  Supp_ManRecycleEntry( p, pPart0 );
349  assert( pPart1->nRefs > 0 );
350  if ( --pPart1->nRefs == 0 )
351  Supp_ManRecycleEntry( p, pPart1 );
352  continue;
353  }
354  if ( Abc_ObjIsCo(pObj) )
355  {
356  pPart0 = (Supp_One_t *)Abc_ObjFanin0(pObj)->pCopy;
357  // only save the CO if it is non-trivial
358  if ( Abc_ObjIsNode(Abc_ObjFanin0(pObj)) )
359  {
360  vSupp = Supp_ManTransferEntry(pPart0);
361  Vec_IntPush( vSupp, (int)(ABC_PTRINT_T)pObj->pNext );
362  Vec_PtrPush( vSupports, vSupp );
363  }
364  assert( pPart0->nRefs > 0 );
365  if ( --pPart0->nRefs == 0 )
366  Supp_ManRecycleEntry( p, pPart0 );
367  continue;
368  }
369  if ( Abc_ObjIsCi(pObj) )
370  {
371  if ( Abc_ObjFanoutNum(pObj) )
372  {
373  pPart0 = (Supp_One_t *)Supp_ManFetchEntry( p, 1, Abc_ObjFanoutNum(pObj) );
374  pPart0->pOuts[ pPart0->nOuts++ ] = (int)(ABC_PTRINT_T)pObj->pNext;
375  pObj->pCopy = (Abc_Obj_t *)pPart0;
376  }
377  continue;
378  }
379  if ( pObj == Abc_AigConst1(pNtk) )
380  {
381  if ( Abc_ObjFanoutNum(pObj) )
382  pObj->pCopy = (Abc_Obj_t *)Supp_ManFetchEntry( p, 0, Abc_ObjFanoutNum(pObj) );
383  continue;
384  }
385  assert( 0 );
386  }
387  Vec_PtrFree( vNodes );
388 //printf( "Memory usage = %d MB.\n", Vec_PtrSize(p->vMemory) * p->nChunkSize / (1<<20) );
389  Supp_ManStop( p );
390  // sort supports by size
391  Vec_VecSort( (Vec_Vec_t *)vSupports, 1 );
392  // clear the number of PIs/POs
393  Abc_NtkForEachCi( pNtk, pObj, i )
394  pObj->pNext = NULL;
395  Abc_NtkForEachCo( pNtk, pObj, i )
396  pObj->pNext = NULL;
397 /*
398  Vec_PtrForEachEntry( Vec_Int_t *, vSupports, vSupp, i )
399  printf( "%d ", Vec_IntSize(vSupp) );
400  printf( "\n" );
401 */
402  return vSupports;
403 }
404 
405 
406 /**Function*************************************************************
407 
408  Synopsis [Computes supports of the POs using naive method.]
409 
410  Description [Returns the ptr-vector of int-vectors.]
411 
412  SideEffects []
413 
414  SeeAlso []
415 
416 ***********************************************************************/
418 {
419  Vec_Ptr_t * vSupp, * vSupports;
420  Vec_Int_t * vSuppI;
421  Abc_Obj_t * pObj, * pTemp;
422  int i, k;
423  // set the PI numbers
424  Abc_NtkForEachCi( pNtk, pObj, i )
425  pObj->pNext = (Abc_Obj_t *)(ABC_PTRINT_T)i;
426  // save the CI numbers
427  vSupports = Vec_PtrAlloc( Abc_NtkCoNum(pNtk) );
428  Abc_NtkForEachCo( pNtk, pObj, i )
429  {
430  if ( !Abc_ObjIsNode(Abc_ObjFanin0(pObj)) )
431  continue;
432  vSupp = Abc_NtkNodeSupport( pNtk, &pObj, 1 );
433  vSuppI = (Vec_Int_t *)vSupp;
434  Vec_PtrForEachEntry( Abc_Obj_t *, vSupp, pTemp, k )
435  Vec_IntWriteEntry( vSuppI, k, (int)(ABC_PTRINT_T)pTemp->pNext );
436  Vec_IntSort( vSuppI, 0 );
437  // append the number of this output
438  Vec_IntPush( vSuppI, i );
439  // save the support in the vector
440  Vec_PtrPush( vSupports, vSuppI );
441  }
442  // clean the CI numbers
443  Abc_NtkForEachCi( pNtk, pObj, i )
444  pObj->pNext = NULL;
445  // sort supports by size
446  Vec_VecSort( (Vec_Vec_t *)vSupports, 1 );
447 /*
448  Vec_PtrForEachEntry( Vec_Int_t *, vSupports, vSuppI, i )
449  printf( "%d ", Vec_IntSize(vSuppI) );
450  printf( "\n" );
451 */
452  return vSupports;
453 }
454 
455 /**Function*************************************************************
456 
457  Synopsis [Start bitwise support representation.]
458 
459  Description []
460 
461  SideEffects []
462 
463  SeeAlso []
464 
465 ***********************************************************************/
466 unsigned * Abc_NtkSuppCharStart( Vec_Int_t * vOne, int nPis )
467 {
468  unsigned * pBuffer;
469  int i, Entry;
470  int nWords = Abc_BitWordNum(nPis);
471  pBuffer = ABC_ALLOC( unsigned, nWords );
472  memset( pBuffer, 0, sizeof(unsigned) * nWords );
473  Vec_IntForEachEntry( vOne, Entry, i )
474  {
475  assert( Entry < nPis );
476  Abc_InfoSetBit( pBuffer, Entry );
477  }
478  return pBuffer;
479 }
480 
481 /**Function*************************************************************
482 
483  Synopsis [Add to bitwise support representation.]
484 
485  Description []
486 
487  SideEffects []
488 
489  SeeAlso []
490 
491 ***********************************************************************/
492 void Abc_NtkSuppCharAdd( unsigned * pBuffer, Vec_Int_t * vOne, int nPis )
493 {
494  int i, Entry;
495  Vec_IntForEachEntry( vOne, Entry, i )
496  {
497  assert( Entry < nPis );
498  Abc_InfoSetBit( pBuffer, Entry );
499  }
500 }
501 
502 /**Function*************************************************************
503 
504  Synopsis [Find the common variables using bitwise support representation.]
505 
506  Description []
507 
508  SideEffects []
509 
510  SeeAlso []
511 
512 ***********************************************************************/
513 int Abc_NtkSuppCharCommon( unsigned * pBuffer, Vec_Int_t * vOne )
514 {
515  int i, Entry, nCommon = 0;
516  Vec_IntForEachEntry( vOne, Entry, i )
517  nCommon += Abc_InfoHasBit(pBuffer, Entry);
518  return nCommon;
519 }
520 
521 /**Function*************************************************************
522 
523  Synopsis [Find the best partition.]
524 
525  Description []
526 
527  SideEffects []
528 
529  SeeAlso []
530 
531 ***********************************************************************/
532 int Abc_NtkPartitionSmartFindPart( Vec_Ptr_t * vPartSuppsAll, Vec_Ptr_t * vPartsAll, Vec_Ptr_t * vPartSuppsChar, int nSuppSizeLimit, Vec_Int_t * vOne )
533 {
534 /*
535  Vec_Int_t * vPartSupp, * vPart;
536  double Attract, Repulse, Cost, CostBest;
537  int i, nCommon, iBest;
538  iBest = -1;
539  CostBest = 0.0;
540  Vec_PtrForEachEntry( Vec_Int_t *, vPartSuppsAll, vPartSupp, i )
541  {
542  vPart = Vec_PtrEntry( vPartsAll, i );
543  if ( nPartSizeLimit > 0 && Vec_IntSize(vPart) >= nPartSizeLimit )
544  continue;
545  nCommon = Vec_IntTwoCountCommon( vPartSupp, vOne );
546  if ( nCommon == 0 )
547  continue;
548  if ( nCommon == Vec_IntSize(vOne) )
549  return i;
550  Attract = 1.0 * nCommon / Vec_IntSize(vOne);
551  if ( Vec_IntSize(vPartSupp) < 100 )
552  Repulse = 1.0;
553  else
554  Repulse = log10( Vec_IntSize(vPartSupp) / 10.0 );
555  Cost = pow( Attract, pow(Repulse, 5.0) );
556  if ( CostBest < Cost )
557  {
558  CostBest = Cost;
559  iBest = i;
560  }
561  }
562  if ( CostBest < 0.6 )
563  return -1;
564  return iBest;
565 */
566 
567  Vec_Int_t * vPartSupp;//, * vPart;
568  int Attract, Repulse, Value, ValueBest;
569  int i, nCommon, iBest;
570 // int nCommon2;
571  iBest = -1;
572  ValueBest = 0;
573  Vec_PtrForEachEntry( Vec_Int_t *, vPartSuppsAll, vPartSupp, i )
574  {
575  // skip partitions with too many outputs
576 // vPart = Vec_PtrEntry( vPartsAll, i );
577 // if ( nSuppSizeLimit > 0 && Vec_IntSize(vPart) >= nSuppSizeLimit )
578 // continue;
579  // find the number of common variables between this output and the partitions
580 // nCommon2 = Vec_IntTwoCountCommon( vPartSupp, vOne );
581  nCommon = Abc_NtkSuppCharCommon( (unsigned *)Vec_PtrEntry(vPartSuppsChar, i), vOne );
582 // assert( nCommon2 == nCommon );
583  // if no common variables, continue searching
584  if ( nCommon == 0 )
585  continue;
586  // if all variables are common, the best partition if found
587  if ( nCommon == Vec_IntSize(vOne) )
588  return i;
589  // skip partitions whose size exceeds the limit
590  if ( nSuppSizeLimit > 0 && Vec_IntSize(vPartSupp) >= 2 * nSuppSizeLimit )
591  continue;
592  // figure out might be the good partition for this one
593  Attract = 1000 * nCommon / Vec_IntSize(vOne);
594  if ( Vec_IntSize(vPartSupp) < 100 )
595  Repulse = 1;
596  else
597  Repulse = 1+Abc_Base2Log(Vec_IntSize(vPartSupp)-100);
598  Value = Attract/Repulse;
599  if ( ValueBest < Value )
600  {
601  ValueBest = Value;
602  iBest = i;
603  }
604  }
605  if ( ValueBest < 75 )
606  return -1;
607  return iBest;
608 }
609 
610 /**Function*************************************************************
611 
612  Synopsis [Perform the smart partitioning.]
613 
614  Description []
615 
616  SideEffects []
617 
618  SeeAlso []
619 
620 ***********************************************************************/
621 void Abc_NtkPartitionPrint( Abc_Ntk_t * pNtk, Vec_Ptr_t * vPartsAll, Vec_Ptr_t * vPartSuppsAll )
622 {
623  Vec_Int_t * vOne;
624  int i, nOutputs, Counter;
625 
626  Counter = 0;
627  Vec_PtrForEachEntry( Vec_Int_t *, vPartSuppsAll, vOne, i )
628  {
629  nOutputs = Vec_IntSize((Vec_Int_t *)Vec_PtrEntry(vPartsAll, i));
630  printf( "%d=(%d,%d) ", i, Vec_IntSize(vOne), nOutputs );
631  Counter += nOutputs;
632  if ( i == Vec_PtrSize(vPartsAll) - 1 )
633  break;
634  }
635 // assert( Counter == Abc_NtkCoNum(pNtk) );
636  printf( "\nTotal = %d. Outputs = %d.\n", Counter, Abc_NtkCoNum(pNtk) );
637 }
638 
639 /**Function*************************************************************
640 
641  Synopsis [Perform the smart partitioning.]
642 
643  Description []
644 
645  SideEffects []
646 
647  SeeAlso []
648 
649 ***********************************************************************/
650 void Abc_NtkPartitionCompact( Vec_Ptr_t * vPartsAll, Vec_Ptr_t * vPartSuppsAll, int nSuppSizeLimit )
651 {
652  Vec_Int_t * vOne, * vPart, * vPartSupp, * vTemp;
653  int i, iPart;
654 
655  if ( nSuppSizeLimit == 0 )
656  nSuppSizeLimit = 200;
657 
658  // pack smaller partitions into larger blocks
659  iPart = 0;
660  vPart = vPartSupp = NULL;
661  Vec_PtrForEachEntry( Vec_Int_t *, vPartSuppsAll, vOne, i )
662  {
663  if ( Vec_IntSize(vOne) < nSuppSizeLimit )
664  {
665  if ( vPartSupp == NULL )
666  {
667  assert( vPart == NULL );
668  vPartSupp = Vec_IntDup(vOne);
669  vPart = (Vec_Int_t *)Vec_PtrEntry(vPartsAll, i);
670  }
671  else
672  {
673  vPartSupp = Vec_IntTwoMerge( vTemp = vPartSupp, vOne );
674  Vec_IntFree( vTemp );
675  vPart = Vec_IntTwoMerge( vTemp = vPart, (Vec_Int_t *)Vec_PtrEntry(vPartsAll, i) );
676  Vec_IntFree( vTemp );
677  Vec_IntFree( (Vec_Int_t *)Vec_PtrEntry(vPartsAll, i) );
678  }
679  if ( Vec_IntSize(vPartSupp) < nSuppSizeLimit )
680  continue;
681  }
682  else
683  vPart = (Vec_Int_t *)Vec_PtrEntry(vPartsAll, i);
684  // add the partition
685  Vec_PtrWriteEntry( vPartsAll, iPart, vPart );
686  vPart = NULL;
687  if ( vPartSupp )
688  {
689  Vec_IntFree( (Vec_Int_t *)Vec_PtrEntry(vPartSuppsAll, iPart) );
690  Vec_PtrWriteEntry( vPartSuppsAll, iPart, vPartSupp );
691  vPartSupp = NULL;
692  }
693  iPart++;
694  }
695  // add the last one
696  if ( vPart )
697  {
698  Vec_PtrWriteEntry( vPartsAll, iPart, vPart );
699  vPart = NULL;
700 
701  assert( vPartSupp != NULL );
702  Vec_IntFree( (Vec_Int_t *)Vec_PtrEntry(vPartSuppsAll, iPart) );
703  Vec_PtrWriteEntry( vPartSuppsAll, iPart, vPartSupp );
704  vPartSupp = NULL;
705  iPart++;
706  }
707  Vec_PtrShrink( vPartsAll, iPart );
708  Vec_PtrShrink( vPartsAll, iPart );
709 }
710 
711 /**Function*************************************************************
712 
713  Synopsis [Perform the smart partitioning.]
714 
715  Description [Returns the ptr-vector of int-vectors.]
716 
717  SideEffects []
718 
719  SeeAlso []
720 
721 ***********************************************************************/
722 Vec_Ptr_t * Abc_NtkPartitionSmart( Abc_Ntk_t * pNtk, int nSuppSizeLimit, int fVerbose )
723 {
724  ProgressBar * pProgress;
725  Vec_Ptr_t * vPartSuppsChar;
726  Vec_Ptr_t * vSupps, * vPartsAll, * vPartsAll2, * vPartSuppsAll;
727  Vec_Int_t * vOne, * vPart, * vPartSupp, * vTemp;
728  int i, iPart, iOut, timeFind = 0;
729  abctime clk, clk2;
730 
731  // compute the supports for all outputs
732 clk = Abc_Clock();
733 // vSupps = Abc_NtkComputeSupportsNaive( pNtk );
734  vSupps = Abc_NtkComputeSupportsSmart( pNtk );
735 if ( fVerbose )
736 {
737 ABC_PRT( "Supps", Abc_Clock() - clk );
738 }
739  // start char-based support representation
740  vPartSuppsChar = Vec_PtrAlloc( 1000 );
741 
742  // create partitions
743 clk = Abc_Clock();
744  vPartsAll = Vec_PtrAlloc( 256 );
745  vPartSuppsAll = Vec_PtrAlloc( 256 );
746  pProgress = Extra_ProgressBarStart( stdout, Vec_PtrSize(vSupps) );
747  Vec_PtrForEachEntry( Vec_Int_t *, vSupps, vOne, i )
748  {
749  Extra_ProgressBarUpdate( pProgress, i, NULL );
750 // if ( i % 1000 == 0 )
751 // printf( "CIs = %6d. COs = %6d. Processed = %6d (out of %6d). Parts = %6d.\r",
752 // Abc_NtkCiNum(pNtk), Abc_NtkCoNum(pNtk), i, Vec_PtrSize(vSupps), Vec_PtrSize(vPartsAll) );
753  // get the output number
754  iOut = Vec_IntPop(vOne);
755  // find closely matching part
756 clk2 = Abc_Clock();
757  iPart = Abc_NtkPartitionSmartFindPart( vPartSuppsAll, vPartsAll, vPartSuppsChar, nSuppSizeLimit, vOne );
758 timeFind += Abc_Clock() - clk2;
759  if ( iPart == -1 )
760  {
761  // create new partition
762  vPart = Vec_IntAlloc( 32 );
763  Vec_IntPush( vPart, iOut );
764  // create new partition support
765  vPartSupp = Vec_IntDup( vOne );
766  // add this partition and its support
767  Vec_PtrPush( vPartsAll, vPart );
768  Vec_PtrPush( vPartSuppsAll, vPartSupp );
769 
770  Vec_PtrPush( vPartSuppsChar, Abc_NtkSuppCharStart(vOne, Abc_NtkCiNum(pNtk)) );
771  }
772  else
773  {
774  // add output to this partition
775  vPart = (Vec_Int_t *)Vec_PtrEntry( vPartsAll, iPart );
776  Vec_IntPush( vPart, iOut );
777  // merge supports
778  vPartSupp = (Vec_Int_t *)Vec_PtrEntry( vPartSuppsAll, iPart );
779  vPartSupp = Vec_IntTwoMerge( vTemp = vPartSupp, vOne );
780  Vec_IntFree( vTemp );
781  // reinsert new support
782  Vec_PtrWriteEntry( vPartSuppsAll, iPart, vPartSupp );
783 
784  Abc_NtkSuppCharAdd( (unsigned *)Vec_PtrEntry(vPartSuppsChar, iPart), vOne, Abc_NtkCiNum(pNtk) );
785  }
786  }
787  Extra_ProgressBarStop( pProgress );
788 
789  // stop char-based support representation
790  Vec_PtrForEachEntry( Vec_Int_t *, vPartSuppsChar, vTemp, i )
791  ABC_FREE( vTemp );
792  Vec_PtrFree( vPartSuppsChar );
793 
794 //printf( "\n" );
795 if ( fVerbose )
796 {
797 ABC_PRT( "Parts", Abc_Clock() - clk );
798 //ABC_PRT( "Find ", timeFind );
799 }
800 
801 clk = Abc_Clock();
802  // remember number of supports
803  Vec_PtrForEachEntry( Vec_Int_t *, vPartSuppsAll, vOne, i )
804  Vec_IntPush( vOne, i );
805  // sort the supports in the decreasing order
806  Vec_VecSort( (Vec_Vec_t *)vPartSuppsAll, 1 );
807  // reproduce partitions
808  vPartsAll2 = Vec_PtrAlloc( 256 );
809  Vec_PtrForEachEntry( Vec_Int_t *, vPartSuppsAll, vOne, i )
810  Vec_PtrPush( vPartsAll2, Vec_PtrEntry(vPartsAll, Vec_IntPop(vOne)) );
811  Vec_PtrFree( vPartsAll );
812  vPartsAll = vPartsAll2;
813 
814  // compact small partitions
815 // Abc_NtkPartitionPrint( pNtk, vPartsAll, vPartSuppsAll );
816  Abc_NtkPartitionCompact( vPartsAll, vPartSuppsAll, nSuppSizeLimit );
817 
818 if ( fVerbose )
819 {
820 ABC_PRT( "Comps", Abc_Clock() - clk );
821 }
822  if ( fVerbose )
823  printf( "Created %d partitions.\n", Vec_PtrSize(vPartsAll) );
824 // Abc_NtkPartitionPrint( pNtk, vPartsAll, vPartSuppsAll );
825 
826  // cleanup
827  Vec_VecFree( (Vec_Vec_t *)vSupps );
828  Vec_VecFree( (Vec_Vec_t *)vPartSuppsAll );
829 /*
830  // converts from intergers to nodes
831  Vec_PtrForEachEntry( Vec_Int_t *, vPartsAll, vPart, iPart )
832  {
833  vPartPtr = Vec_PtrAlloc( Vec_IntSize(vPart) );
834  Vec_IntForEachEntry( vPart, iOut, i )
835  Vec_PtrPush( vPartPtr, Abc_NtkCo(pNtk, iOut) );
836  Vec_IntFree( vPart );
837  Vec_PtrWriteEntry( vPartsAll, iPart, vPartPtr );
838  }
839 */
840  return vPartsAll;
841 }
842 
843 /**Function*************************************************************
844 
845  Synopsis [Perform the naive partitioning.]
846 
847  Description [Returns the ptr-vector of int-vectors.]
848 
849  SideEffects []
850 
851  SeeAlso []
852 
853 ***********************************************************************/
854 Vec_Ptr_t * Abc_NtkPartitionNaive( Abc_Ntk_t * pNtk, int nPartSize )
855 {
856  Vec_Ptr_t * vParts;
857  Abc_Obj_t * pObj;
858  int nParts, i;
859  nParts = (Abc_NtkCoNum(pNtk) / nPartSize) + ((Abc_NtkCoNum(pNtk) % nPartSize) > 0);
860  vParts = (Vec_Ptr_t *)Vec_VecStart( nParts );
861  Abc_NtkForEachCo( pNtk, pObj, i )
862  Vec_IntPush( (Vec_Int_t *)Vec_PtrEntry(vParts, i / nPartSize), i );
863  return vParts;
864 }
865 
866 /**Function*************************************************************
867 
868  Synopsis [Converts from intergers to pointers for the given network.]
869 
870  Description []
871 
872  SideEffects []
873 
874  SeeAlso []
875 
876 ***********************************************************************/
877 void Abc_NtkConvertCos( Abc_Ntk_t * pNtk, Vec_Int_t * vOuts, Vec_Ptr_t * vOutsPtr )
878 {
879  int Out, i;
880  Vec_PtrClear( vOutsPtr );
881  Vec_IntForEachEntry( vOuts, Out, i )
882  Vec_PtrPush( vOutsPtr, Abc_NtkCo(pNtk, Out) );
883 }
884 
885 /**Function*************************************************************
886 
887  Synopsis [Returns representative of the given node.]
888 
889  Description []
890 
891  SideEffects []
892 
893  SeeAlso []
894 
895 ***********************************************************************/
897 {
898  Abc_Obj_t * pRepr;
899  pRepr = (Abc_Obj_t *)Vec_PtrEntry( vEquiv, pObj->Id );
900  if ( pRepr == NULL || pRepr == pObj )
901  return pObj;
902  return Abc_NtkPartStitchFindRepr_rec( vEquiv, pRepr );
903 }
904 
905 /**Function*************************************************************
906 
907  Synopsis [Returns the representative of the fanin.]
908 
909  Description []
910 
911  SideEffects []
912 
913  SeeAlso []
914 
915 ***********************************************************************/
916 static inline Abc_Obj_t * Abc_NtkPartStitchCopy0( Vec_Ptr_t * vEquiv, Abc_Obj_t * pObj )
917 {
918  Abc_Obj_t * pFan = Abc_ObjFanin0( pObj );
919  Abc_Obj_t * pRepr = Abc_NtkPartStitchFindRepr_rec( vEquiv, pFan );
920  return Abc_ObjNotCond( pRepr->pCopy, pRepr->fPhase ^ pFan->fPhase ^ (int)Abc_ObjFaninC1(pObj) );
921 }
922 static inline Abc_Obj_t * Abc_NtkPartStitchCopy1( Vec_Ptr_t * vEquiv, Abc_Obj_t * pObj )
923 {
924  Abc_Obj_t * pFan = Abc_ObjFanin1( pObj );
925  Abc_Obj_t * pRepr = Abc_NtkPartStitchFindRepr_rec( vEquiv, pFan );
926  return Abc_ObjNotCond( pRepr->pCopy, pRepr->fPhase ^ pFan->fPhase ^ (int)Abc_ObjFaninC1(pObj) );
927 }
928 
929 /**Function*************************************************************
930 
931  Synopsis []
932 
933  Description []
934 
935  SideEffects []
936 
937  SeeAlso []
938 
939 ***********************************************************************/
940 static inline Hop_Obj_t * Hop_ObjChild0Next( Abc_Obj_t * pObj ) { return Hop_NotCond( (Hop_Obj_t *)Abc_ObjFanin0(pObj)->pNext, Abc_ObjFaninC0(pObj) ); }
941 static inline Hop_Obj_t * Hop_ObjChild1Next( Abc_Obj_t * pObj ) { return Hop_NotCond( (Hop_Obj_t *)Abc_ObjFanin1(pObj)->pNext, Abc_ObjFaninC1(pObj) ); }
942 
943 
944 /**Function*************************************************************
945 
946  Synopsis [Stitches together several networks with choice nodes.]
947 
948  Description []
949 
950  SideEffects []
951 
952  SeeAlso []
953 
954 ***********************************************************************/
956 {
957  Hop_Man_t * pMan;
958  Abc_Obj_t * pObj;
959  int i;
960  // start the HOP package
961  pMan = Hop_ManStart();
962  pMan->vObjs = Vec_PtrAlloc( Abc_NtkObjNumMax(pNtk) + 1 );
963  Vec_PtrPush( pMan->vObjs, Hop_ManConst1(pMan) );
964  // map constant node and PIs
965  Abc_AigConst1(pNtk)->pNext = (Abc_Obj_t *)Hop_ManConst1(pMan);
966  Abc_NtkForEachCi( pNtk, pObj, i )
967  pObj->pNext = (Abc_Obj_t *)Hop_ObjCreatePi(pMan);
968  // map the internal nodes
969  Abc_AigForEachAnd( pNtk, pObj, i )
970  {
971  pObj->pNext = (Abc_Obj_t *)Hop_And( pMan, Hop_ObjChild0Next(pObj), Hop_ObjChild1Next(pObj) );
972  assert( !Abc_ObjIsComplement(pObj->pNext) );
973  }
974  // set the choice nodes
975  Abc_AigForEachAnd( pNtk, pObj, i )
976  {
977  if ( pObj->pCopy )
978  ((Hop_Obj_t *)pObj->pNext)->pData = pObj->pCopy->pNext;
979  }
980  // transfer the POs
981  Abc_NtkForEachCo( pNtk, pObj, i )
982  Hop_ObjCreatePo( pMan, Hop_ObjChild0Next(pObj) );
983  // check the new manager
984  if ( !Hop_ManCheck(pMan) )
985  printf( "Abc_NtkPartStartHop: HOP manager check has failed.\n" );
986  return pMan;
987 }
988 
989 /**Function*************************************************************
990 
991  Synopsis [Stitches together several networks with choice nodes.]
992 
993  Description []
994 
995  SideEffects []
996 
997  SeeAlso []
998 
999 ***********************************************************************/
1001 {
1002  extern Abc_Ntk_t * Abc_NtkHopRemoveLoops( Abc_Ntk_t * pNtk, Hop_Man_t * pMan );
1003  Hop_Man_t * pMan;
1004  Vec_Ptr_t * vNodes;
1005  Abc_Ntk_t * pNtkNew, * pNtkTemp;
1006  Abc_Obj_t * pObj, * pFanin;
1007  int i, k, iNodeId;
1008 
1009  // start a new network similar to the original one
1010  assert( Abc_NtkIsStrash(pNtk) );
1011  pNtkNew = Abc_NtkStartFrom( pNtk, ABC_NTK_STRASH, ABC_FUNC_AIG );
1012 
1013  // annotate parts to point to the new network
1014  Vec_PtrForEachEntry( Abc_Ntk_t *, vParts, pNtkTemp, i )
1015  {
1016  assert( Abc_NtkIsStrash(pNtkTemp) );
1017  Abc_NtkCleanCopy( pNtkTemp );
1018 
1019  // map the CI nodes
1020  Abc_AigConst1(pNtkTemp)->pCopy = Abc_AigConst1(pNtkNew);
1021  Abc_NtkForEachCi( pNtkTemp, pObj, k )
1022  {
1023  iNodeId = Nm_ManFindIdByNameTwoTypes( pNtkNew->pManName, Abc_ObjName(pObj), ABC_OBJ_PI, ABC_OBJ_BO );
1024  if ( iNodeId == -1 )
1025  {
1026  printf( "Cannot find CI node %s in the original network.\n", Abc_ObjName(pObj) );
1027  return NULL;
1028  }
1029  pObj->pCopy = Abc_NtkObj( pNtkNew, iNodeId );
1030  }
1031 
1032  // add the internal nodes while saving representatives
1033  vNodes = Abc_AigDfs( pNtkTemp, 1, 0 );
1034  Vec_PtrForEachEntry( Abc_Obj_t *, vNodes, pObj, k )
1035  {
1036  pObj->pCopy = Abc_AigAnd( (Abc_Aig_t *)pNtkNew->pManFunc, Abc_ObjChild0Copy(pObj), Abc_ObjChild1Copy(pObj) );
1037  assert( !Abc_ObjIsComplement(pObj->pCopy) );
1038  if ( Abc_AigNodeIsChoice(pObj) )
1039  for ( pFanin = (Abc_Obj_t *)pObj->pData; pFanin; pFanin = (Abc_Obj_t *)pFanin->pData )
1040  pFanin->pCopy->pCopy = pObj->pCopy;
1041  }
1042  Vec_PtrFree( vNodes );
1043 
1044  // map the CO nodes
1045  Abc_NtkForEachCo( pNtkTemp, pObj, k )
1046  {
1047  iNodeId = Nm_ManFindIdByNameTwoTypes( pNtkNew->pManName, Abc_ObjName(pObj), ABC_OBJ_PO, ABC_OBJ_BI );
1048  if ( iNodeId == -1 )
1049  {
1050  printf( "Cannot find CO node %s in the original network.\n", Abc_ObjName(pObj) );
1051  return NULL;
1052  }
1053  pObj->pCopy = Abc_NtkObj( pNtkNew, iNodeId );
1054  Abc_ObjAddFanin( pObj->pCopy, Abc_ObjChild0Copy(pObj) );
1055  }
1056  }
1057 
1058  // connect the remaining POs
1059 /*
1060  Abc_AigConst1(pNtk)->pCopy = Abc_AigConst1(pNtkNew);
1061  Abc_NtkForEachCi( pNtk, pObj, i )
1062  pObj->pCopy = Abc_NtkCi( pNtkNew, i );
1063  Abc_NtkForEachCo( pNtk, pObj, i )
1064  pObj->pCopy = Abc_NtkCo( pNtkNew, i );
1065 */
1066  Abc_NtkForEachCo( pNtk, pObj, i )
1067  {
1068  if ( Abc_ObjFaninNum(pObj->pCopy) == 0 )
1069  Abc_ObjAddFanin( pObj->pCopy, Abc_ObjChild0Copy(pObj) );
1070  }
1071 
1072  // transform into the HOP manager
1073  pMan = Abc_NtkPartStartHop( pNtkNew );
1074  pNtkNew = Abc_NtkHopRemoveLoops( pNtkTemp = pNtkNew, pMan );
1075  Abc_NtkDelete( pNtkTemp );
1076 
1077  // check correctness of the new network
1078  if ( !Abc_NtkCheck( pNtkNew ) )
1079  {
1080  printf( "Abc_NtkPartStitchChoices: The network check has failed.\n" );
1081  Abc_NtkDelete( pNtkNew );
1082  return NULL;
1083  }
1084  return pNtkNew;
1085 }
1086 
1087 /**Function*************************************************************
1088 
1089  Synopsis [Stitches together several networks with choice nodes.]
1090 
1091  Description []
1092 
1093  SideEffects []
1094 
1095  SeeAlso []
1096 
1097 ***********************************************************************/
1098 Abc_Ntk_t * Abc_NtkFraigPartitioned( Vec_Ptr_t * vStore, void * pParams )
1099 {
1100  Vec_Ptr_t * vParts, * vFraigs, * vOnePtr;
1101  Vec_Int_t * vOne;
1102  Abc_Ntk_t * pNtk, * pNtk2, * pNtkAig, * pNtkFraig;
1103  int i, k;
1104 
1105  // perform partitioning
1106  pNtk = (Abc_Ntk_t *)Vec_PtrEntry( vStore, 0 );
1107  assert( Abc_NtkIsStrash(pNtk) );
1108 // vParts = Abc_NtkPartitionNaive( pNtk, 20 );
1109  vParts = Abc_NtkPartitionSmart( pNtk, 300, 0 );
1110 
1111  Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "unset progressbar" );
1112 
1113  // fraig each partition
1114  vOnePtr = Vec_PtrAlloc( 1000 );
1115  vFraigs = Vec_PtrAlloc( Vec_PtrSize(vParts) );
1116  Vec_PtrForEachEntry( Vec_Int_t *, vParts, vOne, i )
1117  {
1118  // start the partition
1119  Abc_NtkConvertCos( pNtk, vOne, vOnePtr );
1120  pNtkAig = Abc_NtkCreateConeArray( pNtk, vOnePtr, 0 );
1121  // add nodes to the partition
1122  Vec_PtrForEachEntryStart( Abc_Ntk_t *, vStore, pNtk2, k, 1 )
1123  {
1124  Abc_NtkConvertCos( pNtk2, vOne, vOnePtr );
1125  Abc_NtkAppendToCone( pNtkAig, pNtk2, vOnePtr );
1126  }
1127  printf( "Fraiging part %4d (out of %4d) PI = %5d. PO = %5d. And = %6d. Lev = %4d.\r",
1128  i+1, Vec_PtrSize(vParts), Abc_NtkPiNum(pNtkAig), Abc_NtkPoNum(pNtkAig),
1129  Abc_NtkNodeNum(pNtkAig), Abc_AigLevel(pNtkAig) );
1130  // fraig the partition
1131  pNtkFraig = Abc_NtkFraig( pNtkAig, pParams, 1, 0 );
1132  Vec_PtrPush( vFraigs, pNtkFraig );
1133  Abc_NtkDelete( pNtkAig );
1134  }
1135  printf( " \r" );
1136  Vec_VecFree( (Vec_Vec_t *)vParts );
1137 
1138  Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "set progressbar" );
1139 
1140  // derive the final network
1141  pNtkFraig = Abc_NtkPartStitchChoices( pNtk, vFraigs );
1142  Vec_PtrForEachEntry( Abc_Ntk_t *, vFraigs, pNtkAig, i )
1143  Abc_NtkDelete( pNtkAig );
1144  Vec_PtrFree( vFraigs );
1145  Vec_PtrFree( vOnePtr );
1146  return pNtkFraig;
1147 }
1148 
1149 /**Function*************************************************************
1150 
1151  Synopsis [Stitches together several networks with choice nodes.]
1152 
1153  Description []
1154 
1155  SideEffects []
1156 
1157  SeeAlso []
1158 
1159 ***********************************************************************/
1160 void Abc_NtkFraigPartitionedTime( Abc_Ntk_t * pNtk, void * pParams )
1161 {
1162  Vec_Ptr_t * vParts, * vFraigs, * vOnePtr;
1163  Vec_Int_t * vOne;
1164  Abc_Ntk_t * pNtkAig, * pNtkFraig;
1165  int i;
1166  abctime clk = Abc_Clock();
1167 
1168  // perform partitioning
1169  assert( Abc_NtkIsStrash(pNtk) );
1170 // vParts = Abc_NtkPartitionNaive( pNtk, 20 );
1171  vParts = Abc_NtkPartitionSmart( pNtk, 300, 0 );
1172 
1173  Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "unset progressbar" );
1174 
1175  // fraig each partition
1176  vOnePtr = Vec_PtrAlloc( 1000 );
1177  vFraigs = Vec_PtrAlloc( Vec_PtrSize(vParts) );
1178  Vec_PtrForEachEntry( Vec_Int_t *, vParts, vOne, i )
1179  {
1180  Abc_NtkConvertCos( pNtk, vOne, vOnePtr );
1181  pNtkAig = Abc_NtkCreateConeArray( pNtk, vOnePtr, 0 );
1182  pNtkFraig = Abc_NtkFraig( pNtkAig, pParams, 0, 0 );
1183  Vec_PtrPush( vFraigs, pNtkFraig );
1184  Abc_NtkDelete( pNtkAig );
1185 
1186  printf( "Finished part %5d (out of %5d)\r", i+1, Vec_PtrSize(vParts) );
1187  }
1188  Vec_VecFree( (Vec_Vec_t *)vParts );
1189 
1190  Cmd_CommandExecute( Abc_FrameGetGlobalFrame(), "set progressbar" );
1191 
1192  // derive the final network
1193  Vec_PtrForEachEntry( Abc_Ntk_t *, vFraigs, pNtkAig, i )
1194  Abc_NtkDelete( pNtkAig );
1195  Vec_PtrFree( vFraigs );
1196  Vec_PtrFree( vOnePtr );
1197  ABC_PRT( "Partitioned fraiging time", Abc_Clock() - clk );
1198 }
1199 
1200 ////////////////////////////////////////////////////////////////////////
1201 /// END OF FILE ///
1202 ////////////////////////////////////////////////////////////////////////
1203 
1204 
1206 
char * memset()
int Hop_ManCheck(Hop_Man_t *p)
DECLARATIONS ///.
Definition: hopCheck.c:45
void Supp_ManRecycle(Supp_Man_t *p, char *pMemory, int nSize)
Definition: abcPart.c:153
static Supp_One_t * Supp_ManFetchEntry(Supp_Man_t *p, int nWords, int nRefs)
Definition: abcPart.c:173
static int Abc_NtkIsStrash(Abc_Ntk_t *pNtk)
Definition: abc.h:251
Definition: abc.h:91
typedefABC_NAMESPACE_HEADER_START struct Vec_Ptr_t_ Vec_Ptr_t
INCLUDES ///.
Definition: vecPtr.h:42
static Abc_Obj_t * Abc_ObjFanin1(Abc_Obj_t *pObj)
Definition: abc.h:374
Vec_Ptr_t * vFree
Definition: abcPart.c:40
static int Abc_ObjIsCi(Abc_Obj_t *pObj)
Definition: abc.h:351
Nm_Man_t * pManName
Definition: abc.h:160
static void Vec_VecSort(Vec_Vec_t *p, int fReverse)
Definition: vecVec.h:546
ABC_DLL void Abc_NtkAppendToCone(Abc_Ntk_t *pNtkNew, Abc_Ntk_t *pNtk, Vec_Ptr_t *vRoots)
Definition: abcNtk.c:969
#define Vec_PtrForEachEntryStart(Type, vVec, pEntry, i, Start)
Definition: vecPtr.h:57
static Vec_Int_t * Vec_IntDup(Vec_Int_t *pVec)
Definition: vecInt.h:214
int nRefs
Definition: abcPart.c:46
static int Abc_NtkObjNumMax(Abc_Ntk_t *pNtk)
Definition: abc.h:284
typedefABC_NAMESPACE_HEADER_START struct Vec_Vec_t_ Vec_Vec_t
INCLUDES ///.
Definition: vecVec.h:42
static Hop_Obj_t * Hop_ManConst1(Hop_Man_t *p)
Definition: hop.h:132
ABC_DLL Abc_Obj_t * Abc_AigConst1(Abc_Ntk_t *pNtk)
Definition: abcAig.c:683
Hop_Obj_t * Hop_And(Hop_Man_t *p, Hop_Obj_t *p0, Hop_Obj_t *p1)
Definition: hopOper.c:104
static Llb_Mgr_t * p
Definition: llb3Image.c:950
static int Abc_ObjFaninC1(Abc_Obj_t *pObj)
Definition: abc.h:378
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition: bblif.c:37
int Cmd_CommandExecute(void *pAbc, char *pCommandLine)
static int Abc_InfoHasBit(unsigned *p, int i)
Definition: abc_global.h:258
unsigned * Abc_NtkSuppCharStart(Vec_Int_t *vOne, int nPis)
Definition: abcPart.c:466
ABC_DLL Abc_Ntk_t * Abc_NtkCreateConeArray(Abc_Ntk_t *pNtk, Vec_Ptr_t *vRoots, int fUseAllCis)
Definition: abcNtk.c:889
static int Abc_ObjFanoutNum(Abc_Obj_t *pObj)
Definition: abc.h:365
void Abc_NtkSuppCharAdd(unsigned *pBuffer, Vec_Int_t *vOne, int nPis)
Definition: abcPart.c:492
int Abc_NtkPartitionSmartFindPart(Vec_Ptr_t *vPartSuppsAll, Vec_Ptr_t *vPartsAll, Vec_Ptr_t *vPartSuppsChar, int nSuppSizeLimit, Vec_Int_t *vOne)
Definition: abcPart.c:532
void Supp_ManStop(Supp_Man_t *p)
Definition: abcPart.c:94
void Abc_NtkPartitionPrint(Abc_Ntk_t *pNtk, Vec_Ptr_t *vPartsAll, Vec_Ptr_t *vPartSuppsAll)
Definition: abcPart.c:621
static void Vec_PtrFillExtra(Vec_Ptr_t *p, int nSize, void *Fill)
Definition: vecPtr.h:469
static Abc_Obj_t * Abc_ObjChild1Copy(Abc_Obj_t *pObj)
Definition: abc.h:387
static int Abc_ObjFaninNum(Abc_Obj_t *pObj)
Definition: abc.h:364
static int Abc_ObjFaninC0(Abc_Obj_t *pObj)
Definition: abc.h:377
int nStepSize
Definition: abcPart.c:36
static void Vec_PtrPush(Vec_Ptr_t *p, void *Entry)
Definition: vecPtr.h:606
static int Abc_NtkCiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:287
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
#define Abc_NtkForEachCo(pNtk, pCo, i)
Definition: abc.h:519
static Hop_Obj_t * Hop_ObjChild1Next(Abc_Obj_t *pObj)
Definition: abcPart.c:941
ABC_DLL int Abc_NtkCheck(Abc_Ntk_t *pNtk)
FUNCTION DEFINITIONS ///.
Definition: abcCheck.c:61
Vec_Ptr_t * Abc_NtkPartitionSmart(Abc_Ntk_t *pNtk, int nSuppSizeLimit, int fVerbose)
Definition: abcPart.c:722
Vec_Ptr_t * vMemory
Definition: abcPart.c:39
static abctime Abc_Clock()
Definition: abc_global.h:279
static Abc_Obj_t * Abc_NtkObj(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:314
static int Vec_PtrSize(Vec_Ptr_t *p)
Definition: vecPtr.h:295
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
static void Vec_IntSort(Vec_Int_t *p, int fReverse)
Definition: vecInt.h:1293
int nWords
Definition: abcNpn.c:127
static Abc_Obj_t * Abc_ObjFanin0(Abc_Obj_t *pObj)
Definition: abc.h:373
Definition: hop.h:65
static int Abc_NtkCoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:288
DECLARATIONS ///.
Definition: abcAig.c:52
static void Supp_ManRecycleEntry(Supp_Man_t *p, Supp_One_t *pEntry)
Definition: abcPart.c:194
ABC_DLL Abc_Ntk_t * Abc_NtkFraig(Abc_Ntk_t *pNtk, void *pParams, int fAllNodes, int fExdc)
FUNCTION DEFINITIONS ///.
Definition: abcFraig.c:58
ABC_DLL void Abc_NtkDelete(Abc_Ntk_t *pNtk)
Definition: abcNtk.c:1233
static int Abc_ObjIsCo(Abc_Obj_t *pObj)
Definition: abc.h:352
static Abc_Obj_t * Abc_NtkCo(Abc_Ntk_t *pNtk, int i)
Definition: abc.h:318
ABC_DLL void Abc_ObjAddFanin(Abc_Obj_t *pObj, Abc_Obj_t *pFanin)
Definition: abcFanio.c:84
#define Abc_AigForEachAnd(pNtk, pNode, i)
Definition: abc.h:485
static void Vec_IntWriteEntry(Vec_Int_t *p, int i, int Entry)
Definition: bblif.c:285
void * pManFunc
Definition: abc.h:191
static int Abc_ObjIsNode(Abc_Obj_t *pObj)
Definition: abc.h:355
Vec_Ptr_t * Abc_NtkComputeSupportsNaive(Abc_Ntk_t *pNtk)
Definition: abcPart.c:417
static int Abc_NtkNodeNum(Abc_Ntk_t *pNtk)
Definition: abc.h:293
ABC_DLL Abc_Obj_t * Abc_AigAnd(Abc_Aig_t *pMan, Abc_Obj_t *p0, Abc_Obj_t *p1)
Definition: abcAig.c:700
static Abc_Obj_t * Abc_ObjChild0Copy(Abc_Obj_t *pObj)
Definition: abc.h:386
int pOuts[0]
Definition: abcPart.c:49
static char * Supp_OneNext(char *pPart)
Definition: abcPart.c:53
DECLARATIONS ///.
ABC_DLL Abc_Ntk_t * Abc_NtkStartFrom(Abc_Ntk_t *pNtk, Abc_NtkType_t Type, Abc_NtkFunc_t Func)
Definition: abcNtk.c:106
Abc_Obj_t * pCopy
Definition: abc.h:148
Vec_Int_t * Supp_ManTransferEntry(Supp_One_t *p)
Definition: abcPart.c:251
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
ABC_DLL int Abc_AigLevel(Abc_Ntk_t *pNtk)
Definition: abcAig.c:292
int Nm_ManFindIdByNameTwoTypes(Nm_Man_t *p, char *pName, int Type1, int Type2)
Definition: nmApi.c:239
static int Supp_SizeType(int nSize, int nStepSize)
Definition: abcPart.c:52
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
void * Abc_FrameGetGlobalFrame()
Definition: mainFrame.c:593
static Abc_Obj_t * Abc_NtkPartStitchCopy0(Vec_Ptr_t *vEquiv, Abc_Obj_t *pObj)
Definition: abcPart.c:916
ABC_DLL Vec_Ptr_t * Abc_NtkNodeSupport(Abc_Ntk_t *pNtk, Abc_Obj_t **ppNodes, int nNodes)
Definition: abcDfs.c:859
static int Vec_IntPop(Vec_Int_t *p)
Hop_Man_t * Hop_ManStart()
DECLARATIONS ///.
Definition: hopMan.c:45
int nFreeSize
Definition: abcPart.c:38
Supp_One_t * Supp_ManMergeEntry(Supp_Man_t *pMan, Supp_One_t *p1, Supp_One_t *p2, int nRefs)
Definition: abcPart.c:212
void Abc_NtkConvertCos(Abc_Ntk_t *pNtk, Vec_Int_t *vOuts, Vec_Ptr_t *vOutsPtr)
Definition: abcPart.c:877
int nOutsAlloc
Definition: abcPart.c:48
static void Vec_IntPush(Vec_Int_t *p, int Entry)
Definition: bblif.c:468
static int Counter
Abc_Ntk_t * Abc_NtkHopRemoveLoops(Abc_Ntk_t *pNtk, Hop_Man_t *pMan)
Definition: abcHaig.c:533
typedefABC_NAMESPACE_IMPL_START struct Supp_Man_t_ Supp_Man_t
DECLARATIONS ///.
Definition: abcPart.c:32
static Vec_Int_t * Vec_IntTwoMerge(Vec_Int_t *vArr1, Vec_Int_t *vArr2)
Definition: vecInt.h:1684
static Vec_Vec_t * Vec_VecStart(int nSize)
Definition: vecVec.h:168
Abc_Ntk_t * Abc_NtkFraigPartitioned(Vec_Ptr_t *vStore, void *pParams)
Definition: abcPart.c:1098
Vec_Ptr_t * Abc_NtkPartitionNaive(Abc_Ntk_t *pNtk, int nPartSize)
Definition: abcPart.c:854
void Extra_ProgressBarStop(ProgressBar *p)
static void Vec_PtrWriteEntry(Vec_Ptr_t *p, int i, void *Entry)
Definition: vecPtr.h:396
#define Abc_NtkForEachNode(pNtk, pNode, i)
Definition: abc.h:461
ABC_DLL Vec_Ptr_t * Abc_AigDfs(Abc_Ntk_t *pNtk, int fCollectAll, int fCollectCos)
Definition: abcDfs.c:1014
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static void * Vec_PtrEntry(Vec_Ptr_t *p, int i)
Definition: vecPtr.h:362
static void Abc_InfoSetBit(unsigned *p, int i)
Definition: abc_global.h:259
char * Supp_ManFetch(Supp_Man_t *p, int nSize)
Definition: abcPart.c:116
static int Abc_NodeIsTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:411
static int Abc_AigNodeIsChoice(Abc_Obj_t *pNode)
Definition: abc.h:398
Vec_Ptr_t * Abc_NtkDfsNatural(Abc_Ntk_t *pNtk)
Definition: abcPart.c:272
static int Vec_IntSize(Vec_Int_t *p)
Definition: bblif.c:252
Definition: abc.h:89
void Abc_NtkFraigPartitionedTime(Abc_Ntk_t *pNtk, void *pParams)
Definition: abcPart.c:1160
#define Abc_ObjForEachFanout(pObj, pFanout, i)
Definition: abc.h:526
#define Abc_NtkForEachCi(pNtk, pCi, i)
Definition: abc.h:515
static int Abc_NtkPoNum(Abc_Ntk_t *pNtk)
Definition: abc.h:286
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
int Abc_NtkSuppCharCommon(unsigned *pBuffer, Vec_Int_t *vOne)
Definition: abcPart.c:513
#define Abc_ObjForEachFanin(pObj, pFanin, i)
Definition: abc.h:524
static Hop_Obj_t * Hop_NotCond(Hop_Obj_t *p, int c)
Definition: hop.h:128
#define ABC_FREE(obj)
Definition: abc_global.h:232
int Id
Definition: abc.h:132
static int Abc_NtkPiNum(Abc_Ntk_t *pNtk)
Definition: abc.h:285
ABC_DLL char * Abc_ObjName(Abc_Obj_t *pNode)
DECLARATIONS ///.
Definition: abcNames.c:48
#define ABC_PRT(a, t)
Definition: abc_global.h:220
static int Abc_Base2Log(unsigned n)
Definition: abc_global.h:251
void Abc_NtkPartitionCompact(Vec_Ptr_t *vPartsAll, Vec_Ptr_t *vPartSuppsAll, int nSuppSizeLimit)
Definition: abcPart.c:650
static void Abc_NtkIncrementTravId(Abc_Ntk_t *p)
Definition: abc.h:406
ProgressBar * Extra_ProgressBarStart(FILE *pFile, int nItemsTotal)
FUNCTION DEFINITIONS ///.
Definition: abc.h:90
char * pFreeBuf
Definition: abcPart.c:37
int nChunkSize
Definition: abcPart.c:35
static Hop_Obj_t * Hop_ObjChild0Next(Abc_Obj_t *pObj)
Definition: abcPart.c:940
Definition: abc.h:92
Abc_Obj_t * pNext
Definition: abc.h:131
ABC_DLL void Abc_NtkCleanCopy(Abc_Ntk_t *pNtk)
Definition: abcUtil.c:507
static int Abc_BitWordNum(int nBits)
Definition: abc_global.h:255
static Abc_Obj_t * Abc_ObjNotCond(Abc_Obj_t *p, int c)
Definition: abc.h:325
int nOuts
Definition: abcPart.c:47
#define assert(ex)
Definition: util_old.h:213
static void Extra_ProgressBarUpdate(ProgressBar *p, int nItemsCur, char *pString)
Definition: extra.h:243
static void Vec_PtrClear(Vec_Ptr_t *p)
Definition: vecPtr.h:545
Abc_Ntk_t * Abc_NtkPartStitchChoices(Abc_Ntk_t *pNtk, Vec_Ptr_t *vParts)
Definition: abcPart.c:1000
Hop_Obj_t * Hop_ObjCreatePo(Hop_Man_t *p, Hop_Obj_t *pDriver)
Definition: hopObj.c:67
void * pData
Definition: abc.h:145
Vec_Ptr_t * Abc_NtkComputeSupportsSmart(Abc_Ntk_t *pNtk)
Definition: abcPart.c:318
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
#define Vec_PtrForEachEntry(Type, vVec, pEntry, i)
MACRO DEFINITIONS ///.
Definition: vecPtr.h:55
static int Abc_ObjIsComplement(Abc_Obj_t *p)
Definition: abc.h:322
ABC_INT64_T abctime
Definition: abc_global.h:278
static void Supp_OneSetNext(char *pPart, char *pNext)
Definition: abcPart.c:54
static void Vec_PtrShrink(Vec_Ptr_t *p, int nSizeNew)
Definition: vecPtr.h:528
static int Abc_NtkObjNum(Abc_Ntk_t *pNtk)
Definition: abc.h:283
Hop_Obj_t * Hop_ObjCreatePi(Hop_Man_t *p)
DECLARATIONS ///.
Definition: hopObj.c:45
#define Vec_IntForEachEntry(vVec, Entry, i)
MACRO DEFINITIONS ///.
Definition: vecInt.h:54
unsigned fPhase
Definition: abc.h:137
typedefABC_NAMESPACE_HEADER_START struct Hop_Man_t_ Hop_Man_t
INCLUDES ///.
Definition: hop.h:49
Supp_Man_t * Supp_ManStart(int nChunkSize, int nStepSize)
FUNCTION DEFINITIONS ///.
Definition: abcPart.c:71
Hop_Man_t * Abc_NtkPartStartHop(Abc_Ntk_t *pNtk)
Definition: abcPart.c:955
Abc_Obj_t * Abc_NtkPartStitchFindRepr_rec(Vec_Ptr_t *vEquiv, Abc_Obj_t *pObj)
Definition: abcPart.c:896
static Abc_Obj_t * Abc_NtkPartStitchCopy1(Vec_Ptr_t *vEquiv, Abc_Obj_t *pObj)
Definition: abcPart.c:922
static void Abc_NodeSetTravIdCurrent(Abc_Obj_t *p)
Definition: abc.h:409
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223