Commit 7977b2dd by Alan Mishchenko

Modificationd to CUDD to enable runtime-limit in variable reordering.

parent 53217cdc
...@@ -401,6 +401,10 @@ int Llb_NonlinReachability( Llb_Mnn_t * p ) ...@@ -401,6 +401,10 @@ int Llb_NonlinReachability( Llb_Mnn_t * p )
p->pPars->TimeTarget = clock() + p->pPars->TimeLimit * CLOCKS_PER_SEC; p->pPars->TimeTarget = clock() + p->pPars->TimeLimit * CLOCKS_PER_SEC;
else else
p->pPars->TimeTarget = 0; p->pPars->TimeTarget = 0;
// set the stop time parameter
p->dd->TimeStop = p->pPars->TimeTarget;
p->ddG->TimeStop = p->pPars->TimeTarget;
p->ddR->TimeStop = p->pPars->TimeTarget;
// set reordering hooks // set reordering hooks
assert( p->dd->bFunc == NULL ); assert( p->dd->bFunc == NULL );
......
...@@ -110,11 +110,11 @@ static int originalLevel; ...@@ -110,11 +110,11 @@ static int originalLevel;
/* Static function prototypes */ /* Static function prototypes */
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
static int ddTreeSiftingAux ARGS((DdManager *table, MtrNode *treenode, Cudd_ReorderingType method)); static int ddTreeSiftingAux ARGS((DdManager *table, MtrNode *treenode, Cudd_ReorderingType method, int TimeStop));
#ifdef DD_STATS #ifdef DD_STATS
static int ddCountInternalMtrNodes ARGS((DdManager *table, MtrNode *treenode)); static int ddCountInternalMtrNodes ARGS((DdManager *table, MtrNode *treenode));
#endif #endif
static int ddReorderChildren ARGS((DdManager *table, MtrNode *treenode, Cudd_ReorderingType method)); static int ddReorderChildren ARGS((DdManager *table, MtrNode *treenode, Cudd_ReorderingType method, int TimeStop));
static void ddFindNodeHiLo ARGS((DdManager *table, MtrNode *treenode, int *lower, int *upper)); static void ddFindNodeHiLo ARGS((DdManager *table, MtrNode *treenode, int *lower, int *upper));
static int ddUniqueCompareGroup ARGS((int *ptrX, int *ptrY)); static int ddUniqueCompareGroup ARGS((int *ptrX, int *ptrY));
static int ddGroupSifting ARGS((DdManager *table, int lower, int upper, int (*checkFunction)(DdManager *, int, int), int lazyFlag)); static int ddGroupSifting ARGS((DdManager *table, int lower, int upper, int (*checkFunction)(DdManager *, int, int), int lazyFlag));
...@@ -231,7 +231,8 @@ Cudd_MakeTreeNode( ...@@ -231,7 +231,8 @@ Cudd_MakeTreeNode(
int int
cuddTreeSifting( cuddTreeSifting(
DdManager * table /* DD table */, DdManager * table /* DD table */,
Cudd_ReorderingType method /* reordering method for the groups of leaves */) Cudd_ReorderingType method /* reordering method for the groups of leaves */,
int TimeStop)
{ {
int i; int i;
int nvars; int nvars;
...@@ -276,7 +277,7 @@ cuddTreeSifting( ...@@ -276,7 +277,7 @@ cuddTreeSifting(
/* Reorder. */ /* Reorder. */
result = ddTreeSiftingAux(table, table->tree, method); result = ddTreeSiftingAux(table, table->tree, method, TimeStop);
#ifdef DD_STATS /* print stats */ #ifdef DD_STATS /* print stats */
if (!tempTree && method == CUDD_REORDER_GROUP_SIFT && if (!tempTree && method == CUDD_REORDER_GROUP_SIFT &&
...@@ -319,7 +320,8 @@ static int ...@@ -319,7 +320,8 @@ static int
ddTreeSiftingAux( ddTreeSiftingAux(
DdManager * table, DdManager * table,
MtrNode * treenode, MtrNode * treenode,
Cudd_ReorderingType method) Cudd_ReorderingType method,
int TimeStop)
{ {
MtrNode *auxnode; MtrNode *auxnode;
int res; int res;
...@@ -332,20 +334,20 @@ ddTreeSiftingAux( ...@@ -332,20 +334,20 @@ ddTreeSiftingAux(
auxnode = treenode; auxnode = treenode;
while (auxnode != NULL) { while (auxnode != NULL) {
if (auxnode->child != NULL) { if (auxnode->child != NULL) {
if (!ddTreeSiftingAux(table, auxnode->child, method)) if (!ddTreeSiftingAux(table, auxnode->child, method, TimeStop))
return(0); return(0);
saveCheck = table->groupcheck; saveCheck = table->groupcheck;
table->groupcheck = CUDD_NO_CHECK; table->groupcheck = CUDD_NO_CHECK;
if (method != CUDD_REORDER_LAZY_SIFT) if (method != CUDD_REORDER_LAZY_SIFT)
res = ddReorderChildren(table, auxnode, CUDD_REORDER_GROUP_SIFT); res = ddReorderChildren(table, auxnode, CUDD_REORDER_GROUP_SIFT, TimeStop);
else else
res = ddReorderChildren(table, auxnode, CUDD_REORDER_LAZY_SIFT); res = ddReorderChildren(table, auxnode, CUDD_REORDER_LAZY_SIFT, TimeStop);
table->groupcheck = saveCheck; table->groupcheck = saveCheck;
if (res == 0) if (res == 0)
return(0); return(0);
} else if (auxnode->size > 1) { } else if (auxnode->size > 1) {
if (!ddReorderChildren(table, auxnode, method)) if (!ddReorderChildren(table, auxnode, method, TimeStop))
return(0); return(0);
} }
auxnode = auxnode->younger; auxnode = auxnode->younger;
...@@ -411,7 +413,8 @@ static int ...@@ -411,7 +413,8 @@ static int
ddReorderChildren( ddReorderChildren(
DdManager * table, DdManager * table,
MtrNode * treenode, MtrNode * treenode,
Cudd_ReorderingType method) Cudd_ReorderingType method,
int TimeStop)
{ {
int lower; int lower;
int upper; int upper;
...@@ -450,7 +453,7 @@ ddReorderChildren( ...@@ -450,7 +453,7 @@ ddReorderChildren(
} while (result != 0); } while (result != 0);
break; break;
case CUDD_REORDER_SYMM_SIFT: case CUDD_REORDER_SYMM_SIFT:
result = cuddSymmSifting(table,lower,upper); result = cuddSymmSifting(table,lower,upper,TimeStop);
break; break;
case CUDD_REORDER_SYMM_SIFT_CONV: case CUDD_REORDER_SYMM_SIFT_CONV:
result = cuddSymmSiftingConv(table,lower,upper); result = cuddSymmSiftingConv(table,lower,upper);
......
...@@ -441,6 +441,7 @@ struct DdManager { /* specialized DD symbol table */ ...@@ -441,6 +441,7 @@ struct DdManager { /* specialized DD symbol table */
#endif #endif
DdNode * bFunc; DdNode * bFunc;
DdNode * bFunc2; DdNode * bFunc2;
int TimeStop; /* timeout for reordering */
}; };
typedef struct Move { typedef struct Move {
...@@ -1016,7 +1017,7 @@ EXTERN DdNode * cuddAddConstrainRecur ARGS((DdManager *dd, DdNode *f, DdNode *c) ...@@ -1016,7 +1017,7 @@ EXTERN DdNode * cuddAddConstrainRecur ARGS((DdManager *dd, DdNode *f, DdNode *c)
EXTERN DdNode * cuddAddRestrictRecur ARGS((DdManager *dd, DdNode *f, DdNode *c)); EXTERN DdNode * cuddAddRestrictRecur ARGS((DdManager *dd, DdNode *f, DdNode *c));
EXTERN DdNode * cuddBddLICompaction ARGS((DdManager *dd, DdNode *f, DdNode *c)); EXTERN DdNode * cuddBddLICompaction ARGS((DdManager *dd, DdNode *f, DdNode *c));
EXTERN int cuddGa ARGS((DdManager *table, int lower, int upper)); EXTERN int cuddGa ARGS((DdManager *table, int lower, int upper));
EXTERN int cuddTreeSifting ARGS((DdManager *table, Cudd_ReorderingType method)); EXTERN int cuddTreeSifting ARGS((DdManager *table, Cudd_ReorderingType method, int TimeStop));
EXTERN int cuddZddInitUniv ARGS((DdManager *zdd)); EXTERN int cuddZddInitUniv ARGS((DdManager *zdd));
EXTERN void cuddZddFreeUniv ARGS((DdManager *zdd)); EXTERN void cuddZddFreeUniv ARGS((DdManager *zdd));
EXTERN void cuddSetInteract ARGS((DdManager *table, int x, int y)); EXTERN void cuddSetInteract ARGS((DdManager *table, int x, int y));
...@@ -1071,7 +1072,7 @@ EXTERN DdNode* cuddSplitSetRecur ARGS((DdManager *manager, st_table *mtable, int ...@@ -1071,7 +1072,7 @@ EXTERN DdNode* cuddSplitSetRecur ARGS((DdManager *manager, st_table *mtable, int
EXTERN DdNode * cuddSubsetHeavyBranch ARGS((DdManager *dd, DdNode *f, int numVars, int threshold)); EXTERN DdNode * cuddSubsetHeavyBranch ARGS((DdManager *dd, DdNode *f, int numVars, int threshold));
EXTERN DdNode * cuddSubsetShortPaths ARGS((DdManager *dd, DdNode *f, int numVars, int threshold, int hardlimit)); EXTERN DdNode * cuddSubsetShortPaths ARGS((DdManager *dd, DdNode *f, int numVars, int threshold, int hardlimit));
EXTERN int cuddSymmCheck ARGS((DdManager *table, int x, int y)); EXTERN int cuddSymmCheck ARGS((DdManager *table, int x, int y));
EXTERN int cuddSymmSifting ARGS((DdManager *table, int lower, int upper)); EXTERN int cuddSymmSifting ARGS((DdManager *table, int lower, int upper, int TimeStop));
EXTERN int cuddSymmSiftingConv ARGS((DdManager *table, int lower, int upper)); EXTERN int cuddSymmSiftingConv ARGS((DdManager *table, int lower, int upper));
EXTERN DdNode * cuddAllocNode ARGS((DdManager *unique)); EXTERN DdNode * cuddAllocNode ARGS((DdManager *unique));
EXTERN DdManager * cuddInitTable ARGS((unsigned int numVars, unsigned int numVarsZ, unsigned int numSlots, unsigned int looseUpTo)); EXTERN DdManager * cuddInitTable ARGS((unsigned int numVars, unsigned int numVarsZ, unsigned int numSlots, unsigned int looseUpTo));
......
...@@ -158,6 +158,7 @@ Cudd_ReduceHeap( ...@@ -158,6 +158,7 @@ Cudd_ReduceHeap(
unsigned int finalSize; unsigned int finalSize;
#endif #endif
long localTime; long localTime;
int TimeStop = table->TimeStop;
/* Don't reorder if there are too many dead nodes. */ /* Don't reorder if there are too many dead nodes. */
if (table->keys - table->dead < (unsigned) minsize) if (table->keys - table->dead < (unsigned) minsize)
...@@ -239,10 +240,10 @@ Cudd_ReduceHeap( ...@@ -239,10 +240,10 @@ Cudd_ReduceHeap(
if (table->reordCycle && table->reorderings % table->reordCycle == 0) { if (table->reordCycle && table->reorderings % table->reordCycle == 0) {
double saveGrowth = table->maxGrowth; double saveGrowth = table->maxGrowth;
table->maxGrowth = table->maxGrowthAlt; table->maxGrowth = table->maxGrowthAlt;
result = cuddTreeSifting(table,heuristic); result = cuddTreeSifting(table,heuristic,TimeStop);
table->maxGrowth = saveGrowth; table->maxGrowth = saveGrowth;
} else { } else {
result = cuddTreeSifting(table,heuristic); result = cuddTreeSifting(table,heuristic,TimeStop);
} }
#ifdef DD_STATS #ifdef DD_STATS
......
...@@ -294,7 +294,8 @@ int ...@@ -294,7 +294,8 @@ int
cuddSymmSifting( cuddSymmSifting(
DdManager * table, DdManager * table,
int lower, int lower,
int upper) int upper,
int TimeStop)
{ {
int i; int i;
int *var; int *var;
...@@ -338,6 +339,8 @@ cuddSymmSifting( ...@@ -338,6 +339,8 @@ cuddSymmSifting(
for (i = 0; i < ddMin(table->siftMaxVar,size); i++) { for (i = 0; i < ddMin(table->siftMaxVar,size); i++) {
if (ddTotalNumberSwapping >= table->siftMaxSwap) if (ddTotalNumberSwapping >= table->siftMaxSwap)
break; break;
if ( TimeStop && TimeStop < clock() )
break;
x = table->perm[var[i]]; x = table->perm[var[i]];
#ifdef DD_STATS #ifdef DD_STATS
previousSize = table->keys - table->isolated; previousSize = table->keys - table->isolated;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment