src/calBdd/calHashTableThree.c File Reference

#include "calInt.h"
Include dependency graph for calHashTableThree.c:

Go to the source code of this file.

Defines

#define CalDoHash3(fBddNode, gBddNode, hBddNode, table)

Functions

static void CalHashTableThreeRehash (CalHashTable_t *hashTable, int grow)
int CalHashTableThreeFindOrAdd (CalHashTable_t *hashTable, Cal_Bdd_t f, Cal_Bdd_t g, Cal_Bdd_t h, Cal_Bdd_t *bddPtr)

Define Documentation

#define CalDoHash3 ( fBddNode,
gBddNode,
hBddNode,
table   ) 
Value:
((((CalAddress_t)fBddNode + \
  (CalAddress_t)gBddNode + \
  (CalAddress_t) hBddNode) \
  / NODE_SIZE)% table->numBins)

CFile***********************************************************************

FileName [calHashTableThree.c]

PackageName [cal]

Synopsis [Functions to manage the hash tables that are a part of ITE operation]

Description [CalHashTableThreeFindOrAdd]

SeeAlso [optional]

Author [Jagesh Sanghavi (sanghavi@eecs.berkeley.edu) Rajeev Ranjan (rajeev@eecs.berkeley.edu)]

Copyright [Copyright (c) 1994-1996 The Regents of the Univ. of California. All rights reserved.

Permission is hereby granted, without written agreement and without license or royalty fees, to use, copy, modify, and distribute this software and its documentation for any purpose, provided that the above copyright notice and the following two paragraphs appear in all copies of this software.

IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.]

Revision [

Id
calHashTableThree.c,v 1.1.1.3 1998/05/04 00:58:58 hsv Exp

]

Definition at line 71 of file calHashTableThree.c.


Function Documentation

int CalHashTableThreeFindOrAdd ( CalHashTable_t hashTable,
Cal_Bdd_t  f,
Cal_Bdd_t  g,
Cal_Bdd_t  h,
Cal_Bdd_t bddPtr 
)

AutomaticEnd Function********************************************************************

Synopsis [required]

Description [optional]

SideEffects [required]

SeeAlso [optional]

Definition at line 108 of file calHashTableThree.c.

00113 {
00114   CalBddNode_t *ptr, *ptrIndirect;
00115   Cal_Bdd_t tmpBdd;
00116   int hashValue;
00117   
00118   hashValue = CalDoHash3(CalBddGetBddNode(f), 
00119       CalBddGetBddNode(g), CalBddGetBddNode(h), hashTable);
00120   ptr = hashTable->bins[hashValue];
00121   while(ptr != Cal_Nil(CalBddNode_t)){
00122     CalBddNodeGetThenBdd(ptr, tmpBdd);
00123     if(CalBddIsEqual(f, tmpBdd)){
00124       ptrIndirect = CalBddNodeGetElseBddNode(ptr);
00125       CalBddNodeGetThenBdd(ptrIndirect, tmpBdd);
00126       if(CalBddIsEqual(g, tmpBdd)){
00127         CalBddNodeGetElseBdd(ptrIndirect, tmpBdd);
00128         if(CalBddIsEqual(h, tmpBdd)){
00129           CalBddPutBddId(*bddPtr, hashTable->bddId);
00130           CalBddPutBddNode(*bddPtr, ptr);
00131           return 1;
00132         }
00133       }
00134     }
00135     ptr = CalBddNodeGetNextBddNode(ptr);
00136   }
00137   hashTable->numEntries++;
00138   if(hashTable->numEntries > hashTable->maxCapacity){
00139     CalHashTableThreeRehash(hashTable,1);
00140     hashValue = CalDoHash3(CalBddGetBddNode(f),
00141         CalBddGetBddNode(g), CalBddGetBddNode(h), hashTable);
00142   }
00143   CalNodeManagerAllocNode(hashTable->nodeManager, ptr);
00144   CalNodeManagerAllocNode(hashTable->nodeManager, ptrIndirect);
00145   CalBddNodePutThenBdd(ptr, f);
00146   CalBddNodePutThenBdd(ptrIndirect, g);
00147   CalBddNodePutElseBdd(ptrIndirect, h);
00148   CalBddNodePutElseBddNode(ptr, ptrIndirect);
00149   CalBddNodePutNextBddNode(ptr, hashTable->bins[hashValue]);
00150   hashTable->bins[hashValue] = ptr;
00151   CalBddPutBddId(*bddPtr, hashTable->bddId);
00152   CalBddPutBddNode(*bddPtr, ptr);
00153   return 0;
00154 }

static void CalHashTableThreeRehash ( CalHashTable_t hashTable,
int  grow 
) [static]

AutomaticStart

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

Synopsis [required]

Description [optional]

SideEffects [required]

SeeAlso [optional]

Definition at line 171 of file calHashTableThree.c.

00172 {
00173   CalBddNode_t *ptr, *ptrIndirect, *next;
00174   CalBddNode_t **oldBins = hashTable->bins;
00175   int i, hashValue;
00176   int oldNumBins = hashTable->numBins;
00177 
00178   if(grow){
00179     hashTable->sizeIndex++;
00180   }
00181   else{
00182     if (hashTable->sizeIndex <= HASH_TABLE_DEFAULT_SIZE_INDEX){/* No need to rehash */
00183       return;
00184     }
00185     hashTable->sizeIndex--;
00186   }
00187 
00188   hashTable->numBins = TABLE_SIZE(hashTable->sizeIndex);
00189   hashTable->numBins = hashTable->numBins;
00190   hashTable->maxCapacity = hashTable->numBins * HASH_TABLE_DEFAULT_MAX_DENSITY;
00191   hashTable->bins = Cal_MemAlloc(CalBddNode_t *, hashTable->numBins);
00192   if(hashTable->bins == Cal_Nil(CalBddNode_t *)){
00193     CalBddFatalMessage("out of memory");
00194   }
00195   for(i = 0; i < hashTable->numBins; i++){
00196     hashTable->bins[i] = Cal_Nil(CalBddNode_t);
00197   }
00198 
00199   for(i = 0; i < oldNumBins; i++){
00200     ptr = oldBins[i];
00201     while(ptr != Cal_Nil(CalBddNode_t)){
00202       next = CalBddNodeGetNextBddNode(ptr);
00203       ptrIndirect = CalBddNodeGetElseBddNode(ptr);
00204       hashValue = CalDoHash3(CalBddNodeGetThenBddNode(ptr),
00205           CalBddNodeGetThenBddNode(ptrIndirect),
00206           CalBddNodeGetElseBddNode(ptrIndirect), hashTable);
00207       CalBddNodePutNextBddNode(ptr, hashTable->bins[hashValue]);
00208       hashTable->bins[hashValue] = ptr;
00209       ptr = next;
00210     }
00211   }
00212   Cal_MemFree(oldBins);
00213 }


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