abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cuddInit.c File Reference
#include "misc/util/util_hack.h"
#include "cuddInt.h"

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

131 {
132  DdManager *unique;
133  int i,result;
134  DdNode *one, *zero;
135  unsigned int maxCacheSize;
136  unsigned int looseUpTo;
137  extern DD_OOMFP MMoutOfMemory;
138  DD_OOMFP saveHandler;
139 
140  if (maxMemory == 0) {
141  maxMemory = getSoftDataLimit();
142  }
143  looseUpTo = (unsigned int) ((maxMemory / sizeof(DdNode)) /
145  unique = cuddInitTable(numVars,numVarsZ,numSlots,looseUpTo);
146  if (unique == NULL) return(NULL);
147  unique->maxmem = (unsigned long) maxMemory / 10 * 9;
148  maxCacheSize = (unsigned int) ((maxMemory / sizeof(DdCache)) /
150  result = cuddInitCache(unique,cacheSize,maxCacheSize);
151  if (result == 0) return(NULL);
152 
153  saveHandler = MMoutOfMemory;
154  MMoutOfMemory = Cudd_OutOfMem;
155  unique->stash = ABC_ALLOC(char,(maxMemory / DD_STASH_FRACTION) + 4);
156  MMoutOfMemory = saveHandler;
157  if (unique->stash == NULL) {
158  (void) fprintf(unique->err,"Unable to set aside memory\n");
159  }
160 
161  /* Initialize constants. */
162  unique->one = cuddUniqueConst(unique,1.0);
163  if (unique->one == NULL) return(0);
164  cuddRef(unique->one);
165  unique->zero = cuddUniqueConst(unique,0.0);
166  if (unique->zero == NULL) return(0);
167  cuddRef(unique->zero);
168 #ifdef HAVE_IEEE_754
169  if (DD_PLUS_INF_VAL != DD_PLUS_INF_VAL * 3 ||
171  (void) fprintf(unique->err,"Warning: Crippled infinite values\n");
172  (void) fprintf(unique->err,"Recompile without -DHAVE_IEEE_754\n");
173  }
174 #endif
175  unique->plusinfinity = cuddUniqueConst(unique,DD_PLUS_INF_VAL);
176  if (unique->plusinfinity == NULL) return(0);
177  cuddRef(unique->plusinfinity);
179  if (unique->minusinfinity == NULL) return(0);
180  cuddRef(unique->minusinfinity);
181  unique->background = unique->zero;
182 
183  /* The logical zero is different from the CUDD_VALUE_TYPE zero! */
184  one = unique->one;
185  zero = Cudd_Not(one);
186  /* Create the projection functions. */
187  unique->vars = ABC_ALLOC(DdNodePtr,unique->maxSize);
188  if (unique->vars == NULL) {
189  unique->errorCode = CUDD_MEMORY_OUT;
190  return(NULL);
191  }
192  for (i = 0; i < unique->size; i++) {
193  unique->vars[i] = cuddUniqueInter(unique,i,one,zero);
194  if (unique->vars[i] == NULL) return(0);
195  cuddRef(unique->vars[i]);
196  }
197 
198  if (unique->sizeZ)
199  cuddZddInitUniv(unique);
200 
201  unique->memused += sizeof(DdNode *) * unique->maxSize;
202 
203  unique->bFunc = NULL;
204  unique->bFunc2 = NULL;
205  unique->TimeStop = 0;
206  return(unique);
207 
208 } /* end of Cudd_Init */
#define cuddRef(n)
Definition: cuddInt.h:584
void(* DD_OOMFP)(long)
Definition: cudd.h:324
int cuddZddInitUniv(DdManager *zdd)
Definition: cuddInit.c:252
void Cudd_OutOfMem(long size)
Definition: cuddUtil.c:2837
abctime TimeStop
Definition: cuddInt.h:489
Definition: cudd.h:278
#define Cudd_Not(node)
Definition: cudd.h:367
#define DD_MAX_CACHE_FRACTION
Definition: cuddInt.h:140
DdNode * cuddUniqueConst(DdManager *unique, CUDD_VALUE_TYPE value)
Definition: cuddTable.c:1450
int size
Definition: cuddInt.h:361
#define DD_STASH_FRACTION
Definition: cuddInt.h:142
DdNode * zero
Definition: cuddInt.h:346
#define DD_MAX_LOOSE_FRACTION
Definition: cuddInt.h:138
FILE * err
Definition: cuddInt.h:442
DdNode * bFunc
Definition: cuddInt.h:487
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
#define DD_PLUS_INF_VAL
Definition: cuddInt.h:117
int cuddInitCache(DdManager *unique, unsigned int cacheSize, unsigned int maxCacheSize)
Definition: cuddCache.c:136
EXTERN long getSoftDataLimit()
char * stash
Definition: cuddInt.h:399
static DdNode * one
Definition: cuddDecomp.c:112
int maxSize
Definition: cuddInt.h:363
DdNode * bFunc2
Definition: cuddInt.h:488
DdManager * cuddInitTable(unsigned int numVars, unsigned int numVarsZ, unsigned int numSlots, unsigned int looseUpTo)
Definition: cuddTable.c:351
unsigned long memused
Definition: cuddInt.h:449
int sizeZ
Definition: cuddInt.h:362
DdNode ** vars
Definition: cuddInt.h:390
DdNode * one
Definition: cuddInt.h:345
DdNode * plusinfinity
Definition: cuddInt.h:347
static int result
Definition: cuddGenetic.c:125
unsigned long maxmem
Definition: cuddInt.h:450
DdNode * minusinfinity
Definition: cuddInt.h:348
#define DD_MINUS_INF_VAL
Definition: cuddInt.h:121
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
DdNode * cuddUniqueInter(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1128
static DdNode * zero
Definition: cuddApa.c:100
DdNode * background
Definition: cuddInt.h:349
#define MMoutOfMemory
Definition: util_hack.h:38
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 225 of file cuddInit.c.

227 {
228  if (unique->stash != NULL) ABC_FREE(unique->stash);
229  cuddFreeTable(unique);
230 
231 } /* end of Cudd_Quit */
char * stash
Definition: cuddInt.h:399
#define ABC_FREE(obj)
Definition: abc_global.h:232
void cuddFreeTable(DdManager *unique)
Definition: cuddTable.c:659
void cuddZddFreeUniv ( DdManager zdd)

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

Synopsis [Frees the ZDD universe.]

Description [Frees the ZDD universe.]

SideEffects [None]

SeeAlso [cuddZddInitUniv]

Definition at line 301 of file cuddInit.c.

303 {
304  if (zdd->univ) {
305  Cudd_RecursiveDerefZdd(zdd, zdd->univ[0]);
306  ABC_FREE(zdd->univ);
307  }
308 
309 } /* end of cuddZddFreeUniv */
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:385
#define ABC_FREE(obj)
Definition: abc_global.h:232
DdNode ** univ
Definition: cuddInt.h:392
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 252 of file cuddInit.c.

254 {
255  DdNode *p, *res;
256  int i;
257 
258  zdd->univ = ABC_ALLOC(DdNodePtr, zdd->sizeZ);
259  if (zdd->univ == NULL) {
260  zdd->errorCode = CUDD_MEMORY_OUT;
261  return(0);
262  }
263 
264  res = DD_ONE(zdd);
265  cuddRef(res);
266  for (i = zdd->sizeZ - 1; i >= 0; i--) {
267  unsigned int index = zdd->invpermZ[i];
268  p = res;
269  res = cuddUniqueInterZdd(zdd, index, p, p);
270  if (res == NULL) {
271  Cudd_RecursiveDerefZdd(zdd,p);
272  ABC_FREE(zdd->univ);
273  return(0);
274  }
275  cuddRef(res);
276  cuddDeref(p);
277  zdd->univ[i] = res;
278  }
279 
280 #ifdef DD_VERBOSE
281  cuddZddP(zdd, zdd->univ[0]);
282 #endif
283 
284  return(1);
285 
286 } /* end of cuddZddInitUniv */
#define cuddRef(n)
Definition: cuddInt.h:584
void Cudd_RecursiveDerefZdd(DdManager *table, DdNode *n)
Definition: cuddRef.c:385
#define cuddDeref(n)
Definition: cuddInt.h:604
Definition: cudd.h:278
static Llb_Mgr_t * p
Definition: llb3Image.c:950
int * invpermZ
Definition: cuddInt.h:389
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
DdNode * cuddUniqueInterZdd(DdManager *unique, int index, DdNode *T, DdNode *E)
Definition: cuddTable.c:1343
int sizeZ
Definition: cuddInt.h:362
#define ABC_FREE(obj)
Definition: abc_global.h:232
#define DD_ONE(dd)
Definition: cuddInt.h:911
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int cuddZddP(DdManager *zdd, DdNode *f)
Definition: cuddZddUtil.c:822
DdNode ** univ
Definition: cuddInt.h:392

Variable Documentation

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