abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
rwrMan.c File Reference
#include "rwr.h"
#include "base/main/main.h"
#include "bool/dec/dec.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START
Rwr_Man_t
Rwr_ManStart (int fPrecompute)
 DECLARATIONS ///. More...
 
void Rwr_ManStop (Rwr_Man_t *p)
 
void Rwr_ManPrintStats (Rwr_Man_t *p)
 
void Rwr_ManPrintStatsFile (Rwr_Man_t *p)
 
void * Rwr_ManReadDecs (Rwr_Man_t *p)
 
Vec_Ptr_tRwr_ManReadLeaves (Rwr_Man_t *p)
 
int Rwr_ManReadCompl (Rwr_Man_t *p)
 
void Rwr_ManAddTimeCuts (Rwr_Man_t *p, abctime Time)
 
void Rwr_ManAddTimeUpdate (Rwr_Man_t *p, abctime Time)
 
void Rwr_ManAddTimeTotal (Rwr_Man_t *p, abctime Time)
 
void Rwr_Precompute ()
 

Function Documentation

void Rwr_ManAddTimeCuts ( Rwr_Man_t p,
abctime  Time 
)

Function*************************************************************

Synopsis [Stops the resynthesis manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 261 of file rwrMan.c.

262 {
263  p->timeCut += Time;
264 }
abctime timeCut
Definition: rwr.h:90
void Rwr_ManAddTimeTotal ( Rwr_Man_t p,
abctime  Time 
)

Function*************************************************************

Synopsis [Stops the resynthesis manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 293 of file rwrMan.c.

294 {
295  p->timeTotal += Time;
296 }
abctime timeTotal
Definition: rwr.h:95
void Rwr_ManAddTimeUpdate ( Rwr_Man_t p,
abctime  Time 
)

Function*************************************************************

Synopsis [Stops the resynthesis manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 277 of file rwrMan.c.

278 {
279  p->timeUpdate += Time;
280 }
abctime timeUpdate
Definition: rwr.h:94
void Rwr_ManPrintStats ( Rwr_Man_t p)

Function*************************************************************

Synopsis [Stops the resynthesis manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 143 of file rwrMan.c.

144 {
145  int i, Counter = 0;
146  for ( i = 0; i < 222; i++ )
147  Counter += (p->nScores[i] > 0);
148 
149  printf( "Rewriting statistics:\n" );
150  printf( "Total cuts tries = %8d.\n", p->nCutsGood );
151  printf( "Bad cuts found = %8d.\n", p->nCutsBad );
152  printf( "Total subgraphs = %8d.\n", p->nSubgraphs );
153  printf( "Used NPN classes = %8d.\n", Counter );
154  printf( "Nodes considered = %8d.\n", p->nNodesConsidered );
155  printf( "Nodes rewritten = %8d.\n", p->nNodesRewritten );
156  printf( "Gain = %8d. (%6.2f %%).\n", p->nNodesBeg-p->nNodesEnd, 100.0*(p->nNodesBeg-p->nNodesEnd)/p->nNodesBeg );
157  ABC_PRT( "Start ", p->timeStart );
158  ABC_PRT( "Cuts ", p->timeCut );
159  ABC_PRT( "Resynthesis ", p->timeRes );
160  ABC_PRT( " Mffc ", p->timeMffc );
161  ABC_PRT( " Eval ", p->timeEval );
162  ABC_PRT( "Update ", p->timeUpdate );
163  ABC_PRT( "TOTAL ", p->timeTotal );
164 
165 /*
166  printf( "The scores are:\n" );
167  for ( i = 0; i < 222; i++ )
168  if ( p->nScores[i] > 0 )
169  {
170  extern void Ivy_TruthDsdComputePrint( unsigned uTruth );
171  printf( "%3d = %8d canon = %5d ", i, p->nScores[i], p->pMapInv[i] );
172  Ivy_TruthDsdComputePrint( (unsigned)p->pMapInv[i] | ((unsigned)p->pMapInv[i] << 16) );
173  }
174 */
175  printf( "\n" );
176 
177 }
abctime timeTotal
Definition: rwr.h:95
abctime timeEval
Definition: rwr.h:92
abctime timeStart
Definition: rwr.h:89
int nNodesEnd
Definition: rwr.h:83
int nNodesBeg
Definition: rwr.h:82
abctime timeCut
Definition: rwr.h:90
static int Counter
int nSubgraphs
Definition: rwr.h:87
int nCutsGood
Definition: rwr.h:85
#define ABC_PRT(a, t)
Definition: abc_global.h:220
int nCutsBad
Definition: rwr.h:86
int nNodesRewritten
Definition: rwr.h:80
int nNodesConsidered
Definition: rwr.h:79
abctime timeMffc
Definition: rwr.h:93
abctime timeUpdate
Definition: rwr.h:94
abctime timeRes
Definition: rwr.h:91
int nScores[222]
Definition: rwr.h:84
void Rwr_ManPrintStatsFile ( Rwr_Man_t p)

Function*************************************************************

Synopsis [Stops the resynthesis manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 190 of file rwrMan.c.

191 {
192  FILE * pTable;
193  pTable = fopen( "stats.txt", "a+" );
194  fprintf( pTable, "%d ", p->nCutsGood );
195  fprintf( pTable, "%d ", p->nSubgraphs );
196  fprintf( pTable, "%d ", p->nNodesRewritten );
197  fprintf( pTable, "%d", p->nNodesGained );
198  fprintf( pTable, "\n" );
199  fclose( pTable );
200 }
int nNodesGained
Definition: rwr.h:81
int nSubgraphs
Definition: rwr.h:87
int nCutsGood
Definition: rwr.h:85
int nNodesRewritten
Definition: rwr.h:80
int Rwr_ManReadCompl ( Rwr_Man_t p)

Function*************************************************************

Synopsis [Stops the resynthesis manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 245 of file rwrMan.c.

246 {
247  return p->fCompl;
248 }
int fCompl
Definition: rwr.h:72
void* Rwr_ManReadDecs ( Rwr_Man_t p)

Function*************************************************************

Synopsis [Stops the resynthesis manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 213 of file rwrMan.c.

214 {
215  return p->pGraph;
216 }
void * pGraph
Definition: rwr.h:73
Vec_Ptr_t* Rwr_ManReadLeaves ( Rwr_Man_t p)

Function*************************************************************

Synopsis [Stops the resynthesis manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 229 of file rwrMan.c.

230 {
231  return p->vFanins;
232 }
Vec_Ptr_t * vFanins
Definition: rwr.h:74
ABC_NAMESPACE_IMPL_START Rwr_Man_t* Rwr_ManStart ( int  fPrecompute)

DECLARATIONS ///.

CFile****************************************************************

FileName [rwrMan.c]

SystemName [ABC: Logic synthesis and verification system.]

PackageName [DAG-aware AIG rewriting package.]

Synopsis [Rewriting manager.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - June 20, 2005.]

Revision [

Id:
rwrMan.c,v 1.00 2005/06/20 00:00:00 alanmi Exp

]FUNCTION DEFINITIONS /// Function*************************************************************

Synopsis [Starts rewriting manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 47 of file rwrMan.c.

48 {
49  Dec_Man_t * pManDec;
50  Rwr_Man_t * p;
51  abctime clk = Abc_Clock();
52 clk = Abc_Clock();
53  p = ABC_ALLOC( Rwr_Man_t, 1 );
54  memset( p, 0, sizeof(Rwr_Man_t) );
55  p->nFuncs = (1<<16);
56  pManDec = (Dec_Man_t *)Abc_FrameReadManDec();
57  p->puCanons = pManDec->puCanons;
58  p->pPhases = pManDec->pPhases;
59  p->pPerms = pManDec->pPerms;
60  p->pMap = pManDec->pMap;
61  // initialize practical NPN classes
63  // create the table
64  p->pTable = ABC_ALLOC( Rwr_Node_t *, p->nFuncs );
65  memset( p->pTable, 0, sizeof(Rwr_Node_t *) * p->nFuncs );
66  // create the elementary nodes
67  p->pMmNode = Extra_MmFixedStart( sizeof(Rwr_Node_t) );
68  p->vForest = Vec_PtrAlloc( 100 );
69  Rwr_ManAddVar( p, 0x0000, fPrecompute ); // constant 0
70  Rwr_ManAddVar( p, 0xAAAA, fPrecompute ); // var A
71  Rwr_ManAddVar( p, 0xCCCC, fPrecompute ); // var B
72  Rwr_ManAddVar( p, 0xF0F0, fPrecompute ); // var C
73  Rwr_ManAddVar( p, 0xFF00, fPrecompute ); // var D
74  p->nClasses = 5;
75  // other stuff
76  p->nTravIds = 1;
77  p->pPerms4 = Extra_Permutations( 4 );
78  p->vLevNums = Vec_IntAlloc( 50 );
79  p->vFanins = Vec_PtrAlloc( 50 );
80  p->vFaninsCur = Vec_PtrAlloc( 50 );
81  p->vNodesTemp = Vec_PtrAlloc( 50 );
82  if ( fPrecompute )
83  { // precompute subgraphs
84  Rwr_ManPrecompute( p );
85 // Rwr_ManPrint( p );
87  }
88  else
89  { // load saved subgraphs
90  Rwr_ManLoadFromArray( p, 0 );
91 // Rwr_ManPrint( p );
92  Rwr_ManPreprocess( p );
93  }
94 p->timeStart = Abc_Clock() - clk;
95  return p;
96 }
char * memset()
char * Rwr_ManGetPractical(Rwr_Man_t *p)
Definition: rwrUtil.c:640
abctime timeStart
Definition: rwr.h:89
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Rwr_Node_t * Rwr_ManAddVar(Rwr_Man_t *p, unsigned uTruth, int fPrecompute)
Definition: rwrLib.c:253
void Rwr_ManPrecompute(Rwr_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition: rwrLib.c:48
unsigned char * pMap
Definition: rwr.h:57
Definition: rwr.h:50
void Rwr_ManWriteToArray(Rwr_Man_t *p)
FUNCTION DEFINITIONS ///.
Definition: rwrUtil.c:426
unsigned short * puCanons
Definition: rwr.h:54
void Rwr_ManPreprocess(Rwr_Man_t *p)
MACRO DEFINITIONS ///.
Definition: rwrDec.c:49
char ** pPerms4
Definition: rwr.h:60
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
char * pPhases
Definition: dec.h:87
Vec_Ptr_t * vNodesTemp
Definition: rwr.h:77
Vec_Int_t * vLevNums
Definition: rwr.h:76
unsigned char * pMap
Definition: dec.h:89
static abctime Abc_Clock()
Definition: abc_global.h:279
Extra_MmFixed_t * pMmNode
Definition: rwr.h:65
int nTravIds
Definition: rwr.h:67
ABC_DLL void * Abc_FrameReadManDec()
Definition: mainFrame.c:61
char ** Extra_Permutations(int n)
static Vec_Int_t * Vec_IntAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: bblif.c:149
Vec_Ptr_t * vFanins
Definition: rwr.h:74
Extra_MmFixed_t * Extra_MmFixedStart(int nEntrySize)
Vec_Ptr_t * vFaninsCur
Definition: rwr.h:75
unsigned short * puCanons
Definition: dec.h:86
char * pPhases
Definition: rwr.h:55
static Vec_Ptr_t * Vec_PtrAlloc(int nCap)
FUNCTION DEFINITIONS ///.
Definition: vecPtr.h:83
int nClasses
Definition: rwr.h:70
Rwr_Node_t ** pTable
Definition: rwr.h:63
void Rwr_ManLoadFromArray(Rwr_Man_t *p, int fVerbose)
Definition: rwrUtil.c:472
char * pPractical
Definition: rwr.h:59
Definition: dec.h:80
ABC_INT64_T abctime
Definition: abc_global.h:278
char * pPerms
Definition: dec.h:88
Vec_Ptr_t * vForest
Definition: rwr.h:62
int nFuncs
Definition: rwr.h:53
char * pPerms
Definition: rwr.h:56
void Rwr_ManStop ( Rwr_Man_t p)

Function*************************************************************

Synopsis [Stops rewriting manager.]

Description []

SideEffects []

SeeAlso []

Definition at line 109 of file rwrMan.c.

110 {
111  if ( p->vClasses )
112  {
113  Rwr_Node_t * pNode;
114  int i, k;
115  Vec_VecForEachEntry( Rwr_Node_t *, p->vClasses, pNode, i, k )
116  Dec_GraphFree( (Dec_Graph_t *)pNode->pNext );
117  }
118  if ( p->vClasses ) Vec_VecFree( p->vClasses );
119  Vec_PtrFree( p->vNodesTemp );
120  Vec_PtrFree( p->vForest );
121  Vec_IntFree( p->vLevNums );
122  Vec_PtrFree( p->vFanins );
123  Vec_PtrFree( p->vFaninsCur );
124  Extra_MmFixedStop( p->pMmNode );
125  ABC_FREE( p->pMapInv );
126  ABC_FREE( p->pTable );
127  ABC_FREE( p->pPractical );
128  ABC_FREE( p->pPerms4 );
129  ABC_FREE( p );
130 }
#define Vec_VecForEachEntry(Type, vGlob, pEntry, i, k)
Definition: vecVec.h:87
void Extra_MmFixedStop(Extra_MmFixed_t *p)
static void Vec_VecFree(Vec_Vec_t *p)
Definition: vecVec.h:347
Vec_Vec_t * vClasses
Definition: rwr.h:64
if(last==0)
Definition: sparse_int.h:34
#define ABC_FREE(obj)
Definition: abc_global.h:232
static void Dec_GraphFree(Dec_Graph_t *pGraph)
Definition: dec.h:307
static void Vec_IntFree(Vec_Int_t *p)
Definition: bblif.c:235
static void Vec_PtrFree(Vec_Ptr_t *p)
Definition: vecPtr.h:223
void Rwr_Precompute ( )

Function*************************************************************

Synopsis [Precomputes AIG subgraphs.]

Description []

SideEffects []

SeeAlso []

Definition at line 310 of file rwrMan.c.

311 {
312  Rwr_Man_t * p;
313  p = Rwr_ManStart( 1 );
314  Rwr_ManStop( p );
315 }
static Llb_Mgr_t * p
Definition: llb3Image.c:950
Definition: rwr.h:50
void Rwr_ManStop(Rwr_Man_t *p)
Definition: rwrMan.c:109
ABC_NAMESPACE_IMPL_START Rwr_Man_t * Rwr_ManStart(int fPrecompute)
DECLARATIONS ///.
Definition: rwrMan.c:47