#include "util_hack.h"
#include "cuddInt.h"
Go to the source code of this file.
Defines | |
#define | CUDD_MAIN |
Functions | |
DdManager * | Cudd_Init (unsigned int numVars, unsigned int numVarsZ, unsigned int numSlots, unsigned int cacheSize, unsigned long maxMemory) |
void | Cudd_Quit (DdManager *unique) |
int | cuddZddInitUniv (DdManager *zdd) |
void | cuddZddFreeUniv (DdManager *zdd) |
Variables | |
static char rcsid[] | DD_UNUSED = "$Id: cuddInit.c,v 1.1.1.1 2003/02/24 22:23:52 wjiang Exp $" |
#define CUDD_MAIN |
CFile***********************************************************************
FileName [cuddInit.c]
PackageName [cudd]
Synopsis [Functions to initialize and shut down the DD manager.]
Description [External procedures included in this module:
Internal procedures included in this module:
]
SeeAlso []
Author [Fabio Somenzi]
Copyright [ This file was created at the University of Colorado at Boulder. The University of Colorado at Boulder makes no warranty about the suitability of this software for any purpose. It is presented on an AS IS basis.]
Definition at line 33 of file cuddInit.c.
DdManager* Cudd_Init | ( | unsigned int | numVars, | |
unsigned int | numVarsZ, | |||
unsigned int | numSlots, | |||
unsigned int | cacheSize, | |||
unsigned long | maxMemory | |||
) |
AutomaticStart AutomaticEnd Function********************************************************************
Synopsis [Creates a new DD manager.]
Description [Creates a new DD manager, initializes the table, the basic constants and the projection functions. If maxMemory is 0, Cudd_Init decides suitable values for the maximum size of the cache and for the limit for fast unique table growth based on the available memory. Returns a pointer to the manager if successful; NULL otherwise.]
SideEffects [None]
SeeAlso [Cudd_Quit]
Definition at line 96 of file cuddInit.c.
00102 { 00103 DdManager *unique; 00104 int i,result; 00105 DdNode *one, *zero; 00106 unsigned int maxCacheSize; 00107 unsigned int looseUpTo; 00108 extern void (*MMoutOfMemory)(long); 00109 void (*saveHandler)(long); 00110 00111 if (maxMemory == 0) { 00112 maxMemory = getSoftDataLimit(); 00113 } 00114 looseUpTo = (unsigned int) ((maxMemory / sizeof(DdNode)) / 00115 DD_MAX_LOOSE_FRACTION); 00116 unique = cuddInitTable(numVars,numVarsZ,numSlots,looseUpTo); 00117 unique->maxmem = (unsigned) maxMemory / 10 * 9; 00118 if (unique == NULL) return(NULL); 00119 maxCacheSize = (unsigned int) ((maxMemory / sizeof(DdCache)) / 00120 DD_MAX_CACHE_FRACTION); 00121 result = cuddInitCache(unique,cacheSize,maxCacheSize); 00122 if (result == 0) return(NULL); 00123 00124 saveHandler = MMoutOfMemory; 00125 MMoutOfMemory = Cudd_OutOfMem; 00126 unique->stash = ALLOC(char,(maxMemory / DD_STASH_FRACTION) + 4); 00127 MMoutOfMemory = saveHandler; 00128 if (unique->stash == NULL) { 00129 (void) fprintf(unique->err,"Unable to set aside memory\n"); 00130 } 00131 00132 /* Initialize constants. */ 00133 unique->one = cuddUniqueConst(unique,1.0); 00134 if (unique->one == NULL) return(0); 00135 cuddRef(unique->one); 00136 unique->zero = cuddUniqueConst(unique,0.0); 00137 if (unique->zero == NULL) return(0); 00138 cuddRef(unique->zero); 00139 #ifdef HAVE_IEEE_754 00140 if (DD_PLUS_INF_VAL != DD_PLUS_INF_VAL * 3 || 00141 DD_PLUS_INF_VAL != DD_PLUS_INF_VAL / 3) { 00142 (void) fprintf(unique->err,"Warning: Crippled infinite values\n"); 00143 (void) fprintf(unique->err,"Recompile without -DHAVE_IEEE_754\n"); 00144 } 00145 #endif 00146 unique->plusinfinity = cuddUniqueConst(unique,DD_PLUS_INF_VAL); 00147 if (unique->plusinfinity == NULL) return(0); 00148 cuddRef(unique->plusinfinity); 00149 unique->minusinfinity = cuddUniqueConst(unique,DD_MINUS_INF_VAL); 00150 if (unique->minusinfinity == NULL) return(0); 00151 cuddRef(unique->minusinfinity); 00152 unique->background = unique->zero; 00153 00154 /* The logical zero is different from the CUDD_VALUE_TYPE zero! */ 00155 one = unique->one; 00156 zero = Cudd_Not(one); 00157 /* Create the projection functions. */ 00158 unique->vars = ALLOC(DdNodePtr,unique->maxSize); 00159 if (unique->vars == NULL) { 00160 unique->errorCode = CUDD_MEMORY_OUT; 00161 return(NULL); 00162 } 00163 for (i = 0; i < unique->size; i++) { 00164 unique->vars[i] = cuddUniqueInter(unique,i,one,zero); 00165 if (unique->vars[i] == NULL) return(0); 00166 cuddRef(unique->vars[i]); 00167 } 00168 00169 if (unique->sizeZ) 00170 cuddZddInitUniv(unique); 00171 00172 unique->memused += sizeof(DdNode *) * unique->maxSize; 00173 00174 return(unique); 00175 00176 } /* end of Cudd_Init */
void Cudd_Quit | ( | DdManager * | unique | ) |
Function********************************************************************
Synopsis [Deletes resources associated with a DD manager.]
Description [Deletes resources associated with a DD manager and resets the global statistical counters. (Otherwise, another manaqger subsequently created would inherit the stats of this one.)]
SideEffects [None]
SeeAlso [Cudd_Init]
Definition at line 193 of file cuddInit.c.
00195 { 00196 if (unique->stash != NULL) FREE(unique->stash); 00197 cuddFreeTable(unique); 00198 00199 } /* end of Cudd_Quit */
void cuddZddFreeUniv | ( | DdManager * | zdd | ) |
Function********************************************************************
Synopsis [Frees the ZDD universe.]
Description [Frees the ZDD universe.]
SideEffects [None]
SeeAlso [cuddZddInitUniv]
Definition at line 269 of file cuddInit.c.
00271 { 00272 if (zdd->univ) { 00273 Cudd_RecursiveDerefZdd(zdd, zdd->univ[0]); 00274 FREE(zdd->univ); 00275 } 00276 00277 } /* end of cuddZddFreeUniv */
int cuddZddInitUniv | ( | DdManager * | zdd | ) |
Function********************************************************************
Synopsis [Initializes the ZDD universe.]
Description [Initializes the ZDD universe. Returns 1 if successful; 0 otherwise.]
SideEffects [None]
SeeAlso [cuddZddFreeUniv]
Definition at line 220 of file cuddInit.c.
00222 { 00223 DdNode *p, *res; 00224 int i; 00225 00226 zdd->univ = ALLOC(DdNodePtr, zdd->sizeZ); 00227 if (zdd->univ == NULL) { 00228 zdd->errorCode = CUDD_MEMORY_OUT; 00229 return(0); 00230 } 00231 00232 res = DD_ONE(zdd); 00233 cuddRef(res); 00234 for (i = zdd->sizeZ - 1; i >= 0; i--) { 00235 unsigned int index = zdd->invpermZ[i]; 00236 p = res; 00237 res = cuddUniqueInterZdd(zdd, index, p, p); 00238 if (res == NULL) { 00239 Cudd_RecursiveDerefZdd(zdd,p); 00240 FREE(zdd->univ); 00241 return(0); 00242 } 00243 cuddRef(res); 00244 cuddDeref(p); 00245 zdd->univ[i] = res; 00246 } 00247 00248 #ifdef DD_VERBOSE 00249 cuddZddP(zdd, zdd->univ[0]); 00250 #endif 00251 00252 return(1); 00253 00254 } /* end of cuddZddInitUniv */
char rcsid [] DD_UNUSED = "$Id: cuddInit.c,v 1.1.1.1 2003/02/24 22:23:52 wjiang Exp $" [static] |
Definition at line 57 of file cuddInit.c.