abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
reoApi.c File Reference
#include "reo.h"

Go to the source code of this file.

Functions

ABC_NAMESPACE_IMPL_START reo_manExtra_ReorderInit (int nDdVarsMax, int nNodesMax)
 DECLARATIONS ///. More...
 
void Extra_ReorderQuit (reo_man *p)
 
void Extra_ReorderSetMinimizationType (reo_man *p, reo_min_type fMinType)
 
void Extra_ReorderSetRemapping (reo_man *p, int fRemapUp)
 
void Extra_ReorderSetIterations (reo_man *p, int nIters)
 
void Extra_ReorderSetVerification (reo_man *p, int fVerify)
 
void Extra_ReorderSetVerbosity (reo_man *p, int fVerbose)
 
DdNodeExtra_Reorder (reo_man *p, DdManager *dd, DdNode *Func, int *pOrder)
 
void Extra_ReorderArray (reo_man *p, DdManager *dd, DdNode *Funcs[], DdNode *FuncsRes[], int nFuncs, int *pOrder)
 

Function Documentation

DdNode* Extra_Reorder ( reo_man p,
DdManager dd,
DdNode Func,
int *  pOrder 
)

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

Synopsis [Performs reordering of the function.]

Description [Returns the DD minimized by variable reordering in the REO engine. Takes the CUDD decision diagram manager (dd) and the function (Func) represented as a BDD or ADD (MTBDD). If the variable array (pOrder) is not NULL, returns the resulting variable permutation. The permutation is such that if the resulting function is permuted by Cudd_(add,bdd)Permute() using pOrder as the permutation array, the initial function (Func) results. Several flag set by other interface functions specify reordering options:

  • Remappig can be set by Extra_ReorderSetRemapping(). Then the resulting DD after reordering is remapped into the topmost levels of the DD manager. Otherwise, the resulting DD after reordering is mapped using the same variables, on which it originally depended, only (possibly) permuted as a result of reordering.
  • Minimization type can be set by Extra_ReorderSetMinimizationType(). Note that when the BDD is minimized for the total width of the total APL, the number BDD nodes can increase. The total width is defines as sum total of widths on each level. The width on one level is defined as the number of distinct BDD nodes pointed by the nodes situated above the given level.
  • The number of iterations of sifting can be set by Extra_ReorderSetIterations(). The decision diagram returned by this procedure is not referenced.]

SideEffects []

SeeAlso []

Definition at line 262 of file reoApi.c.

263 {
264  DdNode * FuncRes;
265  Extra_ReorderArray( p, dd, &Func, &FuncRes, 1, pOrder );
266  Cudd_Deref( FuncRes );
267  return FuncRes;
268 }
Definition: cudd.h:278
void Cudd_Deref(DdNode *node)
Definition: cuddRef.c:438
void Extra_ReorderArray(reo_man *p, DdManager *dd, DdNode *Funcs[], DdNode *FuncsRes[], int nFuncs, int *pOrder)
Definition: reoApi.c:283
void Extra_ReorderArray ( reo_man p,
DdManager dd,
DdNode Funcs[],
DdNode FuncsRes[],
int  nFuncs,
int *  pOrder 
)

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

Synopsis [Performs reordering of the array of functions.]

Description [The options are similar to the procedure Extra_Reorder(), except that the user should also provide storage for the resulting DDs, which are returned referenced.]

SideEffects []

SeeAlso []

Definition at line 283 of file reoApi.c.

284 {
285  reoReorderArray( p, dd, Funcs, FuncsRes, nFuncs, pOrder );
286 }
void reoReorderArray(reo_man *p, DdManager *dd, DdNode *Funcs[], DdNode *FuncsRes[], int nFuncs, int *pOrder)
FUNCTION DEFINITIONS ///.
Definition: reoCore.c:50
ABC_NAMESPACE_IMPL_START reo_man* Extra_ReorderInit ( int  nDdVarsMax,
int  nNodesMax 
)

DECLARATIONS ///.

FUNCTION DECLARATIONS ///.

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

FileName [reoApi.c]

