#include "reo.h"
Go to the source code of this file.
Functions | |
void | reoProfileNodesStart (reo_man *p) |
void | reoProfileAplStart (reo_man *p) |
void | reoProfileWidthStart (reo_man *p) |
void | reoProfileWidthStart2 (reo_man *p) |
void | reoProfileNodesPrint (reo_man *p) |
void | reoProfileAplPrint (reo_man *p) |
void | reoProfileWidthPrint (reo_man *p) |
void | reoProfileWidthVerifyLevel (reo_plane *pPlane, int Level) |
void reoProfileAplPrint | ( | reo_man * | p | ) |
Function********************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 302 of file reoProfile.c.
void reoProfileAplStart | ( | reo_man * | p | ) |
Function*************************************************************
Synopsis [Start the profile for the APL.]
Description [Computes the total path length. The path length is normalized by dividing it by 2^|supp(f)|. To get the "real" APL, multiply by 2^|supp(f)|. This procedure assumes that Weight field of all nodes has been set to 0.0 before the call, except for the weight of the topmost node, which is set to 1.0 (1.0 is the probability of traversing the topmost node). This procedure assigns the edge weights. Because of the equal probability of selecting 0 and 1 assignment at a node, the edge weights are the same for the node. Instead of storing them, we store the weight of the node, which is the probability of traversing the node (pUnit->Weight) during the top down evalation of the BDD. ]
SideEffects []
SeeAlso []
Definition at line 75 of file reoProfile.c.
00076 { 00077 reo_unit * pER, * pTR; 00078 reo_unit * pUnit; 00079 double Res, Half; 00080 int i; 00081 00082 // clean the weights of all nodes 00083 for ( i = 0; i < p->nSupp; i++ ) 00084 for ( pUnit = p->pPlanes[i].pHead; pUnit; pUnit = pUnit->Next ) 00085 pUnit->Weight = 0.0; 00086 // to assign the node weights (the probability of visiting each node) 00087 // we visit the node after visiting its predecessors 00088 00089 // set the probability of visits to the top nodes 00090 for ( i = 0; i < p->nTops; i++ ) 00091 Unit_Regular(p->pTops[i])->Weight += 1.0; 00092 00093 // to compute the path length (the sum of products of edge weight by edge length) 00094 // we visit the nodes in any order (the above order will do) 00095 Res = 0.0; 00096 for ( i = 0; i < p->nSupp; i++ ) 00097 { 00098 p->pPlanes[i].statsCost = 0.0; 00099 for ( pUnit = p->pPlanes[i].pHead; pUnit; pUnit = pUnit->Next ) 00100 { 00101 pER = Unit_Regular(pUnit->pE); 00102 pTR = Unit_Regular(pUnit->pT); 00103 Half = 0.5 * pUnit->Weight; 00104 pER->Weight += Half; 00105 pTR->Weight += Half; 00106 // add to the path length 00107 p->pPlanes[i].statsCost += pUnit->Weight; 00108 } 00109 Res += p->pPlanes[i].statsCost; 00110 } 00111 p->pPlanes[p->nSupp].statsCost = 0.0; 00112 p->nAplBeg = p->nAplCur = Res; 00113 }
void reoProfileNodesPrint | ( | reo_man * | p | ) |
Function********************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 286 of file reoProfile.c.
void reoProfileNodesStart | ( | reo_man * | p | ) |
CFile****************************************************************
FileName [reoProfile.c]
PackageName [REO: A specialized DD reordering engine.]
Synopsis [Procudures that compute variables profiles (nodes, width, APL).]
Author [Alan Mishchenko]
Affiliation [UC Berkeley]
Date [Ver. 1.0. Started - October 15, 2002.]
Revision [
] DECLARATIONS /// FUNCTION DEFINITIONS ///Function********************************************************************
Synopsis [Start the profile for the BDD nodes.]
Description [TopRef is the first level, on this the given node counts towards the width of the BDDs. (In other words, it is the level of the referencing node plus 1.)]
SideEffects []
SeeAlso []
Definition at line 43 of file reoProfile.c.
void reoProfileWidthPrint | ( | reo_man * | p | ) |
Function********************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 318 of file reoProfile.c.
00319 { 00320 int WidthMax; 00321 int TotalWidth; 00322 int i; 00323 00324 WidthMax = 0; 00325 TotalWidth = 0; 00326 for ( i = 0; i <= p->nSupp; i++ ) 00327 { 00328 // printf( "Level = %2d. Width = %3d.\n", i, p->pProfile[i] ); 00329 if ( WidthMax < p->pPlanes[i].statsWidth ) 00330 WidthMax = p->pPlanes[i].statsWidth; 00331 TotalWidth += p->pPlanes[i].statsWidth; 00332 } 00333 assert( p->nWidthCur == TotalWidth ); 00334 printf( "WIDTH: " ); 00335 printf( "Maximum = %5d. ", WidthMax ); 00336 printf( "Total = %7d. ", p->nWidthCur ); 00337 printf( "Average = %6.2f.\n", TotalWidth / (float)p->nSupp ); 00338 }
void reoProfileWidthStart | ( | reo_man * | p | ) |
Function********************************************************************
Synopsis [Start the profile for the BDD width. Complexity of the algorithm is O(N + n).]
Description [TopRef is the first level, on which the given node counts towards the width of the BDDs. (In other words, it is the level of the referencing node plus 1.)]
SideEffects []
SeeAlso []
Definition at line 127 of file reoProfile.c.
00128 { 00129 reo_unit * pUnit; 00130 int * pWidthStart; 00131 int * pWidthStop; 00132 int v; 00133 00134 // allocate and clean the storage for starting and stopping levels 00135 pWidthStart = ALLOC( int, p->nSupp + 1 ); 00136 pWidthStop = ALLOC( int, p->nSupp + 1 ); 00137 memset( pWidthStart, 0, sizeof(int) * (p->nSupp + 1) ); 00138 memset( pWidthStop, 0, sizeof(int) * (p->nSupp + 1) ); 00139 00140 // go through the non-constant nodes and set the topmost level of their cofactors 00141 for ( v = 0; v <= p->nSupp; v++ ) 00142 for ( pUnit = p->pPlanes[v].pHead; pUnit; pUnit = pUnit->Next ) 00143 { 00144 pUnit->TopRef = REO_TOPREF_UNDEF; 00145 pUnit->Sign = 0; 00146 } 00147 00148 // add the topmost level of the width profile 00149 for ( v = 0; v < p->nTops; v++ ) 00150 { 00151 pUnit = Unit_Regular(p->pTops[v]); 00152 if ( pUnit->TopRef == REO_TOPREF_UNDEF ) 00153 { 00154 // set the starting level 00155 pUnit->TopRef = 0; 00156 pWidthStart[pUnit->TopRef]++; 00157 // set the stopping level 00158 if ( pUnit->lev != REO_CONST_LEVEL ) 00159 pWidthStop[pUnit->lev+1]++; 00160 } 00161 } 00162 00163 for ( v = 0; v < p->nSupp; v++ ) 00164 for ( pUnit = p->pPlanes[v].pHead; pUnit; pUnit = pUnit->Next ) 00165 { 00166 if ( pUnit->pE->TopRef == REO_TOPREF_UNDEF ) 00167 { 00168 // set the starting level 00169 pUnit->pE->TopRef = pUnit->lev + 1; 00170 pWidthStart[pUnit->pE->TopRef]++; 00171 // set the stopping level 00172 if ( pUnit->pE->lev != REO_CONST_LEVEL ) 00173 pWidthStop[pUnit->pE->lev+1]++; 00174 } 00175 if ( pUnit->pT->TopRef == REO_TOPREF_UNDEF ) 00176 { 00177 // set the starting level 00178 pUnit->pT->TopRef = pUnit->lev + 1; 00179 pWidthStart[pUnit->pT->TopRef]++; 00180 // set the stopping level 00181 if ( pUnit->pT->lev != REO_CONST_LEVEL ) 00182 pWidthStop[pUnit->pT->lev+1]++; 00183 } 00184 } 00185 00186 // verify the top reference 00187 for ( v = 0; v < p->nSupp; v++ ) 00188 reoProfileWidthVerifyLevel( p->pPlanes + v, v ); 00189 00190 // derive the profile 00191 p->nWidthCur = 0; 00192 for ( v = 0; v <= p->nSupp; v++ ) 00193 { 00194 if ( v == 0 ) 00195 p->pPlanes[v].statsWidth = pWidthStart[v] - pWidthStop[v]; 00196 else 00197 p->pPlanes[v].statsWidth = p->pPlanes[v-1].statsWidth + pWidthStart[v] - pWidthStop[v]; 00198 p->pPlanes[v].statsCost = p->pPlanes[v].statsWidth; 00199 p->nWidthCur += p->pPlanes[v].statsWidth; 00200 // printf( "Level %2d: Width = %5d. Correct = %d.\n", v, Temp, p->pPlanes[v].statsWidth ); 00201 } 00202 p->nWidthBeg = p->nWidthCur; 00203 free( pWidthStart ); 00204 free( pWidthStop ); 00205 }
void reoProfileWidthStart2 | ( | reo_man * | p | ) |
Function********************************************************************
Synopsis [Start the profile for the BDD width. Complexity of the algorithm is O(N * n).]
Description [TopRef is the first level, on which the given node counts towards the width of the BDDs. (In other words, it is the level of the referencing node plus 1.)]
SideEffects []
SeeAlso []
Definition at line 219 of file reoProfile.c.
00220 { 00221 reo_unit * pUnit; 00222 int i, v; 00223 00224 // clean the profile 00225 for ( i = 0; i <= p->nSupp; i++ ) 00226 p->pPlanes[i].statsWidth = 0; 00227 00228 // clean the node structures 00229 for ( v = 0; v <= p->nSupp; v++ ) 00230 for ( pUnit = p->pPlanes[v].pHead; pUnit; pUnit = pUnit->Next ) 00231 { 00232 pUnit->TopRef = REO_TOPREF_UNDEF; 00233 pUnit->Sign = 0; 00234 } 00235 00236 // set the topref to the topmost nodes 00237 for ( i = 0; i < p->nTops; i++ ) 00238 Unit_Regular(p->pTops[i])->TopRef = 0; 00239 00240 // go through the non-constant nodes and set the topmost level of their cofactors 00241 for ( i = 0; i < p->nSupp; i++ ) 00242 for ( pUnit = p->pPlanes[i].pHead; pUnit; pUnit = pUnit->Next ) 00243 { 00244 if ( pUnit->pE->TopRef > i+1 ) 00245 pUnit->pE->TopRef = i+1; 00246 if ( pUnit->pT->TopRef > i+1 ) 00247 pUnit->pT->TopRef = i+1; 00248 } 00249 00250 // verify the top reference 00251 for ( i = 0; i < p->nSupp; i++ ) 00252 reoProfileWidthVerifyLevel( p->pPlanes + i, i ); 00253 00254 // compute the profile for the internal nodes 00255 for ( i = 0; i < p->nSupp; i++ ) 00256 for ( pUnit = p->pPlanes[i].pHead; pUnit; pUnit = pUnit->Next ) 00257 for ( v = pUnit->TopRef; v <= pUnit->lev; v++ ) 00258 p->pPlanes[v].statsWidth++; 00259 00260 // compute the profile for the constant nodes 00261 for ( pUnit = p->pPlanes[p->nSupp].pHead; pUnit; pUnit = pUnit->Next ) 00262 for ( v = pUnit->TopRef; v <= p->nSupp; v++ ) 00263 p->pPlanes[v].statsWidth++; 00264 00265 // get the width cost 00266 p->nWidthCur = 0; 00267 for ( i = 0; i <= p->nSupp; i++ ) 00268 { 00269 p->pPlanes[i].statsCost = p->pPlanes[i].statsWidth; 00270 p->nWidthCur += p->pPlanes[i].statsWidth; 00271 } 00272 p->nWidthBeg = p->nWidthCur; 00273 }
void reoProfileWidthVerifyLevel | ( | reo_plane * | pPlane, | |
int | Level | |||
) |
Function********************************************************************
Synopsis []
Description []
SideEffects []
SeeAlso []
Definition at line 351 of file reoProfile.c.