91 static char rcsid[]
DD_UNUSED =
"$Id: cuddCheck.c,v 1.35 2009/03/08 02:49:01 fabio Exp $";
163 for (i = 0; i < (unsigned) table->
size; i++) {
165 if (i != (
unsigned) table->
perm[index]) {
166 (void) fprintf(table->
err,
167 "Permutation corrupted: invperm[%u] = %d\t perm[%d] = %d\n",
168 i, index, index, table->
perm[index]);
175 for (j = 0; j < slots; j++) {
177 while (f != sentinel) {
180 if ((
int) f->
index != index) {
181 (void) fprintf(table->
err,
182 "Error: node has illegal index\n");
186 if ((
unsigned)
cuddI(table,
cuddT(f)->index) <= i ||
189 (void) fprintf(table->
err,
190 "Error: node has illegal children\n");
195 (void) fprintf(table->
err,
196 "Error: node has illegal form\n");
201 (void) fprintf(table->
err,
202 "Error: node has identical children\n");
207 (void) fprintf(table->
err,
208 "Error: live node has dead children\n");
240 }
else if (
cuddT(f) != NULL &&
cuddE(f) != NULL && f->
ref == 0) {
243 debugCheckParent(table,f);
247 "Error: node has illegal Then or Else pointers\n");
257 fprintf(table->
err,
"Error: wrong number of total nodes\n");
261 fprintf(table->
err,
"Error: wrong number of dead nodes\n");
267 for (i = 0; i < (unsigned) table->
sizeZ; i++) {
269 if (i != (
unsigned) table->
permZ[index]) {
270 (void) fprintf(table->
err,
271 "Permutation corrupted: invpermZ[%u] = %d\t permZ[%d] = %d in ZDD\n",
272 i, index, index, table->
permZ[index]);
279 for (j = 0; j < slots; j++) {
284 if ((
int) f->
index != index) {
285 (void) fprintf(table->
err,
286 "Error: ZDD node has illegal index\n");
292 (void) fprintf(table->
err,
293 "Error: ZDD node has complemented children\n");
297 if ((
unsigned)
cuddIZ(table,
cuddT(f)->index) <= i ||
299 (void) fprintf(table->
err,
300 "Error: ZDD node has illegal children\n");
307 (void) fprintf(table->
err,
308 "Error: ZDD node has zero then child\n");
312 if (
cuddT(f)->ref == 0 ||
cuddE(f)->ref == 0) {
313 (void) fprintf(table->
err,
314 "Error: ZDD live node has dead children\n");
346 }
else if (
cuddT(f) != NULL &&
cuddE(f) != NULL && f->
ref == 0) {
349 debugCheckParent(table,f);
353 "Error: ZDD node has illegal Then or Else pointers\n");
364 "Error: wrong number of total nodes in ZDD\n");
369 "Error: wrong number of dead nodes in ZDD\n");
380 for (j = 0; j < slots; j++) {
386 fprintf(table->
err,
"Error: node has illegal index\n");
387 #if SIZEOF_VOID_P == 8
389 " node 0x%lx, id = %u, ref = %u, value = %g\n",
393 " node 0x%x, id = %hu, ref = %hu, value = %g\n",
405 (void) fprintf(table->
err,
406 "Error: wrong number of total nodes in constants\n");
410 (void) fprintf(table->
err,
411 "Error: wrong number of dead nodes in constants\n");
415 while (
st__gen(gen, (
const char **)&f, (
char **)&count)) {
417 #if SIZEOF_VOID_P == 8
418 fprintf(table->
err,
"ref count error at node 0x%lx, count = %d, id = %u, ref = %u, then = 0x%lx, else = 0x%lx\n",(
ptruint)f,count,f->
index,f->ref,(
ptruint)
cuddT(f),(
ptruint)
cuddE(f));
420 fprintf(table->
err,
"ref count error at node 0x%x, count = %d, id = %hu, ref = %hu, then = 0x%x, else = 0x%x\n",(
ptruint)f,count,f->index,f->ref,(
ptruint)
cuddT(f),(
ptruint)
cuddE(f));
480 for (i = 0; i <
size; i++) {
483 keys = subtable->
keys;
484 dead = subtable->
dead;
486 slots = subtable->
slots;
487 shift = subtable->
shift;
488 logSlots =
sizeof(int) * 8 - shift;
489 if (((slots >> logSlots) << logSlots) != slots) {
490 (void) fprintf(table->
err,
491 "Unique table %d is not the right power of 2\n", i);
492 (void) fprintf(table->
err,
493 " slots = %u shift = %d\n", slots, shift);
497 for (j = 0; (unsigned) j < slots; j++) {
499 if (node != sentinel) {
502 while (node != sentinel) {
504 if (node->
ref == 0) {
511 (void) fprintf(table->
err,
"Wrong number of keys found \
512 in unique table %d (difference=%d)\n", i, keys);
516 (void) fprintf(table->
err,
"Wrong number of dead found \
517 in unique table no. %d (difference=%d)\n", i, dead);
524 for (i = 0; i <
size; i++) {
527 keys = subtable->
keys;
528 dead = subtable->
dead;
530 totalSlots += subtable->
slots;
532 for (j = 0; (unsigned) j < subtable->slots; j++) {
537 while (node != NULL) {
539 if (node->
ref == 0) {
546 (void) fprintf(table->
err,
"Wrong number of keys found \
547 in ZDD unique table no. %d (difference=%d)\n", i, keys);
551 (void) fprintf(table->
err,
"Wrong number of dead found \
552 in ZDD unique table no. %d (difference=%d)\n", i, dead);
559 keys = subtable->
keys;
560 dead = subtable->
dead;
562 totalSlots += subtable->
slots;
564 for (j = 0; (unsigned) j < subtable->slots; j++) {
569 while (node != NULL) {
571 if (node->
ref == 0) {
578 (void) fprintf(table->
err,
"Wrong number of keys found \
579 in the constant table (difference=%d)\n", keys);
583 (void) fprintf(table->
err,
"Wrong number of dead found \
584 in the constant table (difference=%d)\n", dead);
586 if ((
unsigned) totalKeys != table->
keys + table->
keysZ) {
587 (void) fprintf(table->
err,
"Wrong number of total keys found \
588 (difference=%d)\n", (
int) (totalKeys-table->
keys));
590 if ((
unsigned) totalSlots != table->
slots) {
591 (void) fprintf(table->
err,
"Wrong number of total slots found \
592 (difference=%d)\n", (
int) (totalSlots-table->
slots));
595 (void) fprintf(table->
err,
"Wrong number of minimum dead found \
596 (%u vs. %u)\n", table->
minDead,
597 (
unsigned) (table->
gcFrac * (double) table->
slots));
599 if ((
unsigned) totalDead != table->
dead + table->
deadZ) {
600 (void) fprintf(table->
err,
"Wrong number of total dead found \
601 (difference=%d)\n", (
int) (totalDead-table->
dead));
603 (void)printf(
"Average length of non-empty lists = %g\n",
604 (
double) table->
keys / (double) nonEmpty);
642 int ntables = dd->
size;
652 #if SIZEOF_VOID_P == 8
653 retval = fprintf(dd->
out,
"*** DD heap profile for 0x%lx ***\n",
656 retval = fprintf(dd->out,
"*** DD heap profile for 0x%x ***\n",
659 if (retval == EOF)
return 0;
662 for (i=0; i<ntables; i++) {
663 nodes = subtables[i].
keys - subtables[i].
dead;
666 retval = fprintf(dd->out,
"%5d: %5d nodes\n", i, nodes);
667 if (retval == EOF)
return 0;
668 if (nodes > maxnodes) {
675 nodes = dd->constants.keys - dd->constants.dead;
678 retval = fprintf(dd->out,
"const: %5d nodes\n", nodes);
679 if (retval == EOF)
return 0;
680 if (nodes > maxnodes) {
687 retval = fprintf(dd->out,
"Summary: %d tables, %d non-empty, largest: %d ",
688 ntables+1, nonempty, largest);
689 if (retval == EOF)
return 0;
690 retval = fprintf(dd->out,
"(with %d nodes)\n", maxnodes);
691 if (retval == EOF)
return 0;
715 #if SIZEOF_VOID_P == 8
716 (void) fprintf(fp,
" node 0x%lx, id = %u, ref = %u, then = 0x%lx, else = 0x%lx\n",(
ptruint)f,f->
index,f->
ref,(
ptruint)
cuddT(f),(
ptruint)
cuddE(f));
718 (void) fprintf(fp,
" node 0x%x, id = %hu, ref = %hu, then = 0x%x, else = 0x%x\n",(
ptruint)f,f->
index,f->
ref,(
ptruint)
cuddT(f),(
ptruint)
cuddE(f));
764 if (!silent) (void) printf(
"(%d",level);
766 if (!silent) (void) printf(
",");
769 while (node != NULL) {
777 (void) printf(
"%d", (
int) (level + root->
size - 1));
785 if (root->
parent == NULL) (void) printf(
"\n");
819 for (i = 0; i <
cuddI(table,node->
index); i++) {
823 for (j=0;j<slots;j++) {
827 #if SIZEOF_VOID_P == 8
828 (void) fprintf(table->
out,
"parent is at 0x%lx, id = %u, ref = %u, then = 0x%lx, else = 0x%lx\n",
831 (void) fprintf(table->
out,
"parent is at 0x%x, id = %hu, ref = %hu, then = 0x%x, else = 0x%x\n",
865 for (i = 0; i <
cuddI(table,node->
index); i++) {
869 for (j=0;j<slots;j++) {
873 (void) fprintf(table->
err,
874 "error with zero ref count\n");
875 (void) fprintf(table->
err,
"parent is 0x%x, id = %u, ref = %u, then = 0x%x, else = 0x%x\n",f,f->
index,f->
ref,
cuddT(f),
cuddE(f));
876 (void) fprintf(table->
err,
"child is 0x%x, id = %u, ref = %u, then = 0x%x, else = 0x%x\n",node,node->
index,node->
ref,
cuddT(node),
cuddE(node));
int Cudd_CheckKeys(DdManager *table)
void st__free_table(st__table *table)
void cuddPrintVarGroups(DdManager *dd, MtrNode *root, int zdd, int silent)
#define cuddIZ(dd, index)
void st__free_gen(st__generator *gen)
int st__insert(st__table *table, const char *key, char *value)
static void debugFindParent(DdManager *table, DdNode *node)
#define Cudd_Regular(node)
int cuddHeapProfile(DdManager *dd)
int st__ptrcmp(const char *, const char *)
int st__lookup_int(st__table *table, char *key, int *value)
int Cudd_DebugCheck(DdManager *table)
#define MTR_TEST(node, flag)
st__table * st__init_table(st__compare_func_type compare, st__hash_func_type hash)
#define Cudd_IsComplement(node)
void cuddPrintNode(DdNode *f, FILE *fp)
#define ABC_NAMESPACE_IMPL_END
st__generator * st__init_gen(st__table *table)
#define ABC_NAMESPACE_IMPL_START
static ABC_NAMESPACE_IMPL_START char rcsid[] DD_UNUSED
int st__ptrhash(const char *, int)
int st__gen(st__generator *gen, const char **key_p, char **value_p)