PIPS
utils.c
Go to the documentation of this file.
1 /*
2 
3  $Id: utils.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 #ifdef HAVE_CONFIG_H
25  #include "pips_config.h"
26 #endif
27 
28 #ifndef lint
29 char vcid_prgm_mapping_utils[] = "$Id: utils.c 23065 2016-03-02 09:05:50Z coelho $";
30 #endif /* lint */
31 
32 /* Name : utils.c
33  * Package : prgm_mapping
34  * Author : Alexis Platonoff
35  * Date : 23 september 1993
36  *
37  * Historic :
38  * - 6 dec 93, some new functions, AP
39  * - 14 nov 94, remove find_implicit_equation(), put in paf-util, AP
40  *
41  * Documents:
42  *
43  * Comments : This file contains useful functions used for the computation of
44  * prgm_mapping.
45  */
46 
47 /* Ansi includes */
48 #include <stdlib.h>
49 #include <stdio.h>
50 #include <stdlib.h>
51 #include <string.h>
52 
53 /* Newgen includes */
54 #include "genC.h"
55 
56 /* C3 includes */
57 #include "boolean.h"
58 #include "arithmetique.h"
59 #include "vecteur.h"
60 #include "contrainte.h"
61 #include "ray_dte.h"
62 #include "sommet.h"
63 #include "sg.h"
64 #include "sc.h"
65 #include "polyedre.h"
66 #include "union.h"
67 #include "matrice.h"
68 #include "matrix.h"
69 
70 /* Pips includes */
71 #include "ri.h"
72 #include "ri-util.h"
73 #include "constants.h"
74 #include "graph.h"
75 #include "paf_ri.h"
76 #include "text.h"
77 #include "text-util.h"
78 #include "misc.h"
79 #include "static_controlize.h"
80 #include "paf-util.h"
81 #include "prgm_mapping.h"
82 
83 /* Useful constants */
84 
85 /* Macro functions */
86 
87 /* Global variables */
88 extern list prgm_parameter_l;
89 
90 /* Internal variables */
91 
92 /* Local defines */
95 
96 
97 /* ======================================================================== */
98 /* list insert_sort(list l, bool (*compare_obj)()): returns the result of
99  * sorting the list "l" using the comparison function "compare_obj". This
100  * bool function should retuns true if its first argument has to be placed
101  * before its second argument in the sorted list, else FALSE.
102  *
103  * This is a generic function that accepts any homogene list of newgen
104  * objects. The comparison function must be coded by the user, its prototype
105  * should be: bool my_compare_obj(chunk * obj1, chunk * obj2);
106  *
107  * This function uses the insert sort algorithm which has a mean and worst case
108  * complexity of n^2.
109  */
110 list insert_sort(l, compare_obj)
111 list l;
112 bool (*compare_obj)();
113 {
114  list al, aal, nl = NIL, nnl, nnl_q;
115  chunk * ngo, * aux_ngo;
116  bool not_inserted;
117 
118  for(al = l; al != NIL; al = CDR(al)) {
119  ngo = CHUNK(CAR(al));
120  not_inserted = true;
121  nnl = NIL;
122  nnl_q = nnl;
123 
124  for(aal = nl; (aal != NIL) && not_inserted ; aal = CDR(aal)) {
125  aux_ngo = CHUNK(CAR(aal));
126  if(compare_obj(ngo, aux_ngo)) {
127  nnl = gen_nconc(gen_nconc(nnl, CONS(CHUNK, ngo, NIL)), aal);
128  not_inserted = false;
129  }
130  else
131  nnl = gen_nconc(nnl, CONS(CHUNK, aux_ngo, NIL));
132  }
133  if(not_inserted)
134  nnl = gen_nconc(nnl, CONS(CHUNK, ngo, NIL));
135 
136  nl = nnl;
137  }
138 
139  return(nl);
140 }
141 
142 
143 /* ======================================================================== */
145 entity e;
146 {
147  if( (strncmp(entity_local_name(e), INDEX_COEFF, 1) == 0) ||
148  (strncmp(entity_local_name(e), MU_COEFF, 1) == 0) )
149  return(true);
150  else
151  return(false);
152 }
153 
154 
155 /* ======================================================================== */
156 /* bool compare_coeff(c1, c2):
157  *
158  * returns a bool saying true if "c1" is before "c2" in the lexicographic
159  * order, else FALSE. "c1" and "c2" are entities, we compare their
160  * name. */
161 bool compare_coeff(c1, c2)
162 chunk * c1, * c2;
163 {
164  return strcmp(entity_local_name((entity) c1),
165  entity_local_name((entity) c2))<0;
166 }
167 
168 
169 /* ======================================================================== */
170 bool compare_nodes_dim(n1, n2)
171 chunk * n1, * n2;
172 {
173  extern hash_table StmtToDim;
174 
175  return((int) hash_get(StmtToDim, (char *) vertex_int_stmt((vertex) n1)) >
176  (int) hash_get(StmtToDim, (char *) vertex_int_stmt((vertex) n2)) );
177 }
178 
179 
180 /* ======================================================================== */
181 bool compare_dfs_weight(d1, d2)
182 chunk * d1, * d2;
183 {
184  extern hash_table DtfToWgh;
185 
186  return( (int) hash_get(DtfToWgh, (char *) d1) >
187  (int) hash_get(DtfToWgh, (char *) d2) );
188 }
189 
190 
191 /* ======================================================================== */
192 bool compare_unks_frenq(e1, e2)
193 chunk * e1, * e2;
194 {
195  extern hash_table UnkToFrenq;
196 
197  return( (int) hash_get(UnkToFrenq, (char *) e1) >
198  (int) hash_get(UnkToFrenq, (char *) e2) );
199 }
200 
201 
202 /* ======================================================================== */
203 /* entity make_coeff(string prefix, int n): returns a new entity which
204  * will be used as a coefficient in a prototype of a placement function. All
205  * coefficients differ in their name which is something like:
206  * "MAPPING:prefix#"
207  * where # is the integer value of "n".
208  */
210 string prefix;
211 int n;
212 {
213  string num, name;
214  entity new_coeff;
215 
216  num=int2a(n);
217 
219  prefix, num, (char *) NULL));
220 
221  new_coeff = make_entity(name,
224  NIL)),
227 
228  free(num);
229  return(new_coeff);
230 }
231 
232 
233 /* ======================================================================== */
234 /* entity find_or_create_coeff(string prefix, int n): returns the entity
235  * that represent the coefficient numbered "n" and prefixed by "prefix". If it
236  * does not exist yet, we create it.
237  */
239 string prefix;
240 int n;
241 {
242  string num, name;
243  entity new_coeff;
244 
245  num=int2a(n);
247  prefix, num, (char *) NULL));
248  new_coeff = gen_find_tabulated(name, entity_domain);
249 
250  /* We create it, if it does not exist yet */
251  if(new_coeff == entity_undefined)
252  new_coeff = make_coeff(prefix, n);
253 
254  free(num);
255  return(new_coeff);
256 }
257 
258 
259 /* ======================================================================== */
261 list l;
262 {
263  list prec, aux_l;
264 
265 if(get_debug_level() > 6) {
266 fprintf(stderr, "\n[rm_non_x_var] Bases de depart :\n");
267 fprint_entity_list(stderr, l);
268 fprintf(stderr, "\n");
269 }
270 
271  prec = NIL;
272  for(aux_l = l; !ENDP(aux_l); POP(aux_l)) {
273  entity crt_var = ENTITY(CAR(aux_l));
274  if(!is_index_coeff_p(crt_var)) {
275  if(prec == NIL)
276  l = CDR(l);
277  else
278  CDR(prec) = CDR(aux_l);
279  }
280  else
281  prec = aux_l;
282  }
283 
284 if(get_debug_level() > 6) {
285 fprintf(stderr, "\n[rm_non_x_var] Base d'arrivee :\n");
286 fprint_entity_list(stderr, l);
287 fprintf(stderr, "\n");
288 }
289 
290  return(l);
291 }
292 
293 
294 /* ======================================================================== */
296 list l1, l2;
297 {
298  list l;
299 
300  if(l1 == NULL)
301  l = gen_append(l2, NIL);
302  else {
303  l = gen_append(l1, NIL);
304 
305  for(; !ENDP(l2); POP(l2)) {
306  chunk * c2 = CHUNK(CAR(l2));
307  bool found = false;
308  for(; (!ENDP(l1)) && (!found); POP(l1)) {
309  chunk *c1 = CHUNK(CAR(l1));
310  if(c1 == c2)
311  found = true;
312  }
313  if(! found)
314  gen_nconc(l, CONS(CHUNK, c2, NIL));
315  }
316  }
317 
318  return(l);
319 }
320 
321 
322 /* ======================================================================== */
323 /* Psysteme new_elim_var_with_eg(Psysteme ps, list *init_l, list *elim_l):
324  * Computes the gaussian elimination of variables in the system "ps". The
325  * modifications are directly done on "ps".
326  *
327  * However, we keep all the eliminated equations in "sc_elim", and return that
328  * system.
329  *
330  * Initially, "init_l" gives the list of variables that can be eliminated, at
331  * the end, it only contains the variables that were not eliminated. We take
332  * the order of this list in our process of eliminating.
333  *
334  * Initially, "elim_l" is empty, at the end it contains the variables that were
335  * eliminated.
336  *
337  */
338 Psysteme new_elim_var_with_eg(ps, init_l, elim_l)
339 Psysteme ps;
340 list *init_l, *elim_l;
341 {
342  Psysteme sc_elim = sc_new();
343 
344  /* During the computation, we modify *init_l, so we duplicate it.
345  * We use "el" not *elim_l, which should be empty at the beginning.
346  */
347  list vl = gen_append(*init_l, NIL),
348  el = NIL,
349  l;
350  Pcontrainte eq, eg;
351 
352  for(l = vl; !ENDP(l); POP(l)) {
353  Variable v = (Variable) ENTITY(CAR(l));
354  Value coeff;
355 
356  if ((eq = contrainte_var_min_coeff(ps->egalites,v, &coeff, true))
357  != NULL) {
358 
359  if(get_debug_level() > 7) {
360 fprintf(stderr, "System is :");
361 fprint_psysteme(stderr, ps);
362 fprintf(stderr, "\t\tElim var %s in equation:", entity_local_name((entity) v));
363 pu_vect_fprint(stderr, eq->vecteur);
364 fprintf(stderr, "\n");
365  }
366 
367  if(!egalite_normalize(eq))
368  pips_internal_error("Egalite bizarre");
369 
370  sc_nbre_egalites(ps)--;
371  if (eq == (ps->egalites)) ps->egalites = eq->succ;
372  /* si eq etait en tete il faut l'enlever de la liste, sinon, eq a
373  ete enleve dans la fonction contrainte_var_min_coeff(). */
374 
375  for(eg = ps->egalites; eg != NULL; eg = eg->succ)
376  (void) contrainte_subst_ofl_ctrl(v, eq, eg, true, NO_OFL_CTRL);
377  for(eg = ps->inegalites; eg != NULL; eg = eg->succ)
378  (void) contrainte_subst_ofl_ctrl(v, eq, eg, false, NO_OFL_CTRL);
379 
380  for(eg = sc_elim->egalites; eg != NULL; eg = eg->succ)
381  (void) contrainte_subst_ofl_ctrl(v, eq, eg, true, NO_OFL_CTRL);
382  for(eg = sc_elim->inegalites; eg != NULL; eg = eg->succ)
383  (void) contrainte_subst_ofl_ctrl(v, eq, eg, false, NO_OFL_CTRL);
384 
385  sc_add_egalite(sc_elim, eq);
386  gen_remove(init_l, (chunk *) v);
387  el = CONS(ENTITY, (entity) v, el);
388  }
389  }
390 
391  *elim_l = el;
392  sc_elim->base = NULL;
393  sc_creer_base(sc_elim);
394 
395  if(get_debug_level() > 6) {
396 fprintf(stderr, "[new_elim_var_with_eg] Results:\n");
397 fprintf(stderr, "Elim sys:\n");
398 fprint_entity_list(stderr, el);
399 fprint_psysteme(stderr, sc_elim);
400 fprintf(stderr, "Remnants sys:\n");
401 fprint_entity_list(stderr, *init_l);
402 fprint_psysteme(stderr, ps);
403 fprintf(stderr, "\n");
404  }
405 
406  return(sc_elim);
407 }
408 
409 
410 /* ======================================================================== */
411 /* Psysteme plc_elim_var_with_eg(Psysteme ps, list *init_l, list *elim_l):
412  * Computes the gaussian elimination of variables in the system "ps". The
413  * modifications are directly done on "ps".
414  *
415  * However, we keep all the eliminated equations in "sc_elim", and return that
416  * system.
417  *
418  * Initially, "init_l" gives the list of variables that can be eliminated, at
419  * the end, it only contains the variables that were not eliminated. We take
420  * the order of this list in our process of eliminating.
421  *
422  * Initially, "elim_l" is empty, at the end it contains the variables that were
423  * eliminated.
424  *
425  */
426 Psysteme plc_elim_var_with_eg(ps, init_l, elim_l)
427 Psysteme ps;
428 list *init_l, *elim_l;
429 {
430  bool var_not_found;
431  Psysteme sc_elim = sc_new();
432  Pcontrainte eqs;
433  Pvecteur ve, pv_elim;
434  entity crt_var = entity_undefined;
435  int crt_val = 0;
436  list vl = *init_l, /* We use "vl" during the computation, not *init_l */
437  el = NIL, /* We use "el" during the computation, not *elim_l */
438  l;
439 
440  /* This elimination works only on equalities. While there remains equalities,
441  * we can eliminate variables.
442  */
443  eqs = ps->egalites;
444  while(eqs != NULL)
445  {
446  ve = eqs->vecteur;
447 
448  if(get_debug_level() > 8) {
449 fprintf(stderr, "System is :");
450 fprint_psysteme(stderr, ps);
451 fprintf(stderr, "\t\tConsidered Vect :");
452 pu_vect_fprint(stderr, ve);
453 fprintf(stderr, "\n");
454  }
455 
456  /* We look, in vl (i.e. init_l), for a variable that we can eliminate in
457  * ve, i.e. with a coefficient equal to 1 or -1.
458  */
459  var_not_found = true;
460  for(l = vl ; (l != NIL) && var_not_found; l = CDR(l)) {
461  crt_var = ENTITY(CAR(l));
462  crt_val = (int) vect_coeff((Variable) crt_var, ve);
463  if((crt_val == 1) || (crt_val == -1))
464  var_not_found = false;
465  }
466 
467  /* If we get such a variable, we eliminate it. */
468  if(! var_not_found)
469  {
470  Pvecteur init_vec;
471 
472  /* First, we remove it from "vl". */
473  gen_remove(&vl, (chunk *) crt_var);
474 
475  /* Then, we add it to "el". */
476  el = CONS(ENTITY, crt_var, el);
477 
478  /* We keep a copy of the initial vector. */
479  init_vec = vect_dup(eqs->vecteur);
480 
481  /* We compute the expression (pv_elim) by which we are going to
482  * substitute our variable (var):
483  *
484  * We have: var = pv_elim
485  *
486  * The equality is: V = 0, with: V = val*var + Vaux, and: val in {-1,1}
487  *
488  * So, we have: pv_elim = -val*Vaux, with: Vaux = V - val*var
489  *
490  * So: pv_elim = -val(V - val*var)
491  * i.e.: pv_elim = -val+V + (val^2)*var
492  * but: val in {-1,1}, so: val^2 = 1
493  *
494  * so: pv_elim = -val*V + var
495  *
496  */
497  pv_elim = vect_cl2_ofl_ctrl((crt_val)*(-1), eqs->vecteur,
498  1, vect_new((Variable) crt_var, 1),
499  NO_OFL_CTRL);
500 
501  if(get_debug_level() > 7) {
502 fprintf(stderr, "\t\tElim with %s = ", entity_local_name(crt_var));
503 pu_vect_fprint(stderr, pv_elim);
504 fprintf(stderr, "\n");
505  }
506 
507  /* We substitute var by its value (pv_elim) in "ps". */
508  my_substitute_var_with_vec(ps, crt_var, 1, vect_dup(pv_elim));
509 
510  /* We substitute var by its value (pv_elim) in "sc_elim". */
511  my_substitute_var_with_vec(sc_elim, crt_var, 1, vect_dup(pv_elim));
512 
513  ps = sc_normalize(ps);
514  vect_rm(pv_elim);
515 
516  if(get_debug_level() > 7) {
517 fprintf(stderr, "New System is :");
518 fprint_psysteme(stderr, ps);
519  }
520 
521  /* The initial equality is added to "sc_elim". */
522  sc_add_egalite(sc_elim, contrainte_make(init_vec));
523 
524 
525  /* We reinitialize the list of equalities. */
526  eqs = ps->egalites;
527  }
528  /* Else, we try on the next equality. */
529  else
530  eqs = eqs->succ;
531  }
532  *init_l = vl;
533  *elim_l = el;
534  sc_elim->base = NULL;
535  sc_creer_base(sc_elim);
536 
537  if(get_debug_level() > 6) {
538 fprintf(stderr, "[plc_elim_var_with_eg] Results:\n");
539 fprintf(stderr, "Elim sys:\n");
540 fprint_entity_list(stderr, el);
541 fprint_psysteme(stderr, sc_elim);
542 fprintf(stderr, "Remnants sys:\n");
543 fprint_entity_list(stderr, vl);
544 fprint_psysteme(stderr, ps);
545 fprintf(stderr, "\n");
546  }
547 
548  return(sc_elim);
549 }
550 
551 
552 /* ======================================================================== */
553 /* int new_count_implicit_equation(Psysteme ps): returns the number of implicit
554  * equations there are in the system "ps".
555  *
556  * Practically, we construct a system containing all the implicit equations,
557  * then we count the number of equations (there should be no redondant
558  * equation since find_implicit_equation() normalizes its result).
559  *
560  * See the description of find_implicit_equation().
561  */
563 Psysteme ps;
564 {
565  Psysteme impl_ps;
566 
567  if(ps == NULL)
568  return(0);
569 
570  impl_ps = find_implicit_equation(ps);
571 
572  /* If impl_ps is empty, then no data are communicated */
573  if(impl_ps == NULL)
574  return(ps->nb_ineq + ps->nb_eq);
575 
576  if(get_debug_level() > 6) {
577  fprintf(stderr, "Number of equations in Implicit system : %d\n", impl_ps->nb_eq);
578  }
579  return(impl_ps->nb_eq);
580 }
581 
582 
583 /* ======================================================================== */
584 /* list put_source_ind(list le): returns a list of expressions computed from
585  * the list given in argument ("le").
586  *
587  * We want to associate a variable (var) to each expression (exp) in order to
588  * have some kind of equality : 0 = exp - var
589  * which means in fact : var = exp
590  *
591  * The name of the variables are not important, however, we need a different
592  * variable for each expression.
593  *
594  * Note: the variables are entities.
595  */
597 list le;
598 {
599  int count = 1; /* This counter makes sure that each new variable is different
600  * for the preceding one.
601  */
602  expression texp, new_texp;
603  entity en;
604  list l,
605  new_le = NIL; /* The resulting list is initialized to NIL. */
606 
607  /* For each expression we compute the new expression. */
608  for(l = le; l != NIL; l = CDR(l), count++)
609  {
610  normalized nor;
611 
612  /* We get a new variable (an entity). */
614 
615  texp = EXPRESSION(CAR(l));
616  NORMALIZE_EXPRESSION(texp);
617  nor = expression_normalized(texp);
618 
620  Pvecteur pv = normalized_linear(nor);
621  pv = vect_cl_ofl_ctrl(pv, -1, vect_new((Variable) en, 1), NO_OFL_CTRL);
622  new_texp = make_vecteur_expression(pv);
623  }
624  else {
625  /* We make the new expression : exp - var. */
626  new_texp = make_op_exp(MINUS_OPERATOR_NAME,
627  texp, make_entity_expression(en, NIL));
628  }
629 
630  /* This expression is added to the new list. The order is kept. */
631  new_le = gen_nconc(new_le, CONS(EXPRESSION, new_texp, NIL));
632  }
633  return(new_le);
634 }
635 
636 
637 /* ======================================================================== */
638 /* Ppolynome apply_farkas(Ppolynome F, Psysteme D,
639  * list *L, int *count_lambdas)
640  * returns the affine from of farkas lemma computed from the polynome "F"
641  * (the affine form) and the domain of its variables "ps_dom".
642  *
643  * Farkas Lemma:
644  * -------------
645  * Let D be a non empty polyhedron defined by n affine inequalities:
646  * Ik(x) >= 0, k in 1,..,n
647  *
648  * Then an affine form F is a non negative everywhere in D iff it is a
649  * positive affine combination of the above inequalities:
650  * F(x) >= 0 in D <=> F(x) == L0 + L1.I1(x) + .. + Ln.In(x)
651  * with Lk >= 0, k in 1,..,n
652  *
653  * Here, *L" is the list (L0,..,Ln).
654  * If we note P(x) = L0 + L1.I1(x) + .. + Ln.In(x), the polynome returned
655  * is the Farkas polynome: FP = F(x) - P(x)
656  *
657  * We also have to add the structure parameters that do not appear in D and
658  * that are in the global var "prgm_parameter_l". For instance, if "p"
659  * (in "prgm_parameter_l") does not appear in D, we'll have:
660  * P(x) = L0 + L1.I1(x) + .. + Ln.In(x) + Ln+1.p
661  * and "*L" will be (L0,..,Ln,Ln+1)
662  *
663  * In the following code, variable "P" is the opposite of our P(x). In doing so,
664  * we'll be able to simplified the final calculus (F(x) - P(x)) by an addition.
665  */
666 
667 typedef bool (*argh)(Pvecteur*, Pvecteur*);
668 
669 Ppolynome apply_farkas(F, D, L, count_lambdas)
670 Ppolynome F;
671 Psysteme D;
672 list * L;
673 int *count_lambdas;
674 {
675  Ppolynome FP, pp_v, P, last_P;
676  int cl = *count_lambdas;
677  entity nl;
678  list local_l = NIL, params_in_D, l, ll;
679  Pcontrainte pc;
680 
681  nl = find_or_create_coeff(LAMBD_COEFF, cl++);
682  local_l = CONS(ENTITY, nl, local_l);
683 
684  /* Constant term: L0 */
685  P = make_polynome(-1.0, (Variable) nl, 1);
686  last_P = P;
687 
688  /* We associate to each equation or inequation a different coefficient, so
689  * the addition is never simplified, it just put a few monomes to the end
690  * of "P", i.e. "last_P". We do not used "polynome_add()" because this
691  * function looks for similar monomes.
692  */
693  if(D != NULL) {
694  for(pc = D->inegalites; pc != NULL; pc = pc->succ) {
695  Pvecteur pv = pc->vecteur;
696 
697  nl = find_or_create_coeff(LAMBD_COEFF, cl++);
698  local_l = CONS(ENTITY, nl, local_l);
699 
700  pp_v = vecteur_mult(pv, vect_new((Variable) nl, 1));
701 
702  for(last_P->succ = pp_v; last_P->succ != NULL; last_P = last_P->succ) {}
703  }
704 
705  /* An equality (v == 0) is also two inequalities (v >= 0, v <= 0) */
706  for(pc = D->egalites; pc != NULL; pc = pc->succ) {
707  Pvecteur pv = pc->vecteur;
708 
709  nl = find_or_create_coeff(LAMBD_COEFF, cl++);
710  local_l = CONS(ENTITY, nl, local_l);
711 
712  pp_v = vecteur_mult(pv, vect_new((Variable) nl, 1));
713 
714  for(last_P->succ = pp_v; last_P->succ != NULL; last_P = last_P->succ) {}
715 
716  nl = find_or_create_coeff(LAMBD_COEFF, cl++);
717  local_l = CONS(ENTITY, nl, local_l);
718 
719  pp_v = vecteur_mult(pv, vect_new((Variable) nl, -1));
720 
721  for(last_P->succ = pp_v; last_P->succ != NULL; last_P = last_P->succ) {}
722  }
723  }
724 
725  /* We add to (-P) the parameters that do not appear in D */
726  /* pu_is_inferior_var is not implemented and does not match prototype... */
728  for(l = gen_append(prgm_parameter_l, NIL); !ENDP(l); POP(l)) {
729  bool not_found = true;
730  entity p = ENTITY(CAR(l));
731  for(ll = params_in_D; !ENDP(ll) && (not_found); POP(ll)) {
732  if( same_entity_p(p, ENTITY(CAR(ll))) )
733  not_found = false;
734  }
735  if(not_found) {
736  nl = find_or_create_coeff(LAMBD_COEFF, cl++);
737  local_l = CONS(ENTITY, nl, local_l);
738 
739  pp_v = vecteur_mult(vect_new((Variable) nl, -1),
740  vect_new((Variable) p, 1));
741 
742  for(last_P->succ = pp_v; last_P->succ != NULL; last_P = last_P->succ) {}
743  }
744  }
745 
746  /* FP = F + (-P)
747  * We are sure that F-P can not be simplified, i.e. that there are similar
748  * monomes; this is because each monome of P has a variable that never
749  * appear outside of P.
750  */
751  FP = P;
752  last_P->succ = F;
753 
754  *L = local_l;
755  *count_lambdas = cl;
756  return(FP);
757 }
758 
759 
760 /* ======================================================================== */
761 /* list get_graph_dataflows(graph g): returns the list of dataflows of the DFG
762  * graph "g". Each edge of "g" contains a list of dataflows, so we concatenate
763  * these lists into one.
764  */
766 graph g;
767 {
768  list l, su_l, g_dfs;
769 
770  g_dfs = NIL;
771  for(l = graph_vertices(g); !ENDP(l); POP(l)) {
772  for(su_l = vertex_successors(VERTEX(CAR(l))); !ENDP(su_l); POP(su_l)) {
773  list dfs = gen_append(SUCC_DATAFLOWS(SUCCESSOR(CAR(su_l))), NIL);
774  g_dfs = gen_nconc(g_dfs, dfs);
775  }
776  }
777 
778  return(g_dfs);
779 }
780 
781 
782 /* ======================================================================== */
783 /*
784  * list get_stmt_index_coeff(int stmt, int n, hash_table StoL): returns the
785  * index coeff from the coeff used in the prototype of statement "stmt".
786  *
787  * The hash table "StoL" maps a statement number to the lists of coeff used
788  * for the prototype. When this list is gotten, we have to remove the non index
789  * coeff.
790  * An index coeff is recognized with is_index_coeff_p().
791  */
793 int stmt;
794 hash_table StoL;
795 {
796  list proto_lambda, prec, pl;
797 
798  proto_lambda = gen_append((list) hash_get(StoL, (char *) stmt), NIL);
799 
800  prec = NIL;
801  for(pl = proto_lambda; !ENDP(pl); POP(pl)) {
802  entity e = ENTITY(CAR(pl));
803  if(is_index_coeff_p(e))
804  prec = pl;
805  else
806  if(prec == NIL)
807  proto_lambda = CDR(proto_lambda);
808  else
809  CDR(prec) = CDR(pl);
810  }
811 
812  return(proto_lambda);
813 }
814 
815 
816 /* ======================================================================== */
817 /*
818  * Psysteme completer_base(Psysteme sys, list var_l, list par_l): "sys" gives
819  * a family of free vectors {V1, ..., Vs} represented by a linear combinations
820  * of indices from "var_l". This function wants to find the indices
821  * (I1, ..., Id) of "var_l" for which we have that {V1, ..., Vs, I1, ..., Id}
822  * is a family of free vectors.
823  * "par_l" gives the symbolic constants that may appear in "sys".
824  *
825  * "s" is the number of equations of "sys" (its number of vectors).
826  * "d" is the number of vectors we have to find in order to get as much
827  * equations in "sys" as there are indices in "var_l".
828  *
829  * Example: with "sys" equal to {i+j = 0, i-k+2j = 0}, and "var_l" equal to
830  * {i, j, k} we obtain the new system {i+j = 0, i-k+2j = 0, i = 0}
831  */
832 Psysteme completer_base(sys, var_l, par_l)
833 Psysteme sys;
834 list var_l, par_l;
835 {
836  Psysteme ps = sc_dup(sys), new_ps = sc_new();
837  int dim = gen_length(var_l) - sys->nb_eq;
838  list l;
839 
840  for(l = var_l; (!ENDP(l)) && (new_ps->nb_eq < dim); POP(l)) {
841  entity var = ENTITY(CAR(l));
842  Pvecteur pv = vect_new((Variable) var, 1);
843  Psysteme aux_ps = sc_dup(ps);
844  Psysteme aux_new_ps = sc_dup(new_ps);
845 
846  sc_add_egalite(aux_new_ps, contrainte_make(pv));
847  aux_ps = append_eg(aux_ps, aux_new_ps);
848 
849  if(vecteurs_libres_p(aux_ps, list_to_base(var_l), list_to_base(par_l))) {
850  new_ps = aux_new_ps;
851  }
852  else
853  sc_rm(aux_new_ps);
854  }
855  ps = append_eg(ps, new_ps);
856  ps->base = NULL;
857  sc_creer_base(ps);
858  return(ps);
859 }
860 
861 
862 /* ======================================================================== */
863 /*
864  * list diff_lists(list l1, list l2): return the difference between two lists.
865  *
866  * Example: the diff between (e1, e2, e3) and (e2, e4) is (e1, e3).
867  */
869 list l1, l2;
870 {
871  list l = NIL;
872 
873  if(l2 == NULL)
874  return(l1);
875 
876  for( ; !ENDP(l1); POP(l1)) {
877  chunk *c1 = CHUNK(CAR(l1));
878  bool found = false;
879  for(; (!ENDP(l2)) && (!found); POP(l2)) {
880  chunk *c2 = CHUNK(CAR(l2));
881  if(c1 == c2)
882  found = true;
883  }
884  if(!found)
885  l = gen_nconc(l, CONS(CHUNK, c1, NIL));
886  }
887  return(l);
888 }
889 
890 
891 /* ======================================================================== */
892 /*
893  * bool vecteurs_libres_p(Psysteme sys, Pbase v_base, Pbase c_base):
894  * returns true if "sys" contains a list of equalities that can represent a
895  * family of free vectors.
896  * "v_base" is the list unit vectors, and "c_base" is the list of symbolic
897  * constants.
898  *
899  * Example: (i,j) are unit vectors, n is a symbolic constant
900  * {i + n == 0, i - n == 0} is not a free family
901  * {i + j == 0, i - j == 0} is a free family
902  */
903 bool vecteurs_libres_p(sys, v_base, c_base)
904 Psysteme sys;
905 Pbase v_base, c_base;
906 {
907  int n, m1, m2, r;
908  Value det_p, det_q;
909  matrice A, B, P, H, Q;
910 
911  n = sys->nb_eq;
912  m1 = base_dimension(v_base);
913 
914  if(m1 < n)
915  return(false);
916 
917  m2 = base_dimension(c_base) + 1; /* add 1, because of the TCST */
918  A = matrice_new(n,m1);
919  B = matrice_new(n,m2);
920 
921  contraintes_with_sym_cst_to_matrices(sys->egalites,v_base,c_base,
922  A,B,n,m1,m2);
923 
924  P = matrice_new(n,n);
925  Q = matrice_new(m1,m1);
926  H = matrice_new(n,m1);
927  matrice_hermite(A, n, m1, P, H, Q, &det_p, &det_q);
928 
929  r = matrice_hermite_rank(H, n, m1);
930 
931  matrice_free(A);
932  matrice_free(B);
933  matrice_free(P);
934  matrice_free(Q);
935  matrice_free(H);
936 
937  return(r == n);
938 }
939 
940 
941 /* ======================================================================== */
942 /*
943  * Psysteme append_eg(M1, M2): returns a system containing all the equations of
944  * "M1" and all the equations of "M2". The order is kept, i.e. "M1" and "M2".
945  */
947 Psysteme M1, M2;
948 {
949  Pcontrainte pc1, pc2, prec;
950  Pvecteur pv;
951 
952  if(M1 == NULL)
953  return(M2);
954  if(M2 == NULL)
955  return(M1);
956 
957  pc1 = M1->egalites;
958  pc2 = M2->egalites;
959  for(prec = NULL; pc1 != NULL; pc1 = pc1->succ)
960  prec = pc1;
961 
962  if(prec == NULL)
963  return(M2);
964 
965  prec->succ = pc2;
966  M1->nb_eq += M2->nb_eq;
967 
968  pv = M1->base;
969  M1->base = NULL;
970  vect_rm(pv);
971  sc_creer_base(M1);
972 
973  return(M1);
974 }
975 
976 /* ======================================================================== */
977 /*
978  * void di_polynome_var_subst_null(Ppolynome *pp, entity var)
979  */
981 Ppolynome *pp;
982 entity var;
983 {
984  Ppolynome ppp, p = POLYNOME_UNDEFINED;
985  Pvecteur pv;
986 
987  for(ppp = *pp; ppp != NULL; ppp = ppp->succ) {
988  entity first = entity_undefined,
989  second = entity_undefined;
990  pv = (ppp->monome)->term;
991  for(; (pv != NULL) && (second == entity_undefined); pv = pv->succ) {
992  second = first;
993  first = (entity) pv->var;
994  }
995  if(pv != NULL)
996  pips_internal_error("Vecteur should contains 2 var");
997  else if(same_entity_p(first, var) || same_entity_p(second, var)) {
998  if(POLYNOME_UNDEFINED_P(p)) {
999  *pp = ppp->succ;
1000  }
1001  else
1002  p->succ = ppp->succ;
1003  }
1004  else
1005  p = ppp;
1006  }
1007 }
1008 
1009 
1010 /* ======================================================================== */
1011 /*
1012  * Psysteme nullify_factors(Ppolynome *pp, list var_l, bool with_remnants):
1013  * returns a system of equalities ("new_ps") computed from a polynome "pp"
1014  * and a list of variables "var_l".
1015  *
1016  * This list gives the variables of the polynome for which we need to nullify
1017  * the factor. Thus, the resulting system contains the equations that nullify
1018  * these factors (the degree of the polynome must be less or equal to two).
1019  *
1020  * If "with_remnants" is true, then the remaining polynome, from which we
1021  * have removed all the occurences of these variables, is also nullify and the
1022  * equation added to the system (then, these remnants must be of degree 1).
1023  *
1024  * Note: "pp" is modified, it contains at the end these remnants.
1025  */
1026 Psysteme nullify_factors(pp, var_l, with_remnants)
1027 Ppolynome *pp;
1028 list var_l;
1029 bool with_remnants;
1030 {
1031  Ppolynome aux_pp = *pp;
1032  Psysteme new_ps = sc_new();
1033  list l;
1034 
1035  if(get_debug_level() > 4) {
1036  fprintf(stderr, "[nullify_factors] polynome is :");
1038  fprintf(stderr, "\n");
1039  }
1040 
1041  if(!POLYNOME_NUL_P(aux_pp)) {
1042 
1043  /* For each variable, we nullify its factor in the polynome. */
1044  for(l = var_l; l != NIL; l = CDR(l)) {
1045  /* We get the current variable. */
1046  entity var = ENTITY(CAR(l));
1047 
1048  /* We get its factor in the polynome. */
1049  Pvecteur pv_fac = prototype_factorize(aux_pp, (Variable) var);
1050 
1051  if(get_debug_level() > 5) {
1052  fprintf(stderr, "[nullify_factors] factor is :");
1053  pu_vect_fprint(stderr, pv_fac);
1054  fprintf(stderr, "\n");
1055  }
1056 
1057  if(!VECTEUR_NUL_P(pv_fac)) {
1058  /* We add a new equality in the system. */
1059  sc_add_egalite(new_ps, contrainte_make(pv_fac));
1060 
1061  /* We delete the occurences of this variable in the polynome. */
1062  aux_pp = prototype_var_subst(aux_pp, (Variable) var, POLYNOME_NUL);
1063  }
1064  }
1065 
1066  if( (with_remnants) && (!POLYNOME_NUL_P(aux_pp)) )
1067  /* The remnants are zero out and are added as one equation. */
1068  sc_add_egalite(new_ps, polynome_to_contrainte(aux_pp));
1069 
1070  if(get_debug_level() > 4) {
1071  fprintf(stderr, "[nullify_factors] final new sys :");
1072  fprint_psysteme(stderr, new_ps);
1073  fprintf(stderr, "\n");
1074  }
1075 
1076  sc_creer_base(new_ps);
1077  sc_normalize(new_ps);
1078  *pp = aux_pp;
1079  }
1080  return(new_ps);
1081 }
1082 
1083 
1084 /* ======================================================================== */
1085 /* bool is_broadcast_p(dataflow df): returns true if the dataflow "df"
1086  * has a defined broadcast communication. Otherwise it returns FALSE.
1087  */
1089 dataflow df;
1090 {
1091  communication com;
1092  predicate bp;
1093  Psysteme ps;
1094 
1095  com = dataflow_communication(df);
1096  if(com == communication_undefined)
1097  return(false);
1098 
1099  bp = communication_broadcast(com);
1100  if(bp == predicate_undefined)
1101  return(false);
1102 
1103  ps = (Psysteme) predicate_system(bp);
1104  if(ps == NULL)
1105  return(false);
1106  else
1107  return(true);
1108 }
1109 
1110 
1111 /* ======================================================================== */
1112 /* int communication_dim(dataflow df): returns the number of directions
1113  * vectors of the dataflow if it a broadcast or a reduction. Oterwise,
1114  * returns 0.
1115  */
1117 dataflow df;
1118 {
1119  communication com;
1120  predicate bp, rp;
1121  Psysteme ps;
1122  Pcontrainte pc;
1123  int dim = 0;
1124 
1125  com = dataflow_communication(df);
1126  if(com == communication_undefined)
1127  return(0);
1128 
1129  bp = communication_broadcast(com);
1130  rp = communication_reduction(com);
1131  if((bp == predicate_undefined) && (rp == predicate_undefined))
1132  return(0);
1133 
1134  if(bp == predicate_undefined)
1135  ps = (Psysteme) predicate_system(rp);
1136  else
1137  ps = (Psysteme) predicate_system(bp);
1138 
1139  for(pc = ps->egalites; pc != NULL; pc = pc->succ)
1140  dim++;
1141 
1142  return(dim);
1143 }
1144 
1145 
1146 /* ======================================================================== */
1147 /* bool is_reduction_p(dataflow df): returns true if the dataflow "df"
1148  * has a defined reduction communication. Otherwise it returns FALSE.
1149  */
1151 dataflow df;
1152 {
1154  predicate bp;
1155  Psysteme ps;
1156 
1157  if(com == communication_undefined)
1158  return(false);
1159 
1160  bp = communication_reduction(com);
1161  if(bp == predicate_undefined)
1162  return(false);
1163 
1164  ps = (Psysteme) predicate_system(bp);
1165  if(ps == NULL)
1166  return(false);
1167  else
1168  return(true);
1169 }
1170 
1171 
1172 /* ======================================================================== */
1173 /* bool is_shift_p(dataflow df): returns true if the dataflow "df" has a
1174  * defined shift communication. Otherwise it returns FALSE.
1175  */
1176 bool is_shift_p(df)
1177 dataflow df;
1178 {
1180  predicate bp;
1181  Psysteme ps;
1182 
1183  if(com == communication_undefined)
1184  return(false);
1185 
1186  bp = communication_shift(com);
1187  if(bp == predicate_undefined)
1188  return(false);
1189 
1190  ps = (Psysteme) predicate_system(bp);
1191  if(ps == NULL)
1192  return(false);
1193  else
1194  return(true);
1195 }
1196 
1197 
1198 /*============================================================================*/
1199 /* void my_substitute_var_with_vec(Psysteme ps, entity var, int val, Pvecteur vec):
1200  * Substitutes in a system ("ps") a variable ("var"), factor of a positive
1201  * value ("val"), by an expression ("vec").
1202  *
1203  * This substitution is done on all assertions of the system (equalities and
1204  * inequalities). For each assertion (represented by a vector Vold) we have:
1205  *
1206  * Vold = c*var + Vaux
1207  * val*var = vec
1208  *
1209  * Vnew represents the new assertion. With: p = gcd(c, val) >= 1, we have:
1210  *
1211  * Vnew = (c/p)*vec + (val/p)*Vaux = (c/p)*vec + (val/p)*(Vold - c*var)
1212  *
1213  * Note: we have: Vold == 0 <=> (val/p)*Vold == 0
1214  * Vold > 0 <=> (val/p)*Vold > 0
1215  * ...
1216  *
1217  * because "val" is positive.
1218  */
1219 void my_substitute_var_with_vec(ps, var, val, vec)
1220 Psysteme ps;
1221 entity var;
1222 int val;
1223 Pvecteur vec;
1224 {
1225  Variable Var = (Variable) var;
1227 
1228  if(get_debug_level() > 8) {
1229 fprintf(stderr, "\t\t\tAvant Sub: \n");
1230 fprint_psysteme(stderr, ps);
1231 fprintf(stderr, "\n");
1232  }
1233 
1234  /* If we want to substitute a NULL vector, we just erase "Var" */
1235  if(VECTEUR_NUL_P(vec)) {
1236  for(assert = ps->egalites; assert != NULL; assert = assert->succ) {
1237  Pvecteur v_old = assert->vecteur;
1238  vect_erase_var(&v_old, Var);
1239  }
1240  for(assert = ps->inegalites; assert != NULL; assert = assert->succ) {
1241  Pvecteur v_old = assert->vecteur;
1242  vect_erase_var(&v_old, Var);
1243  }
1244  }
1245 
1246  /* "val" must be positive. */
1247  if(val < 0) {
1248  val = 0-val;
1249  vect_chg_sgn(vec);
1250  }
1251 
1252  /* Vnew = (c/p)*vec + (val/p)*Vaux = (c/p)*vec + (val/p)*(Vold - c*var) */
1253  for(assert = ps->egalites; assert != NULL; assert = assert->succ) {
1254  Pvecteur v_old = assert->vecteur;
1255  int coeff = vect_coeff(Var, v_old);
1256  if(coeff != 0) {
1257  int p = pgcd(coeff, val);
1258 
1259  assert->vecteur = vect_cl2_ofl_ctrl(coeff/p, vec,
1260  val/p,
1261  vect_cl2_ofl_ctrl(1, v_old, -1,
1262  vect_new(Var,
1263  coeff),
1264  NO_OFL_CTRL),
1265  NO_OFL_CTRL);
1266  }
1267  }
1268  for(assert = ps->inegalites; assert != NULL; assert = assert->succ) {
1269  Pvecteur v_old = assert->vecteur;
1270  int coeff = vect_coeff(Var, v_old);
1271  if(coeff != 0) {
1272  int p = pgcd(coeff, val);
1273 
1274  assert->vecteur = vect_cl2_ofl_ctrl(coeff/p, vec,
1275  val/p,
1276  vect_cl2_ofl_ctrl(1, v_old, -1,
1277  vect_new(Var,
1278  coeff),
1279  NO_OFL_CTRL),
1280  NO_OFL_CTRL);
1281  }
1282  }
1283  vect_rm((Pvecteur) ps->base);
1284  ps->base = (Pbase) NULL;
1285  sc_creer_base(ps);
1286 
1287  if(get_debug_level() > 8) {
1288 fprintf(stderr, "\t\t\tApres Sub: \n");
1289 fprint_psysteme(stderr, ps);
1290 fprintf(stderr, "\n");
1291  }
1292 
1293 }
1294 
1295 
1296 /* ======================================================================== */
1297 /*
1298  * Pvecteur old_prototype_factorize(Ppolynome pp, Variable var)
1299  */
1301 Ppolynome pp;
1302 Variable var;
1303 {
1304  Pvecteur pv = NULL;
1305 
1306  if(POLYNOME_NUL_P(pp))
1307  pv = VECTEUR_NUL;
1308  else if(var == TCST)
1309  pv = vect_new(TCST, (int) polynome_TCST(pp));
1310  else {
1311  Ppolynome ppp;
1312 
1313  for(ppp = pp; ppp != NULL; ppp = ppp->succ) {
1314  Variable newvar = VARIABLE_UNDEFINED;
1315  int newval;
1316  Pvecteur vec, newpv;
1317  entity first = entity_undefined, second = entity_undefined;
1318  bool factor_found = true;
1319 
1320  vec = (ppp->monome)->term;
1321  for(; (vec != NULL) && (second == entity_undefined); vec = vec->succ) {
1322  second = first;
1323  first = (entity) vec->var;
1324  }
1325  if(vec != NULL)
1326  pips_internal_error("Vecteur should contains 2 var");
1327  else if(same_entity_p(first, (entity) var))
1328  if(second == entity_undefined)
1329  newvar = TCST;
1330  else
1331  newvar = (Variable) second;
1332  else if(same_entity_p(second, (entity) var))
1333  newvar = (Variable) first;
1334  else
1335  factor_found = false;
1336 
1337  if(factor_found) {
1338  newval = (int) (ppp->monome)->coeff;
1339  newpv = vect_new(newvar, newval);
1340  newpv->succ = pv;
1341  pv = newpv;
1342  }
1343  }
1344  }
1345 
1346  return(pv);
1347 }
1348 
basic make_basic(enum basic_utype tag, void *val)
Definition: ri.c:155
storage make_storage(enum storage_utype tag, void *val)
Definition: ri.c:2273
value make_value(enum value_utype tag, void *val)
Definition: ri.c:2832
variable make_variable(basic a1, list a2, list a3)
Definition: ri.c:2895
type make_type(enum type_utype tag, void *val)
Definition: ri.c:2706
static int count
Definition: SDG.c:519
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
#define pgcd(a, b)
Pour la recherche de performance, selection d'une implementation particuliere des fonctions.
void const char const char const int
int Value
static int num
Definition: bourdoncle.c:137
#define A(i, j)
comp_matrice.c
Definition: comp_matrice.c:63
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
Definition: alloc.c:73
int contrainte_subst_ofl_ctrl(Variable v, Pcontrainte def, Pcontrainte c, bool eq_p, int ofl_ctrl)
int contrainte_subst_ofl_ctrl(Variable v, Pcontrainte def, Pcontrainte c Boolean eq_p,...
Definition: binaires.c:107
Pcontrainte contrainte_var_min_coeff(Pcontrainte, Variable, Value *, bool)
Pcontrainte contrainte_var_min_coeff(Pcontrainte contraintes, Variable v, int *coeff) input : a list ...
Definition: unaires.c:345
bool egalite_normalize(Pcontrainte)
bool egalite_normalize(Pcontrainte eg): reduction d'une equation diophantienne par le pgcd de ses coe...
Definition: normalize.c:136
#define F
Definition: freia-utils.c:51
#define CHUNK(x)
Definition: genC.h:90
void free(void *)
#define vertex_successors(x)
Definition: graph.h:154
#define SUCCESSOR(x)
SUCCESSOR.
Definition: graph.h:86
#define graph_vertices(x)
Definition: graph.h:82
#define VERTEX(x)
VERTEX.
Definition: graph.h:122
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
void gen_remove(list *cpp, const void *o)
remove all occurences of item o from list *cpp, which is thus modified.
Definition: list.c:685
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
size_t gen_length(const list l)
Definition: list.c:150
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
list gen_append(list l1, const list l2)
Definition: list.c:471
void * hash_get(const hash_table htp, const void *key)
this function retrieves in the hash table pointed to by htp the couple whose key is equal to key.
Definition: hash.c:449
void fprint_entity_list(FILE *fp, list l)
void fprint_entity_list(FILE *fp,list l): prints a list of entities on file fp.
Definition: entity.c:3188
list base_to_list(Pbase base)
Most includes are centralized here.
#define B(A)
Definition: iabrev.h:61
#define D(A)
Definition: iabrev.h:56
static void term(Pproblem XX, int s, Value k, int x)
Definition: isolve.c:315
#define matrice_free(m)
Definition: matrice-local.h:78
#define matrice_new(n, m)
Allocation et desallocation d'une matrice.
Definition: matrice-local.h:77
Value * matrice
package matrice
Definition: matrice-local.h:71
int matrice_hermite_rank(matrice a, int n, int m __attribute__((unused)))
int matrice_hermite_rank(matrice a, int n, int m): rang d'une matrice en forme de hermite
Definition: hermite.c:178
void matrice_hermite(Value *MAT, int n, int m, Value *P, Value *H, Value *Q, Value *det_p, Value *det_q)
package matrice
Definition: hermite.c:78
#define pips_internal_error
Definition: misc-local.h:149
int get_debug_level(void)
GET_DEBUG_LEVEL returns the current debugging level.
Definition: debug.c:67
Pbase list_to_base(list l)
Pbase list_to_base(list l): returns the Pbase that contains the variables of list "l",...
#define MODULE_SEP_STRING
Definition: naming-local.h:30
#define assert(ex)
Definition: newgen_assert.h:41
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
int bool
we cannot use an enum or stdbool because we need to be compatible with newgen, thus boolean need to h...
Definition: newgen_types.h:78
#define UU
Definition: newgen_types.h:98
#define MAPPING_MODULE_NAME
dfg_arc_label arc_label
Name : utils.c Package : paf-util Author : Alexis Platonoff Date : july 1993.
Definition: utils.c:88
Ppolynome vecteur_mult(Pvecteur v1, Pvecteur v2)
========================================================================
Definition: utils.c:2024
Psysteme find_implicit_equation(Psysteme ps)
========================================================================
Definition: utils.c:2350
dfg_vertex_label vertex_label
Definition: utils.c:89
Ppolynome prototype_var_subst(Ppolynome pp, Variable var, Ppolynome ppsubst)
=================================================================
Definition: utils.c:1978
int vertex_int_stmt(vertex v)
===========================================================================
Definition: utils.c:866
Pvecteur prototype_factorize(Ppolynome pp, Variable var)
========================================================================
Definition: utils.c:2070
void contraintes_with_sym_cst_to_matrices(Pcontrainte pc, Pbase index_base, Pbase const_base, matrice A, matrice B, int n, int m1, int m2)
Creation de la matrice A correspondant au systeme lineaire et de la matrice correspondant a la partie...
Definition: utils.c:446
Pcontrainte polynome_to_contrainte(Ppolynome pp)
========================================================================
Definition: utils.c:1095
const char * pu_variable_name(Variable)
package mapping : Alexis Platonoff, april 1993
Definition: print.c:421
void pu_vect_fprint(FILE *, Pvecteur)
===========================================================================
Definition: print.c:446
bool pu_is_inferior_var(Variable, Variable)
void fprint_psysteme(FILE *, Psysteme)
===========================================================================
Definition: print.c:302
#define communication_shift(x)
Definition: paf_ri.h:265
#define dataflow_communication(x)
Definition: paf_ri.h:346
#define communication_undefined
Definition: paf_ri.h:236
#define communication_reduction(x)
Definition: paf_ri.h:263
#define communication_broadcast(x)
Definition: paf_ri.h:261
#define Q
Definition: pip__type.h:39
Ppolynome make_polynome(float coeff, Variable var, Value expo)
Ppolynome make_polynome(float coeff, Variable var, Value expo) PRIVATE allocates space for,...
Definition: pnome-alloc.c:100
void polynome_fprint(FILE *fd, Ppolynome pp, char *(*variable_name)(Variable), int *is_inferior_var)
void polynome_fprint(FILE* fd, Ppolynome pp, char* (*variable_name)(), bool (*is_inferior_var)()) Out...
Definition: pnome-io.c:173
Pbase polynome_used_var(Ppolynome pp, int *is_inferior_var)
Pbase polynome_used_var(Ppolynome pp, bool *is_inferior_var()) PRIVATE Returns, in a Pbase,...
Definition: pnome-reduc.c:204
float polynome_TCST(Ppolynome pp)
float polynome_TCST(Ppolynome pp) returns the constant term of polynomial pp.
Definition: pnome-reduc.c:156
#define POLYNOME_NUL
#define POLYNOME_UNDEFINED
#define POLYNOME_UNDEFINED_P(pp)
#define POLYNOME_NUL_P(pp)
#define SUCC_DATAFLOWS(s)
#define LAMBD_COEFF
#define MU_COEFF
#define INDEX_VARIA
#define INDEX_COEFF
Ppolynome apply_farkas(Ppolynome F, Psysteme D, list *L, int *count_lambdas)
Definition: utils.c:669
void my_substitute_var_with_vec(Psysteme ps, entity var, int val, Pvecteur vec)
===========================================================================
Definition: utils.c:1219
Psysteme new_elim_var_with_eg(Psysteme ps, list *init_l, list *elim_l)
========================================================================
Definition: utils.c:338
bool is_shift_p(dataflow df)
========================================================================
Definition: utils.c:1176
list rm_non_x_var(list l)
========================================================================
Definition: utils.c:260
bool is_broadcast_p(dataflow df)
========================================================================
Definition: utils.c:1088
Psysteme plc_elim_var_with_eg(Psysteme ps, list *init_l, list *elim_l)
========================================================================
Definition: utils.c:426
bool compare_dfs_weight(chunk *d1, chunk *d2)
========================================================================
Definition: utils.c:181
list get_stmt_index_coeff(int stmt, hash_table StoL)
========================================================================
Definition: utils.c:792
list unify_lists(list l1, list l2)
========================================================================
Definition: utils.c:295
int count_implicit_equation(Psysteme ps)
========================================================================
Definition: utils.c:562
entity find_or_create_coeff(string prefix, int n)
========================================================================
Definition: utils.c:238
list prgm_parameter_l
lint
Definition: prgm_mapping.c:115
int communication_dim(dataflow df)
========================================================================
Definition: utils.c:1116
Pvecteur old_prototype_factorize(Ppolynome pp, Variable var)
========================================================================
Definition: utils.c:1300
bool is_index_coeff_p(entity e)
========================================================================
Definition: utils.c:144
list insert_sort(list l, bool(*compare_obj)())
========================================================================
Definition: utils.c:110
list get_graph_dataflows(graph g)
========================================================================
Definition: utils.c:765
bool is_reduction_p(dataflow df)
========================================================================
Definition: utils.c:1150
Psysteme completer_base(Psysteme sys, list var_l, list par_l)
========================================================================
Definition: utils.c:832
bool vecteurs_libres_p(Psysteme sys, Pbase v_base, Pbase c_base)
========================================================================
Definition: utils.c:903
bool compare_nodes_dim(chunk *n1, chunk *n2)
========================================================================
Definition: utils.c:170
bool(* argh)(Pvecteur *, Pvecteur *)
========================================================================
Definition: utils.c:667
list diff_lists(list l1, list l2)
========================================================================
Definition: utils.c:868
char vcid_prgm_mapping_utils[]
Definition: utils.c:29
Psysteme append_eg(Psysteme M1, Psysteme M2)
========================================================================
Definition: utils.c:946
entity make_coeff(string prefix, int n)
========================================================================
Definition: utils.c:209
Psysteme nullify_factors(Ppolynome *pp, list var_l, bool with_remnants)
========================================================================
Definition: utils.c:1026
bool compare_coeff(chunk *c1, chunk *c2)
========================================================================
Definition: utils.c:161
void di_polynome_var_subst_null(Ppolynome *pp, entity var)
========================================================================
Definition: utils.c:980
list put_source_ind(list le)
========================================================================
Definition: utils.c:596
bool compare_unks_frenq(chunk *e1, chunk *e2)
========================================================================
Definition: utils.c:192
hash_table DtfToWgh
Mapping from a dataflow to its distance.
Definition: prgm_mapping.c:105
hash_table StmtToDim
Mapping from a statement to the dim of its bdt.
Definition: prgm_mapping.c:109
hash_table UnkToFrenq
Mapping from a stmt to its mu coeff.
Definition: prgm_mapping.c:112
static hash_table pl
properties are stored in this hash table (string -> property) for fast accesses.
Definition: properties.c:783
#define M2
Definition: r1.c:27
#define M1
Definition: r1.c:26
static const char * prefix
#define MINUS_OPERATOR_NAME
#define NORMALIZE_EXPRESSION(e)
#define make_entity(n, t, s, i)
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
bool same_entity_p(entity e1, entity e2)
predicates on entities
Definition: entity.c:1321
expression make_vecteur_expression(Pvecteur pv)
make expression for vector (Pvecteur)
Definition: expression.c:1650
expression make_entity_expression(entity e, cons *inds)
Definition: expression.c:176
expression make_op_exp(char *op_name, expression exp1, expression exp2)
================================================================
Definition: expression.c:2012
@ is_basic_int
Definition: ri.h:571
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
@ is_value_unknown
Definition: ri.h:3035
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
@ is_storage_rom
Definition: ri.h:2494
#define entity_undefined
Definition: ri.h:2761
#define normalized_tag(x)
Definition: ri.h:1778
#define predicate_undefined
Definition: ri.h:2046
#define expression_normalized(x)
Definition: ri.h:1249
@ is_type_variable
Definition: ri.h:2900
#define normalized_linear(x)
Definition: ri.h:1781
#define predicate_system(x)
Definition: ri.h:2069
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
@ is_normalized_linear
Definition: ri.h:1760
struct Ssysteme * Psysteme
void sc_creer_base(Psysteme ps)
void sc_creer_base(Psysteme ps): initialisation des parametres dimension et base d'un systeme lineair...
Definition: sc_alloc.c:129
void sc_rm(Psysteme ps)
void sc_rm(Psysteme ps): liberation de l'espace memoire occupe par le systeme de contraintes ps;
Definition: sc_alloc.c:277
void sc_add_egalite(Psysteme p, Pcontrainte e)
void sc_add_egalite(Psysteme p, Pcontrainte e): macro ajoutant une egalite e a un systeme p; la base ...
Definition: sc_alloc.c:389
Psysteme sc_new(void)
Psysteme sc_new(): alloue un systeme vide, initialise tous les champs avec des valeurs nulles,...
Definition: sc_alloc.c:55
Psysteme sc_dup(Psysteme ps)
Psysteme sc_dup(Psysteme ps): should becomes a link.
Definition: sc_alloc.c:176
Pcontrainte eq
element du vecteur colonne du systeme donne par l'analyse
Definition: sc_gram.c:108
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
char * strdup()
Psysteme sc_normalize(Psysteme ps)
Psysteme sc_normalize(Psysteme ps): normalisation d'un systeme d'equation et d'inequations lineaires ...
void vect_chg_sgn(Pvecteur v)
void vect_chg_sgn(Pvecteur v): multiplie v par -1
Definition: scalaires.c:151
Definition: pip__tab.h:25
Definition: pip__tab.h:30
Pvecteur vecteur
struct Scontrainte * succ
Pmonome monome
struct Spolynome * succ
Pcontrainte inegalites
Definition: sc-local.h:71
Pcontrainte egalites
Definition: sc-local.h:70
Pbase base
Definition: sc-local.h:75
int nb_eq
Definition: sc-local.h:72
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
Variable var
Definition: vecteur-local.h:90
struct Svecteur * succ
Definition: vecteur-local.h:92
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
Definition: statement.c:54
char * int2a(int)
util.c
Definition: util.c:42
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.
#define NO_OFL_CTRL
struct Svecteur * Pbase
#define VECTEUR_NUL_P(v)
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
#define VARIABLE_UNDEFINED
Definition: vecteur-local.h:64
#define base_dimension(b)
Pvecteur vect_dup(Pvecteur v_in)
Pvecteur vect_dup(Pvecteur v_in): duplication du vecteur v_in; allocation de et copie dans v_out;.
Definition: alloc.c:51
Pvecteur vect_new(Variable var, Value coeff)
Pvecteur vect_new(Variable var,Value coeff): allocation d'un vecteur colineaire au vecteur de base va...
Definition: alloc.c:110
void vect_rm(Pvecteur v)
void vect_rm(Pvecteur v): desallocation des couples de v;
Definition: alloc.c:78
Pvecteur vect_cl2_ofl_ctrl(Value x1, Pvecteur v1, Value x2, Pvecteur v2, int ofl_ctrl)
Pvecteur vect_cl2_ofl(Value x1, Pvecteur v1, Value x2, Pvecteur v2): allocation d'un vecteur v dont l...
Definition: binaires.c:204
Pvecteur vect_cl_ofl_ctrl(Pvecteur v, Value lambda, Pvecteur u, int ofl_ctrl)
Pvecteur vect_cl_ofl_ctrl(Pvecteur v, Value lambda, Pvecteur u, int ofl_ctrl): etape d'acculumulation...
Definition: binaires.c:128
void vect_erase_var(Pvecteur *ppv, Variable v)
void vect_erase_var(Pvecteur * ppv, Variable v): projection du vecteur *ppv selon la direction v (i....
Definition: unaires.c:106
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