#include "calInt.h"
Go to the source code of this file.
Defines | |
#define | BPL 32 |
#define | LOGBPL 5 |
Functions | |
static void | ddSuppInteract (Cal_BddManager_t *bddManager, Cal_Bdd_t f, int *support) |
static void | ddClearLocal (Cal_Bdd_t f) |
static void | ddUpdateInteract (Cal_BddManager_t *bddManager, int *support) |
void | CalSetInteract (Cal_BddManager_t *bddManager, int x, int y) |
int | CalTestInteract (Cal_BddManager_t *bddManager, int x, int y) |
int | CalInitInteract (Cal_BddManager_t *bddManager) |
#define BPL 32 |
CFile***********************************************************************
FileName [calInteract.c]
PackageName [cal]
Synopsis [Functions to manipulate the variable interaction matrix.]
Description [ The interaction matrix tells whether two variables are both in the support of some function of the DD. The main use of the interaction matrix is in the in-place swapping. Indeed, if two variables do not interact, there is no arc connecting the two layers; therefore, the swap can be performed in constant time, without scanning the subtables. Another use of the interaction matrix is in the computation of the lower bounds for sifting. Finally, the interaction matrix can be used to speed up aggregation checks in symmetric and group sifting.
The computation of the interaction matrix is done with a series of depth-first searches. The searches start from those nodes that have only external references. The matrix is stored as a packed array of bits; since it is symmetric, only the upper triangle is kept in memory. As a final remark, we note that there may be variables that do intercat, but that for a given variable order have no arc connecting their layers when they are adjacent.]
SeeAlso []
Author [Original author:Fabio Somenzi. Modified for CAL package by Rajeev K. Ranjan]
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 49 of file calInteract.c.
#define LOGBPL 5 |
Definition at line 50 of file calInteract.c.
int CalInitInteract | ( | Cal_BddManager_t * | bddManager | ) |
Function********************************************************************
Synopsis [Initializes the interaction matrix.]
Description [Initializes the interaction matrix. The interaction matrix is implemented as a bit vector storing the upper triangle of the symmetric interaction matrix. The bit vector is kept in an array of long integers. The computation is based on a series of depth-first searches, one for each root of the DAG. A local flag (the mark bits) is used.]
SideEffects [None]
SeeAlso []
Definition at line 181 of file calInteract.c.
00182 { 00183 int i,k; 00184 int words; 00185 long *interact; 00186 int *support; 00187 long numBins; 00188 CalBddNode_t **bins, *bddNode, *nextBddNode; 00189 00190 int n = bddManager->numVars; 00191 00192 words = ((n * (n-1)) >> (1 + LOGBPL)) + 1; 00193 bddManager->interact = interact = Cal_MemAlloc(long, words); 00194 if (interact == NULL) return(0); 00195 for (i = 0; i < words; i++) { 00196 interact[i] = 0; 00197 } 00198 00199 support = Cal_MemAlloc(int, n); 00200 if (support == Cal_Nil(int)) { 00201 Cal_MemFree(interact); 00202 return(0); 00203 } 00204 bins = bddManager->uniqueTable[0]->bins; 00205 numBins = bddManager->uniqueTable[0]->numBins; 00206 for (i=0; i<numBins; i++){ 00207 for (bddNode = bins[i]; bddNode; bddNode = nextBddNode) { 00208 Cal_Bdd_t internalBdd; 00209 nextBddNode = CalBddNodeGetNextBddNode(bddNode); 00210 CalBddNodeGetThenBdd(bddNode, internalBdd); 00211 for (k = 0; k < n; k++) { 00212 support[k] = 0; 00213 } 00214 ddSuppInteract(bddManager, internalBdd, support); 00215 ddClearLocal(internalBdd); 00216 ddUpdateInteract(bddManager, support); 00217 } 00218 } 00219 /* If there are some results pending in the pipeline, we need to 00220 take those into account as well */ 00221 00222 if (bddManager->pipelineState == CREATE){ 00223 CalRequestNode_t **requestNodeListArray = 00224 bddManager->requestNodeListArray; 00225 Cal_Bdd_t resultBdd; 00226 for (i=0; 00227 i<bddManager->pipelineDepth-bddManager->currentPipelineDepth; 00228 i++){ 00229 for (bddNode = *requestNodeListArray; bddNode; 00230 bddNode = nextBddNode){ 00231 nextBddNode = CalBddNodeGetNextBddNode(bddNode); 00232 Cal_Assert(CalBddNodeIsForwarded(bddNode)); 00233 CalBddNodeGetThenBdd(bddNode, resultBdd); 00234 Cal_Assert(CalBddIsForwarded(resultBdd) == 0); 00235 for (k = 0; k < n; k++) { 00236 support[k] = 0; 00237 } 00238 ddSuppInteract(bddManager, resultBdd, support); 00239 ddClearLocal(resultBdd); 00240 ddUpdateInteract(bddManager, support); 00241 } 00242 requestNodeListArray++; 00243 } 00244 } 00245 00246 00247 Cal_MemFree(support); 00248 return(1); 00249 00250 } /* end of CalInitInteract */
void CalSetInteract | ( | Cal_BddManager_t * | bddManager, | |
int | x, | |||
int | y | |||
) |
AutomaticEnd Function********************************************************************
Synopsis [Set interaction matrix entries.]
Description [Given a pair of variables 0 <= x < y < table->size, sets the corresponding bit of the interaction matrix to 1.]
SideEffects [None]
SeeAlso []
Definition at line 109 of file calInteract.c.
00110 { 00111 int posn, word, bit; 00112 00113 Cal_Assert(x < y); 00114 Cal_Assert(y < bddManager->numVars); 00115 Cal_Assert(x >= 0); 00116 00117 posn = ((((bddManager->numVars << 1) - x - 3) * x) >> 1) + y - 1; 00118 word = posn >> LOGBPL; 00119 bit = posn & (BPL-1); 00120 bddManager->interact[word] |= 1 << bit; 00121 00122 } /* end of CalSetInteract */
int CalTestInteract | ( | Cal_BddManager_t * | bddManager, | |
int | x, | |||
int | y | |||
) |
Function********************************************************************
Synopsis [Test interaction matrix entries.]
Description [Given a pair of variables 0 <= x < y < bddManager->numVars, tests whether the corresponding bit of the interaction matrix is 1. Returns the value of the bit.]
SideEffects [None]
SeeAlso []
Definition at line 139 of file calInteract.c.
00140 { 00141 int posn, word, bit, result; 00142 00143 x -= 1; 00144 y -= 1; 00145 00146 if (x > y) { 00147 int tmp = x; 00148 x = y; 00149 y = tmp; 00150 } 00151 Cal_Assert(x < y); 00152 Cal_Assert(y < bddManager->numVars); 00153 Cal_Assert(x >= 0); 00154 00155 posn = ((((bddManager->numVars << 1) - x - 3) * x) >> 1) + y - 1; 00156 word = posn >> LOGBPL; 00157 bit = posn & (BPL-1); 00158 result = (bddManager->interact[word] >> bit) & 1; 00159 return(result); 00160 00161 } /* end of CalTestInteract */
static void ddClearLocal | ( | Cal_Bdd_t | f | ) | [static] |
Function********************************************************************
Synopsis [Performs a DFS from f, clearing the LSB of the then pointers.]
Description []
SideEffects [None]
SeeAlso []
Definition at line 300 of file calInteract.c.
00301 { 00302 Cal_Bdd_t thenBdd; 00303 Cal_Bdd_t elseBdd; 00304 CalBddGetElseBdd(f, elseBdd); 00305 if (CalBddIsBddConst(f) || !CalBddIsMarked(f)){ 00306 return; 00307 } 00308 /* clear visited flag */ 00309 CalBddUnmark(f); 00310 CalBddGetThenBdd(f, thenBdd); 00311 CalBddGetElseBdd(f, elseBdd); 00312 ddClearLocal(thenBdd); 00313 ddClearLocal(elseBdd); 00314 return; 00315 } /* end of ddClearLocal */
static void ddSuppInteract | ( | Cal_BddManager_t * | bddManager, | |
Cal_Bdd_t | f, | |||
int * | support | |||
) | [static] |
AutomaticStart
Function********************************************************************
Synopsis [Find the support of f.]
Description [Performs a DFS from f. Uses the LSB of the then pointer as visited flag.]
SideEffects [Accumulates in support the variables on which f depends.]
SeeAlso []
Definition at line 271 of file calInteract.c.
00272 { 00273 Cal_Bdd_t thenBdd, elseBdd; 00274 00275 if (CalBddIsBddConst(f) || CalBddIsMarked(f)){ 00276 return; 00277 } 00278 support[f.bddId-1] = 1; 00279 CalBddGetThenBdd(f, thenBdd); 00280 CalBddGetElseBdd(f, elseBdd); 00281 ddSuppInteract(bddManager, thenBdd, support); 00282 ddSuppInteract(bddManager, elseBdd, support); 00283 CalBddMark(f); 00284 return; 00285 } /* end of ddSuppInteract */
static void ddUpdateInteract | ( | Cal_BddManager_t * | bddManager, | |
int * | support | |||
) | [static] |
Function********************************************************************
Synopsis [Marks as interacting all pairs of variables that appear in support.]
Description [If support[i] == support[j] == 1, sets the (i,j) entry of the interaction matrix to 1.]
SideEffects [None]
SeeAlso []
Definition at line 332 of file calInteract.c.
00333 { 00334 int i,j; 00335 int n = bddManager->numVars; 00336 00337 for (i = 0; i < n-1; i++) { 00338 if (support[i] == 1) { 00339 for (j = i+1; j < n; j++) { 00340 if (support[j] == 1) { 00341 CalSetInteract(bddManager, i, j); 00342 } 00343 } 00344 } 00345 } 00346 } /* end of ddUpdateInteract */