Skip to content

Commit

Permalink
pluto_constraints_negate_row/constraint fix
Browse files Browse the repository at this point in the history
Signed-off-by: Uday Bondhugula <udayreddy@gmail.com>
  • Loading branch information
bondhugula committed Jan 10, 2012
1 parent 384d776 commit 89aed23
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 15 deletions.
20 changes: 18 additions & 2 deletions src/constraints.c
Original file line number Diff line number Diff line change
Expand Up @@ -973,20 +973,36 @@ PlutoConstraints *pluto_constraints_select_row(const PlutoConstraints *cst, int

PlutoConstraints *row = pluto_constraints_alloc(1, cst->ncols);
row->is_eq[0] = cst->is_eq[pos];
for (j=0; j<cst->ncols-1; j++) {
for (j=0; j<cst->ncols; j++) {
row->val[0][j] = cst->val[pos][j];
}
row->nrows = 1;
return row;
}

/*
* Negate a single row in cst.
*/
void pluto_constraints_negate_row(PlutoConstraints *cst, int pos)
{
int j;

for (j=0; j<cst->ncols; j++) {
cst->val[pos][j] = -cst->val[pos][j];
}
}


/*
* Negation of a single constraint in cst.
*/
void pluto_constraints_negate_constraint(PlutoConstraints *cst, int pos)
{
int j;

for (j=0; j<cst->ncols-1; j++) {
cst->val[pos][j] = -cst->val[pos][j];
}
cst->val[pos][cst->ncols-1]--;
}

Expand Down Expand Up @@ -1036,7 +1052,7 @@ void check_redundancy(PlutoConstraints *cst)
pluto_constraints_copy(check, cst);
PlutoConstraints *row = pluto_constraints_select_row(cst, i);
pluto_constraints_remove_row(check, i);
pluto_constraints_negate_row(row, 0);
pluto_constraints_negate_constraint(row, 0);
pluto_constraints_add(check, row);
if (!pluto_constraints_solve(check, options->islsolve)) {
// printf("%dth constraint is redundant\n", i);
Expand Down
1 change: 1 addition & 0 deletions src/constraints.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ void pluto_constraints_zero_row(PlutoConstraints *, int);
void pluto_constraints_normalize_row(PlutoConstraints *cst, int pos);
PlutoConstraints *pluto_constraints_select_row(const PlutoConstraints *cst, int pos);
void pluto_constraints_negate_row(PlutoConstraints *cst, int pos);
void pluto_constraints_negate_constraint(PlutoConstraints *cst, int pos);

void pluto_constraints_print(FILE *fp, const PlutoConstraints *);
void pluto_constraints_pretty_print(FILE *fp, const PlutoConstraints *cst);
Expand Down
14 changes: 1 addition & 13 deletions src/framework.c
Original file line number Diff line number Diff line change
Expand Up @@ -592,18 +592,6 @@ static PlutoMatrix *pluto_matrix_from_isl_mat(__isl_keep isl_mat *mat)
}


/*
* Negate the single constraint in cst.
*/
static void negate_constraint(PlutoConstraints *cst)
{
int i;

for (i = 0; i < cst->ncols; ++i)
cst->val[0][i] = -cst->val[0][i];
}


/*
* Returns linear independence constraints for a single statement.
*
Expand Down Expand Up @@ -754,7 +742,7 @@ PlutoConstraints **get_stmt_ortho_constraints(Stmt *stmt, const PlutoProg *prog,
orthcst_i = isl_basic_set_intersect(orthcst_i,
isl_basic_set_copy(isl_currcst));
if (isl_basic_set_fast_is_empty(orthcst_i))
negate_constraint(orthcst[p]);
pluto_constraints_negate_row(orthcst[p], 0);
isl_basic_set_free(orthcst_i);
p++;
assert(p<=nvar-1);
Expand Down

0 comments on commit 89aed23

Please sign in to comment.