ABC: A System for Sequential Synthesis and Verification
 
Loading...
Searching...
No Matches
reo.h
Go to the documentation of this file.
1
18
19#ifndef ABC__bdd__reo__reo_h
20#define ABC__bdd__reo__reo_h
21
22
23#include <stdio.h>
24#include <stdlib.h>
25#include "bdd/extrab/extraBdd.h"
26
30
31
32
34
35
36// reordering parameters
37#define REO_REORDER_LIMIT 1.15 // determines the quality/runtime trade-off
38#define REO_QUAL_PAR 3 // the quality [1 = simple lower bound, 2 = strict, larger = heuristic]
39// internal parameters
40#define REO_CONST_LEVEL 30000 // the number of the constant level
41#define REO_TOPREF_UNDEF 30000 // the undefined top reference
42#define REO_CHUNK_SIZE 5000 // the number of units allocated at one time
43#define REO_COST_EPSILON 0.0000001 // difference in cost large enough so that it counted as an error
44#define REO_HIGH_VALUE 10000000 // a large value used to initialize some variables
45// interface parameters
46#define REO_ENABLE 1 // the value of the enable flag
47#define REO_DISABLE 0 // the value of the disable flag
48
49// the types of minimization currently supported
50typedef enum {
52 REO_MINIMIZE_WIDTH, // may not work for BDDs with complemented edges
55
59
60typedef struct _reo_unit reo_unit; // the unit representing one DD node during reordering
61typedef struct _reo_plane reo_plane; // the set of nodes on one level
62typedef struct _reo_hash reo_hash; // the entry in the hash table
63typedef struct _reo_man reo_man; // the reordering manager
64typedef struct _reo_test reo_test; //
65
67{
68 short lev; // the level of this node at the beginning
69 short TopRef; // the top level from which this node is refed (used to update BDD width)
70 short TopRefNew; // the new top level from which this node is refed (used to update BDD width)
71 short n; // the number of incoming edges (similar to ref count in the BDD)
72 int Sign; // the signature
73
74 reo_unit * pE; // the pointer to the "else" branch
75 reo_unit * pT; // the pointer to the "then" branch
76 reo_unit * Next; // the link to the next one in the list
77 double Weight; // the probability of traversing this node
78};
79
81{
82 int fSifted; // to mark the sifted variables
83 int statsNodes; // the number of nodes in the current level
84 int statsWidth; // the width on the current level
85 double statsApl; // the sum of node probabilities on this level
86 double statsCost; // the current cost is stored here
87 double statsCostAbove; // the current cost is stored here
88 double statsCostBelow; // the current cost is stored here
89
90 reo_unit * pHead; // the pointer to the beginning of the unit list
91};
92
94{
95 int Sign; // signature of the current cache operation
96 reo_unit * Arg1; // the first argument
97 reo_unit * Arg2; // the second argument
98 reo_unit * Arg3; // the third argument
99};
100
102{
103 // these paramaters can be set by the API functions
104 int fMinWidth; // the flag to enable reordering for minimum width
105 int fMinApl; // the flag to enable reordering for minimum APL
106 int fVerbose; // the verbosity level
107 int fVerify; // the flag toggling verification
108 int fRemapUp; // the flag to enable remapping
109 int nIters; // the number of iterations of sifting to perform
110
111 // parameters given by the user when reordering is called
112 DdManager * dd; // the CUDD BDD manager
113 int * pOrder; // the resulting variable order will be returned here
114
115 // derived parameters
116 int fThisIsAdd; // this flag is one if the function is the ADD
117 int * pSupp; // the support of the given function
118 int nSuppAlloc; // the max allowed number of support variables
119 int nSupp; // the number of support variables
120 int * pOrderInt; // the array storing the internal variable permutation
121 double * pVarCosts; // other arrays
122 int * pLevelOrder; // other arrays
123 reo_unit ** pWidthCofs; // temporary storage for cofactors used during reordering for width
124
125 // parameters related to cost
132 double nAplCur;
133 double nAplBeg;
134 double nAplEnd;
135
136 // mapping of the function into planes and back
137 int * pMapToPlanes; // the mapping of var indexes into plane levels
138 int * pMapToDdVarsOrig;// the mapping of plane levels into the original indexes
139 int * pMapToDdVarsFinal;// the mapping of plane levels into the final indexes
140
141 // the planes table
145 int nTops;
147
148 // the hash table
149 reo_hash * HTable; // the table itself
150 int nTableSize; // the size of the hash table
151 int Signature; // the signature counter
152
153 // the referenced node list
154 int nNodesMaxAlloc; // this parameters determins how much memory is allocated
155 DdNode ** pRefNodes;
158
159 // unit memory management
165
166 // statistic variables
169 int nSwaps; // the number of swaps
170 int nNISwaps; // the number of swaps without interaction
171};
172
173// used to manipulate units
174#define Unit_Regular(u) ((reo_unit *)((ABC_PTRUINT_T)(u) & ~01))
175#define Unit_Not(u) ((reo_unit *)((ABC_PTRUINT_T)(u) ^ 01))
176#define Unit_NotCond(u,c) ((reo_unit *)((ABC_PTRUINT_T)(u) ^ (c)))
177#define Unit_IsConstant(u) ((int)((u)->lev == REO_CONST_LEVEL))
178
182
183// ======================= reoApi.c ========================================
184extern reo_man * Extra_ReorderInit( int nDdVarsMax, int nNodesMax );
185extern void Extra_ReorderQuit( reo_man * p );
186extern void Extra_ReorderSetMinimizationType( reo_man * p, reo_min_type fMinType );
187extern void Extra_ReorderSetRemapping( reo_man * p, int fRemapUp );
188extern void Extra_ReorderSetIterations( reo_man * p, int nIters );
189extern void Extra_ReorderSetVerbosity( reo_man * p, int fVerbose );
190extern void Extra_ReorderSetVerification( reo_man * p, int fVerify );
191extern DdNode * Extra_Reorder( reo_man * p, DdManager * dd, DdNode * Func, int * pOrder );
192extern void Extra_ReorderArray( reo_man * p, DdManager * dd, DdNode * Funcs[], DdNode * FuncsRes[], int nFuncs, int * pOrder );
193// ======================= reoCore.c =======================================
194extern void reoReorderArray( reo_man * p, DdManager * dd, DdNode * Funcs[], DdNode * FuncsRes[], int nFuncs, int * pOrder );
195extern void reoResizeStructures( reo_man * p, int nDdVarsMax, int nNodesMax, int nFuncs );
196// ======================= reoProfile.c ======================================
197extern void reoProfileNodesStart( reo_man * p );
198extern void reoProfileAplStart( reo_man * p );
199extern void reoProfileWidthStart( reo_man * p );
200extern void reoProfileWidthStart2( reo_man * p );
201extern void reoProfileAplPrint( reo_man * p );
202extern void reoProfileNodesPrint( reo_man * p );
203extern void reoProfileWidthPrint( reo_man * p );
204extern void reoProfileWidthVerifyLevel( reo_plane * pPlane, int Level );
205// ======================= reoSift.c =======================================
206extern void reoReorderSift( reo_man * p );
207// ======================= reoSwap.c =======================================
208extern double reoReorderSwapAdjacentVars( reo_man * p, int Level, int fMovingUp );
209// ======================= reoTransfer.c ===================================
210extern reo_unit * reoTransferNodesToUnits_rec( reo_man * p, DdNode * F );
211extern DdNode * reoTransferUnitsToNodes_rec( reo_man * p, reo_unit * pUnit );
212// ======================= reoUnits.c ======================================
214extern void reoUnitsRecycleUnit( reo_man * p, reo_unit * pUnit );
215extern void reoUnitsRecycleUnitList( reo_man * p, reo_plane * pPlane );
216extern void reoUnitsAddUnitToPlane( reo_plane * pPlane, reo_unit * pUnit );
217extern void reoUnitsStopDispenser( reo_man * p );
218// ======================= reoTest.c =======================================
219extern void Extra_ReorderTest( DdManager * dd, DdNode * Func );
220extern DdNode * Extra_ReorderCudd( DdManager * dd, DdNode * aFunc, int pPermuteReo[] );
221extern int Extra_bddReorderTest( DdManager * dd, DdNode * bF );
222extern int Extra_addReorderTest( DdManager * dd, DdNode * aF );
223
224
225
227
228
229
230#endif
231
#define ABC_NAMESPACE_HEADER_END
#define ABC_NAMESPACE_HEADER_START
NAMESPACES ///.
Cube * p
Definition exorList.c:222
reo_unit * reoTransferNodesToUnits_rec(reo_man *p, DdNode *F)
DECLARATIONS ///.
Definition reoTransfer.c:43
struct _reo_man reo_man
Definition reo.h:63
void reoProfileWidthVerifyLevel(reo_plane *pPlane, int Level)
Definition reoProfile.c:354
void reoProfileWidthStart(reo_man *p)
Definition reoProfile.c:130
int Extra_bddReorderTest(DdManager *dd, DdNode *bF)
Definition reoTest.c:180
void reoUnitsRecycleUnitList(reo_man *p, reo_plane *pPlane)
Definition reoUnits.c:87
void reoResizeStructures(reo_man *p, int nDdVarsMax, int nNodesMax, int nFuncs)
Definition reoCore.c:269
void Extra_ReorderTest(DdManager *dd, DdNode *Func)
DECLARATIONS ///.
Definition reoTest.c:43
DdNode * Extra_ReorderCudd(DdManager *dd, DdNode *aFunc, int pPermuteReo[])
Definition reoTest.c:109
void Extra_ReorderQuit(reo_man *p)
Definition reoApi.c:79
double reoReorderSwapAdjacentVars(reo_man *p, int Level, int fMovingUp)
FUNCTION DEFINITIONS ///.
Definition reoSwap.c:46
DdNode * Extra_Reorder(reo_man *p, DdManager *dd, DdNode *Func, int *pOrder)
Definition reoApi.c:262
void reoProfileWidthStart2(reo_man *p)
Definition reoProfile.c:222
void reoReorderArray(reo_man *p, DdManager *dd, DdNode *Funcs[], DdNode *FuncsRes[], int nFuncs, int *pOrder)
FUNCTION DEFINITIONS ///.
Definition reoCore.c:50
void reoReorderSift(reo_man *p)
DECLARATIONS ///.
Definition reoSift.c:44
void reoProfileNodesStart(reo_man *p)
DECLARATIONS ///.
Definition reoProfile.c:46
void Extra_ReorderArray(reo_man *p, DdManager *dd, DdNode *Funcs[], DdNode *FuncsRes[], int nFuncs, int *pOrder)
Definition reoApi.c:283
void Extra_ReorderSetRemapping(reo_man *p, int fRemapUp)
Definition reoApi.c:172
struct _reo_test reo_test
Definition reo.h:64
void Extra_ReorderSetIterations(reo_man *p, int nIters)
Definition reoApi.c:192
reo_man * Extra_ReorderInit(int nDdVarsMax, int nNodesMax)
FUNCTION DECLARATIONS ///.
Definition reoApi.c:50
void reoProfileAplPrint(reo_man *p)
Definition reoProfile.c:305
DdNode * reoTransferUnitsToNodes_rec(reo_man *p, reo_unit *pUnit)
reo_min_type
Definition reo.h:50
@ REO_MINIMIZE_NODES
Definition reo.h:51
@ REO_MINIMIZE_APL
Definition reo.h:53
@ REO_MINIMIZE_WIDTH
Definition reo.h:52
void Extra_ReorderSetVerbosity(reo_man *p, int fVerbose)
Definition reoApi.c:229
struct _reo_plane reo_plane
Definition reo.h:61
struct _reo_hash reo_hash
Definition reo.h:62
void reoUnitsStopDispenser(reo_man *p)
Definition reoUnits.c:115
void reoProfileWidthPrint(reo_man *p)
Definition reoProfile.c:321
void Extra_ReorderSetMinimizationType(reo_man *p, reo_min_type fMinType)
Definition reoApi.c:122
void reoProfileAplStart(reo_man *p)
Definition reoProfile.c:78
int Extra_addReorderTest(DdManager *dd, DdNode *aF)
Definition reoTest.c:217
void reoUnitsAddUnitToPlane(reo_plane *pPlane, reo_unit *pUnit)
Definition reoUnits.c:135
void reoProfileNodesPrint(reo_man *p)
Definition reoProfile.c:289
void reoUnitsRecycleUnit(reo_man *p, reo_unit *pUnit)
Definition reoUnits.c:69
void Extra_ReorderSetVerification(reo_man *p, int fVerify)
Definition reoApi.c:212
reo_unit * reoUnitsGetNextUnit(reo_man *p)
FUNCTION DEFINITIONS ///.
Definition reoUnits.c:45
struct _reo_unit reo_unit
DATA STRUCTURES ///.
Definition reo.h:60
reo_unit * Arg2
Definition reo.h:97
reo_unit * Arg3
Definition reo.h:98
int Sign
Definition reo.h:95
reo_unit * Arg1
Definition reo.h:96
int nNodesEnd
Definition reo.h:128
double nAplCur
Definition reo.h:132
reo_hash * HTable
Definition reo.h:149
int * pMapToPlanes
Definition reo.h:137
reo_unit ** pWidthCofs
Definition reo.h:123
int nMemChunks
Definition reo.h:162
int nWidthBeg
Definition reo.h:130
int nNISwaps
Definition reo.h:170
double nAplBeg
Definition reo.h:133
DdManager * dd
Definition reo.h:112
int nRefNodes
Definition reo.h:156
int nUnitsUsed
Definition reo.h:164
int * pLevelOrder
Definition reo.h:122
int * pMapToDdVarsFinal
Definition reo.h:139
int nPlanes
Definition reo.h:143
int nTops
Definition reo.h:145
int nIters
Definition reo.h:109
int fRemapUp
Definition reo.h:108
int nRefNodesAlloc
Definition reo.h:157
DdNode ** pRefNodes
Definition reo.h:155
int fThisIsAdd
Definition reo.h:116
int nSupp
Definition reo.h:119
int Signature
Definition reo.h:151
int fMinApl
Definition reo.h:105
reo_unit * pUnitFreeList
Definition reo.h:160
int * pSupp
Definition reo.h:117
int HashSuccess
Definition reo.h:167
int nSwaps
Definition reo.h:169
reo_unit ** pTops
Definition reo.h:144
int nTableSize
Definition reo.h:150
double * pVarCosts
Definition reo.h:121
int nSuppAlloc
Definition reo.h:118
double nAplEnd
Definition reo.h:134
int fVerbose
Definition reo.h:106
int * pOrder
Definition reo.h:113
int nWidthEnd
Definition reo.h:131
int nNodesMaxAlloc
Definition reo.h:154
int nWidthCur
Definition reo.h:129
reo_plane * pPlanes
Definition reo.h:142
int nTopsAlloc
Definition reo.h:146
int fVerify
Definition reo.h:107
int * pMapToDdVarsOrig
Definition reo.h:138
int HashFailure
Definition reo.h:168
int nNodesBeg
Definition reo.h:126
int nMemChunksAlloc
Definition reo.h:163
int * pOrderInt
Definition reo.h:120
int fMinWidth
Definition reo.h:104
int nNodesCur
Definition reo.h:127
reo_unit ** pMemChunks
Definition reo.h:161
double statsApl
Definition reo.h:85
int statsWidth
Definition reo.h:84
double statsCostAbove
Definition reo.h:87
double statsCost
Definition reo.h:86
int statsNodes
Definition reo.h:83
int fSifted
Definition reo.h:82
double statsCostBelow
Definition reo.h:88
reo_unit * pHead
Definition reo.h:90
reo_unit * Next
Definition reo.h:76
short lev
Definition reo.h:68
int Sign
Definition reo.h:72
double Weight
Definition reo.h:77
short n
Definition reo.h:71
short TopRef
Definition reo.h:69
reo_unit * pE
Definition reo.h:74
short TopRefNew
Definition reo.h:70
reo_unit * pT
Definition reo.h:75