ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
cutMan.c
Go to the documentation of this file.
1
20
21#include "cutInt.h"
22
24
25
29
30extern void Npn_StartTruth8( uint8 uTruths[][32] );
31
35
48{
49 Cut_Man_t * p;
50// extern int nTruthDsd;
51// nTruthDsd = 0;
52 assert( pParams->nVarsMax >= 3 && pParams->nVarsMax <= CUT_SIZE_MAX );
53 p = ABC_ALLOC( Cut_Man_t, 1 );
54 memset( p, 0, sizeof(Cut_Man_t) );
55 // set and correct parameters
56 p->pParams = pParams;
57 // prepare storage for cuts
58 p->vCutsNew = Vec_PtrAlloc( pParams->nIdsMax );
59 Vec_PtrFill( p->vCutsNew, pParams->nIdsMax, NULL );
60 // prepare storage for sequential cuts
61 if ( pParams->fSeq )
62 {
63 p->pParams->fFilter = 1;
64 p->vCutsOld = Vec_PtrAlloc( pParams->nIdsMax );
65 Vec_PtrFill( p->vCutsOld, pParams->nIdsMax, NULL );
66 p->vCutsTemp = Vec_PtrAlloc( pParams->nCutSet );
67 Vec_PtrFill( p->vCutsTemp, pParams->nCutSet, NULL );
68 if ( pParams->fTruth && pParams->nVarsMax > 5 )
69 {
70 pParams->fTruth = 0;
71 printf( "Skipping computation of truth tables for sequential cuts with more than 5 inputs.\n" );
72 }
73 }
74 // entry size
75 p->EntrySize = sizeof(Cut_Cut_t) + pParams->nVarsMax * sizeof(int);
76 if ( pParams->fTruth )
77 {
78 if ( pParams->nVarsMax > 14 )
79 {
80 pParams->fTruth = 0;
81 printf( "Skipping computation of truth table for more than %d inputs.\n", 14 );
82 }
83 else
84 {
85 p->nTruthWords = Cut_TruthWords( pParams->nVarsMax );
86 p->EntrySize += p->nTruthWords * sizeof(unsigned);
87 }
88 p->puTemp[0] = ABC_ALLOC( unsigned, 4 * p->nTruthWords );
89 p->puTemp[1] = p->puTemp[0] + p->nTruthWords;
90 p->puTemp[2] = p->puTemp[1] + p->nTruthWords;
91 p->puTemp[3] = p->puTemp[2] + p->nTruthWords;
92 }
93 // enable cut computation recording
94 if ( pParams->fRecord )
95 {
96 p->vNodeCuts = Vec_IntStart( pParams->nIdsMax );
97 p->vNodeStarts = Vec_IntStart( pParams->nIdsMax );
98 p->vCutPairs = Vec_IntAlloc( 0 );
99 }
100 // allocate storage for delays
101 if ( pParams->fMap && !p->pParams->fSeq )
102 {
103 p->vDelays = Vec_IntStart( pParams->nIdsMax );
104 p->vDelays2 = Vec_IntStart( pParams->nIdsMax );
105 p->vCutsMax = Vec_PtrStart( pParams->nIdsMax );
106 }
107 // memory for cuts
108 p->pMmCuts = Extra_MmFixedStart( p->EntrySize );
109 p->vTemp = Vec_PtrAlloc( 100 );
110 return p;
111}
112
125{
126 if ( p->vCutsNew ) Vec_PtrFree( p->vCutsNew );
127 if ( p->vCutsOld ) Vec_PtrFree( p->vCutsOld );
128 if ( p->vCutsTemp ) Vec_PtrFree( p->vCutsTemp );
129 if ( p->vFanCounts ) Vec_IntFree( p->vFanCounts );
130 if ( p->vTemp ) Vec_PtrFree( p->vTemp );
131
132 if ( p->vCutsMax ) Vec_PtrFree( p->vCutsMax );
133 if ( p->vDelays ) Vec_IntFree( p->vDelays );
134 if ( p->vDelays2 ) Vec_IntFree( p->vDelays2 );
135 if ( p->vNodeCuts ) Vec_IntFree( p->vNodeCuts );
136 if ( p->vNodeStarts ) Vec_IntFree( p->vNodeStarts );
137 if ( p->vCutPairs ) Vec_IntFree( p->vCutPairs );
138 if ( p->puTemp[0] ) ABC_FREE( p->puTemp[0] );
139
140 Extra_MmFixedStop( p->pMmCuts );
141 ABC_FREE( p );
142}
143
156{
157 if ( p->pReady )
158 {
159 Cut_CutRecycle( p, p->pReady );
160 p->pReady = NULL;
161 }
162 printf( "Cut computation statistics:\n" );
163 printf( "Current cuts = %8d. (Trivial = %d.)\n", p->nCutsCur-p->nCutsTriv, p->nCutsTriv );
164 printf( "Peak cuts = %8d.\n", p->nCutsPeak );
165 printf( "Total allocated = %8d.\n", p->nCutsAlloc );
166 printf( "Total deallocated = %8d.\n", p->nCutsDealloc );
167 printf( "Cuts filtered = %8d.\n", p->nCutsFilter );
168 printf( "Nodes saturated = %8d. (Max cuts = %d.)\n", p->nCutsLimit, p->pParams->nKeepMax );
169 printf( "Cuts per node = %8.1f\n", ((float)(p->nCutsCur-p->nCutsTriv))/p->nNodes );
170 printf( "The cut size = %8d bytes.\n", p->EntrySize );
171 printf( "Peak memory = %8.2f MB.\n", (float)p->nCutsPeak * p->EntrySize / (1<<20) );
172 printf( "Total nodes = %8d.\n", p->nNodes );
173 if ( p->pParams->fDag || p->pParams->fTree )
174 {
175 printf( "DAG nodes = %8d.\n", p->nNodesDag );
176 printf( "Tree nodes = %8d.\n", p->nNodes - p->nNodesDag );
177 }
178 printf( "Nodes w/o cuts = %8d.\n", p->nNodesNoCuts );
179 if ( p->pParams->fMap && !p->pParams->fSeq )
180 printf( "Mapping delay = %8d.\n", p->nDelayMin );
181
182 ABC_PRT( "Merge ", p->timeMerge );
183 ABC_PRT( "Union ", p->timeUnion );
184 ABC_PRT( "Filter", p->timeFilter );
185 ABC_PRT( "Truth ", p->timeTruth );
186 ABC_PRT( "Map ", p->timeMap );
187// printf( "Nodes = %d. Multi = %d. Cuts = %d. Multi = %d.\n",
188// p->nNodes, p->nNodesMulti, p->nCutsCur-p->nCutsTriv, p->nCutsMulti );
189// printf( "Count0 = %d. Count1 = %d. Count2 = %d.\n\n", p->Count0, p->Count1, p->Count2 );
190}
191
192
204void Cut_ManPrintStatsToFile( Cut_Man_t * p, char * pFileName, abctime TimeTotal )
205{
206 FILE * pTable;
207 pTable = fopen( "cut_stats.txt", "a+" );
208 fprintf( pTable, "%-20s ", pFileName );
209 fprintf( pTable, "%8d ", p->nNodes );
210 fprintf( pTable, "%6.1f ", ((float)(p->nCutsCur))/p->nNodes );
211 fprintf( pTable, "%6.2f ", ((float)(100.0 * p->nCutsLimit))/p->nNodes );
212 fprintf( pTable, "%6.2f ", (float)p->nCutsPeak * p->EntrySize / (1<<20) );
213 fprintf( pTable, "%6.2f ", (float)(TimeTotal)/(float)(CLOCKS_PER_SEC) );
214 fprintf( pTable, "\n" );
215 fclose( pTable );
216}
217
230{
231 p->vFanCounts = vFanCounts;
232}
233
246{
247 p->vNodeAttrs = vNodeAttrs;
248}
249
262{
263 return p->pParams->nVarsMax;
264}
265
278{
279 return p->pParams;
280}
281
294{
295 return p->vNodeAttrs;
296}
297
310{
311 p->nNodesDag++;
312}
313
317
318
320
ABC_INT64_T abctime
Definition abc_global.h:332
#define ABC_PRT(a, t)
Definition abc_global.h:255
#define ABC_ALLOC(type, num)
Definition abc_global.h:264
#define ABC_FREE(obj)
Definition abc_global.h:267
#define ABC_NAMESPACE_IMPL_START
#define ABC_NAMESPACE_IMPL_END
typedefABC_NAMESPACE_IMPL_START struct Vec_Int_t_ Vec_Int_t
DECLARATIONS ///.
Definition bblif.c:37
void Cut_CutRecycle(Cut_Man_t *p, Cut_Cut_t *pCut)
Definition cutCut.c:72
ABC_NAMESPACE_IMPL_START void Npn_StartTruth8(uint8 uTruths[][32])
DECLARATIONS ///.
void Cut_ManIncrementDagNodes(Cut_Man_t *p)
Definition cutMan.c:309
void Cut_ManPrintStatsToFile(Cut_Man_t *p, char *pFileName, abctime TimeTotal)
Definition cutMan.c:204
void Cut_ManPrintStats(Cut_Man_t *p)
Definition cutMan.c:155
void Cut_ManSetNodeAttrs(Cut_Man_t *p, Vec_Int_t *vNodeAttrs)
Definition cutMan.c:245
Cut_Man_t * Cut_ManStart(Cut_Params_t *pParams)
FUNCTION DEFINITIONS ///.
Definition cutMan.c:47
Vec_Int_t * Cut_ManReadNodeAttrs(Cut_Man_t *p)
Definition cutMan.c:293
void Cut_ManSetFanoutCounts(Cut_Man_t *p, Vec_Int_t *vFanCounts)
Definition cutMan.c:229
int Cut_ManReadVarsMax(Cut_Man_t *p)
Definition cutMan.c:261
Cut_Params_t * Cut_ManReadParams(Cut_Man_t *p)
Definition cutMan.c:277
void Cut_ManStop(Cut_Man_t *p)
Definition cutMan.c:124
struct Cut_ParamsStruct_t_ Cut_Params_t
Definition cut.h:51
struct Cut_ManStruct_t_ Cut_Man_t
BASIC TYPES ///.
Definition cut.h:48
#define CUT_SIZE_MAX
Definition cut.h:39
struct Cut_CutStruct_t_ Cut_Cut_t
Definition cut.h:50
Cube * p
Definition exorList.c:222
void Extra_MmFixedStop(Extra_MmFixed_t *p)
Extra_MmFixed_t * Extra_MmFixedStart(int nEntrySize)
ABC_NAMESPACE_HEADER_START typedef unsigned char uint8
Definition extra.h:71
#define assert(ex)
Definition util_old.h:213
char * memset()