00001
00019 #ifndef __REO_H__
00020 #define __REO_H__
00021
00022 #ifdef __cplusplus
00023 extern "C" {
00024 #endif
00025
00026 #include <stdio.h>
00027 #include <stdlib.h>
00028 #include "extra.h"
00029
00030
00031
00035
00036
00037 #define REO_REORDER_LIMIT 1.15 // determines the quality/runtime trade-off
00038 #define REO_QUAL_PAR 3 // the quality [1 = simple lower bound, 2 = strict, larger = heuristic]
00039
00040 #define REO_CONST_LEVEL 30000 // the number of the constant level
00041 #define REO_TOPREF_UNDEF 30000 // the undefined top reference
00042 #define REO_CHUNK_SIZE 5000 // the number of units allocated at one time
00043 #define REO_COST_EPSILON 0.0000001 // difference in cost large enough so that it counted as an error
00044 #define REO_HIGH_VALUE 10000000 // a large value used to initialize some variables
00045
00046 #define REO_ENABLE 1 // the value of the enable flag
00047 #define REO_DISABLE 0 // the value of the disable flag
00048
00049
00050 typedef enum {
00051 REO_MINIMIZE_NODES,
00052 REO_MINIMIZE_WIDTH,
00053 REO_MINIMIZE_APL
00054 } reo_min_type;
00055
00059
00060 typedef struct _reo_unit reo_unit;
00061 typedef struct _reo_plane reo_plane;
00062 typedef struct _reo_hash reo_hash;
00063 typedef struct _reo_man reo_man;
00064 typedef struct _reo_test reo_test;
00065
00066 struct _reo_unit
00067 {
00068 short lev;
00069 short TopRef;
00070 short TopRefNew;
00071 short n;
00072 int Sign;
00073
00074 reo_unit * pE;
00075 reo_unit * pT;
00076 reo_unit * Next;
00077 double Weight;
00078 };
00079
00080 struct _reo_plane
00081 {
00082 int fSifted;
00083 int statsNodes;
00084 int statsWidth;
00085 double statsApl;
00086 double statsCost;
00087 double statsCostAbove;
00088 double statsCostBelow;
00089
00090 reo_unit * pHead;
00091 };
00092
00093 struct _reo_hash
00094 {
00095 int Sign;
00096 reo_unit * Arg1;
00097 reo_unit * Arg2;
00098 reo_unit * Arg3;
00099 };
00100
00101 struct _reo_man
00102 {
00103
00104 int fMinWidth;
00105 int fMinApl;
00106 int fVerbose;
00107 int fVerify;
00108 int fRemapUp;
00109 int nIters;
00110
00111
00112 DdManager * dd;
00113 int * pOrder;
00114
00115
00116 int fThisIsAdd;
00117 int * pSupp;
00118 int nSuppAlloc;
00119 int nSupp;
00120 int * pOrderInt;
00121 double * pVarCosts;
00122 int * pLevelOrder;
00123 reo_unit ** pWidthCofs;
00124
00125
00126 int nNodesBeg;
00127 int nNodesCur;
00128 int nNodesEnd;
00129 int nWidthCur;
00130 int nWidthBeg;
00131 int nWidthEnd;
00132 double nAplCur;
00133 double nAplBeg;
00134 double nAplEnd;
00135
00136
00137 int * pMapToPlanes;
00138 int * pMapToDdVarsOrig;
00139 int * pMapToDdVarsFinal;
00140
00141
00142 reo_plane * pPlanes;
00143 int nPlanes;
00144 reo_unit ** pTops;
00145 int nTops;
00146 int nTopsAlloc;
00147
00148
00149 reo_hash * HTable;
00150 int nTableSize;
00151 int Signature;
00152
00153
00154 int nNodesMaxAlloc;
00155 DdNode ** pRefNodes;
00156 int nRefNodes;
00157 int nRefNodesAlloc;
00158
00159
00160 reo_unit * pUnitFreeList;
00161 reo_unit ** pMemChunks;
00162 int nMemChunks;
00163 int nMemChunksAlloc;
00164 int nUnitsUsed;
00165
00166
00167 int HashSuccess;
00168 int HashFailure;
00169 int nSwaps;
00170 int nNISwaps;
00171 };
00172
00173
00174 #define Unit_Regular(u) ((reo_unit *)((unsigned long)(u) & ~01))
00175 #define Unit_Not(u) ((reo_unit *)((unsigned long)(u) ^ 01))
00176 #define Unit_NotCond(u,c) ((reo_unit *)((unsigned long)(u) ^ (c)))
00177 #define Unit_IsConstant(u) ((int)((u)->lev == REO_CONST_LEVEL))
00178
00182
00183
00184 extern reo_man * Extra_ReorderInit( int nDdVarsMax, int nNodesMax );
00185 extern void Extra_ReorderQuit( reo_man * p );
00186 extern void Extra_ReorderSetMinimizationType( reo_man * p, reo_min_type fMinType );
00187 extern void Extra_ReorderSetRemapping( reo_man * p, int fRemapUp );
00188 extern void Extra_ReorderSetIterations( reo_man * p, int nIters );
00189 extern void Extra_ReorderSetVerbosity( reo_man * p, int fVerbose );
00190 extern void Extra_ReorderSetVerification( reo_man * p, int fVerify );
00191 extern DdNode * Extra_Reorder( reo_man * p, DdManager * dd, DdNode * Func, int * pOrder );
00192 extern void Extra_ReorderArray( reo_man * p, DdManager * dd, DdNode * Funcs[], DdNode * FuncsRes[], int nFuncs, int * pOrder );
00193
00194 extern void reoReorderArray( reo_man * p, DdManager * dd, DdNode * Funcs[], DdNode * FuncsRes[], int nFuncs, int * pOrder );
00195 extern void reoResizeStructures( reo_man * p, int nDdVarsMax, int nNodesMax, int nFuncs );
00196
00197 extern void reoProfileNodesStart( reo_man * p );
00198 extern void reoProfileAplStart( reo_man * p );
00199 extern void reoProfileWidthStart( reo_man * p );
00200 extern void reoProfileWidthStart2( reo_man * p );
00201 extern void reoProfileAplPrint( reo_man * p );
00202 extern void reoProfileNodesPrint( reo_man * p );
00203 extern void reoProfileWidthPrint( reo_man * p );
00204 extern void reoProfileWidthVerifyLevel( reo_plane * pPlane, int Level );
00205
00206 extern void reoReorderSift( reo_man * p );
00207
00208 extern double reoReorderSwapAdjacentVars( reo_man * p, int Level, int fMovingUp );
00209
00210 extern reo_unit * reoTransferNodesToUnits_rec( reo_man * p, DdNode * F );
00211 extern DdNode * reoTransferUnitsToNodes_rec( reo_man * p, reo_unit * pUnit );
00212
00213 extern reo_unit * reoUnitsGetNextUnit(reo_man * p );
00214 extern void reoUnitsRecycleUnit( reo_man * p, reo_unit * pUnit );
00215 extern void reoUnitsRecycleUnitList( reo_man * p, reo_plane * pPlane );
00216 extern void reoUnitsAddUnitToPlane( reo_plane * pPlane, reo_unit * pUnit );
00217 extern void reoUnitsStopDispenser( reo_man * p );
00218
00219 extern void Extra_ReorderTest( DdManager * dd, DdNode * Func );
00220 extern DdNode * Extra_ReorderCudd( DdManager * dd, DdNode * aFunc, int pPermuteReo[] );
00221 extern int Extra_bddReorderTest( DdManager * dd, DdNode * bF );
00222 extern int Extra_addReorderTest( DdManager * dd, DdNode * aF );
00223
00224 #ifdef __cplusplus
00225 }
00226 #endif
00227
00228 #endif
00229