PIPS
sc_integer_analyze.c File Reference
#include <stdio.h>
#include "boolean.h"
#include "arithmetique.h"
#include "vecteur.h"
#include "contrainte.h"
#include "sc.h"
+ Include dependency graph for sc_integer_analyze.c:

Go to the source code of this file.

Functions

Variable variable_of_rank ()
 
Variable search_var_of_higher_rank ()
 
bool var_with_unity_coeff_p (Psysteme sc, Variable var)
 This function returns true: if all positive OR all negative coefficients of the variable var in the system are equal to 1. More...
 
void sc_integer_projection_information (Psysteme sc, Pbase index_base, int sc_info[][4], int dim_h, int n)
 This function gives information about the variables and the constraints of the system. More...
 
void constraint_integer_combination (Pbase index_base, Pcontrainte ineq1, Pcontrainte ineq2, int rank, Variable *right_var, int *right_rank, Value *right_coeff, Variable *left_var, int *left_rank, Value *left_coeff)
 This function computes the coefficients of the constraint resulting from the elimination of the variable of rank "rank" from the 2 inequalities ineq1 and ineq2. More...
 

Function Documentation

◆ constraint_integer_combination()

void constraint_integer_combination ( Pbase  index_base,
Pcontrainte  ineq1,
Pcontrainte  ineq2,
int  rank,
Variable right_var,
int right_rank,
Value right_coeff,
Variable left_var,
int left_rank,
Value left_coeff 
)

This function computes the coefficients of the constraint resulting from the elimination of the variable of rank "rank" from the 2 inequalities ineq1 and ineq2.

