abc-master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
cuddLCache.c
Go to the documentation of this file.
1 /**CFile***********************************************************************
2 
3  FileName [cuddLCache.c]
4 
5  PackageName [cudd]
6 
7  Synopsis [Functions for local caches.]
8 
9  Description [Internal procedures included in this module:
10  <ul>
11  <li> cuddLocalCacheInit()
12  <li> cuddLocalCacheQuit()
13  <li> cuddLocalCacheInsert()
14  <li> cuddLocalCacheLookup()
15  <li> cuddLocalCacheClearDead()
16  <li> cuddLocalCacheClearAll()
17  <li> cuddLocalCacheProfile()
18  <li> cuddHashTableInit()
19  <li> cuddHashTableQuit()
20  <li> cuddHashTableInsert()
21  <li> cuddHashTableLookup()
22  <li> cuddHashTableInsert2()
23  <li> cuddHashTableLookup2()
24  <li> cuddHashTableInsert3()
25  <li> cuddHashTableLookup3()
26  </ul>
27  Static procedures included in this module:
28  <ul>
29  <li> cuddLocalCacheResize()
30  <li> ddLCHash()
31  <li> cuddLocalCacheAddToList()
32  <li> cuddLocalCacheRemoveFromList()
33  <li> cuddHashTableResize()
34  <li> cuddHashTableAlloc()
35  </ul> ]
36 
37  SeeAlso []
38 
39  Author [Fabio Somenzi]
40 
41  Copyright [Copyright (c) 1995-2004, Regents of the University of Colorado
42 
43  All rights reserved.
44 
45  Redistribution and use in source and binary forms, with or without
46  modification, are permitted provided that the following conditions
47  are met:
48 
49  Redistributions of source code must retain the above copyright
50  notice, this list of conditions and the following disclaimer.
51 
52  Redistributions in binary form must reproduce the above copyright
53  notice, this list of conditions and the following disclaimer in the
54  documentation and/or other materials provided with the distribution.
55 
56  Neither the name of the University of Colorado nor the names of its
57  contributors may be used to endorse or promote products derived from
58  this software without specific prior written permission.
59 
60  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
61  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
62  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
63  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
64  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
65  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
66  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
67  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
68  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
69  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
70  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
71  POSSIBILITY OF SUCH DAMAGE.]
72 
73 ******************************************************************************/
74 
75 #include "misc/util/util_hack.h"
76 #include "cuddInt.h"
77 
79 
80 
81 
82 /*---------------------------------------------------------------------------*/
83 /* Constant declarations */
84 /*---------------------------------------------------------------------------*/
85 
86 #define DD_MAX_HASHTABLE_DENSITY 2 /* tells when to resize a table */
87 
88 /*---------------------------------------------------------------------------*/
89 /* Stucture declarations */
90 /*---------------------------------------------------------------------------*/
91 
92 
93 /*---------------------------------------------------------------------------*/
94 /* Type declarations */
95 /*---------------------------------------------------------------------------*/
96 
97 
98 /*---------------------------------------------------------------------------*/
99 /* Variable declarations */
100 /*---------------------------------------------------------------------------*/
101 
102 #ifndef lint
103 static char rcsid[] DD_UNUSED = "$Id: cuddLCache.c,v 1.24 2009/03/08 02:49:02 fabio Exp $";
104 #endif
105 
106 /*---------------------------------------------------------------------------*/
107 /* Macro declarations */
108 /*---------------------------------------------------------------------------*/
109 
110 /**Macro***********************************************************************
111 
112  Synopsis [Computes hash function for keys of two operands.]
113 
114  Description []
115 
116  SideEffects [None]
117 
118  SeeAlso [ddLCHash3 ddLCHash]
119 
120 ******************************************************************************/
121 #if SIZEOF_VOID_P == 8 && SIZEOF_INT == 4
122 #define ddLCHash2(f,g,shift) \
123 ((((unsigned)(ptruint)(f) * DD_P1 + \
124  (unsigned)(ptruint)(g)) * DD_P2) >> (shift))
125 #else
126 #define ddLCHash2(f,g,shift) \
127 ((((unsigned)(f) * DD_P1 + (unsigned)(g)) * DD_P2) >> (shift))
128 #endif
129 
130 
131 /**Macro***********************************************************************
132 
133  Synopsis [Computes hash function for keys of three operands.]
134 
135  Description []
136 
137  SideEffects [None]
138 
139  SeeAlso [ddLCHash2 ddLCHash]
140 
141 ******************************************************************************/
142 #define ddLCHash3(f,g,h,shift) ddCHash2(f,g,h,shift)
143 
144 
145 /**AutomaticStart*************************************************************/
146 
147 /*---------------------------------------------------------------------------*/
148 /* Static function prototypes */
149 /*---------------------------------------------------------------------------*/
150 
151 static void cuddLocalCacheResize (DdLocalCache *cache);
152 DD_INLINE static unsigned int ddLCHash (DdNodePtr *key, unsigned int keysize, int shift);
153 static void cuddLocalCacheAddToList (DdLocalCache *cache);
154 static void cuddLocalCacheRemoveFromList (DdLocalCache *cache);
155 static int cuddHashTableResize (DdHashTable *hash);
157 
158 /**AutomaticEnd***************************************************************/
159 
160 
161 /*---------------------------------------------------------------------------*/
162 /* Definition of exported functions */
163 /*---------------------------------------------------------------------------*/
164 
165 /*---------------------------------------------------------------------------*/
166 /* Definition of internal functions */
167 /*---------------------------------------------------------------------------*/
168 
169 
170 /**Function********************************************************************
171 
172  Synopsis [Initializes a local computed table.]
173 
174  Description [Initializes a computed table. Returns a pointer the
175  the new local cache in case of success; NULL otherwise.]
176 
177  SideEffects [None]
178 
179  SeeAlso [cuddInitCache]
180 
181 ******************************************************************************/
182 DdLocalCache *
184  DdManager * manager /* manager */,
185  unsigned int keySize /* size of the key (number of operands) */,
186  unsigned int cacheSize /* Initial size of the cache */,
187  unsigned int maxCacheSize /* Size of the cache beyond which no resizing occurs */)
188 {
189  DdLocalCache *cache;
190  int logSize;
191 
192  cache = ABC_ALLOC(DdLocalCache,1);
193  if (cache == NULL) {
194  manager->errorCode = CUDD_MEMORY_OUT;
195  return(NULL);
196  }
197  cache->manager = manager;
198  cache->keysize = keySize;
199  cache->itemsize = (keySize + 1) * sizeof(DdNode *);
200 #ifdef DD_CACHE_PROFILE
201  cache->itemsize += sizeof(ptrint);
202 #endif
203  logSize = cuddComputeFloorLog2(ddMax(cacheSize,manager->slots/2));
204  cacheSize = 1 << logSize;
205  cache->item = (DdLocalCacheItem *)
206  ABC_ALLOC(char, cacheSize * cache->itemsize);
207  if (cache->item == NULL) {
208  manager->errorCode = CUDD_MEMORY_OUT;
209  ABC_FREE(cache);
210  return(NULL);
211  }
212  cache->slots = cacheSize;
213  cache->shift = sizeof(int) * 8 - logSize;
214  cache->maxslots = ddMin(maxCacheSize,manager->slots);
215  cache->minHit = manager->minHit;
216  /* Initialize to avoid division by 0 and immediate resizing. */
217  cache->lookUps = (double) (int) (cacheSize * cache->minHit + 1);
218  cache->hits = 0;
219  manager->memused += cacheSize * cache->itemsize + sizeof(DdLocalCache);
220 
221  /* Initialize the cache. */
222  memset(cache->item, 0, cacheSize * cache->itemsize);
223 
224  /* Add to manager's list of local caches for GC. */
226 
227  return(cache);
228 
229 } /* end of cuddLocalCacheInit */
230 
231 
232 /**Function********************************************************************
233 
234  Synopsis [Shuts down a local computed table.]
235 
236  Description [Initializes the computed table. It is called by
237  Cudd_Init. Returns a pointer the the new local cache in case of
238  success; NULL otherwise.]
239 
240  SideEffects [None]
241 
242  SeeAlso [cuddLocalCacheInit]
243 
244 ******************************************************************************/
245 void
247  DdLocalCache * cache /* cache to be shut down */)
248 {
249  cache->manager->memused -=
250  cache->slots * cache->itemsize + sizeof(DdLocalCache);
252  ABC_FREE(cache->item);
253  ABC_FREE(cache);
254 
255  return;
256 
257 } /* end of cuddLocalCacheQuit */
258 
259 
260 /**Function********************************************************************
261 
262  Synopsis [Inserts a result in a local cache.]
263 
264  Description []
265 
266  SideEffects [None]
267 
268  SeeAlso []
269 
270 ******************************************************************************/
271 void
273  DdLocalCache * cache,
274  DdNodePtr * key,
275  DdNode * value)
276 {
277  unsigned int posn;
279 
280  posn = ddLCHash(key,cache->keysize,cache->shift);
281  entry = (DdLocalCacheItem *) ((char *) cache->item +
282  posn * cache->itemsize);
283  memcpy(entry->key,key,cache->keysize * sizeof(DdNode *));
284  entry->value = value;
285 #ifdef DD_CACHE_PROFILE
286  entry->count++;
287 #endif
288 
289 } /* end of cuddLocalCacheInsert */
290 
291 
292 /**Function********************************************************************
293 
294  Synopsis [Looks up in a local cache.]
295 
296  Description [Looks up in a local cache. Returns the result if found;
297  it returns NULL if no result is found.]
298 
299  SideEffects [None]
300 
301  SeeAlso []
302 
303 ******************************************************************************/
304 DdNode *
306  DdLocalCache * cache,
307  DdNodePtr * key)
308 {
309  unsigned int posn;
311  DdNode *value;
312 
313  cache->lookUps++;
314  posn = ddLCHash(key,cache->keysize,cache->shift);
315  entry = (DdLocalCacheItem *) ((char *) cache->item +
316  posn * cache->itemsize);
317  if (entry->value != NULL &&
318  memcmp(key,entry->key,cache->keysize*sizeof(DdNode *)) == 0) {
319  cache->hits++;
320  value = Cudd_Regular(entry->value);
321  if (value->ref == 0) {
322  cuddReclaim(cache->manager,value);
323  }
324  return(entry->value);
325  }
326 
327  /* Cache miss: decide whether to resize */
328 
329  if (cache->slots < cache->maxslots &&
330  cache->hits > cache->lookUps * cache->minHit) {
331  cuddLocalCacheResize(cache);
332  }
333 
334  return(NULL);
335 
336 } /* end of cuddLocalCacheLookup */
337 
338 
339 /**Function********************************************************************
340 
341  Synopsis [Clears the dead entries of the local caches of a manager.]
342 
343  Description [Clears the dead entries of the local caches of a manager.
344  Used during garbage collection.]
345 
346  SideEffects [None]
347 
348  SeeAlso []
349 
350 ******************************************************************************/
351 void
353  DdManager * manager)
354 {
355  DdLocalCache *cache = manager->localCaches;
356  unsigned int keysize;
357  unsigned int itemsize;
358  unsigned int slots;
359  DdLocalCacheItem *item;
360  DdNodePtr *key;
361  unsigned int i, j;
362 
363  while (cache != NULL) {
364  keysize = cache->keysize;
365  itemsize = cache->itemsize;
366  slots = cache->slots;
367  item = cache->item;
368  for (i = 0; i < slots; i++) {
369  if (item->value != NULL) {
370  if (Cudd_Regular(item->value)->ref == 0) {
371  item->value = NULL;
372  } else {
373  key = item->key;
374  for (j = 0; j < keysize; j++) {
375  if (Cudd_Regular(key[j])->ref == 0) {
376  item->value = NULL;
377  break;
378  }
379  }
380  }
381  }
382  item = (DdLocalCacheItem *) ((char *) item + itemsize);
383  }
384  cache = cache->next;
385  }
386  return;
387 
388 } /* end of cuddLocalCacheClearDead */
389 
390 
391 /**Function********************************************************************
392 
393  Synopsis [Clears the local caches of a manager.]
394 
395  Description [Clears the local caches of a manager.
396  Used before reordering.]
397 
398  SideEffects [None]
399 
400  SeeAlso []
401 
402 ******************************************************************************/
403 void
405  DdManager * manager)
406 {
407  DdLocalCache *cache = manager->localCaches;
408 
409  while (cache != NULL) {
410  memset(cache->item, 0, cache->slots * cache->itemsize);
411  cache = cache->next;
412  }
413  return;
414 
415 } /* end of cuddLocalCacheClearAll */
416 
417 
418 #ifdef DD_CACHE_PROFILE
419 
420 #define DD_HYSTO_BINS 8
421 
422 /**Function********************************************************************
423 
424  Synopsis [Computes and prints a profile of a local cache usage.]
425 
426  Description [Computes and prints a profile of a local cache usage.
427  Returns 1 if successful; 0 otherwise.]
428 
429  SideEffects [None]
430 
431  SeeAlso []
432 
433 ******************************************************************************/
434 int
435 cuddLocalCacheProfile(
436  DdLocalCache * cache)
437 {
438  double count, mean, meansq, stddev, expected;
439  long max, min;
440  int imax, imin;
441  int i, retval, slots;
442  long *hystogram;
443  int nbins = DD_HYSTO_BINS;
444  int bin;
445  long thiscount;
446  double totalcount;
447  int nzeroes;
449  FILE *fp = cache->manager->out;
450 
451  slots = cache->slots;
452 
453  meansq = mean = expected = 0.0;
454  max = min = (long) cache->item[0].count;
455  imax = imin = nzeroes = 0;
456  totalcount = 0.0;
457 
458  hystogram = ABC_ALLOC(long, nbins);
459  if (hystogram == NULL) {
460  return(0);
461  }
462  for (i = 0; i < nbins; i++) {
463  hystogram[i] = 0;
464  }
465 
466  for (i = 0; i < slots; i++) {
467  entry = (DdLocalCacheItem *) ((char *) cache->item +
468  i * cache->itemsize);
469  thiscount = (long) entry->count;
470  if (thiscount > max) {
471  max = thiscount;
472  imax = i;
473  }
474  if (thiscount < min) {
475  min = thiscount;
476  imin = i;
477  }
478  if (thiscount == 0) {
479  nzeroes++;
480  }
481  count = (double) thiscount;
482  mean += count;
483  meansq += count * count;
484  totalcount += count;
485  expected += count * (double) i;
486  bin = (i * nbins) / slots;
487  hystogram[bin] += thiscount;
488  }
489  mean /= (double) slots;
490  meansq /= (double) slots;
491  stddev = sqrt(meansq - mean*mean);
492 
493  retval = fprintf(fp,"Cache stats: slots = %d average = %g ", slots, mean);
494  if (retval == EOF) return(0);
495  retval = fprintf(fp,"standard deviation = %g\n", stddev);
496  if (retval == EOF) return(0);
497  retval = fprintf(fp,"Cache max accesses = %ld for slot %d\n", max, imax);
498  if (retval == EOF) return(0);
499  retval = fprintf(fp,"Cache min accesses = %ld for slot %d\n", min, imin);
500  if (retval == EOF) return(0);
501  retval = fprintf(fp,"Cache unused slots = %d\n", nzeroes);
502  if (retval == EOF) return(0);
503 
504  if (totalcount) {
505  expected /= totalcount;
506  retval = fprintf(fp,"Cache access hystogram for %d bins", nbins);
507  if (retval == EOF) return(0);
508  retval = fprintf(fp," (expected bin value = %g)\n# ", expected);
509  if (retval == EOF) return(0);
510  for (i = nbins - 1; i>=0; i--) {
511  retval = fprintf(fp,"%ld ", hystogram[i]);
512  if (retval == EOF) return(0);
513  }
514  retval = fprintf(fp,"\n");
515  if (retval == EOF) return(0);
516  }
517 
518  ABC_FREE(hystogram);
519  return(1);
520 
521 } /* end of cuddLocalCacheProfile */
522 #endif
523 
524 
525 /**Function********************************************************************
526 
527  Synopsis [Initializes a hash table.]
528 
529  Description [Initializes a hash table. Returns a pointer to the new
530  table if successful; NULL otherwise.]
531 
532  SideEffects [None]
533 
534  SeeAlso [cuddHashTableQuit]
535 
536 ******************************************************************************/
537 DdHashTable *
539  DdManager * manager,
540  unsigned int keySize,
541  unsigned int initSize)
542 {
543  DdHashTable *hash;
544  int logSize;
545 
546 #ifdef __osf__
547 #pragma pointer_size save
548 #pragma pointer_size short
549 #endif
550  hash = ABC_ALLOC(DdHashTable, 1);
551  if (hash == NULL) {
552  manager->errorCode = CUDD_MEMORY_OUT;
553  return(NULL);
554  }
555  hash->keysize = keySize;
556  hash->manager = manager;
557  hash->memoryList = NULL;
558  hash->nextFree = NULL;
559  hash->itemsize = (keySize + 1) * sizeof(DdNode *) +
560  sizeof(ptrint) + sizeof(DdHashItem *);
561  /* We have to guarantee that the shift be < 32. */
562  if (initSize < 2) initSize = 2;
563  logSize = cuddComputeFloorLog2(initSize);
564  hash->numBuckets = 1 << logSize;
565  hash->shift = sizeof(int) * 8 - logSize;
566  hash->bucket = ABC_ALLOC(DdHashItem *, hash->numBuckets);
567  if (hash->bucket == NULL) {
568  manager->errorCode = CUDD_MEMORY_OUT;
569  ABC_FREE(hash);
570  return(NULL);
571  }
572  memset(hash->bucket, 0, hash->numBuckets * sizeof(DdHashItem *));
573  hash->size = 0;
575 #ifdef __osf__
576 #pragma pointer_size restore
577 #endif
578  return(hash);
579 
580 } /* end of cuddHashTableInit */
581 
582 
583 /**Function********************************************************************
584 
585  Synopsis [Shuts down a hash table.]
586 
587  Description [Shuts down a hash table, dereferencing all the values.]
588 
589  SideEffects [None]
590 
591  SeeAlso [cuddHashTableInit]
592 
593 ******************************************************************************/
594 void
596  DdHashTable * hash)
597 {
598 #ifdef __osf__
599 #pragma pointer_size save
600 #pragma pointer_size short
601 #endif
602  unsigned int i;
603  DdManager *dd = hash->manager;
604  DdHashItem *bucket;
605  DdHashItem **memlist, **nextmem;
606  unsigned int numBuckets = hash->numBuckets;
607 
608  for (i = 0; i < numBuckets; i++) {
609  bucket = hash->bucket[i];
610  while (bucket != NULL) {
611  Cudd_RecursiveDeref(dd, bucket->value);
612  bucket = bucket->next;
613  }
614  }
615 
616  memlist = hash->memoryList;
617  while (memlist != NULL) {
618  nextmem = (DdHashItem **) memlist[0];
619  ABC_FREE(memlist);
620  memlist = nextmem;
621  }
622 
623  ABC_FREE(hash->bucket);
624  ABC_FREE(hash);
625 #ifdef __osf__
626 #pragma pointer_size restore
627 #endif
628 
629  return;
630 
631 } /* end of cuddHashTableQuit */
632 
633 
634 /**Function********************************************************************
635 
636  Synopsis [Inserts an item in a hash table.]
637 
638  Description [Inserts an item in a hash table when the key has more than
639  three pointers. Returns 1 if successful; 0 otherwise.]
640 
641  SideEffects [None]
642 
643  SeeAlso [[cuddHashTableInsert1 cuddHashTableInsert2 cuddHashTableInsert3
644  cuddHashTableLookup]
645 
646 ******************************************************************************/
647 int
649  DdHashTable * hash,
650  DdNodePtr * key,
651  DdNode * value,
652  ptrint count)
653 {
654  int result;
655  unsigned int posn;
656  DdHashItem *item;
657  unsigned int i;
658 
659 #ifdef DD_DEBUG
660  assert(hash->keysize > 3);
661 #endif
662 
663  if (hash->size > hash->maxsize) {
664  result = cuddHashTableResize(hash);
665  if (result == 0) return(0);
666  }
667  item = cuddHashTableAlloc(hash);
668  if (item == NULL) return(0);
669  hash->size++;
670  item->value = value;
671  cuddRef(value);
672  item->count = count;
673  for (i = 0; i < hash->keysize; i++) {
674  item->key[i] = key[i];
675  }
676  posn = ddLCHash(key,hash->keysize,hash->shift);
677  item->next = hash->bucket[posn];
678  hash->bucket[posn] = item;
679 
680  return(1);
681 
682 } /* end of cuddHashTableInsert */
683 
684 
685 /**Function********************************************************************
686 
687  Synopsis [Looks up a key in a hash table.]
688 
689  Description [Looks up a key consisting of more than three pointers
690  in a hash table. Returns the value associated to the key if there
691  is an entry for the given key in the table; NULL otherwise. If the
692  entry is present, its reference counter is decremented if not
693  saturated. If the counter reaches 0, the value of the entry is
694  dereferenced, and the entry is returned to the free list.]
695 
696  SideEffects [None]
697 
698  SeeAlso [cuddHashTableLookup1 cuddHashTableLookup2 cuddHashTableLookup3
699  cuddHashTableInsert]
700 
701 ******************************************************************************/
702 DdNode *
704  DdHashTable * hash,
705  DdNodePtr * key)
706 {
707  unsigned int posn;
708  DdHashItem *item, *prev;
709  unsigned int i, keysize;
710 
711 #ifdef DD_DEBUG
712  assert(hash->keysize > 3);
713 #endif
714 
715  posn = ddLCHash(key,hash->keysize,hash->shift);
716  item = hash->bucket[posn];
717  prev = NULL;
718 
719  keysize = hash->keysize;
720  while (item != NULL) {
721  DdNodePtr *key2 = item->key;
722  int equal = 1;
723  for (i = 0; i < keysize; i++) {
724  if (key[i] != key2[i]) {
725  equal = 0;
726  break;
727  }
728  }
729  if (equal) {
730  DdNode *value = item->value;
731  cuddSatDec(item->count);
732  if (item->count == 0) {
733  cuddDeref(value);
734  if (prev == NULL) {
735  hash->bucket[posn] = item->next;
736  } else {
737  prev->next = item->next;
738  }
739  item->next = hash->nextFree;
740  hash->nextFree = item;
741  hash->size--;
742  }
743  return(value);
744  }
745  prev = item;
746  item = item->next;
747  }
748  return(NULL);
749 
750 } /* end of cuddHashTableLookup */
751 
752 
753 /**Function********************************************************************
754 
755  Synopsis [Inserts an item in a hash table.]
756 
757  Description [Inserts an item in a hash table when the key is one pointer.
758  Returns 1 if successful; 0 otherwise.]
759 
760  SideEffects [None]
761 
762  SeeAlso [cuddHashTableInsert cuddHashTableInsert2 cuddHashTableInsert3
763  cuddHashTableLookup1]
764 
765 ******************************************************************************/
766 int
768  DdHashTable * hash,
769  DdNode * f,
770  DdNode * value,
771  ptrint count)
772 {
773  int result;
774  unsigned int posn;
775  DdHashItem *item;
776 
777 #ifdef DD_DEBUG
778  assert(hash->keysize == 1);
779 #endif
780 
781  if (hash->size > hash->maxsize) {
782  result = cuddHashTableResize(hash);
783  if (result == 0) return(0);
784  }
785  item = cuddHashTableAlloc(hash);
786  if (item == NULL) return(0);
787  hash->size++;
788  item->value = value;
789  cuddRef(value);
790  item->count = count;
791  item->key[0] = f;
792  posn = ddLCHash2(cuddF2L(f),cuddF2L(f),hash->shift);
793  item->next = hash->bucket[posn];
794  hash->bucket[posn] = item;
795 
796  return(1);
797 
798 } /* end of cuddHashTableInsert1 */
799 
800 
801 /**Function********************************************************************
802 
803  Synopsis [Looks up a key consisting of one pointer in a hash table.]
804 
805  Description [Looks up a key consisting of one pointer in a hash table.
806  Returns the value associated to the key if there is an entry for the given
807  key in the table; NULL otherwise. If the entry is present, its reference
808  counter is decremented if not saturated. If the counter reaches 0, the
809  value of the entry is dereferenced, and the entry is returned to the free
810  list.]
811 
812  SideEffects [None]
813 
814  SeeAlso [cuddHashTableLookup cuddHashTableLookup2 cuddHashTableLookup3
815  cuddHashTableInsert1]
816 
817 ******************************************************************************/
818 DdNode *
820  DdHashTable * hash,
821  DdNode * f)
822 {
823  unsigned int posn;
824  DdHashItem *item, *prev;
825 
826 #ifdef DD_DEBUG
827  assert(hash->keysize == 1);
828 #endif
829 
830  posn = ddLCHash2(cuddF2L(f),cuddF2L(f),hash->shift);
831  item = hash->bucket[posn];
832  prev = NULL;
833 
834  while (item != NULL) {
835  DdNodePtr *key = item->key;
836  if (f == key[0]) {
837  DdNode *value = item->value;
838  cuddSatDec(item->count);
839  if (item->count == 0) {
840  cuddDeref(value);
841  if (prev == NULL) {
842  hash->bucket[posn] = item->next;
843  } else {
844  prev->next = item->next;
845  }
846  item->next = hash->nextFree;
847  hash->nextFree = item;
848  hash->size--;
849  }
850  return(value);
851  }
852  prev = item;
853  item = item->next;
854  }
855  return(NULL);
856 
857 } /* end of cuddHashTableLookup1 */
858 
859 
860 /**Function********************************************************************
861 
862  Synopsis [Inserts an item in a hash table.]
863 
864  Description [Inserts an item in a hash table when the key is
865  composed of two pointers. Returns 1 if successful; 0 otherwise.]
866 
867  SideEffects [None]
868 
869  SeeAlso [cuddHashTableInsert cuddHashTableInsert1 cuddHashTableInsert3
870  cuddHashTableLookup2]
871 
872 ******************************************************************************/
873 int
875  DdHashTable * hash,
876  DdNode * f,
877  DdNode * g,
878  DdNode * value,
879  ptrint count)
880 {
881  int result;
882  unsigned int posn;
883  DdHashItem *item;
884 
885 #ifdef DD_DEBUG
886  assert(hash->keysize == 2);
887 #endif
888 
889  if (hash->size > hash->maxsize) {
890  result = cuddHashTableResize(hash);
891  if (result == 0) return(0);
892  }
893  item = cuddHashTableAlloc(hash);
894  if (item == NULL) return(0);
895  hash->size++;
896  item->value = value;
897  cuddRef(value);
898  item->count = count;
899  item->key[0] = f;
900  item->key[1] = g;
901  posn = ddLCHash2(cuddF2L(f),cuddF2L(g),hash->shift);
902  item->next = hash->bucket[posn];
903  hash->bucket[posn] = item;
904 
905  return(1);
906 
907 } /* end of cuddHashTableInsert2 */
908 
909 
910 /**Function********************************************************************
911 
912  Synopsis [Looks up a key consisting of two pointers in a hash table.]
913 
914  Description [Looks up a key consisting of two pointer in a hash table.
915  Returns the value associated to the key if there is an entry for the given
916  key in the table; NULL otherwise. If the entry is present, its reference
917  counter is decremented if not saturated. If the counter reaches 0, the
918  value of the entry is dereferenced, and the entry is returned to the free
919  list.]
920 
921  SideEffects [None]
922 
923  SeeAlso [cuddHashTableLookup cuddHashTableLookup1 cuddHashTableLookup3
924  cuddHashTableInsert2]
925 
926 ******************************************************************************/
927 DdNode *
929  DdHashTable * hash,
930  DdNode * f,
931  DdNode * g)
932 {
933  unsigned int posn;
934  DdHashItem *item, *prev;
935 
936 #ifdef DD_DEBUG
937  assert(hash->keysize == 2);
938 #endif
939 
940  posn = ddLCHash2(cuddF2L(f),cuddF2L(g),hash->shift);
941  item = hash->bucket[posn];
942  prev = NULL;
943 
944  while (item != NULL) {
945  DdNodePtr *key = item->key;
946  if ((f == key[0]) && (g == key[1])) {
947  DdNode *value = item->value;
948  cuddSatDec(item->count);
949  if (item->count == 0) {
950  cuddDeref(value);
951  if (prev == NULL) {
952  hash->bucket[posn] = item->next;
953  } else {
954  prev->next = item->next;
955  }
956  item->next = hash->nextFree;
957  hash->nextFree = item;
958  hash->size--;
959  }
960  return(value);
961  }
962  prev = item;
963  item = item->next;
964  }
965  return(NULL);
966 
967 } /* end of cuddHashTableLookup2 */
968 
969 
970 /**Function********************************************************************
971 
972  Synopsis [Inserts an item in a hash table.]
973 
974  Description [Inserts an item in a hash table when the key is
975  composed of three pointers. Returns 1 if successful; 0 otherwise.]
976 
977  SideEffects [None]
978 
979  SeeAlso [cuddHashTableInsert cuddHashTableInsert1 cuddHashTableInsert2
980  cuddHashTableLookup3]
981 
982 ******************************************************************************/
983 int
985  DdHashTable * hash,
986  DdNode * f,
987  DdNode * g,
988  DdNode * h,
989  DdNode * value,
990  ptrint count)
991 {
992  int result;
993  unsigned int posn;
994  DdHashItem *item;
995 
996 #ifdef DD_DEBUG
997  assert(hash->keysize == 3);
998 #endif
999 
1000  if (hash->size > hash->maxsize) {
1001  result = cuddHashTableResize(hash);
1002  if (result == 0) return(0);
1003  }
1004  item = cuddHashTableAlloc(hash);
1005  if (item == NULL) return(0);
1006  hash->size++;
1007  item->value = value;
1008  cuddRef(value);
1009  item->count = count;
1010  item->key[0] = f;
1011  item->key[1] = g;
1012  item->key[2] = h;
1013  posn = ddLCHash3(cuddF2L(f),cuddF2L(g),cuddF2L(h),hash->shift);
1014  item->next = hash->bucket[posn];
1015  hash->bucket[posn] = item;
1016 
1017  return(1);
1018 
1019 } /* end of cuddHashTableInsert3 */
1020 
1021 
1022 /**Function********************************************************************
1023 
1024  Synopsis [Looks up a key consisting of three pointers in a hash table.]
1025 
1026  Description [Looks up a key consisting of three pointers in a hash table.
1027  Returns the value associated to the key if there is an entry for the given
1028  key in the table; NULL otherwise. If the entry is present, its reference
1029  counter is decremented if not saturated. If the counter reaches 0, the
1030  value of the entry is dereferenced, and the entry is returned to the free
1031  list.]
1032 
1033  SideEffects [None]
1034 
1035  SeeAlso [cuddHashTableLookup cuddHashTableLookup1 cuddHashTableLookup2
1036  cuddHashTableInsert3]
1037 
1038 ******************************************************************************/
1039 DdNode *
1041  DdHashTable * hash,
1042  DdNode * f,
1043  DdNode * g,
1044  DdNode * h)
1045 {
1046  unsigned int posn;
1047  DdHashItem *item, *prev;
1048 
1049 #ifdef DD_DEBUG
1050  assert(hash->keysize == 3);
1051 #endif
1052 
1053  posn = ddLCHash3(cuddF2L(f),cuddF2L(g),cuddF2L(h),hash->shift);
1054  item = hash->bucket[posn];
1055  prev = NULL;
1056 
1057  while (item != NULL) {
1058  DdNodePtr *key = item->key;
1059  if ((f == key[0]) && (g == key[1]) && (h == key[2])) {
1060  DdNode *value = item->value;
1061  cuddSatDec(item->count);
1062  if (item->count == 0) {
1063  cuddDeref(value);
1064  if (prev == NULL) {
1065  hash->bucket[posn] = item->next;
1066  } else {
1067  prev->next = item->next;
1068  }
1069  item->next = hash->nextFree;
1070  hash->nextFree = item;
1071  hash->size--;
1072  }
1073  return(value);
1074  }
1075  prev = item;
1076  item = item->next;
1077  }
1078  return(NULL);
1079 
1080 } /* end of cuddHashTableLookup3 */
1081 
1082 
1083 /*---------------------------------------------------------------------------*/
1084 /* Definition of static functions */
1085 /*---------------------------------------------------------------------------*/
1086 
1087 
1088 /**Function********************************************************************
1089 
1090  Synopsis [Resizes a local cache.]
1091 
1092  Description []
1093 
1094  SideEffects [None]
1095 
1096  SeeAlso []
1097 
1098 ******************************************************************************/
1099 static void
1101  DdLocalCache * cache)
1102 {
1103  DdLocalCacheItem *item, *olditem, *entry, *old;
1104  int i, shift;
1105  unsigned int posn;
1106  unsigned int slots, oldslots;
1107  extern DD_OOMFP MMoutOfMemory;
1108  DD_OOMFP saveHandler;
1109 
1110  olditem = cache->item;
1111  oldslots = cache->slots;
1112  slots = cache->slots = oldslots << 1;
1113 
1114 #ifdef DD_VERBOSE
1115  (void) fprintf(cache->manager->err,
1116  "Resizing local cache from %d to %d entries\n",
1117  oldslots, slots);
1118  (void) fprintf(cache->manager->err,
1119  "\thits = %.0f\tlookups = %.0f\thit ratio = %5.3f\n",
1120  cache->hits, cache->lookUps, cache->hits / cache->lookUps);
1121 #endif
1122 
1123  saveHandler = MMoutOfMemory;
1124  MMoutOfMemory = Cudd_OutOfMem;
1125  cache->item = item =
1126  (DdLocalCacheItem *) ABC_ALLOC(char, slots * cache->itemsize);
1127  MMoutOfMemory = saveHandler;
1128  /* If we fail to allocate the new table we just give up. */
1129  if (item == NULL) {
1130 #ifdef DD_VERBOSE
1131  (void) fprintf(cache->manager->err,"Resizing failed. Giving up.\n");
1132 #endif
1133  cache->slots = oldslots;
1134  cache->item = olditem;
1135  /* Do not try to resize again. */
1136  cache->maxslots = oldslots - 1;
1137  return;
1138  }
1139  shift = --(cache->shift);
1140  cache->manager->memused += (slots - oldslots) * cache->itemsize;
1141 
1142  /* Clear new cache. */
1143  memset(item, 0, slots * cache->itemsize);
1144 
1145  /* Copy from old cache to new one. */
1146  for (i = 0; (unsigned) i < oldslots; i++) {
1147  old = (DdLocalCacheItem *) ((char *) olditem + i * cache->itemsize);
1148  if (old->value != NULL) {
1149  posn = ddLCHash(old->key,cache->keysize,shift);
1150  entry = (DdLocalCacheItem *) ((char *) item +
1151  posn * cache->itemsize);
1152  memcpy(entry->key,old->key,cache->keysize*sizeof(DdNode *));
1153  entry->value = old->value;
1154  }
1155  }
1156 
1157  ABC_FREE(olditem);
1158 
1159  /* Reinitialize measurements so as to avoid division by 0 and
1160  ** immediate resizing.
1161  */
1162  cache->lookUps = (double) (int) (slots * cache->minHit + 1);
1163  cache->hits = 0;
1164 
1165 } /* end of cuddLocalCacheResize */
1166 
1167 
1168 /**Function********************************************************************
1169 
1170  Synopsis [Computes the hash value for a local cache.]
1171 
1172  Description [Computes the hash value for a local cache. Returns the
1173  bucket index.]
1174 
1175  SideEffects [None]
1176 
1177  SeeAlso []
1178 
1179 ******************************************************************************/
1180 DD_INLINE
1181 static unsigned int
1183  DdNodePtr * key,
1184  unsigned int keysize,
1185  int shift)
1186 {
1187  unsigned int val = (unsigned int) (ptrint) key[0] * DD_P2;
1188  unsigned int i;
1189 
1190  for (i = 1; i < keysize; i++) {
1191  val = val * DD_P1 + (int) (ptrint) key[i];
1192  }
1193 
1194  return(val >> shift);
1195 
1196 } /* end of ddLCHash */
1197 
1198 
1199 /**Function********************************************************************
1200 
1201  Synopsis [Inserts a local cache in the manager list.]
1202 
1203  Description []
1204 
1205  SideEffects [None]
1206 
1207  SeeAlso []
1208 
1209 ******************************************************************************/
1210 static void
1212  DdLocalCache * cache)
1213 {
1214  DdManager *manager = cache->manager;
1215 
1216  cache->next = manager->localCaches;
1217  manager->localCaches = cache;
1218  return;
1219 
1220 } /* end of cuddLocalCacheAddToList */
1221 
1222 
1223 /**Function********************************************************************
1224 
1225  Synopsis [Removes a local cache from the manager list.]
1226 
1227  Description []
1228 
1229  SideEffects [None]
1230 
1231  SeeAlso []
1232 
1233 ******************************************************************************/
1234 static void
1236  DdLocalCache * cache)
1237 {
1238  DdManager *manager = cache->manager;
1239 #ifdef __osf__
1240 #pragma pointer_size save
1241 #pragma pointer_size short
1242 #endif
1243  DdLocalCache **prevCache, *nextCache;
1244 #ifdef __osf__
1245 #pragma pointer_size restore
1246 #endif
1247 
1248  prevCache = &(manager->localCaches);
1249  nextCache = manager->localCaches;
1250 
1251  while (nextCache != NULL) {
1252  if (nextCache == cache) {
1253  *prevCache = nextCache->next;
1254  return;
1255  }
1256  prevCache = &(nextCache->next);
1257  nextCache = nextCache->next;
1258  }
1259  return; /* should never get here */
1260 
1261 } /* end of cuddLocalCacheRemoveFromList */
1262 
1263 
1264 /**Function********************************************************************
1265 
1266  Synopsis [Resizes a hash table.]
1267 
1268  Description [Resizes a hash table. Returns 1 if successful; 0
1269  otherwise.]
1270 
1271  SideEffects [None]
1272 
1273  SeeAlso [cuddHashTableInsert]
1274 
1275 ******************************************************************************/
1276 static int
1278  DdHashTable * hash)
1279 {
1280  int j;
1281  unsigned int posn;
1282  DdHashItem *item;
1283  DdHashItem *next;
1284 #ifdef __osf__
1285 #pragma pointer_size save
1286 #pragma pointer_size short
1287 #endif
1288  DdNode **key;
1289  int numBuckets;
1290  DdHashItem **buckets;
1291  DdHashItem **oldBuckets = hash->bucket;
1292 #ifdef __osf__
1293 #pragma pointer_size restore
1294 #endif
1295  int shift;
1296  int oldNumBuckets = hash->numBuckets;
1297  extern DD_OOMFP MMoutOfMemory;
1298  DD_OOMFP saveHandler;
1299 
1300  /* Compute the new size of the table. */
1301  numBuckets = oldNumBuckets << 1;
1302  saveHandler = MMoutOfMemory;
1303  MMoutOfMemory = Cudd_OutOfMem;
1304 #ifdef __osf__
1305 #pragma pointer_size save
1306 #pragma pointer_size short
1307 #endif
1308  buckets = ABC_ALLOC(DdHashItem *, numBuckets);
1309  MMoutOfMemory = saveHandler;
1310  if (buckets == NULL) {
1311  hash->maxsize <<= 1;
1312  return(1);
1313  }
1314 
1315  hash->bucket = buckets;
1316  hash->numBuckets = numBuckets;
1317  shift = --(hash->shift);
1318  hash->maxsize <<= 1;
1319  memset(buckets, 0, numBuckets * sizeof(DdHashItem *));
1320 #ifdef __osf__
1321 #pragma pointer_size restore
1322 #endif
1323  if (hash->keysize == 1) {
1324  for (j = 0; j < oldNumBuckets; j++) {
1325  item = oldBuckets[j];
1326  while (item != NULL) {
1327  next = item->next;
1328  key = item->key;
1329  posn = ddLCHash2(cuddF2L(key[0]), cuddF2L(key[0]), shift);
1330  item->next = buckets[posn];
1331  buckets[posn] = item;
1332  item = next;
1333  }
1334  }
1335  } else if (hash->keysize == 2) {
1336  for (j = 0; j < oldNumBuckets; j++) {
1337  item = oldBuckets[j];
1338  while (item != NULL) {
1339  next = item->next;
1340  key = item->key;
1341  posn = ddLCHash2(cuddF2L(key[0]), cuddF2L(key[1]), shift);
1342  item->next = buckets[posn];
1343  buckets[posn] = item;
1344  item = next;
1345  }
1346  }
1347  } else if (hash->keysize == 3) {
1348  for (j = 0; j < oldNumBuckets; j++) {
1349  item = oldBuckets[j];
1350  while (item != NULL) {
1351  next = item->next;
1352  key = item->key;
1353  posn = ddLCHash3(cuddF2L(key[0]), cuddF2L(key[1]), cuddF2L(key[2]), shift);
1354  item->next = buckets[posn];
1355  buckets[posn] = item;
1356  item = next;
1357  }
1358  }
1359  } else {
1360  for (j = 0; j < oldNumBuckets; j++) {
1361  item = oldBuckets[j];
1362  while (item != NULL) {
1363  next = item->next;
1364  posn = ddLCHash(item->key, hash->keysize, shift);
1365  item->next = buckets[posn];
1366  buckets[posn] = item;
1367  item = next;
1368  }
1369  }
1370  }
1371  ABC_FREE(oldBuckets);
1372  return(1);
1373 
1374 } /* end of cuddHashTableResize */
1375 
1376 
1377 /**Function********************************************************************
1378 
1379  Synopsis [Fast storage allocation for items in a hash table.]
1380 
1381  Description [Fast storage allocation for items in a hash table. The
1382  first 4 bytes of a chunk contain a pointer to the next block; the
1383  rest contains DD_MEM_CHUNK spaces for hash items. Returns a pointer to
1384  a new item if successful; NULL is memory is full.]
1385 
1386  SideEffects [None]
1387 
1388  SeeAlso [cuddAllocNode cuddDynamicAllocNode]
1389 
1390 ******************************************************************************/
1391 DD_INLINE
1392 static DdHashItem *
1394  DdHashTable * hash)
1395 {
1396  int i;
1397  unsigned int itemsize = hash->itemsize;
1398  extern DD_OOMFP MMoutOfMemory;
1399  DD_OOMFP saveHandler;
1400 #ifdef __osf__
1401 #pragma pointer_size save
1402 #pragma pointer_size short
1403 #endif
1404  DdHashItem **mem, *thisOne, *next, *item;
1405 
1406  if (hash->nextFree == NULL) {
1407  saveHandler = MMoutOfMemory;
1408  MMoutOfMemory = Cudd_OutOfMem;
1409  mem = (DdHashItem **) ABC_ALLOC(char,(DD_MEM_CHUNK+1) * itemsize);
1410  MMoutOfMemory = saveHandler;
1411 #ifdef __osf__
1412 #pragma pointer_size restore
1413 #endif
1414  if (mem == NULL) {
1415  if (hash->manager->stash != NULL) {
1416  ABC_FREE(hash->manager->stash);
1417  hash->manager->stash = NULL;
1418  /* Inhibit resizing of tables. */
1419  hash->manager->maxCacheHard = hash->manager->cacheSlots - 1;
1420  hash->manager->cacheSlack = - (int) (hash->manager->cacheSlots + 1);
1421  for (i = 0; i < hash->manager->size; i++) {
1422  hash->manager->subtables[i].maxKeys <<= 2;
1423  }
1424  hash->manager->gcFrac = 0.2;
1425  hash->manager->minDead =
1426  (unsigned) (0.2 * (double) hash->manager->slots);
1427 #ifdef __osf__
1428 #pragma pointer_size save
1429 #pragma pointer_size short
1430 #endif
1431  mem = (DdHashItem **) ABC_ALLOC(char,(DD_MEM_CHUNK+1) * itemsize);
1432 #ifdef __osf__
1433 #pragma pointer_size restore
1434 #endif
1435  }
1436  if (mem == NULL) {
1437  (*MMoutOfMemory)((long)((DD_MEM_CHUNK + 1) * itemsize));
1439  return(NULL);
1440  }
1441  }
1442 
1443  mem[0] = (DdHashItem *) hash->memoryList;
1444  hash->memoryList = mem;
1445 
1446  thisOne = (DdHashItem *) ((char *) mem + itemsize);
1447  hash->nextFree = thisOne;
1448  for (i = 1; i < DD_MEM_CHUNK; i++) {
1449  next = (DdHashItem *) ((char *) thisOne + itemsize);
1450  thisOne->next = next;
1451  thisOne = next;
1452  }
1453 
1454  thisOne->next = NULL;
1455 
1456  }
1457  item = hash->nextFree;
1458  hash->nextFree = item->next;
1459  return(item);
1460 
1461 } /* end of cuddHashTableAlloc */
1462 
1463 
1465 
char * memset()
unsigned int keysize
Definition: cuddInt.h:304
DdHalfWord ref
Definition: cudd.h:280
#define cuddRef(n)
Definition: cuddInt.h:584
DdHashItem ** bucket
Definition: cuddInt.h:306
void(* DD_OOMFP)(long)
Definition: cudd.h:324
DdNode * value
Definition: cuddInt.h:298
unsigned int size
Definition: cuddInt.h:311
static void cuddLocalCacheRemoveFromList(DdLocalCache *cache)
Definition: cuddLCache.c:1235
#define cuddDeref(n)
Definition: cuddInt.h:604
void Cudd_OutOfMem(long size)
Definition: cuddUtil.c:2837
void Cudd_RecursiveDeref(DdManager *table, DdNode *n)
Definition: cuddRef.c:154
Definition: cudd.h:278
void cuddLocalCacheInsert(DdLocalCache *cache, DdNodePtr *key, DdNode *value)
Definition: cuddLCache.c:272
DdManager * manager
Definition: cuddInt.h:313
int size
Definition: cuddInt.h:361
double gcFrac
Definition: cuddInt.h:375
static DD_INLINE DdHashItem * cuddHashTableAlloc(DdHashTable *hash)
Definition: cuddLCache.c:1393
unsigned int maxCacheHard
Definition: cuddInt.h:359
unsigned int slots
Definition: cuddInt.h:368
#define Cudd_Regular(node)
Definition: cudd.h:397
void cuddReclaim(DdManager *table, DdNode *n)
Definition: cuddRef.c:584
ptrint count
Definition: cuddInt.h:297
DdNode * cuddHashTableLookup3(DdHashTable *hash, DdNode *f, DdNode *g, DdNode *h)
Definition: cuddLCache.c:1040
FILE * err
Definition: cuddInt.h:442
struct DdHashItem * next
Definition: cuddInt.h:296
char * memcpy()
DdHashTable * cuddHashTableInit(DdManager *manager, unsigned int keySize, unsigned int initSize)
Definition: cuddLCache.c:538
#define ABC_ALLOC(type, num)
Definition: abc_global.h:229
void cuddLocalCacheQuit(DdLocalCache *cache)
Definition: cuddLCache.c:246
DdSubtable * subtables
Definition: cuddInt.h:365
DdNode * value
Definition: cuddInt.h:272
double minHit
Definition: cuddInt.h:287
unsigned int keysize
Definition: cuddInt.h:283
DdLocalCacheItem * item
Definition: cuddInt.h:281
static char rcsid[] DD_UNUSED
Definition: cuddLCache.c:103
struct DdLocalCache * next
Definition: cuddInt.h:291
static int * entry
Definition: cuddGroup.c:122
DdNode * cuddHashTableLookup2(DdHashTable *hash, DdNode *f, DdNode *g)
Definition: cuddLCache.c:928
unsigned int maxslots
Definition: cuddInt.h:289
#define DD_INLINE
Definition: cuddInt.h:90
int cuddHashTableInsert1(DdHashTable *hash, DdNode *f, DdNode *value, ptrint count)
Definition: cuddLCache.c:767
int cuddHashTableInsert3(DdHashTable *hash, DdNode *f, DdNode *g, DdNode *h, DdNode *value, ptrint count)
Definition: cuddLCache.c:984
static DD_INLINE unsigned int ddLCHash(DdNodePtr *key, unsigned int keysize, int shift)
Definition: cuddLCache.c:1182
unsigned int cacheSlots
Definition: cuddInt.h:353
char * stash
Definition: cuddInt.h:399
unsigned int itemsize
Definition: cuddInt.h:282
FILE * out
Definition: cuddInt.h:441
ABC_PTRINT_T ptrint
Definition: cuddInt.h:260
double hits
Definition: cuddInt.h:288
double lookUps
Definition: cuddInt.h:286
unsigned int numBuckets
Definition: cuddInt.h:309
int cuddComputeFloorLog2(unsigned int value)
Definition: cuddCache.c:1079
unsigned int slots
Definition: cuddInt.h:284
DdLocalCache * cuddLocalCacheInit(DdManager *manager, unsigned int keySize, unsigned int cacheSize, unsigned int maxCacheSize)
Definition: cuddLCache.c:183
unsigned int maxKeys
Definition: cuddInt.h:331
#define ABC_NAMESPACE_IMPL_END
Definition: abc_global.h:108
#define DD_P2
Definition: cuddInt.h:156
#define ddMax(x, y)
Definition: cuddInt.h:832
if(last==0)
Definition: sparse_int.h:34
static double max
Definition: cuddSubsetHB.c:134
static uint32_t hash(uint32_t x)
Definition: Map.h:38
int memcmp()
static void cuddLocalCacheResize(DdLocalCache *cache)
Definition: cuddLCache.c:1100
void cuddLocalCacheClearDead(DdManager *manager)
Definition: cuddLCache.c:352
#define cuddF2L(f)
Definition: cuddInt.h:718
unsigned int maxsize
Definition: cuddInt.h:312
#define ddMin(x, y)
Definition: cuddInt.h:818
DdLocalCache * localCaches
Definition: cuddInt.h:432
int cacheSlack
Definition: cuddInt.h:358
DdNode * cuddHashTableLookup1(DdHashTable *hash, DdNode *f)
Definition: cuddLCache.c:819
DdNode * cuddLocalCacheLookup(DdLocalCache *cache, DdNodePtr *key)
Definition: cuddLCache.c:305
void cuddHashTableQuit(DdHashTable *hash)
Definition: cuddLCache.c:595
#define ABC_NAMESPACE_IMPL_START
Definition: abc_global.h:107
unsigned int itemsize
Definition: cuddInt.h:305
unsigned long memused
Definition: cuddInt.h:449
#define DD_P1
Definition: cuddInt.h:155
DdNode * key[1]
Definition: cuddInt.h:276
DdHashItem * nextFree
Definition: cuddInt.h:307
#define ABC_FREE(obj)
Definition: abc_global.h:232
enum keys key
int cuddHashTableInsert2(DdHashTable *hash, DdNode *f, DdNode *g, DdNode *value, ptrint count)
Definition: cuddLCache.c:874
double minHit
Definition: cuddInt.h:357
int value
#define cuddSatDec(x)
Definition: cuddInt.h:896
struct DdLocalCache DdLocalCache
DdNode * key[1]
Definition: cuddInt.h:299
#define ddLCHash2(f, g, shift)
Definition: cuddLCache.c:126
DdNode * cuddHashTableLookup(DdHashTable *hash, DdNodePtr *key)
Definition: cuddLCache.c:703
#define assert(ex)
Definition: util_old.h:213
int shift
Definition: cuddInt.h:310
static int result
Definition: cuddGenetic.c:125
#define DD_MEM_CHUNK
Definition: cuddInt.h:104
DdHashItem ** memoryList
Definition: cuddInt.h:308
DdManager * manager
Definition: cuddInt.h:290
static void cuddLocalCacheAddToList(DdLocalCache *cache)
Definition: cuddLCache.c:1211
Cudd_ErrorType errorCode
Definition: cuddInt.h:447
int cuddHashTableInsert(DdHashTable *hash, DdNodePtr *key, DdNode *value, ptrint count)
Definition: cuddLCache.c:648
unsigned int minDead
Definition: cuddInt.h:374
#define equal(a, b)
Definition: espresso.h:326
#define ddLCHash3(f, g, h, shift)
Definition: cuddLCache.c:142
#define DD_MAX_HASHTABLE_DENSITY
Definition: cuddLCache.c:86
static int cuddHashTableResize(DdHashTable *hash)
Definition: cuddLCache.c:1277
#define MMoutOfMemory
Definition: util_hack.h:38
void cuddLocalCacheClearAll(DdManager *manager)
Definition: cuddLCache.c:404