PackageName [REO: A specialized DD reordering engine.]

Synopsis [Implementation of API functions.]

Author [Alan Mishchenko]

Affiliation [UC Berkeley]

Date [Ver. 1.0. Started - October 15, 2002.]

Revision [

Id:
reoApi.c,v 1.0 2002/15/10 03:00:00 alanmi Exp

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

Synopsis [Initializes the reordering engine.]

Description [The first argument is the max number of variables in the CUDD DD manager which will be used with the reordering engine (this number of should be the maximum of BDD and ZDD parts). The second argument is the maximum number of BDD nodes in the BDDs to be reordered. These limits are soft. Setting lower limits will later cause the reordering manager to resize internal data structures. However, setting the exact values will make reordering more efficient because resizing will be not necessary.]

SideEffects []

SeeAlso []

Definition at line 50 of file reoApi.c.

51 {
52  reo_man * p;
53  // allocate and clean the data structure
54  p = ABC_ALLOC( reo_man, 1 );
55  memset( p, 0, sizeof(reo_man) );
56  // resize the manager to meet user's needs
57  reoResizeStructures( p, nDdVarsMax, nNodesMax, 100 );
58  // set the defaults
59  p->fMinApl = 0;
60  p->fMinWidth = 0;
61  p->fRemapUp = 0;
62  p->fVerbose = 0;
63  p->fVerify = 0;
64  p->nIters = 1;
65  return p;
66 }
char * memset()
int fMinApl
Definition: reo.h:105
int fVerbose
Definition: reo.h:106
static Llb_Mgr_t * p
Definition: llb3Image.c:950
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
int fRemapUp
Definition: reo.h:108
int fMinWidth
Definition: reo.h:104
void reoResizeStructures(reo_man *p, int nDdVarsMax, int nNodesMax, int nFuncs)
Definition: reoCore.c:269
int nIters
Definition: reo.h:109
int fVerify
Definition: reo.h:107
Definition: reo.h:101
void Extra_ReorderQuit ( reo_man p)

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

Synopsis [Disposes of the reordering engine.]

Description [Removes all memory associated with the reordering engine.]

SideEffects []

SeeAlso []

Definition at line 79 of file reoApi.c.

80 {
81  ABC_FREE( p->pTops );
82  ABC_FREE( p->pSupp );
83  ABC_FREE( p->pOrderInt );
84  ABC_FREE( p->pWidthCofs );
85  ABC_FREE( p->pMapToPlanes );
88  ABC_FREE( p->pPlanes );
89  ABC_FREE( p->pVarCosts );
90  ABC_FREE( p->pLevelOrder );
91  ABC_FREE( p->HTable );
92  ABC_FREE( p->pRefNodes );
94  ABC_FREE( p->pMemChunks );
95  ABC_FREE( p );
96 }
reo_unit ** pWidthCofs
Definition: reo.h:123
double * pVarCosts
Definition: reo.h:121
int * pMapToPlanes
Definition: reo.h:137
int * pMapToDdVarsFinal
Definition: reo.h:139
void reoUnitsStopDispenser(reo_man *p)
Definition: reoUnits.c:115
int * pLevelOrder
Definition: reo.h:122
DdNode ** pRefNodes
Definition: reo.h:155
reo_hash * HTable
Definition: reo.h:149
reo_unit ** pTops
Definition: reo.h:144
int * pSupp
Definition: reo.h:117
int * pMapToDdVarsOrig
Definition: reo.h:138
reo_plane * pPlanes
Definition: reo.h:142
#define ABC_FREE(obj)
Definition: abc_global.h:232
reo_unit ** pMemChunks
Definition: reo.h:161
int * pOrderInt
Definition: reo.h:120
void Extra_ReorderSetIterations ( reo_man p,
int  nIters 
)

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

Synopsis [Sets the number of iterations of sifting performed.]

Description [The default is one iteration. But a higher minimization quality is desired, it is possible to set the number of iterations to any number larger than 1. Convergence is often reached after several iterations, so typically it make no sense to set the number of iterations higher than 3.]

SideEffects []

SeeAlso []

Definition at line 192 of file reoApi.c.

193 {
194  p->nIters = nIters;
195 }
int nIters
Definition: reo.h:109
void Extra_ReorderSetMinimizationType ( reo_man p,
reo_min_type  fMinType 
)

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

Synopsis [Sets the type of DD minimizationl that will be performed.]

Description [Currently, three different types of minimization are supported. It is possible to minimize the number of BDD nodes. This is a classical type of minimization, which is attempting to reduce the total number of nodes in the (shared) BDD of the given Boolean functions. It is also possible to minimize the BDD width, defined as the sum total of the number of cofactors on each level in the (shared) BDD (note that the number of cofactors on the given level may be larger than the number of nodes appearing on the given level). It is also possible to minimize the average path length in the (shared) BDD defined as the sum of products, for all BDD paths from the top node to any terminal node, of the number of minterms on the path by the number of nodes on the path. The default reordering type is minimization for the number of BDD nodes. Calling this function with REO_MINIMIZE_WIDTH or REO_MINIMIZE_APL as the second argument, changes the default minimization option for all the reorder calls performed afterwards.]

SideEffects []

SeeAlso []

Definition at line 122 of file reoApi.c.

123 {
124  if ( fMinType == REO_MINIMIZE_NODES )
125  {
126  p->fMinWidth = 0;
127  p->fMinApl = 0;
128  }
129  else if ( fMinType == REO_MINIMIZE_WIDTH )
130  {
131  p->fMinWidth = 1;
132  p->fMinApl = 0;
133  }
134  else if ( fMinType == REO_MINIMIZE_APL )
135  {
136  p->fMinWidth = 0;
137  p->fMinApl = 1;
138  }
139  else
140  {
141  assert( 0 );
142  }
143 }
int fMinApl
Definition: reo.h:105
int fMinWidth
Definition: reo.h:104
#define assert(ex)
Definition: util_old.h:213
void Extra_ReorderSetRemapping ( reo_man p,
int  fRemapUp 
)

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

Synopsis [Sets the type of remapping performed by the engine.]

Description [The remapping refers to the way the resulting BDD is expressed using the elementary variables of the CUDD BDD manager. Currently, two types possibilities are supported: remapping and no remapping. Remapping means that the function(s) after reordering depend on the topmost variables in the manager. No remapping means that the function(s) after reordering depend on the same variables as before. Consider the following example. Suppose the initial four variable function depends on variables 2,4,5, and 9 on the CUDD BDD manager, which may be found anywhere in the current variable order. If remapping is set, the function after ordering depends on the topmost variables in the manager, which may or may not be the same as the variables 2,4,5, and 9. If no remapping is set, then the reordered function depend on the same variables 2,4,5, and 9, but the meaning of each variale has changed according to the new ordering. The resulting ordering is returned in the array "pOrder" filled out by the reordering engine in the call to Extra_Reorder(). The default is no remapping.]

SideEffects []

SeeAlso []

Definition at line 172 of file reoApi.c.

173 {
174  p->fRemapUp = fRemapUp;
175 }
int fRemapUp
Definition: reo.h:108
void Extra_ReorderSetVerbosity ( reo_man p,
int  fVerbose 
)

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

Synopsis [Sets the verbosity level.]

Description [Setting the level to 1 results in printing statistics before and after the reordering.]

SideEffects []

SeeAlso []

Definition at line 229 of file reoApi.c.

230 {
231  p->fVerbose = fVerbose;
232 }
int fVerbose
Definition: reo.h:106
void Extra_ReorderSetVerification ( reo_man p,
int  fVerify 
)

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

Synopsis [Sets the verification mode.]

Description [Setting the level to 1 results in verifying the results of variable reordering. Verification is performed by remapping the resulting functions into the original variable order and comparing them with the original functions given by the user. Enabling verification typically leads to 20-30% increase in the total runtime of REO.]

SideEffects []

SeeAlso []

Definition at line 212 of file reoApi.c.

213 {
214  p->fVerify = fVerify;
215 }
int fVerify
Definition: reo.h:107