src/misc/espresso/sparse.c File Reference

#include "espresso.h"
Include dependency graph for sparse.c:

Go to the source code of this file.

Functions

pcover make_sparse (pcover F, pcover D, pcover R)
pcover mv_reduce (pcover F, pcover D)

Function Documentation

pcover make_sparse ( pcover  F,
pcover  D,
pcover  R 
)

Definition at line 23 of file sparse.c.

00025 {
00026     cost_t cost, best_cost;
00027 
00028     cover_cost(F, &best_cost);
00029 
00030     do {
00031         EXECUTE(F = mv_reduce(F, D), MV_REDUCE_TIME, F, cost);
00032         if (cost.total == best_cost.total)
00033             break;
00034         copy_cost(&cost, &best_cost);
00035 
00036         EXECUTE(F = expand(F, R, TRUE), RAISE_IN_TIME, F, cost);
00037         if (cost.total == best_cost.total)
00038             break;
00039         copy_cost(&cost, &best_cost);
00040     } while (force_irredundant);
00041 
00042     return F;
00043 }

pcover mv_reduce ( pcover  F,
pcover  D 
)

Definition at line 60 of file sparse.c.

00062 {
00063     register int i, var;
00064     register pcube p, p1, last;
00065     int index;
00066     pcover F1, D1;
00067     pcube *F_cube_table;
00068 
00069     /* loop for each multiple-valued variable */
00070     for(var = 0; var < cube.num_vars; var++) {
00071 
00072         if (cube.sparse[var]) {
00073 
00074             /* loop for each part of the variable */
00075             for(i = cube.first_part[var]; i <= cube.last_part[var]; i++) {
00076 
00077                 /* remember mapping of F1 cubes back to F cubes */
00078                 F_cube_table = ALLOC(pcube, F->count);
00079 
00080                 /* 'cofactor' against part #i of variable #var */
00081                 F1 = new_cover(F->count);
00082                 foreach_set(F, last, p) {
00083                     if (is_in_set(p, i)) {
00084                         F_cube_table[F1->count] = p;
00085                         p1 = GETSET(F1, F1->count++);
00086                         (void) set_diff(p1, p, cube.var_mask[var]);
00087                         set_insert(p1, i);
00088                     }
00089                 }
00090 
00091                 /* 'cofactor' against part #i of variable #var */
00092                 /* not really necessary -- just more efficient ? */
00093                 D1 = new_cover(D->count);
00094                 foreach_set(D, last, p) {
00095                     if (is_in_set(p, i)) {
00096                         p1 = GETSET(D1, D1->count++);
00097                         (void) set_diff(p1, p, cube.var_mask[var]);
00098                         set_insert(p1, i);
00099                     }
00100                 }
00101 
00102                 mark_irredundant(F1, D1);
00103 
00104                 /* now remove part i from cubes which are redundant */
00105                 index = 0;
00106                 foreach_set(F1, last, p1) {
00107                     if (! TESTP(p1, ACTIVE)) {
00108                         p = F_cube_table[index];
00109 
00110                         /*   don't reduce a variable which is full
00111                          *   (unless it is the output variable)
00112                          */
00113                         if (var == cube.num_vars-1 ||
00114                              ! setp_implies(cube.var_mask[var], p)) {
00115                             set_remove(p, i);
00116                         }
00117                         RESET(p, PRIME);
00118                     }
00119                     index++;
00120                 }
00121 
00122                 free_cover(F1);
00123                 free_cover(D1);
00124                 FREE(F_cube_table);
00125             }
00126         }
00127     }
00128 
00129     /* Check if any cubes disappeared */
00130     (void) sf_active(F);
00131     for(var = 0; var < cube.num_vars; var++) {
00132         if (cube.sparse[var]) {
00133             foreach_active_set(F, last, p) {
00134                 if (setp_disjoint(p, cube.var_mask[var])) {
00135                     RESET(p, ACTIVE);
00136                     F->active_count--;
00137                 }
00138             }
00139         }
00140     }
00141 
00142     if (F->count != F->active_count) {
00143         F = sf_inactive(F);
00144     }
00145     return F;
00146 }


Generated on Tue Jan 5 12:19:12 2010 for abc70930 by  doxygen 1.6.1