/***************************************************************** File : test_upclose RCS : $Id: test_upclose.c,v 1.1 2000-03-10 05:17:22 dmo Exp $ Author : Peter Schachte Origin : 4 May 1998 Purpose: Test of set sharing upward closure operation *****************************************************************/ #include #include #include "bryant.h" #include "timing.h" int opcount; void usage(char *progname) { printf("usage: %s depth [repetitions]\n", progname); printf(" creates random boolean functions of depth depth (or less) and\n"); printf(" computes their upward closure. If repetitions is >0,\n"); printf(" this will be done that many times.\n"); } #if 0 node *boolfn(unsigned long n) { int d; unsigned long tr, fa; node *trfn, *fafn; if (n == 0) return zero; if (n == 1) return one; for (d = LOG_BITS_PER_WORD-1; (fa=(n>>(1<= 0; --d); tr = n & ((1<<(1<>=1) ++rand_bits; bits = 0; srand(4242); } node *randboolfn(int depth, int level) { node *result; if (bits <= 0) rnd = rand(), bits = rand_bits; if (level == 0) { result = (rnd&1) ? one : zero; bits--; rnd >>= 1; } else { result = make_node(depth-level, randboolfn(depth, level-1), randboolfn(depth, level-1)); } return result; } void doit(int depth, int num) { node *f = randboolfn(depth, depth); node *uf; #ifdef DEBUGALL printf("%6d upclose(", num); printOut(f); printf(") ==> "); fflush(stdout); #endif /* DEBUGALL */ #ifndef OVERHEAD uf = upclose(f); #ifdef DEBUGALL if (f == uf) { printf("UNCHANGED"); } else { printOut(uf); } printf("\n"); #endif /* DEBUGALL */ #endif /* !OVERHEAD */ ++opcount; } void dont_doit(int depth, int num) { (void) randboolfn(depth, depth); } int main(int argc, char **argv) { int depth, repetitions; int reps; millisec clock0, clock1, clock2, clock3; float runtime, overhead, rate; int test_nodes, overhead_nodes; if (argc < 2) { usage(argv[0]); return 20; } if ((depth=atoi(argv[1]))<1 || depth>=MAXVAR) { usage(argv[0]); printf("\n depth must be between 1 <= depth < %d\n", MAXVAR); return 20; } repetitions=(argc>2 ? atoi(argv[2]) : 1); if (repetitions <= 0) repetitions = 1; opcount = 0; initRep(); init_random(); clock0 = milli_time(); for (reps=0; reps