abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
darMan.c
Go to the documentation of this file.
1 /**CFile****************************************************************
2 
3  FileName [darMan.c]
4 
5  SystemName [ABC: Logic synthesis and verification system.]
6 
7  PackageName [DAG-aware AIG rewriting.]
8 
9  Synopsis [AIG manager.]
10 
11  Author [Alan Mishchenko]
12 
13  Affiliation [UC Berkeley]
14 
15  Date [Ver. 1.0. Started - April 28, 2007.]
16 
17  Revision [$Id: darMan.c,v 1.00 2007/04/28 00:00:00 alanmi Exp $]
18 
19 ***********************************************************************/
20 
21 #include "darInt.h"
22 
24 
25 ////////////////////////////////////////////////////////////////////////
26 /// DECLARATIONS ///
27 ////////////////////////////////////////////////////////////////////////
28 
29 ////////////////////////////////////////////////////////////////////////
30 /// FUNCTION DEFINITIONS ///
31 ////////////////////////////////////////////////////////////////////////
32 
33 /**Function*************************************************************
34 
35  Synopsis [Starts the rewriting manager.]
36 
37  Description []
38 
39  SideEffects []
40 
41  SeeAlso []
42 
43 ***********************************************************************/
45 {
46  Dar_Man_t * p;
47  Aig_ManCleanData( pAig );
48  p = ABC_ALLOC( Dar_Man_t, 1 );
49  memset( p, 0, sizeof(Dar_Man_t) );
50  p->pPars = pPars;
51  p->pAig = pAig;
52  p->vCutNodes = Vec_PtrAlloc( 1000 );
53  p->pMemCuts = Aig_MmFixedStart( p->pPars->nCutsMax * sizeof(Dar_Cut_t), 1024 );
54  p->vLeavesBest = Vec_PtrAlloc( 4 );
55  return p;
56 }
57 
58 /**Function*************************************************************
59 
60  Synopsis [Stops the rewriting manager.]
61 
62  Description []
63 
64  SideEffects []
65 
66  SeeAlso []
67 
68 ***********************************************************************/
70 {
71  if ( p->pPars->fVerbose )
72  Dar_ManPrintStats( p );
73  if ( p->vCutNodes )
74  Vec_PtrFree( p->vCutNodes );
75  if ( p->pMemCuts )
76  Aig_MmFixedStop( p->pMemCuts, 0 );
77  if ( p->vLeavesBest )
78  Vec_PtrFree( p->vLeavesBest );
79  ABC_FREE( p );
80 }
81 
82 /**Function*************************************************************
83 
84  Synopsis [Stops the AIG manager.]
85 
86  Description []
87 
88  SideEffects []
89 
90  SeeAlso []
91 
92 ***********************************************************************/
94 {
95  unsigned pCanons[222];
96  int Gain, i;
97  extern void Kit_DsdPrintFromTruth( unsigned * pTruth, int nVars );
98 
99  Gain = p->nNodesInit - Aig_ManNodeNum(p->pAig);
100  printf( "Tried = %8d. Beg = %8d. End = %8d. Gain = %6d. (%6.2f %%). Cut mem = %d MB\n",
101  p->nNodesTried, p->nNodesInit, Aig_ManNodeNum(p->pAig), Gain, 100.0*Gain/p->nNodesInit, p->nCutMemUsed );
102  printf( "Cuts = %8d. Tried = %8d. Used = %8d. Bad = %5d. Skipped = %5d. Ave = %.2f.\n",
103  p->nCutsAll, p->nCutsTried, p->nCutsUsed, p->nCutsBad, p->nCutsSkipped,
104  (float)p->nCutsUsed/Aig_ManNodeNum(p->pAig) );
105 
106  printf( "Bufs = %5d. BufMax = %5d. BufReplace = %6d. BufFix = %6d. Levels = %4d.\n",
107  Aig_ManBufNum(p->pAig), p->pAig->nBufMax, p->pAig->nBufReplaces, p->pAig->nBufFixes, Aig_ManLevels(p->pAig) );
108  ABC_PRT( "Cuts ", p->timeCuts );
109  ABC_PRT( "Eval ", p->timeEval );
110  ABC_PRT( "Other ", p->timeOther );
111  ABC_PRT( "TOTAL ", p->timeTotal );
112 
113  if ( !p->pPars->fVeryVerbose )
114  return;
115  Dar_LibReturnCanonicals( pCanons );
116  for ( i = 0; i < 222; i++ )
117  {
118  if ( p->ClassGains[i] == 0 && p->ClassTimes[i] == 0 )
119  continue;
120  printf( "%3d : ", i );
121  printf( "G = %6d (%5.2f %%) ", p->ClassGains[i], Gain? 100.0*p->ClassGains[i]/Gain : 0.0 );
122  printf( "S = %8d (%5.2f %%) ", p->ClassSubgs[i], p->nTotalSubgs? 100.0*p->ClassSubgs[i]/p->nTotalSubgs : 0.0 );
123  printf( "R = %7d ", p->ClassGains[i]? p->ClassSubgs[i]/p->ClassGains[i] : 9999999 );
124 // Kit_DsdPrintFromTruth( pCanons + i, 4 );
125 // ABC_PRTP( "T", p->ClassTimes[i], p->timeEval );
126  printf( "\n" );
127  }
128  fflush( stdout );
129 }
130 
131 
132 /**Function*************************************************************
133 
134  Synopsis []
135 
136  Description []
137 
138  SideEffects []
139 
140  SeeAlso []
141 
142 ***********************************************************************/
143 #if 0
144 
146 
147 #include "bool/kit/kit.h"
148 
150 
151 void Dar_ManPrintScript()
152 {
153  unsigned pCanons[222];
154  int i;
155  Dar_LibReturnCanonicals( pCanons );
156  for ( i = 1; i < 222; i++ )
157  {
158  Kit_DsdNtk_t * pNtk;
159  pNtk = Kit_DsdDecompose( pCanons + i, 4 );
160  printf( " \"" );
161  Kit_DsdPrint( stdout, pNtk );
162  printf( "\", /* %3d */\n", i );
163  Kit_DsdNtkFree( pNtk );
164  }
165 }
166 #endif
167 
168 ////////////////////////////////////////////////////////////////////////
169 /// END OF FILE ///
170 ////////////////////////////////////////////////////////////////////////
171 
172 
174 
char * memset()
void Dar_ManStop(Dar_Man_t *p)
Definition: darMan.c:69
typedefABC_NAMESPACE_HEADER_START struct Aig_Man_t_ Aig_Man_t
INCLUDES ///.
Definition: aig.h:50
static Llb_Mgr_t * p
Definition: llb3Image.c:950
void Aig_MmFixedStop(Aig_MmFixed_t *p, int fVerbose)
Definition: aigMem.c:132
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
void Kit_DsdPrintFromTruth(unsigned *pTruth, int nVars)
Definition: kitDsd.c:490
Aig_MmFixed_t * Aig_MmFixedStart(int nEntrySize, int nEntriesMax)
FUNCTION DEFINITIONS ///.
Definition: aigMem.c:96
static int Aig_ManNodeNum(Aig_Man_t *p)
Definition: aig.h:256
Kit_DsdNtk_t * Kit_DsdDecompose(unsigned *pTruth, int nVars)
Definition: kitDsd.c:2314
static int Aig_ManBufNum(Aig_Man_t *p)
Definition: aig.h:253
void Kit_DsdPrint(FILE *pFile, Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:374
typedefABC_NAMESPACE_HEADER_START struct Dar_Man_t_ Dar_Man_t
INCLUDES ///.
Definition: darInt.h:51
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
void Dar_ManPrintStats(Dar_Man_t *p)
Definition: darMan.c:93
void Dar_LibReturnCanonicals(unsigned *pCanons)
Definition: darLib.c:211
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define ABC_PRT(a, t)
Definition: abc_global.h:220
typedefABC_NAMESPACE_HEADER_START struct Dar_RwrPar_t_ Dar_RwrPar_t
INCLUDES ///.
Definition: dar.h:42
void Kit_DsdNtkFree(Kit_DsdNtk_t *pNtk)
Definition: kitDsd.c:163
int Aig_ManLevels(Aig_Man_t *p)
Definition: aigUtil.c:102
void Aig_ManCleanData(Aig_Man_t *p)
Definition: aigUtil.c:205
ABC_NAMESPACE_IMPL_START Dar_Man_t * Dar_ManStart(Aig_Man_t *pAig, Dar_RwrPar_t *pPars)
DECLARATIONS ///.
Definition: darMan.c:44
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223