Assuming that: ineq1 is the constraint a0 X2 + + E0 + b0 <= 0 ineq2 is the constraint - a1 X2 + E1 + b1 <=0 where E1 contains X1, E0 contains X0 and a0,a1 >0 then the result of the fonction will be: right_var = X0, right_rank=rank(X0), right_ceoff=ceofficient of X0 in E0 left_var = X1, left_rank=rank(X10, left_coeff=coefficient of X1 in E1

Parameters
right_rankRIGHT
left_rankLEFT

Definition at line 234 of file sc_integer_analyze.c.

245 {
246 
247 
248  Pcontrainte right_ineg= CONTRAINTE_UNDEFINED;
249  Pcontrainte left_ineg = CONTRAINTE_UNDEFINED;
250  Variable el_var= variable_of_rank(index_base,rank);
251 
252  if (value_pos_p(vect_coeff(el_var,ineq1->vecteur))) {
253  right_ineg = ineq1;
254  left_ineg = ineq2;
255  }
256  else {
257  if (value_pos_p(vect_coeff(el_var,ineq2->vecteur))) {
258  right_ineg = ineq2;
259  left_ineg = ineq1;
260  }
261  }
262  *right_var = search_var_of_higher_rank(right_ineg->vecteur,
263  index_base,
264  el_var);
265  *left_var = search_var_of_higher_rank(left_ineg->vecteur,
266  index_base,
267  el_var);
268  *right_rank = rank_of_variable(index_base,*right_var);
269  *left_rank = rank_of_variable(index_base,*left_var);
270  *right_coeff = vect_coeff(*right_var,right_ineg->vecteur);
271  *left_coeff = vect_coeff(*left_var,left_ineg->vecteur);
272 
273 }
#define value_pos_p(val)
int rank_of_variable(Pbase base, Variable var)
this function returns the rank of the variable var in the base 0 encodes TCST, but I do not know why,...
Definition: base.c:497
#define CONTRAINTE_UNDEFINED
static entity rank
Variable search_var_of_higher_rank()
Variable variable_of_rank()
Pvecteur vecteur
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Definition: vecteur-local.h:60
Value vect_coeff(Variable var, Pvecteur vect)
Variable vect_coeff(Variable var, Pvecteur vect): coefficient de coordonnee var du vecteur vect —> So...
Definition: unaires.c:228

References CONTRAINTE_UNDEFINED, rank, rank_of_variable(), search_var_of_higher_rank(), value_pos_p, variable_of_rank(), vect_coeff(), and Scontrainte::vecteur.

Referenced by bound_distribution(), complex_bound_computation(), sc_elim_triang_integer_redund_constraint_p(), and sc_integer_projection_information().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sc_integer_projection_information()

void sc_integer_projection_information ( Psysteme  sc,
Pbase  index_base,
int  sc_info[][4],
int  dim_h,
int  n 
)

This function gives information about the variables and the constraints of the system.

These informations are stored in the array sc_info.

the first information: if the variable must be kept as loop index then sc_info[rank of the variable][1] is greater than 1.

the second information: sc_info[rank of the variable][2] is the number of constraints constraining the variable as upper bound.

ths third information: sc_info[rank of the variable][3] is the number of constraints constraining the variable as lower bound.

Initialisation of the array sc_info

Computation of variables that must be kept as loop indices.

if the variable rank is greater than n, the constraints may be eliminated if they do not appear in constraints of higher rank and having to be keept

Computation of the number of constraints contraining a variable either as lower bound or upper bound

If the variable is a loop index then the constraint ineq gives an upper or a lower bound directly

If the variable is not a loop index then the constraint ineq combined with another constraint pc gives an upper or a lower bound for another variable

If the variable is a loop index then the constraint ineq gives an upper or a lower bound directly

Definition at line 87 of file sc_integer_analyze.c.

93 {
94 
95  Pcontrainte ineq,pc;
96  Variable var_hr,hvr1,hvr2,right_var,left_var;
97  int rank_hr,right_rank,left_rank;
98  int sign1,sign2;
99  Value coeff1,coeff2,right_coeff,left_coeff;
100  bool find_one = false;
101  register int i;
102  register int j;
103 
104  /* Initialisation of the array sc_info */
105  // ??? should it be from 0 to n-1
106  for (i=1; i<=n; i++)
107  for (j=2; j<=3; j++)
108  sc_info[i][j]=0;
109 
110  for (i=1; i<=dim_h; i++)
111  sc_info[i][1]=1;
112 
113  for (i=dim_h+1; i<=n; i++)
114  sc_info[i][1]=0;
115 
116  /* Computation of variables that must be kept as loop indices. */
117 
118  for (ineq = sc->inegalites;
119  !CONTRAINTE_UNDEFINED_P(ineq); ineq=ineq->succ) {
120 
121  find_one=false;
122  if ((rank_hr= search_higher_rank(ineq->vecteur,index_base)) >dim_h) {
123 
124  /* if the variable rank is greater than n, the constraints may be
125  eliminated if they do not appear in constraints of higher
126  rank and having to be keept */
127 
128  var_hr=variable_of_rank(index_base,rank_hr);
129  coeff1 = vect_coeff(var_hr,ineq->vecteur);
130  sign1 = value_sign(coeff1);
131 
132  for (pc = ineq;
133  !CONTRAINTE_UNDEFINED_P(pc) && !find_one;
134  pc = pc->succ) {
135 
136  coeff2 = vect_coeff(var_hr,pc->vecteur);
137  sign2 = value_sign(coeff2);
138  if (value_notzero_p(coeff2) && sign1 == -sign2) {
140  index_base,var_hr);
142  index_base,var_hr);
143  if ((hvr1 ==hvr2) &&
144  (rank_of_variable(index_base,hvr1) >dim_h)) {
145  sc_info[rank_of_variable(index_base,hvr1)][1] ++;
146  find_one = true;
147  }
148  }
149  }
150  }
151  }
152 
153 
154  /* Computation of the number of constraints contraining a variable
155  either as lower bound or upper bound */
156 
157  for (ineq = sc->inegalites;
158  !CONTRAINTE_UNDEFINED_P(ineq); ineq=ineq->succ) {
159  if ((rank_hr= search_higher_rank(ineq->vecteur,index_base))>0) {
160  var_hr=variable_of_rank(index_base,rank_hr);
161  coeff1 = vect_coeff(var_hr,ineq->vecteur);
162 
163  if (rank_hr >dim_h) {
164  if (sc_info[rank_hr][1]) {
165 
166  /* If the variable is a loop index then the constraint
167  ineq gives an upper or a lower bound directly */
168 
169  if (value_pos_p(coeff1)) sc_info[rank_hr][2] ++;
170  else sc_info[rank_hr][3] ++;
171  }
172  else {
173 
174  /* If the variable is not a loop index then the constraint
175  ineq combined with another constraint pc gives an upper
176  or a lower bound for another variable */
177 
178  for (pc = ineq;
180  pc = pc->succ) {
181 
182  coeff2 = vect_coeff(var_hr,pc->vecteur);
183  sign2 = value_sign(coeff2);
184  sign1 = value_sign(coeff1);
185 
186  if (value_notzero_p(coeff2) && sign1 == -sign2) {
188  (index_base, ineq, pc, rank_hr,
189  &right_var, &right_rank, &right_coeff,
190  &left_var, &left_rank, &left_coeff);
191  if (right_rank>left_rank) {
192  if (value_pos_p(right_coeff))
193  sc_info[right_rank][2]++;
194  else
195  sc_info[right_rank][3]++;
196  }
197  else if (right_rank<left_rank){
198  if (value_pos_p(left_coeff))
199  sc_info[left_rank][2]++;
200  else
201  sc_info[left_rank][3]++;
202  }
203  }
204  }
205  }
206  }
207  else
208  /* If the variable is a loop index then the constraint
209  ineq gives an upper or a lower bound directly */
210 
211  if (value_neg_p(vect_coeff(var_hr,ineq->vecteur)))
212  sc_info[rank_hr][3] ++;
213  else
214  sc_info[rank_hr][2] ++;
215 
216  }
217  }
218 }
#define value_sign(v)
trian operators on values
#define value_notzero_p(val)
int Value
#define value_neg_p(val)
int search_higher_rank(Pvecteur vect, Pbase base)
int search_higher_rank(): this fonction returns the rank of the variable of higher rank in the vecteu...
Definition: base.c:541
#define CONTRAINTE_UNDEFINED_P(c)
void constraint_integer_combination(Pbase index_base, Pcontrainte ineq1, Pcontrainte ineq2, int rank, Variable *right_var, int *right_rank, Value *right_coeff, Variable *left_var, int *left_rank, Value *left_coeff)
This function computes the coefficients of the constraint resulting from the elimination of the varia...
struct Scontrainte * succ
Pcontrainte inegalites
Definition: sc-local.h:71

