src/cuBdd/cuddInit.c File Reference

#include "util.h"
#include "cuddInt.h"
Include dependency graph for cuddInit.c:

Go to the source code of this file.

Functions

DdManagerCudd_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.33 2007/07/01 05:10:50 fabio Exp $"

Function Documentation

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 121 of file cuddInit.c.

00127 {
00128     DdManager *unique;
00129     int i,result;
00130     DdNode *one, *zero;
00131     unsigned int maxCacheSize;
00132     unsigned int looseUpTo;
00133     extern DD_OOMFP MMoutOfMemory;
00134     DD_OOMFP saveHandler;
00135 
00136     if (maxMemory == 0) {
00137         maxMemory = getSoftDataLimit();
00138     }
00139     looseUpTo = (unsigned int) ((maxMemory / sizeof(DdNode)) /
00140                                 DD_MAX_LOOSE_FRACTION);
00141     unique = cuddInitTable(numVars,numVarsZ,numSlots,looseUpTo);
00142     if (unique == NULL) return(NULL);
00143     unique->maxmem = (unsigned long) maxMemory / 10 * 9;
00144     maxCacheSize = (unsigned int) ((maxMemory / sizeof(DdCache)) /
00145                                    DD_MAX_CACHE_FRACTION);
00146     result = cuddInitCache(unique,cacheSize,maxCacheSize);
00147     if (result == 0) return(NULL);
00148 
00149     saveHandler = MMoutOfMemory;
00150     MMoutOfMemory = Cudd_OutOfMem;
00151     unique->stash = ALLOC(char,(maxMemory / DD_STASH_FRACTION) + 4);
00152     MMoutOfMemory = saveHandler;
00153     if (unique->stash == NULL) {
00154         (void) fprintf(unique->err,"Unable to set aside memory\n");
00155     }
00156 
00157     /* Initialize constants. */
00158     unique->one = cuddUniqueConst(unique,1.0);
00159     if (unique->one == NULL) return(0);
00160     cuddRef(unique->one);
00161     unique->zero = cuddUniqueConst(unique,0.0);
00162     if (unique->zero == NULL) return(0);
00163     cuddRef(unique->zero);
00164 #ifdef HAVE_IEEE_754
00165     if (DD_PLUS_INF_VAL != DD_PLUS_INF_VAL * 3 ||
00166         DD_PLUS_INF_VAL != DD_PLUS_INF_VAL / 3) {
00167         (void) fprintf(unique->err,"Warning: Crippled infinite values\n");
00168         (void) fprintf(unique->err,"Recompile without -DHAVE_IEEE_754\n");
00169     }
00170 #endif
00171     unique->plusinfinity = cuddUniqueConst(unique,DD_PLUS_INF_VAL);
00172     if (unique->plusinfinity == NULL) return(0);
00173     cuddRef(unique->plusinfinity);
00174     unique->minusinfinity = cuddUniqueConst(unique,DD_MINUS_INF_VAL);
00175     if (unique->minusinfinity == NULL) return(0);
00176     cuddRef(unique->minusinfinity);
00177     unique->background = unique->zero;
00178 
00179     /* The logical zero is different from the CUDD_VALUE_TYPE zero! */
00180     one = unique->one;
00181     zero = Cudd_Not(one);
00182     /* Create the projection functions. */
00183     unique->vars = ALLOC(DdNodePtr,unique->maxSize);
00184     if (unique->vars == NULL) {
00185         unique->errorCode = CUDD_MEMORY_OUT;
00186         return(NULL);
00187     }
00188     for (i = 0; i < unique->size; i++) {
00189         unique->vars[i] = cuddUniqueInter(unique,i,one,zero);
00190         if (unique->vars[i] == NULL) return(0);
00191         cuddRef(unique->vars[i]);
00192     }
00193 
00194     if (unique->sizeZ)
00195         cuddZddInitUniv(unique);
00196 
00197     unique->memused += sizeof(DdNode *) * unique->maxSize;
00198 
00199     return(unique);
00200 
00201 } /* 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 218 of file cuddInit.c.

00220 {
00221     if (unique->stash != NULL) FREE(unique->stash);
00222     cuddFreeTable(unique);
00223 
00224 } /* 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 294 of file cuddInit.c.

00296 {
00297     if (zdd->univ) {
00298         Cudd_RecursiveDerefZdd(zdd, zdd->univ[0]);
00299         FREE(zdd->univ);
00300     }
00301 
00302 } /* 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 245 of file cuddInit.c.

00247 {
00248     DdNode      *p, *res;
00249     int         i;
00250 
00251     zdd->univ = ALLOC(DdNodePtr, zdd->sizeZ);
00252     if (zdd->univ == NULL) {
00253         zdd->errorCode = CUDD_MEMORY_OUT;
00254         return(0);
00255     }
00256 
00257     res = DD_ONE(zdd);
00258     cuddRef(res);
00259     for (i = zdd->sizeZ - 1; i >= 0; i--) {
00260         unsigned int index = zdd->invpermZ[i];
00261         p = res;
00262         res = cuddUniqueInterZdd(zdd, index, p, p);
00263         if (res == NULL) {
00264             Cudd_RecursiveDerefZdd(zdd,p);
00265             FREE(zdd->univ);
00266             return(0);
00267         }
00268         cuddRef(res);
00269         cuddDeref(p);
00270         zdd->univ[i] = res;
00271     }
00272 
00273 #ifdef DD_VERBOSE
00274     cuddZddP(zdd, zdd->univ[0]);
00275 #endif
00276 
00277     return(1);
00278 
00279 } /* end of cuddZddInitUniv */


Variable Documentation

char rcsid [] DD_UNUSED = "$Id: cuddInit.c,v 1.33 2007/07/01 05:10:50 fabio Exp $" [static]

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 [Copyright (c) 1995-2004, Regents of the University of Colorado

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

Neither the name of the University of Colorado nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.]

Definition at line 82 of file cuddInit.c.


Generated on Tue Jan 12 13:57:19 2010 for glu-2.2 by  doxygen 1.6.1