References constraint_integer_combination(), CONTRAINTE_UNDEFINED_P, Ssysteme::inegalites, rank_of_variable(), search_higher_rank(), search_var_of_higher_rank(), Scontrainte::succ, value_neg_p, value_notzero_p, value_pos_p, value_sign, variable_of_rank(), vect_coeff(), and Scontrainte::vecteur.

Referenced by movement_computation(), and parallel_tiling().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ search_var_of_higher_rank()

Variable search_var_of_higher_rank ( )

Referenced by constraint_distribution(), constraint_integer_combination(), and sc_integer_projection_information().

+ Here is the caller graph for this function:

◆ var_with_unity_coeff_p()

bool var_with_unity_coeff_p ( Psysteme  sc,
Variable  var 
)

This function returns true: if all positive OR all negative coefficients of the variable var in the system are equal to 1.

That's mean that the FM projection can be used without problem on integer domain

Definition at line 46 of file sc_integer_analyze.c.

49 {
50  register Pcontrainte pc;
51 
52  if (!var_in_sc_p(sc,var))
53  return false;
54 
55  for (pc = sc->inegalites; !CONTRAINTE_UNDEFINED_P(pc); pc = pc->succ)
56  {
57  Value coeff = vect_coeff(var,pc->vecteur);
58  if (value_gt(coeff, VALUE_ONE) ||
59  value_lt(coeff, VALUE_MONE))
60  return false;
61  }
62  for (pc = sc->egalites; !CONTRAINTE_UNDEFINED_P(pc); pc = pc->succ)
63  {
64  Value coeff = vect_coeff(var,pc->vecteur);
65  if (value_gt(coeff, VALUE_ONE) ||
66  value_lt(coeff, VALUE_MONE))
67  return false;
68  }
69 
70  return true;
71 }
#define value_gt(v1, v2)
#define VALUE_MONE
#define VALUE_ONE
#define value_lt(v1, v2)
bool var_in_sc_p(Psysteme sc, Variable var)
bool var_in_sc_p(Psysteme sc, Variable var) Cette fonction teste si la variable est contrainte par le...
Definition: sc_var.c:139
Pcontrainte egalites
Definition: sc-local.h:70

References CONTRAINTE_UNDEFINED_P, Scontrainte::succ, value_gt, value_lt, VALUE_MONE, VALUE_ONE, var_in_sc_p(), vect_coeff(), and Scontrainte::vecteur.

Referenced by movement_computation().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ variable_of_rank()