PIPS
makebdt.c
Go to the documentation of this file.
1 /*
2 
3  $Id: makebdt.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 #include <stdio.h>
28 #include <setjmp.h>
29 #include <string.h>
30 #include <stdlib.h>
31 
32 #include "genC.h"
33 #include "ri.h"
34 #include "constants.h"
35 #include "ri-util.h"
36 #include "misc.h"
37 
38 /* C3 includes */
39 #include "boolean.h"
40 #include "arithmetique.h"
41 #include "vecteur.h"
42 #include "contrainte.h"
43 #include "ray_dte.h"
44 #include "sommet.h"
45 #include "sg.h"
46 #include "sc.h"
47 #include "polyedre.h"
48 #include "union.h"
49 #include "matrice.h"
50 #include "matrix.h"
51 #include "sparse_sc.h"
52 
53 /* Pips includes */
54 #include "complexity_ri.h"
55 #include "database.h"
56 #include "dg.h"
57 #include "parser_private.h"
58 #include "property.h"
59 #include "reduction.h"
60 #include "tiling.h"
61 /* GO:
62 #include "loop_normalize.h"
63 */
64 
65 
66 #include "text.h"
67 #include "text-util.h"
68 #include "graph.h"
69 #include "paf_ri.h"
70 #include "paf-util.h"
71 #include "pipsdbm.h"
72 #include "resources.h"
73 #include "array_dfg.h"
74 #include "pip.h"
75 #include "static_controlize.h"
76 #include "scheduling.h"
77 
78 /* Local defines */
81 
82 #define my_polynome_fprint(fp,p) \
83  polynome_fprint(fp,p,entity_local_name,default_is_inferior_var);
84 
86 
87 typedef struct n_coef {
90  struct n_coef *next;
92 
93 typedef struct bdt_node {
98 
99 typedef struct sys_list {
100  int nb;
102  struct sys_list *next;
104 
105 /*======================================================================*/
106 /* entity create_var_name(type,source,dest,count) : create the variable
107  * to iut in the vector that we construct in "create_farkas_poly".
108  * Returns an entity for printing commmodities.
109  *
110  * AC 93/11/28
111  */
112 
113 entity create_var_name(Type, source, dest, count)
114 
115  char *Type;
116  int source;
117  int dest;
118  int count;
119 {
120  char *name;
121 
122  asprintf(&name, "%s_%d_%d_%d", Type, source, dest, count);
123 
124  entity e = (create_named_entity(name));
125  free(name);
126  return e;
127 }
128 
129 /*======================================================================*/
130 /* Psys_list add_elt_to_sys_list(ls, s, ps): add a system in the list
131  * of Psysteme.
132  *
133  * AC 94/01/27
134  */
135 
137 
138  Psys_list ls;
139  int s;
140  Psysteme ps;
141 {
142  Psys_list aux, la, lb;
143 
144  aux = (Psys_list)malloc(sizeof(sys_list));
145  aux->nb = s;
146  aux->sys = sc_dup(ps);
147  aux->next = NULL;
148 
149  if (ls == NULL) ls = aux;
150  else
151  {
152  lb = ls;
153  while (lb != NULL)
154  {
155  la = lb;
156  lb = lb->next;
157  }
158  la->next = aux;
159  }
160 
161  return(ls);
162 }
163 
164 /*======================================================================*/
165 /* void fprint_sys_list(fp,ls): print in the file fp the list of systems
166  * ls.
167  *
168  * AC 94/01/27
169  */
170 
171 static void fprint_sys_list(fp,ls)
172 
173  FILE *fp;
174  Psys_list ls;
175 {
176  for (; ls != NULL; ls = ls->next)
177  {
178  fprintf(fp,"\n");
179  fprint_psysteme(fp, ls->sys);
180  fprintf(fp,"\n");
181  }
182 }
183 
184 /*======================================================================*/
185 /* Pn_coef make_n_coef(e,v): allocating the space for a Pn_coef, that is
186  * a cell containing an entity and a Pvecteur, and returns a Pn_coef.
187  *
188  * AC 93/11/15
189  */
190 
191 static Pn_coef make_n_coef(e, v)
192 
193  entity e;
194  Pvecteur v;
195 {
196  Pn_coef aux;
197 
198  aux = (Pn_coef)malloc(sizeof(n_coef));
199  aux->n_ent = e;
200  aux->n_vect = v;
201  aux->next = NULL;
202 
203  return (aux);
204 }
205 
206 /*======================================================================*/
207 /* Pn_coef add_n_coef_to_list(l1,l2): add the n_coef l2 at the end of
208  * the list l1.
209  *
210  * AC 93/11/15
211  */
212 
214 
215  Pn_coef l1, l2;
216 {
217  Pn_coef p = l1;
218 
219  if (p == NULL) l1 = l2;
220  else
221  {
222  while (p->next != NULL) p = p->next;
223  p->next = l2;
224  }
225 
226  return(l1);
227 }
228 
229 /*======================================================================*/
230 /* void fprint_coef_list(fp,l): print in the file fp the list of Pn_coef
231  * l.
232  *
233  * AC 93/11/15
234  */
235 
236 static void fprint_coef_list(fp,l)
237 
238  FILE *fp;
239  Pn_coef l;
240 {
241  while (l != NULL)
242  {
243  fprintf(fp,"Entite : ");
244  fprintf(fp,"%s",entity_local_name(l->n_ent));
245  fprintf(fp,", Vecteur : ");
246  pu_vect_fprint(fp,l->n_vect);
247  l = l->next;
248  }
249 }
250 
251 /*==================================================================*/
252 /* Pn_coef add_lcoef_to_lcoef(l1, l2): appends the list of Pn_coef l2
253  * to l1.
254  *
255  * AC 93/11/16
256  */
257 
259 
260  Pn_coef l1, l2;
261 {
262  Pn_coef l;
263 
264  while (l2 != NULL)
265  {
266  l = l2;
267  l2 = l2->next;
268  l->next = NULL;
269  l1 = add_n_coef_to_list(l1, l);
270  }
271  return (l1);
272 }
273 
274 /*==================================================================*/
275 /* list extract_lambda_list(l): from the list l, extract the sublist
276  * of entities whose name is beginning by "LAMBDA".
277  *
278  * AC 93/11/15
279  */
280 
282 
283  list l;
284 {
285  entity ent;
286  char *name;
287  list laux = NIL;
288 
289  while (l != NIL)
290  {
291  ent = ENTITY(CAR(l));
292  name = entity_local_name(ent);
293  if (!strncmp(name, "LAMBDA", 6))
294  ADD_ELEMENT_TO_LIST(laux, ENTITY, ent);
295  l = CDR(l);
296  }
297 
298  return (laux);
299 }
300 
301 /*==================================================================*/
302 /* list reorder_base(l,lu) : reorder the base list l with the
303  * unknows lu contains in first positions in the list.
304  *
305  * AC 93/11/17
306  */
307 
309 
310  list l, lu;
311 {
312  list laux = NIL;
313  entity ent;
314 
315  for (; lu != NIL; lu = CDR(lu))
316  {
317  ent = ENTITY(CAR(lu));
318  ADD_ELEMENT_TO_LIST(laux, ENTITY, ent);
319  }
320 
321  for (; l != NIL; l = CDR(l))
322  {
323  ent = ENTITY(CAR(l));
324  if (!(is_entity_in_list_p(ent, laux)))
325  ADD_ELEMENT_TO_LIST(laux, ENTITY, ent);
326  }
327  return(laux);
328 }
329 
330 /*==================================================================*/
331 /* Pn_coef add_lambda_list(lunk, lvar): lvar contains the lambda list
332  * that we transform in a list of Pn_coef that we append to lunk.
333  *
334  * AC 93/11/15
335  */
336 
337 static Pn_coef add_lambda_list(lunk, lvar)
338 
339  Pn_coef lunk;
340  list lvar;
341 {
342  Pn_coef aux;
343 
344  while (lvar != NIL)
345  {
346  aux = make_n_coef(ENTITY(CAR(lvar)), VECTEUR_NUL);
347  lunk = add_n_coef_to_list(lunk, aux);
348  lvar = CDR(lvar);
349  }
350 
351  return (lunk);
352 }
353 
354 /*==================================================================*/
355 /* list make_x_list(c): build a list of entity of type X_nb where
356  * nb is a number between 0 and c.
357  *
358  * AC 94/01/27
359  */
360 
362 
363  int c;
364 {
365  entity ent;
366  char *name;
367  list laux = NIL;
368  int i;
369 
370  name = (char*) malloc(10);
371 
372  for (i = 0; i <= c; i++)
373  {
374  sprintf(name, "X_%d", i);
375  ent = create_named_entity(name);
376  ADD_ELEMENT_TO_LIST(laux, ENTITY, ent);
377  }
378  free(name);
379 
380  return(laux);
381 }
382 
383 /*==================================================================*/
384 /* Pn_coef add_x_list(lunk, lvar, me): create the list of Pn_coef
385  * for the X, the second member is the big parameter we will use
386  * for PIP.
387  *
388  * AC 94/01/27
389  */
390 
391 static Pn_coef add_x_list(lunk, lvar, me)
392 
393  Pn_coef lunk;
394  list lvar;
395  entity *me;
396 {
397  Pn_coef aux, laux = NULL;
398  Pvecteur vect_m;
399 
400  *me = create_named_entity("My_Own_Private_M");
401  vect_m = vect_new((Variable)(*me), -1);
402 
403  while (lvar != NIL)
404  {
405  aux = make_n_coef(ENTITY(CAR(lvar)), vect_m);
406  laux = add_n_coef_to_list(laux, aux);
407  lvar = CDR(lvar);
408  }
409  lunk = add_lcoef_to_lcoef(laux, lunk);
410 
411  return(lunk);
412 }
413 
414 /*==================================================================*/
415 /* list extract_var_list(lc): extract from the list of Pn_coef lc
416  * the variables and put them in a list it returns.
417  *
418  * AC 93/11/15
419  */
420 
422 
423  Pn_coef lc;
424 {
425  list l = NIL;
426 
427  for ( ; lc != NULL; lc = lc->next)
428  ADD_ELEMENT_TO_LIST(l, ENTITY, lc->n_ent);
429 
430  return(l);
431 }
432 
433 /*==================================================================*/
434 /* void clean_list_of_unk(l, sc): update the list of unknown for the
435  * problem by erasing the unknown that have been already calculated.
436  *
437  * AC 94/01/27
438  */
439 
440 static void clean_list_of_unk(l, sc)
441 
442  Pn_coef *l;
443  Psysteme *sc;
444 {
445  Pn_coef lout, laux, lin = *l;
446  list base;
447 
448  lout = NULL;
449  base = base_to_list((*sc)->base);
450 
451  while (lin != NULL)
452  {
453  laux = lin;
454  lin = lin->next;
455  laux->next = NULL;
456  if (is_entity_in_list_p(laux->n_ent, base))
457  lout = add_n_coef_to_list(lout, laux);
458  }
459 
460  base = extract_var_list(lout);
461  (*sc)->base = list_to_base(base);
462 
463  *l = lout;
464 }
465 
466 /*==================================================================*/
467 /* list make_list_of_n(n,c) : function that creates a list of new
468  * entities as "u1" or "u2" it returns.
469  *
470  * AC 93/11/16
471  */
472 
474 
475  char *n;
476  int c;
477 {
478  entity ent;
479  list l = NIL;
480  char *name;
481  int i;
482 
483  name = (char*) malloc(10);
484 
485  for (i = 1; i <= c; i++)
486  {
487  sprintf(name, "%s%d", n, i);
488  ent = create_named_entity(name);
489  ADD_ELEMENT_TO_LIST(l, ENTITY, ent);
490  }
491  free(name);
492  return(l);
493 }
494 
495 /*======================================================================*/
496 /* bool is_stat_in_pred_list(stat, pred_list): tests if the stat is
497  * in the list pred_list.
498  *
499  * AC 93/12/06
500  */
501 
502 bool is_stat_in_pred_list(stat, pred_list)
503 
504  int stat;
505  list pred_list;
506 {
507  list l;
508  bool bool = false;
509  int s;
510 
511  l = pred_list;
512 
513  if (l == NIL)
514  bool = false;
515  else {
516  for ( ; l != NIL; l = CDR(l)) {
517  s = INT(CAR(l));
518  if (s == stat)
519  bool = true;
520  }
521  }
522  return(bool);
523 }
524 
525 /*======================================================================*/
526 /* Psysteme include_parameters_in_sc(sys,source): include in the systeme
527  * "sys" the parameters that it does not contain at that moment, and
528  * put them under an inequality (for example: n>=0).
529  *
530  * AC 94/01/05
531  */
532 
534 
535  Psysteme sys;
536  int source;
537 {
538  list lent;
539  Variable var;
540  Pvecteur vect;
541  Pcontrainte cont;
542  static_control stct;
543 
545  lent = static_control_params(stct);
546 
547  if (sys == NULL) sys = sc_new();
548 
549  for (; lent != NIL; lent = CDR(lent))
550  {
551  var = (Variable)ENTITY(CAR(lent));
552 
553  if (!system_contains_var(sys, var))
554  {
555  vect = vect_new(var, (Value)-1);
556  cont = contrainte_make(vect);
557  sc_add_inegalite(sys, cont);
558  sys->base = base_add_variable(sys->base, var);
559  sys->dimension++;
560  }
561  }
562 
563  return(sys);
564 }
565 
566 /*======================================================================*/
567 /* create_farkas_poly() : that function creates the farkas polynom of a
568  * node, from the execution domain "psys". The coefficients created have
569  * the form NAME_i_j_k with i the statement of the source node, j the
570  * statement of the destination node (=0 in the case of a MU polynom)
571  * and k the number of the coefficient. The name NAME is given by Type.
572  * The polynome created is put in "p", each coefficient created is
573  * put in the list of Pn_coef "l" with the vector he is the coef. of,
574  * (0 in case of a Lambda coef), and "c" is a counter of tthe created
575  * coefficient.
576  *
577  * AC 93/10/28
578  */
579 
580 static void create_farkas_poly(Psys, Type, source, dest, p, l, c)
581 
582  Psysteme Psys;
583  char *Type;
584  int source, dest;
585  Ppolynome *p;
586  Pn_coef *l;
587  int *c;
588 {
589  int i, count = *c;
590  Pcontrainte cont;
591  Pvecteur vect, vect_aux;
592  Ppolynome poly, poly_aux;
593  entity ent;
594  Pn_coef coef;
595 
596  poly = *p;
597 
598  if (get_debug_level() > 5)
599  fprintf(stderr,"\nXXX creer equation farkas XXX\n");
600 
601  if (POLYNOME_UNDEFINED_P(poly))
602  {
603  /* creation of the constant term of the polynom */
604  ent = create_var_name(Type, source, dest, count);
605  vect = vect_new((Variable)TCST, (Value)1);
606  coef = make_n_coef(ent, vect);
607  *l = add_n_coef_to_list(*l, coef);
608  poly = make_polynome((float)1, (Variable)ent, (Value)1);
609  count++;
610 
611  if (!SC_UNDEFINED_P(Psys))
612  {
614  cont = Psys->inegalites;
615 
616  /* exploring the Psystem, i.e. each inegality of the execution */
617  /* domain, and making each component */
618  for (i = 0 ; i < Psys->nb_ineq ; i++)
619  {
620  vect = vect_dup(cont->vecteur);
621  ent = create_var_name(Type, source, dest, count);
622 
623  vect_aux = vect_new((Variable)ent, (Value)1);
624  vect_chg_sgn(vect);
625 
626  coef = make_n_coef(ent, vect);
627  *l = add_n_coef_to_list(*l, coef);
628 
629  poly_aux = vecteur_mult(vect, vect_aux);
630  polynome_add(&poly, poly_aux);
631 
632  count++;
633  cont = cont->succ;
634  }
635  }
636  }
637  else
638  {
639  if (!SC_UNDEFINED_P(Psys))
640  {
642  cont = Psys->inegalites;
643 
644  /* exploring the Psystem, i.e. each inegality of the execution */
645  /* domain, and making each component */
646  for (i = 0 ; i< Psys->nb_ineq ; i++)
647  {
648  vect = vect_dup(cont->vecteur);
649  ent = create_var_name(Type, source, dest, count);
650 
651  vect_aux = vect_new((Variable)ent, (Value)1);
652  vect_chg_sgn(vect);
653 
654  coef = make_n_coef(ent, vect);
655  *l = add_n_coef_to_list(*l, coef);
656 
657  poly_aux = vecteur_mult(vect, vect_aux);
658  polynome_add(&poly, poly_aux);
659 
660  count++;
661  cont = cont->succ;
662  }
663  }
664  }
665 
666  *p = poly;
667 
668  if (get_debug_level() > 5)
669  {
670  fprintf(stderr,"\nP[%d] = ",source);
671  my_polynome_fprint(stderr, poly);
672  fprintf(stderr,"\n");
673  }
674 
675  *c = count;
676 }
677 
678 /*==================================================================*/
679 /* void make_proto((hash_table)h, (sccs)rg): function that goes through
680  * the reverse graph "rg", and for each node of each scc, initialize
681  * the node structure associated with each node, that is, creates the
682  * Farkas polynom of each node.
683  *
684  * AC 93/10/28
685  */
686 
687 static void make_proto(h, rg)
688 
689  hash_table h;
690  sccs rg;
691 {
692  list lscc, lver;
693  Pbdt_node this_node;
694  Ppolynome this_poly;
695  Psysteme this_sys;
696  int this_stat, count;
697  vertex this_ver;
698  Pn_coef lvar;
699 
700  for (lscc = sccs_sccs(rg); lscc != NIL; lscc = CDR(lscc))
701  {
702  scc scc_an = SCC(CAR(lscc));
703  for (lver = scc_vertices(scc_an); lver != NIL; lver = CDR(lver))
704  {
705  lvar = NULL;
706  this_poly = POLYNOME_UNDEFINED;
707  this_ver = VERTEX(CAR(lver));
709  vertex_vertex_label(this_ver));
712  this_sys = include_parameters_in_sc(this_sys, this_stat);
713  count = 0;
714  create_farkas_poly(this_sys, "MU", this_stat, 0, &this_poly,\
715  &lvar, &count);
716  this_node = (Pbdt_node)malloc(sizeof(bdt_node));
717  this_node->n_poly = this_poly;
718  this_node->n_bdt = (bdt)NIL;
719  this_node->n_var = lvar;
720 
721  hash_put(h, (char *) this_stat, (char *) this_node);
722  }
723  }
724 }
725 
726 /*==================================================================*/
727 /* build_bdt_null(v): update the hash table by making the
728  * schedule null
729  *
730  * AC 93/10/29
731  */
732 
734 
735  vertex v;
736 {
737  Pbdt_node node;
738  int stat;
739  schedule sche;
740  expression exp;
741  list lexp, lsche;
742  bdt b;
743 
745  node = (Pbdt_node)hash_get(h_node, (char *) stat);
746  exp = int_to_expression(0);
747 
748  lexp = CONS(EXPRESSION, exp, NIL);
749  sche = make_schedule(stat, predicate_undefined, lexp);
750  lsche = CONS(SCHEDULE, sche, NIL);
751  b = make_bdt(lsche);
752  node->n_bdt = true_copy_bdt(b);
753 
754  if (get_debug_level() > 5) fprint_bdt(stderr,node->n_bdt);
755 
756  return(b);
757 }
758 
759 /*==================================================================*/
760 /* if_no_pred(s, b): that function tests if the scc studied has
761  * only 1 vertex and no predecessor. Returns true in this case. At
762  * the same time, this function updates the field schedule of the
763  * hash table with the proper schedule, that is time=0
764  *
765  * AC 93/10/29
766  */
767 
768 bool if_no_pred(s, b)
769 
770  scc s;
771  bdt *b;
772 {
773  list lver_a, lver_b, lsucc;
774  vertex v;
775 
776  lver_a = scc_vertices(s);
777  lver_b = CDR(lver_a);
778  v = VERTEX(CAR(lver_a));
779  lsucc = vertex_successors(v);
780 
781  if ((lver_b == NIL) && (lsucc == NIL))
782  {
783  *b = build_bdt_null(v);
784  return(true);
785  }
786  else return(false) ;
787 }
788 
789 /*==================================================================*/
790 /* Psysteme erase_trivial_ineg(p): erase from the psysteme p all
791  * inequalities like -MU<=0.
792  *
793  * AC 93/11/22
794  */
795 
797 
798  Psysteme p;
799 {
800  Pcontrainte cont;
801  Pvecteur vect;
802 
803  if (!SC_UNDEFINED_P(p))
804  {
805  for (cont = p->inegalites ; cont != NULL ; cont = cont->succ)
806  {
807  vect = cont->vecteur;
808  if ((vect != NULL)&&value_negz_p(vect->val)&&(vect->succ == NULL))
809  {
810  vect_rm(cont->vecteur);
811  cont->vecteur = NULL;
812  }
813  }
814  }
815 
816  return(p);
817 }
818 
819 /*==================================================================*/
820 /* Ppolynome include_trans_in_poly((int)s,(Ppolynome)p,(list)l):
821  * list contains the list of expression defining the edge trans-
822  * formation we want to apply to the node of statement s.
823  * This function replaces the old variable values by their new
824  * values in the polynome p. This is done in 2 steps; first we replace
825  * each variable by a local one,and put this one in a list; then we
826  * replace the local variable by the expression of the transformation.
827  *
828  * AC 93/11/03
829  */
830 
831 
833 
834  int s, *d;
835  Ppolynome p;
836  list l;
837 {
838  list lindice, lexp, lind, lvar, lv;
839  static_control stct;
840  char *name;
841  expression exp;
842  Ppolynome poly_trans;
843  int count = 0, den = 1;
844  Variable var, v;
845  entity ent;
846 
847  if ((p != (Ppolynome)NIL)||(l != NIL))
848  {
849  /* we get the list of the englobing loop of the studied node */
851  lindice = static_control_to_indices(stct);
852 
853  lvar = NIL;
854  name = (char*) malloc(100);
855 
856  /* replace all variables by a local one */
857  for (lind = lindice; lind != NIL; lind = CDR(lind))
858  {
859  var = (Variable)ENTITY(CAR(lind));
860  sprintf(name, "myownprivatevariable_%d", count);
861  ent = create_named_entity(name);
862 
863  if (polynome_contains_var(p, var))
864  poly_chg_var(p, var, (Variable)ent);
865  ADD_ELEMENT_TO_LIST(lvar, ENTITY, ent);
866  count++;
867  }
868  free(name);
869 
870  /* replace all local variables by the transformation */
871  lexp = l;
872 
873  for (lv = lvar; lv != NIL; lv = CDR(lv))
874  {
875  exp = EXPRESSION(CAR(lexp));
876  analyze_expression(&exp, &den);
877  poly_trans = expression_to_polynome(exp);
878  v = (Variable)ENTITY(CAR(lv));
879  if (polynome_contains_var(p, v))
880  p = prototype_var_subst(p, v, poly_trans);
881  lexp = CDR(lexp);
882  }
883 
884  gen_free_list(lindice);
885  gen_free_list(lvar);
886  }
887 
888  *d = den;
889 
890  return(p);
891 }
892 
893 /*==================================================================*/
894 /* Psysteme transform_in_ineq((Psysteme)sc,(list)l):change a system of
895  * equalities in a system of inequalities, and at the same time, try
896  * to eliminate some lambda variables that are useless.
897  *
898  * AC 93/11/08
899  */
900 
901 
903 
904  Psysteme sc;
905  list l;
906 {
907  Psysteme Psyst = sc_dup(sc);
908  Pvecteur v;
909  Pcontrainte c;
910  Variable var;
911  Value val;
912 
913  /* in each vector, isolate a lambda variable if it exists */
914  c = Psyst->egalites;
915 
916  while ((c != NULL) && (l != NIL))
917  {
918  var = (Variable)ENTITY(CAR(l));
919  v = c->vecteur;
920 
921  if (base_contains_variable_p((Pbase)v, var))
922  {
923  val = vect_coeff(var, v);
924  if (value_negz_p(val)) vect_chg_sgn(c->vecteur);
925  vect_erase_var(&c->vecteur, var);
926  }
927  c = c->succ;
928  l = CDR(l);
929  }
930 
931  /* transform each equality in an inequality */
932  sc_elim_empty_constraints(Psyst, true);
933  sc->inegalites = Psyst->egalites;
934  Psyst->egalites = sc->egalites;
935  Psyst->nb_eq = sc->nb_eq;
936  sc->nb_ineq = sc->nb_eq;
937  sc->nb_eq = 0;
938  sc->egalites = NULL;
939 
940  sc_rm(Psyst);
941  sc->base = NULL;
942  sc_creer_base(sc);
943 
944  return(sc);
945 }
946 
947 /*==================================================================*/
948 /* int get_m_coef(e, de): get the coefficient of the variable "m"
949  * in the expression "e".
950  *
951  * AC 94/01/20
952  */
953 
954 int get_m_coef(e, de)
955 
956  expression *e;
957  int *de;
958 {
959  int d, mc = 0;
960  Pvecteur vect;
961  expression exp, e_aux = *e;
962  entity ent;
963 
964  analyze_expression(&e_aux, &d);
965 
966  if (d == 1)
967  {
968  NORMALIZE_EXPRESSION(e_aux);
970 
971  while (!VECTEUR_NUL_P(vect))
972  {
973  if (vect->var != TCST)
974  {
975  ent = (entity)vect->var;
976  if (!strncmp(entity_local_name(ent), "My_Own_Private_M", 16))
977  mc = VALUE_TO_INT(vect->val);
978  }
979  vect = vect->succ;
980  }
981  }
982  else
983  {
985  (expression_syntax(e_aux)))));
988 
989  while (!VECTEUR_NUL_P(vect))
990  {
991  if (vect->var != TCST)
992  {
993  ent = (entity)vect->var;
994  if (!strncmp(entity_local_name(ent), "My_Own_Private_M", 16))
995  mc = VALUE_TO_INT(vect->val);
996  }
997  vect = vect->succ;
998  }
999  mc/=d;
1000  }
1001 
1002  unnormalize_expression(e_aux);
1003 
1004  *de = d;
1005  *e = e_aux;
1006 
1007  return (mc);
1008 }
1009 
1010 /*=======================================================================*/
1011 /* bool coef_of_M_equal(exp1, exp2): tests if two expressions have the
1012  * same coefficient of "M".
1013  *
1014  * AC 94/02/08
1015  */
1016 
1017 bool coef_of_M_equal(exp1, exp2)
1018 
1019  expression *exp1, *exp2;
1020 {
1021  expression e1 = *exp1, e2 = *exp2;
1022  int d1, d2, m1, m2;
1023 
1024  m1 = get_m_coef(&e1, &d1);
1025  m2 = get_m_coef(&e2, &d2);
1026 
1027  return( !(m1-m2) );
1028 }
1029 
1030 /*=======================================================================*/
1031 /* bool list_of_exp_equals_1n_p(l1,l2,n): tests the equality of 2 lists
1032  * of expressions on the first n terms.
1033  *
1034  * AC 94/01/25
1035  */
1036 
1038 
1039  list l1, l2;
1040  int n;
1041 {
1042  bool is_equal = true;
1043  expression exp1, exp2;
1044  int i;
1045 
1046  if (get_debug_level() > 5)
1047  {
1048  fprintf(stderr,"\nPremiere liste: ");
1049  fprint_list_of_exp(stderr, l1);
1050  fprintf(stderr,"\nDeuxieme liste: ");
1051  fprint_list_of_exp(stderr, l2);
1052  }
1053 
1054  exp1 = EXPRESSION(CAR(l1));
1055  exp2 = EXPRESSION(CAR(l2));
1056  is_equal = exp_equals_p(exp1, exp2);
1057  l1 = CDR(l1);
1058  l2 = CDR(l2);
1059 
1060  for (i = 1; (i <= (n-1))&&(is_equal) ; i++)
1061  {
1062  exp1 = EXPRESSION(CAR(l1));
1063  exp2 = EXPRESSION(CAR(l2));
1064  is_equal = coef_of_M_equal(&exp1, &exp2);
1065  l1 = CDR(l1);
1066  l2 = CDR(l2);
1067  }
1068 
1069  return(is_equal);
1070 }
1071 
1072 /*=======================================================================*/
1073 /* quast compact_quast(q, n): try to reduce a quast when it is a condi-
1074  * tional quast by testing the possible equality between the false edge
1075  * and the true edge, and if it exists, suppress one.
1076  *
1077  * AC 94/01/03
1078  */
1079 
1081 
1082  quast q;
1083  int n;
1084 {
1085  quast tq, fq;
1086  quast_value qv;
1087  conditional cond;
1088  list lf, lt;
1089 
1090  if (q == quast_undefined) return (q);
1091 
1092  qv = quast_quast_value(q);
1093  if (qv == quast_value_undefined) return(q);
1094 
1095  if (quast_value_quast_leaf_p(qv)) return(q);
1096  else
1097  {
1098  cond = quast_value_conditional(qv);
1099  tq = conditional_true_quast(cond);
1100  fq = conditional_false_quast(cond);
1101 
1102  /* may be possible source of bug here */
1103  if (quast_undefined_p(tq) || \
1105  return(fq);
1106 
1107  else if (quast_undefined_p(fq) ||\
1109  return(tq);
1110 
1113  {
1115  (quast_quast_value(tq)));
1117  (quast_quast_value(fq)));
1118 
1119  if (list_of_exp_equals_1n_p(lt, lf, n))
1120  {
1121  free_quast(fq);
1122  return(tq);
1123  }
1124  else return(q);
1125  }
1126  else
1127  {
1128  tq = compact_quast(tq, n);
1129  fq = compact_quast(fq, n);
1130 
1133  {
1135  (quast_quast_value(tq)));
1137  (quast_quast_value(fq)));
1138  if (list_of_exp_equals_1n_p(lt, lf, n))
1139  {
1140  q = tq;
1141  free_quast(fq);
1142  return(q);
1143  }
1144  else
1145  {
1146  conditional_true_quast(cond) = tq;
1147  conditional_false_quast(cond) = fq;
1148  return(q);
1149  }
1150  }
1151  else
1152  {
1153  conditional_true_quast(cond) = tq;
1154  conditional_false_quast(cond) = fq;
1155  return(q);
1156  }
1157  }
1158  }
1159 }
1160 
1161 /*==================================================================*/
1162 /* list get_list_of_all_param(s, t): get the entire list of the parame-
1163  * ters for a deisganted node.
1164  *
1165  * AC 94/02/08
1166  */
1167 
1169 
1170  int s, t;
1171 {
1172  static_control stct;
1173  list l, m;
1174  entity ent;
1175 
1177  l = static_control_params(stct);
1178  l = gen_append(l, static_control_to_indices(stct));
1179 
1181  m = static_control_params(stct);
1182  m = gen_append(m, static_control_to_indices(stct));
1183 
1184  for (; m != NIL; m = CDR(m))
1185  {
1186  ent = ENTITY(CAR(m));
1187  if (!is_entity_in_list_p(ent, l))
1188  l = gen_append(l, CONS(ENTITY, ent, NIL));
1189  }
1190 
1191  return(l);
1192 }
1193 
1194 /*==================================================================*/
1195 /* bool is_uniform_rec(l, p): test if a causality condition is
1196  * linear, that is independent of the structure parameters and all
1197  * the loop counters.
1198  *
1199  * AC 93/11/22
1200  */
1201 
1202 bool is_uniform_rec(l, p)
1203 
1204  list l;
1205  Ppolynome p;
1206 {
1207  list lindice = l;
1208  Variable var;
1209  bool bool = false;
1210 
1211  for ( ; lindice != NIL; lindice = CDR(lindice))
1212  {
1213  var = (Variable)ENTITY(CAR(lindice));
1214  bool = (polynome_contains_var(p, var)) || (bool);
1215  }
1216 
1217  return(!bool);
1218 }
1219 
1220 /*==================================================================*/
1221 /* Psysteme include_trans_in_sc(s,sys,l): include in a system the
1222  * indice transformation introduced by an edge.
1223  *
1224  * AC 93/12/20
1225  */
1226 
1228 
1229  int s;
1230  Psysteme sys;
1231  list l;
1232 {
1233  Pcontrainte cont;
1234  Pvecteur vect;
1235  Ppolynome poly;
1236  int d;
1237 
1238  for (cont = sys->inegalites; cont != NULL; cont = cont->succ)
1239  {
1240  vect = cont->vecteur;
1241  poly = vecteur_to_polynome(vect);
1242  poly = include_trans_in_poly(s, poly, l, &d);
1243  if (d != 1) cont->vecteur = vect_multiply(polynome_to_vecteur(poly), d);
1244  else cont->vecteur = polynome_to_vecteur(poly);
1245  }
1246 
1247  sys->base = BASE_UNDEFINED;
1248  sc_creer_base(sys);
1249 
1250  return(sys);
1251 }
1252 
1253 /*==================================================================*/
1254 /* Ppolynome make_polynome_Xe(xc, xe): make the polynom of unknown
1255  * xe = "X_xc".
1256  *
1257  * AC 94/01/27
1258  */
1259 
1261 
1262  int xc;
1263  entity *xe;
1264 {
1265  Ppolynome p;
1266  entity e;
1267  char *n;
1268 
1269  asprintf(&n, "X%d", xc);
1270  e = create_named_entity(n);
1271  free(n);
1272 
1273  p = make_polynome((float)1, (Variable)e, 1);
1274 
1275  *xe = e;
1276  return(p);
1277 }
1278 
1279 /*==================================================================*/
1280 /* list add_others_variables(lvar, n_lvar): check if the elements of
1281  * n_lvar are in lvar, if not add them in lvar.
1282  *
1283  * AC 94/02/10
1284  */
1285 
1287 
1288  list lvar, n_lvar;
1289 {
1290  entity ent;
1291 
1292  for (; n_lvar != NULL; n_lvar = CDR(n_lvar))
1293  {
1294  ent = ENTITY(CAR(n_lvar));
1295  if (!is_entity_in_list_p(ent, lvar))
1296  lvar = gen_append(lvar, CONS(ENTITY, ent, NIL));
1297  }
1298 
1299  return(lvar);
1300 }
1301 
1302 /*==================================================================*/
1303 /* Psysteme make_causal_internal(): build the causality condition.
1304  * If the causality condition is already linear, we do not need to
1305  * apply Farkas lemma to create a Lambda polynom. This function
1306  * identifies the different variables and writes them in a Psystem
1307  * it returns. The integer c is usefull for the creation of the
1308  * parameters LAMBDA in the case of a multi-edge. This function
1309  * is used in the case of an internal edge of the scc where we
1310  * introduce the variable "switch" Xe. The causality condition
1311  * is written as:
1312  * Pdest - Pinit >= Xe
1313  *
1314  * AC 94/01/27
1315  */
1316 
1317 Psysteme make_causal_internal(stat_dest, sys_dest, poly_dest, ldata,\
1318  stat_pred, sys_pred, poly_source,\
1319  c, xc, xe, den)
1320 
1321  int stat_dest, stat_pred;
1322  Psysteme sys_dest, sys_pred;
1323  Ppolynome poly_dest, poly_source;
1324  int *c, xc, den;
1325  list ldata;
1326  entity *xe;
1327 {
1328  list ltrans, lvar, llambda, llambda_el;
1329  predicate pred_edge;
1330  Psysteme psys_aux, sys_edge, pred_sys = SC_RN;
1331  Ppolynome poly_lambda, poly_res, p_source, poly_x;
1332  dataflow pred_data;
1333  Pn_coef llam1, llam2;
1334  entity xe_a;
1335  int co = *c, d, ppc;
1336 
1337  lvar = get_list_of_all_param(stat_dest, stat_pred);
1338  llam1 = NULL;
1339  llam2 = NULL;
1340  xe_a = *xe;
1341  sys_edge = SC_RN;
1342  psys_aux = sc_new();
1343  poly_lambda = POLYNOME_UNDEFINED;
1344  poly_res = POLYNOME_UNDEFINED;
1345  p_source = polynome_dup(poly_source);
1346  pred_sys = sc_dup(sys_pred);
1347 
1348  pred_data = DATAFLOW(CAR(ldata));
1349  ltrans = dataflow_transformation(pred_data);
1350 
1351  p_source = include_trans_in_poly(stat_pred, p_source, ltrans, &d);
1352 
1353  ppc = sol_ppcm(den, d);
1354 
1355  if (get_debug_level() > 5)
1356  {
1357  fprintf(stderr,"\nTRANSFORMATION :\n");
1358  fprint_list_of_exp(stderr,ltrans);
1359  fprintf(stderr,"\n\nPoly_source : ");
1360  my_polynome_fprint(stderr,p_source);
1361  }
1362 
1363  /* write the causality condition under the following form: */
1364  /* P_dest - P_source -Xe = 0 */
1365  poly_res = polynome_dup(poly_dest);
1366  polynome_negate(&p_source);
1367  polynome_add(&poly_res, p_source);
1368  poly_x = make_polynome_Xe(xc, &xe_a);
1369  polynome_negate(&poly_x);
1370  polynome_add(&poly_res, poly_x);
1371 
1372  if (get_debug_level() > 5)
1373  {
1374  fprintf(stderr,"\nInequation de causalite :\n");
1375  my_polynome_fprint(stderr,poly_res);
1376  }
1377 
1378  if (is_uniform_rec(lvar, poly_res))
1379  {
1380  /* case of a uniform causality condition */
1381  if (get_debug_level() > 5) fprintf(stderr,"\nRecurrence uniforme :\n");
1382  polynome_negate(&poly_res);
1383  psys_aux = polynome_to_sc(poly_res, lvar);
1384  psys_aux = transform_in_ineq(psys_aux, NIL);
1385  }
1386  else
1387  {
1388  /* make the polynom of unknown lambda */
1389  sys_edge = sc_dup(sys_dest);
1390  sys_edge = sc_append(sys_edge, pred_sys);
1391  sys_edge = include_parameters_in_sc(sys_edge, stat_dest);
1392  my_sc_normalize(sys_edge);
1393 
1394  /* list of the variables to identify */
1395  if (!SC_UNDEFINED_P(sys_edge))
1396  lvar = add_others_variables(lvar, base_to_list(sys_edge->base));
1397 
1398  create_farkas_poly(sys_edge, "LAMBDA", stat_pred, stat_dest,\
1399  &poly_lambda, &llam1, &co);
1400 
1401  /* Now we add the conditions on the edge, caus' we livin' on */
1402  /* the edge */
1403  pred_edge = dataflow_governing_pred(pred_data);
1404  sys_edge = sc_dup(predicate_to_system(pred_edge));
1405 
1406  /* list of the variables to identify */
1407  if (!SC_UNDEFINED_P(sys_edge))
1408  lvar = add_others_variables(lvar, base_to_list(sys_edge->base));
1409 
1410  create_farkas_poly(sys_edge, "LAMBDA", stat_pred, stat_dest,\
1411  &poly_lambda, &llam2, &co);
1412 
1413  sc_rm(sys_edge);
1414 
1415  llam1 = add_lcoef_to_lcoef(llam1, llam2);
1416  llambda = extract_var_list(llam1);
1417 
1418  /* write the causality condition under the following form: */
1419  /* P_dest - P_source - P_lambda -1 = 0 */
1420  polynome_negate(&poly_lambda);
1421  polynome_add(&poly_res, poly_lambda);
1422 
1423  if (ppc != 1) polynome_scalar_mult(&poly_res, (float)ppc);
1424 
1425  psys_aux = polynome_to_sc(poly_res, lvar);
1426  psys_aux = elim_var_with_eg(psys_aux, &llambda, &llambda_el);
1427 
1428  /* simplify the system and transform it in inequalities */
1429  psys_aux = my_sc_normalize(psys_aux);
1430  llambda_el = gen_nreverse(llambda_el);
1431  psys_aux = transform_in_ineq(psys_aux, llambda_el);
1432  }
1433 
1434  if (get_debug_level() > 5)
1435  {
1436  fprintf(stderr,"\nPoly_resultat : ");
1437  my_polynome_fprint(stderr,poly_res);
1438  fprintf(stderr,"\n\n");
1439  }
1440 
1441  polynome_rm(&poly_res);
1442  polynome_rm(&p_source);
1443 
1444  *xe = xe_a;
1445  *c = co;
1446 
1447  return(psys_aux);
1448 }
1449 
1450 /*==================================================================*/
1451 /* Psysteme make_causal_external(): same function as make_causal
1452  * internal, but in this case we do not introduce the new variables
1453  * Xe, and we write the causality condition under the following
1454  * form:
1455  * Pdest - Pinit >= 1
1456  *
1457  * AC 94/01/27
1458  */
1459 
1460 Psysteme make_causal_external(stat_dest, sys_dest, poly_dest, ldata,\
1461  stat_pred, sys_pred, poly_source, c, den)
1462 
1463  int stat_dest, stat_pred;
1464  Psysteme sys_dest, sys_pred;
1465  Ppolynome poly_dest, poly_source;
1466  int *c, den;
1467  list ldata;
1468 {
1469  list ltrans, lvar, llambda, llambda_el;
1470  predicate pred_edge;
1471  Psysteme psys_aux, sys_edge, pred_sys = SC_RN;
1472  Ppolynome poly_lambda, poly_res, p_source;
1473  dataflow pred_data;
1474  Pn_coef llam1, llam2;
1475  int co = *c, d, ppc;
1476 
1477  lvar = get_list_of_all_param(stat_dest, stat_pred);
1478  llam1 = NULL;
1479  llam2 = NULL;
1480  sys_edge = SC_RN;
1481  psys_aux = sc_new();
1482  poly_lambda = POLYNOME_UNDEFINED;
1483  p_source = polynome_dup(poly_source);
1484 
1485  pred_data = DATAFLOW(CAR(ldata));
1486  ltrans = dataflow_transformation(pred_data);
1487  pred_sys = sc_dup(sys_pred);
1488 
1489  p_source = include_trans_in_poly(stat_pred, p_source, ltrans, &d);
1490 
1491  ppc = sol_ppcm(den, d);
1492 
1493  if (get_debug_level() > 5)
1494  {
1495  fprintf(stderr,"\nTRANSFORMATION :\n");
1496  fprint_list_of_exp(stderr,ltrans);
1497  fprintf(stderr,"\nPred_sys :");
1498  fprint_psysteme(stderr,pred_sys);
1499  fprintf(stderr,"\n\nPoly_source : ");
1500  my_polynome_fprint(stderr,p_source);
1501  }
1502 
1503  /* write the causality condition under the following form: */
1504  /* P_dest - P_source -1 = 0 */
1505  poly_res = polynome_dup(poly_dest);
1506  polynome_negate(&p_source);
1507  polynome_add(&poly_res, p_source);
1508  polynome_decr(poly_res);
1509 
1510  if (get_debug_level() > 5)
1511  {
1512  fprintf(stderr,"\nInequation de causalite :\n");
1513  my_polynome_fprint(stderr,poly_res);
1514  }
1515 
1516  if (is_uniform_rec(lvar, poly_res))
1517  {
1518  /* case of a uniform causality condition */
1519  if (get_debug_level() > 5) fprintf(stderr,"\nRecurrence uniforme :\n");
1520  polynome_negate(&poly_res);
1521  psys_aux = polynome_to_sc(poly_res, lvar);
1522  psys_aux = transform_in_ineq(psys_aux, NIL);
1523  }
1524  else
1525  {
1526  /* make the polynom of unknown lambda */
1527  sys_edge = sc_dup(sys_dest);
1528  sys_edge = sc_append(sys_edge, pred_sys);
1529  sys_edge = include_parameters_in_sc(sys_edge, stat_dest);
1530  my_sc_normalize(sys_edge);
1531 
1532  /* list of the variables to identify */
1533  if (!SC_UNDEFINED_P(sys_edge))
1534  lvar = add_others_variables(lvar, base_to_list(sys_edge->base));
1535 
1536  create_farkas_poly(sys_edge, "LAMBDA", stat_pred, stat_dest,\
1537  &poly_lambda, &llam1, &co);
1538  sc_rm(sys_edge);
1539  sys_edge = NULL;
1540 
1541  /* Now we add the conditions on the edge, caus' we livin' on */
1542  /* the edge */
1543  pred_edge = dataflow_governing_pred(pred_data);
1544  sys_edge = sc_dup(predicate_to_system(pred_edge));
1545 
1546  if (!SC_UNDEFINED_P(sys_edge))
1547  lvar = add_others_variables(lvar, base_to_list(sys_edge->base));
1548 
1549  create_farkas_poly(sys_edge, "LAMBDA", stat_pred, stat_dest,\
1550  &poly_lambda, &llam2, &co);
1551 
1552  llam1 = add_lcoef_to_lcoef(llam1, llam2);
1553  llambda = extract_var_list(llam1);
1554 
1555  /* write the causality condition under the following form: */
1556  /* P_dest - P_source - P_lambda -1 = 0 */
1557  polynome_negate(&poly_lambda);
1558  polynome_add(&poly_res, poly_lambda);
1559 
1560  if (ppc != 1) polynome_scalar_mult(&poly_res, (float)ppc);
1561 
1562  psys_aux = polynome_to_sc(poly_res, lvar);
1563 
1564  psys_aux = elim_var_with_eg(psys_aux, &llambda, &llambda_el);
1565 
1566  /* simplify the system and transform it in inequalities */
1567  llambda_el = gen_nreverse(llambda_el);
1568  psys_aux = transform_in_ineq(psys_aux, llambda_el);
1569  }
1570 
1571  if (get_debug_level() > 5)
1572  {
1573  fprintf(stderr,"\nPoly_resultat : ");
1574  my_polynome_fprint(stderr,poly_res);
1575  fprintf(stderr,"\n\n");
1576  }
1577 
1578  polynome_rm(&poly_res);
1579  polynome_rm(&p_source);
1580  *c = co;
1581 
1582  return(psys_aux);
1583 }
1584 
1585 /*==================================================================*/
1586 /* list make_sched_proto(h,lin,,col,lu): make the vector-list
1587  * representing the prototype of the schedule we search.
1588  *
1589  * AC 93/12/06
1590  */
1591 
1593 
1594  matrice h;
1595  int lin, col;
1596  list lu;
1597 {
1598  list p, lvp = NIL;
1599  int i;
1600 
1601  p = lu;
1602  i = 1;
1603 
1604  while (p != NIL)
1605  {
1606  Value v = ACCESS(h,lin,i,1);
1608  i++;
1609  p = CDR(p);
1610  }
1611 
1612  /* complete the vector to the dimension of the dual problem */
1613  if (gen_length(lvp) != col)
1614  {
1615  for (i = 1; i <= (col-lin); i++)
1616  ADD_ELEMENT_TO_LIST(lvp, INT, 0);
1617  }
1618 
1619  return(lvp);
1620 }
1621 
1622 /*==================================================================*/
1623 /* Psysteme system_new_var_subst(sys, l): replace in a psyteme the
1624  * new variables introduced by PIP by their value.
1625  *
1626  * AC 93/12/20
1627  */
1628 
1630 
1631  Psysteme sys;
1632  list l;
1633 {
1634  Pcontrainte cont;
1635  Pvecteur new_vect;
1636  list le, lexp, lvect;
1637  entity ent;
1638  Value val, va;
1639  expression exp, exp1, exp2;
1640  var_val vv;
1641  call ca;
1642  int d;
1643 
1644  for (cont = sys->inegalites; cont != NULL; cont = cont->succ)
1645  {
1646  for (le = l; le != NIL; le = CDR(le))
1647  {
1648  /* extract the new parameter */
1649  vv = VAR_VAL(CAR(le));
1650  ent = var_val_variable(vv);
1651 
1652  lvect = vecteur_to_list(cont->vecteur);
1653  if (is_entity_in_list_p(ent, lvect))
1654  {
1655  exp = var_val_value(vv);
1656  analyze_expression(&exp, &d);
1658  lexp = call_arguments(ca);
1659 
1660  /* extract the numerator */
1661  exp1 = EXPRESSION(CAR(lexp));
1662  NORMALIZE_EXPRESSION(exp1);
1663  new_vect = normalized_linear(expression_normalized(exp1));
1664 
1665  /* extract the denominator */
1666  lexp = CDR(lexp);
1667  exp2 = EXPRESSION(CAR(lexp));
1668  val = (Value)expression_to_int(exp2);
1669  va = vect_coeff((Variable)ent, cont->vecteur);
1670  vect_erase_var(&(cont->vecteur), (Variable)ent);
1671  cont->vecteur = vect_multiply(cont->vecteur, val);
1672  new_vect = vect_multiply(new_vect, va);
1673  cont->vecteur = vect_add(cont->vecteur, new_vect);
1674  vect_normalize(cont->vecteur);
1675  }
1676  }
1677  }
1678 
1679  sys->base = BASE_NULLE;
1680  sc_creer_base(sys);
1681  return(sys);
1682 }
1683 
1684 /*==================================================================*/
1685 /* Psysteme add_constraint_on_x(psys, lx): in the Psysteme psys, we
1686  * add the constraints on the introduced variables Xe: Xe <= 1.
1687  *
1688  * AC 94/01/27
1689  */
1690 
1692 
1693  Psysteme psys;
1694  list lx;
1695 {
1696  entity e;
1697  Ppolynome p;
1698  Pcontrainte c;
1699  list l, lx_r;
1700 
1701  lx_r = gen_nreverse(lx);
1702 
1703  for (l = lx_r; l != NIL; l = CDR(l))
1704  {
1705  e = ENTITY(CAR(l));
1706  if (!strncmp(entity_local_name(e), "X", 1))
1707  {
1708  p = make_polynome((float)1, (Variable) e, 1);
1709  p = polynome_decr(p);
1710  c = polynome_to_contrainte(p);
1711  sc_add_inegalite(psys, c);
1712  psys->base = base_add_variable(psys->base, (Variable) e);
1713  psys->dimension++;
1714  }
1715  }
1716 
1717  lx = gen_nreverse(lx_r);
1718 
1719  return(psys);
1720 }
1721 
1722 /*==================================================================*/
1723 /* Psysteme make_primal(psys,lvar_u,lvp,lxe): build the primal problem.
1724  * In fact, it does more then that, because it prepares the construc-
1725  * tion of the dual problem by transposing the matrice coming from
1726  * the input Psysteme.
1727  *
1728  * AC 93/12/20
1729  */
1730 
1731 static Psysteme make_primal(psys, lvar_u, lvp, lxe)
1732 
1733  Psysteme psys;
1734  list *lvar_u, *lvp, lxe;
1735 {
1736  int lin, col;
1737  matrice G, tG, h, f;
1738  Pbase base;
1739  Pcontrainte cont;
1740 
1741  if (get_debug_level() > 5)
1742  {
1743  fprintf(stderr,"\nPsysteme primal:\n");
1744  fprint_psysteme(stderr, psys);
1745  }
1746 
1747  col = gen_length(base_to_list(psys->base));
1748  lin = psys->nb_ineq;
1749 
1750  G = matrice_new(lin, col);
1751  tG = matrice_new(col, lin);
1752  h = matrice_new(lin, 1);
1753  f = matrice_new(col, 1);
1754 
1755  /* transform the system into a matrix */
1756  sc_to_matrices(psys, psys->base, G, h, lin, col);
1757 
1758  /* Now, we begin to make the dual problem */
1759  matrice_transpose(G, tG, lin, col);
1760  matrice_nulle(f, col, 1);
1761 
1762  *lvar_u = make_list_of_n("u", lin);
1763  base = list_to_base(*lvar_u);
1764 
1765  *lvp = make_sched_proto(h, lin, col, *lvar_u);
1766 
1767  pu_matrices_to_contraintes(&cont, base, tG, f, col, lin);
1768 
1769  psys = sc_make(NULL, cont);
1770 
1771  matrice_free(G);
1772  matrice_free(tG);
1773  matrice_free(h);
1774  matrice_free(f);
1775 
1776  return(psys);
1777 }
1778 
1779 /*==================================================================*/
1780 /* list get_exp_schedule(e,me,d): extract form the expression exp
1781  * given by the resulting quast of PIP the expression of the schedule
1782  * we search: it takes the expression, put the coef of "M" to 0, and
1783  * change the sign of the vector.
1784  *
1785  * AC 94/01/27
1786  */
1787 
1789 
1790  expression e;
1791  entity me;
1792  int d;
1793 {
1794  list lexp;
1795  Pvecteur v;
1796  expression exp;
1797  call ca;
1798  syntax syn;
1799  entity func;
1800 
1801  if (!expression_undefined_p(e))
1802  {
1803  if (d == 1)
1804  {
1807  vect_chg_coeff(&v, (Variable) me, 0);
1808  vect_chg_sgn(v);
1809  e = make_vecteur_expression(v);
1811  }
1812  else
1813  {
1814  ca = syntax_call(expression_syntax(e));
1815  lexp = call_arguments(ca);
1816  func = call_function(ca);
1817  exp = EXPRESSION(CAR(lexp));
1819  lexp = CDR(lexp);
1821  vect_chg_coeff(&v, (Variable) me, 0);
1822  vect_chg_sgn(v);
1825  lexp = CONS(EXPRESSION, exp, lexp);
1826  ca = make_call(func, lexp);
1827  syn = make_syntax(is_syntax_call, ca);
1829  }
1830  }
1831 
1832  return(CONS(EXPRESSION, e, NIL));
1833 }
1834 
1835 /*==================================================================*/
1836 /* Psysteme get_unsatisfied_system(): we check the
1837  * coefficient of "m" in the solution of the dual variable of "xe",
1838  * if it is nil we update the list of system that could be unsatis-
1839  * fied, the list of Xe, and we build the new system for the
1840  * primal problem.
1841  * lsys is updated, lunk too. "me" contains the entity "M".
1842  *
1843  * AC 94/01/20
1844  */
1845 
1846 static Psysteme get_unsatisfied_system(lexp, lsys, lxe, lunk, me, de)
1847 
1848  list lexp, *lxe;
1849  Psys_list *lsys;
1850  Pn_coef *lunk;
1851  entity me;
1852  int de;
1853 {
1854  Psys_list ls, ls_new;
1855  list lx, lx_new;
1856  Psysteme sys;
1857  expression exp;
1858 
1859  lexp = CDR(lexp);
1860  lx = *lxe;
1861  sys = sc_new();
1862  lx_new = NIL;
1863  ls_new = NULL;
1864 
1865  if (get_debug_level() > 5)
1866  {
1867  fprintf(stderr,"\nList :");
1868  fprint_list_of_exp(stderr,lexp);
1869  }
1870 
1871  for (ls = *lsys; ls != NULL; ls = ls->next)
1872  {
1873  exp = EXPRESSION(CAR(lexp));
1874  if (get_m_coef(&exp, &de) == 0)
1875  {
1876  /* this edge is unsatisfied */
1877  ls_new = add_elt_to_sys_list(ls_new, 0, ls->sys);
1878  ADD_ELEMENT_TO_LIST(lx_new, ENTITY, ENTITY(CAR(lx)));
1879  sys = sc_append(sys, ls->sys);
1880  }
1881  lexp = CDR(lexp);
1882  lx = CDR(lx);
1883  }
1884 
1885  /* we have to add the constraints X<=1 */
1886  sys = add_constraint_on_x(sys, lx_new);
1887 
1888  *lsys = ls_new;
1889  *lxe = lx_new;
1890 
1891  return(sys);
1892 }
1893 
1894 /*==================================================================*/
1895 /* void make_list_of_unk(l, sc, me, lx): build the complete list of
1896  * Pn_coef for the primal problem. At the beginning, l only contains
1897  * the "MU" introduced by the inequation of causality. We check if
1898  * SOME "MU" have been eliminated, we build the list of Xe that we
1899  * put in first position, then we append the list of LAMBDA.
1900  *
1901  * AC 94/01/27
1902  */
1903 
1904 static void make_list_of_unk(l, sc, me, lx)
1905 
1906  Pn_coef *l;
1907  Psysteme *sc;
1908  entity *me;
1909  list lx;
1910 {
1911  Pn_coef laux, lout, lin = *l;
1912  list llambda, base;
1913  entity m;
1914 
1915  lout = NULL;
1916 
1917  base = base_to_list((*sc)->base);
1918 
1919  /* First we check if some MU have been eliminated */
1920  while (lin != NULL)
1921  {
1922  laux = lin;
1923  lin = lin->next;
1924  laux->next = NULL;
1925  if (is_entity_in_list_p(laux->n_ent, base))
1926  lout = add_n_coef_to_list(lout, laux);
1927  }
1928 
1929  /* we add at the beginning of lout the list about the Xs */
1930  lout = add_x_list(lout, lx, &m);
1931 
1932  /* we add at the end of lout the list about the lambda */
1933  llambda = extract_lambda_list(base);
1934  lout = add_lambda_list(lout, llambda);
1935 
1936  base = extract_var_list(lout);
1937  (*sc)->base = list_to_base(base);
1938 
1939  *me = m;
1940  *l = lout;
1941 }
1942 
1943 /*==================================================================*/
1944 /* Psysteme get_predicate_system_of_node(st,s): get the system of
1945  * constraints of a node of statement "st" in a given scc.
1946  *
1947  * AC 93/12/20
1948  */
1949 
1951 
1952  int st;
1953  scc s;
1954 {
1955  list lver;
1956  vertex ver;
1957  Psysteme sys = SC_UNDEFINED;
1958  bool not_found = true;
1959 
1960  lver = scc_vertices(s);
1961 
1962  while ((lver != NIL) && (not_found))
1963  {
1964  ver = VERTEX(CAR(lver));
1965 
1966  if (st == vertex_int_stmt(ver))
1967  {
1970  not_found = false;
1971  }
1972  lver = CDR(lver);
1973  }
1974 
1975  return(sys);
1976 }
1977 
1978 /*==================================================================*/
1979 /* Psyslist add_sc_to_sclist(sc,lsys): add a system in the list of
1980  * systems defined by Psyslist.
1981  *
1982  * AC 93/12/23
1983  */
1984 
1986 
1987  Psysteme sc;
1988  Psyslist lsys;
1989 {
1990  Psyslist lsys_aux;
1991 
1992  lsys_aux = (Psyslist)malloc(sizeof(Ssyslist));
1993 
1994  lsys_aux->psys = sc;
1995  lsys_aux->succ = lsys;
1996 
1997  return(lsys_aux);
1998 }
1999 
2000 /*==================================================================*/
2001 /* Psysteme simplify_predicate(ps, ps_eq, l): simplify the psysteme
2002  * ps by replacing the new variables in l by their expression in
2003  * ps_eq (in the same order).
2004  *
2005  * AC 94/03/28
2006  */
2007 
2009 
2010  Psysteme ps, ps_eq;
2011  list l;
2012 {
2013  Pcontrainte cti, cte = ps_eq->egalites;
2014  list lv;
2015  Value coi, coe, ppc;
2016  Pvecteur vi, ve;
2017  entity ent;
2018 
2019  for (lv = l; lv != NIL; lv = CDR(lv))
2020  {
2021  ent = ENTITY(CAR(lv));
2022 
2023  for (cti = ps->inegalites; cti != NULL; cti = cti->succ)
2024  {
2025  vi = cti->vecteur;
2026  if (base_contains_variable_p(vi, (Variable) ent))
2027  {
2028  coe = vect_coeff((Variable) ent, cte->vecteur);
2029  coi = vect_coeff((Variable) ent, cti->vecteur);
2030  ve = vect_dup(cte->vecteur);
2031  ppc = value_abs(ppcm(coe, coi));
2032  vi = vect_multiply(vi, value_abs(value_div(ppc,coi)));
2033  ve = vect_multiply(ve, value_abs(value_div(ppc,coe)));
2034  if (value_posz_p(value_mult(coe,coi)))
2035  vi = vect_substract(vi,ve);
2036  else vi = vect_add(vi, ve);
2037  cti->vecteur = vi;
2038  }
2039  }
2040  cte = cte->succ;
2041  }
2042 
2043  ps->egalites = ps_eq->egalites;
2044 
2045  return(ps);
2046 }
2047 
2048 /*==================================================================*/
2049 /* list simplify_dimension(ld, ps_eq, l): implify the different
2050  * dimensions f the schedule in the list ld with the variables in l
2051  * with the equalities that ps_eq contains.
2052  *
2053  * AC 94/03/28
2054  */
2055 
2057 
2058  Psysteme ps_eq;
2059  list ld, l;
2060 {
2061  Pcontrainte cte = ps_eq->egalites;
2062  list lv, ln = NIL, ldi;
2063  Value coi, coe, ppc;
2064  int d;
2065  Pvecteur vi, ve;
2066  expression exp, ex;
2067  entity ent;
2068  bool change = false;
2069 
2070  /* loop on the dimension of the schedule to process */
2071  for (ldi = ld; ldi != NIL; ldi = CDR(ldi))
2072  {
2073  exp = EXPRESSION(CAR(ldi));
2074  analyze_expression(&exp, &d);
2075  cte = ps_eq->egalites;
2076 
2077  if (get_debug_level() > 5)
2078  {
2079  fprintf(stderr,"\nExpression en entree :");
2081  fprintf(stderr,"\nd = %d",d);
2082  }
2083 
2084  if (d == 1)
2085  {
2088  }
2089  else
2090  {
2092  (expression_syntax(exp)))));
2095  }
2096 
2097  /* loop on the variables to eliminate */
2098  for (lv = l; lv != NIL; lv = CDR(lv))
2099  {
2100  ent = ENTITY(CAR(lv));
2101  if (get_debug_level() > 5)
2102  {
2103  fprintf(stderr,"\nEntite a eliminer :");
2104  fprint_entity_list(stderr,CONS(ENTITY,ent,NIL));
2105  }
2106 
2107  if (base_contains_variable_p(vi, (Variable) ent))
2108  {
2109  change = true;
2110  coe = vect_coeff((Variable) ent, cte->vecteur);
2111  coi = vect_coeff((Variable) ent, vi);
2112  ve = vect_dup(cte->vecteur);
2113  ppc = ppcm(coe, coi);
2114  vi = vect_multiply(vi, value_abs(value_div(ppc,coi)));
2115  ve = vect_multiply(ve, value_abs(value_div(ppc,coe)));
2116  if (value_posz_p(value_mult(coe,coi)))
2117  vi = vect_substract(vi,ve);
2118  else vi = vect_add(vi, ve);
2119  }
2120  /* try next variable */
2121  cte = cte->succ;
2122  }
2123 
2124  if (change)
2125  {
2126  if (VECTEUR_UNDEFINED_P(vi))
2127  exp = int_to_expression(0);
2128  else
2129  {
2130  if (d == 1) exp = Pvecteur_to_expression(vi);
2131  else exp = make_rational_exp(vi, d);
2132  }
2133  }
2134 
2135  if (get_debug_level() > 5)
2136  {
2137  fprintf(stderr,"\nvi = ");
2138  pu_vect_fprint(stderr, vi);
2139  fprintf(stderr,"\nd = %d", d);
2140  fprintf(stderr,"\nExpression en sortie :");
2142  }
2143 
2145  }
2146 
2147  return(ln);
2148 }
2149 
2150 /*==================================================================*/
2151 /* bdt simplify_bdt(b,s): simplify the list of schedule of a node
2152  * by comparing the predicate of the schedule with the domain on
2153  * which the node is defined. Moreover, replace variables by their
2154  * value when it is possible in the predicate and the expression.
2155  * (i.e. if I == N and dims==N+I+1 => dims==2*N+1 )
2156  *
2157  * AC 93/12/20
2158  */
2159 
2161 
2162  bdt b;
2163  scc s;
2164 {
2165  schedule sc;
2166  list ls, lvar, lvar_e, ldims;
2167  int st;
2168  Psysteme s_bdt, s_node, s_eq, s_aux;
2169  static_control stct;
2170 
2171  if (get_debug_level() > 5) fprintf(stderr,"\nSIMPLIFY BEGIN\n");
2172 
2173  for (ls = bdt_schedules(b); ls != NIL; ls = CDR(ls))
2174  {
2175  if (get_debug_level() > 5) fprintf(stderr,"\nSIMPLIFY new branche\n");
2176  sc = SCHEDULE(CAR(ls));
2177  st = schedule_statement(sc);
2178  ldims = schedule_dims(sc);
2180  lvar = static_control_to_indices(stct);
2181  lvar = gen_append(lvar, static_control_params(stct));
2182  lvar_e = NIL;
2183 
2184  if (get_debug_level() > 5)
2185  {
2186  fprintf(stderr, "\nListe des variables;");
2187  fprint_entity_list(stderr, lvar);
2188  }
2189 
2191  s_node = get_predicate_system_of_node(st, s);
2192 
2193  if (!SC_RN_P(s_bdt))
2194  {
2195  if (get_debug_level() > 5)
2196  {
2197  fprintf(stderr,"\nSYSTEME BDT en entree :");
2198  fprint_psysteme(stderr,s_bdt);
2199  }
2200 
2201  s_eq = find_implicit_equation(s_bdt);
2202  s_aux = elim_var_with_eg(s_eq, &lvar, &lvar_e);
2203 
2204  if (get_debug_level() > 5)
2205  {
2206  fprintf(stderr,"\nSYSTEME D EGALITES apres :");
2207  fprint_psysteme(stderr,s_aux);
2208  fprintf(stderr,"\nListe des eliminees:");
2209  fprint_entity_list(stderr, lvar_e);
2210  }
2211 
2212  if ((lvar_e != NIL)&&(!SC_RN_P(s_bdt)))
2213  {
2214  ldims = simplify_dimension(ldims, s_aux, lvar_e);
2215  s_bdt = simplify_predicate(s_bdt, s_aux, lvar_e);
2216  }
2217 
2218  if (get_debug_level() > 5)
2219  {
2220  fprintf(stderr,"\nSYSTEME BDT en sortie :");
2221  fprint_psysteme(stderr,s_bdt);
2222  }
2223 
2224  s_bdt = suppress_sc_in_sc(s_bdt, s_node);
2225  my_sc_normalize(s_bdt);
2226  schedule_predicate(sc) = make_predicate(s_bdt);
2227  schedule_dims(sc) = ldims;
2228  }
2229  }
2230 
2231  if (get_debug_level() > 5) fprintf(stderr,"\nSIMPLIFY END\n");
2232 
2233  return(b);
2234 }
2235 
2236 /*==================================================================*/
2237 /* Psysteme make_dual(psys,pcont,l,lvar_u,lvp): makes the
2238  * dual problem in the case of a scc containing a single node. In
2239  * this case, we do not introduce a set of "v" in the second member
2240  * we put directly the proper value function of the program
2241  * parameters.
2242  *
2243  * AC 93/12/20
2244  */
2245 
2246 static Psysteme make_dual(psys, pcont, l, lvar_u, lvp)
2247 
2248  Psysteme psys, *pcont;
2249  Pn_coef l;
2250  list *lvar_u, lvp;
2251 {
2252  Pcontrainte cont;
2253  Psysteme sys_cont;
2254  Pvecteur vect, vect_aux, vect_pro, vp;
2255  list lbase, lp, laux;
2256  entity ent;
2257 
2258  sys_cont = sc_new();
2259  lp = lvp;
2260  vp = VECTEUR_NUL;
2261 
2262  /* for each inequalities, build the second member of the system */
2263  /* and at the same time the system of constraints. */
2264 
2265  for (cont = psys->inegalites ; cont != NULL ; cont = cont->succ)
2266  {
2267  vect = vect_dup(cont->vecteur);
2268  vect_chg_sgn(vect);
2269  vect_aux = vect_dup(l->n_vect);
2271  cont->vecteur = vect_add(vect, vect_aux);
2272 
2274 
2275  vect_pro = vect_new((Variable) TCST, INT(CAR(lp)));
2276  vp = vect_add(vp, vect_pro);
2277 
2278  l = l->next;
2279  lp = CDR(lp);
2280  }
2281 
2282  /* build and put the economic function in 1st position in psys */
2283 
2284  ent = create_named_entity("u0");
2285  vect = vect_new((Variable)ent,1);
2286  lp = lvp;
2287 
2288  for (laux = *lvar_u; laux != NIL; laux = CDR(laux))
2289  {
2290  vect_aux = vect_new((Variable) ENTITY(CAR(laux)), INT(CAR(lp)));
2291  vect = vect_add(vect, vect_aux);
2292  lp = CDR(lp);
2293  }
2294 
2295  vect_chg_sgn(vect);
2296  sc_add_inegalite(psys, contrainte_make(vect));
2297  *lvar_u = CONS(ENTITY, ent, *lvar_u);
2298 
2299  psys->base = NULL;
2300  sys_cont->base = NULL;
2301  sc_creer_base(psys);
2302  sc_creer_base(sys_cont);
2303 
2304  lbase = base_to_list(psys->base);
2305  lbase = reorder_base(lbase, *lvar_u);
2306  psys->base = list_to_base(lbase);
2307 
2308  *pcont = my_sc_normalize(sys_cont);
2309 
2310  return(psys);
2311 }
2312 
2313 /*==================================================================*/
2314 /* static Pn_coef extract_stat_lunk(stat, lunk): creates the good
2315  * second member for the dual problem based on the general second
2316  * member lunk. This function is used when we search the schedule
2317  * of each node in a scc one after the other.
2318  *
2319  * AC 94/01/10
2320  */
2321 
2322 static Pn_coef extract_stat_lunk(stat, lunk)
2323 
2324  int stat;
2325  Pn_coef lunk;
2326 {
2327  Pn_coef lv_coef, laux, pn;
2328  char *name;
2329  int len;
2330  entity ent;
2331 
2332  asprintf(&name, "%s_%d", "MU", stat);
2333  len = strlen(name);
2334  lv_coef = NULL;
2335 
2336  for (laux = lunk; laux != NULL; laux = laux->next)
2337  {
2338  ent = laux->n_ent;
2339  if (!strncmp(name, entity_local_name(ent), len))
2340  pn = make_n_coef(ent, laux->n_vect);
2341  else if (!strncmp("X", entity_local_name(ent), 1))
2342  pn = make_n_coef(ent, laux->n_vect);
2343  else pn = make_n_coef(ent, VECTEUR_NUL);
2344  lv_coef = add_n_coef_to_list(lv_coef, pn);
2345  }
2346  free(name);
2347 
2348  return(lv_coef);
2349 }
2350 
2351 /*==================================================================*/
2352 /* bdt include_results_in_bdt(b, baux, lexp): in case of a multi
2353  * dimensionnal bdt, this function is used to append the dimension
2354  * calculated at this step (lexp) with the dimensions calculated
2355  * before (b) and the dimensions calculated after (baux);
2356  *
2357  * AC 94/10/27
2358  */
2359 
2361 
2362  bdt b, baux;
2363  list lexp;
2364 {
2365  list ls, le, lexp_aux;
2366  schedule sched;
2367  Psysteme sys, sc;
2368  predicate pred;
2369 
2370  if (!bdt_undefined_p(baux))
2371  {
2372  ls = bdt_schedules(baux);
2374  sys = predicate_to_system(pred);
2375 
2376  for (; ls != NIL; ls = CDR(ls))
2377  {
2378  lexp_aux = CONS(EXPRESSION,(EXPRESSION(CAR(lexp))),NIL);
2379 
2380  /* update the predicate */
2381  sched = SCHEDULE(CAR(ls));
2383  sc = sc_append(sc,sys);
2384  schedule_predicate(sched) = make_predicate(sc);
2385 
2386  /* update the list of expressions */
2387  le = schedule_dims(sched);
2388  le = gen_nconc(lexp_aux, le);
2389  schedule_dims(sched) = le;
2390  }
2391  b = baux;
2392  }
2393  else
2394  {
2395  ls = bdt_schedules(b);
2396  sched = SCHEDULE(CAR(ls));
2397  schedule_dims(sched) = lexp;
2398  bdt_schedules(b) = CONS(SCHEDULE, sched, NIL);
2399  }
2400 
2401  return(b);
2402 }
2403 
2404 /*==================================================================*/
2405 /* bool is_mu_stat_in_sc(stat, sc): check if the system "sc"
2406  * contains some variable of type "MU_stat".
2407  *
2408  * AC 94/01/27
2409  */
2410 
2411 bool is_mu_stat_in_sc(stat, sc)
2412 
2413  int stat;
2414  Psysteme sc;
2415 {
2416  entity ent;
2417  char *name;
2418  int len;
2419  list lbase;
2420  bool is_here = false;
2421 
2422  asprintf(&name, "%s_%d", "MU", stat);
2423  len = strlen(name);
2424 
2425  lbase = base_to_list(sc->base);
2426 
2427  for (; lbase != NIL; lbase = CDR(lbase))
2428  {
2429  ent = ENTITY(CAR(lbase));
2430  if (!strncmp(name, entity_local_name(ent), len))
2431  is_here = true;
2432  }
2433  free(name);
2434  return(is_here);
2435 }
2436 
2437 /*==================================================================*/
2438 /* bdt analyze_quast(q,lu,nb): this function substitute the new
2439  * parameters that can appear, go down to each branch of the quast
2440  * and analyze if all edge have been satisfied, if not find recur-
2441  * sively the dimension of the schedule.
2442  *
2443  * AC 94/01/27
2444  */
2445 
2446 static bdt analyze_quast(q, stat, lunk, lsys, b, lxe, me)
2447 
2448  quast q;
2449  int stat;
2450  Pn_coef lunk;
2451  Psys_list lsys;
2452  bdt b;
2453  list lxe;
2454  entity me;
2455 {
2456  list lsol, new_lsol, lnew, lst, lsf, ls, lu, lvp;
2457  predicate pred;
2458  conditional cond, cond_aux;
2459  quast_value quv;
2460  expression exp;
2461  quast_leaf qul;
2462  entity ent;
2463  var_val vv;
2464  Psysteme sys, st_sys, sf_sys;
2465  int m_coef, nb_arc, d;
2466  schedule st, sf;
2467  Pdisjunct dj;
2468  bdt bt, bf;
2469  quast qua;
2470  Pvecteur vu;
2471 
2472  new_lsol = NIL;
2473  lnew = NIL;
2474  quv = quast_quast_value(q);
2475  lnew = quast_newparms(q);
2476 
2477  ls = NIL;
2478  lst = NIL;
2479  lsf = NIL;
2480 
2481  if (quast_undefined_p(q))
2482  pips_internal_error("Quast should not be undefined!");
2483 
2484  if (bdt_undefined_p(b))
2485  {
2486  st = make_schedule(stat, predicate_undefined, NIL);
2487  b = make_bdt(CONS(SCHEDULE, st, NIL));
2488  }
2489  else st = SCHEDULE(CAR(bdt_schedules(b)));
2490 
2491  /* see if there are some new parameters to replace */
2492  if ((lnew != NIL) && (get_debug_level() > 5))
2493  {
2494  vv = VAR_VAL(CAR(lnew));
2495  ent = var_val_variable(vv);
2496  exp = var_val_value(vv);
2497  fprintf(stderr,"\nNouveau parametre :\n");
2498  fprint_entity_list(stderr, CONS(ENTITY,ent,NIL));
2499  fprintf(stderr," => ");
2501  }
2502 
2503  switch(quast_value_tag(quv))
2504  {
2506  cond = quast_value_conditional(quv);
2507  pred = conditional_predicate(cond);
2508  sys = sc_dup(predicate_to_system(pred));
2509 
2510  /* replace the new parameters in the predicate system */
2511  sys = system_new_var_subst(sys, lnew);
2512  sf = true_copy_schedule(st);
2515 
2516  /* we process the true edge */
2517  st_sys = sc_append(st_sys, sys);
2518 
2519  if (sc_rational_feasibility_ofl_ctrl(st_sys, NO_OFL_CTRL, true)) {
2520  st = make_schedule(stat, make_predicate(st_sys), NIL);
2521  bt = make_bdt(CONS(SCHEDULE, st, NIL));
2522  cond_aux = conditional_true_quast(cond);
2523  bt = analyze_quast(cond_aux, stat, lunk, lsys, bt, lxe, me);
2524  lst = bdt_schedules(bt);
2525  }
2526  else
2527  {
2528  lst = NIL;
2529  sc_rm(st_sys);
2530  }
2531 
2532  /* we process the false edge */
2533  dj = dj_system_complement(sys);
2534  sys = dj->psys;
2535  sf_sys = sc_append(sf_sys, sys);
2536 
2537  if (sc_rational_feasibility_ofl_ctrl(sf_sys, NO_OFL_CTRL, true))
2538  {
2539  sf = make_schedule(stat, make_predicate(sf_sys), NIL);
2540  bf = make_bdt(CONS(SCHEDULE, sf, NIL));
2541  cond_aux = conditional_false_quast(cond);
2542  bf = analyze_quast(cond_aux, stat, lunk, lsys, bf, lxe, me);
2543  lsf = bdt_schedules(bf);
2544  }
2545  else
2546  {
2547  lsf = NIL;
2548  sc_rm(sf_sys);
2549  }
2550 
2551  bdt_schedules(b) = gen_nconc(lst, lsf);
2552  sc_rm(sys);
2553  break;
2554 
2556  qul = quast_value_quast_leaf( quv );
2557  lsol = quast_leaf_solution( qul );
2558  exp = EXPRESSION(CAR(lsol));
2559  m_coef = get_m_coef(&exp, &d);
2560  nb_arc = gen_length(lxe);
2561  if (m_coef == nb_arc)
2562  {
2563  /* all the edges are satisfied, we get the schedule */
2564  if (get_debug_level() > 5)
2565  {
2566  fprintf(stderr,"\nTous les arcs sont satisfaits car\
2567  le coef de M est %d\n",m_coef);
2568  fprint_entity_list(stderr, lxe);
2569  fprint_entity_list(stderr,CONS(ENTITY,me,NIL));
2570  }
2571 
2572  schedule_dims(st) = get_exp_schedule(exp, me, d);
2573  }
2574  else
2575  {
2576  /* some edges have not been satisfied: we get the */
2577  /* dimension of the schedule already calculated */
2578  /* and search the others */
2579  if (get_debug_level() > 5)
2580  {
2581  fprintf(stderr,"\nTous les arcs ne sont pas satisfaits car\
2582  le coef de M est %d\n",m_coef);
2583  }
2584 
2585  new_lsol = get_exp_schedule(exp, me, d);
2586 
2587  sys = get_unsatisfied_system(lsol, &lsys, &lxe, me, d);
2588  clean_list_of_unk(&lunk, &sys);
2589 
2590  if (get_debug_level() > 5)
2591  {
2592  fprintf(stderr,"\nDimension trouvee :");
2593  fprint_list_of_exp(stderr, new_lsol);
2594  fprintf(stderr,"\n\n\nNb d'arc = %d", nb_arc);
2595  fprintf(stderr,"\nSYS LIST:\n");
2596  fprint_sys_list(stderr, lsys);
2597  fprint_entity_list(stderr, lxe);
2598  }
2599 
2600  bt = bdt_undefined;
2601 
2602  if (is_mu_stat_in_sc(stat, sys))
2603  {
2604  sys = make_primal(sys, &lu, &lvp, lxe);
2605 
2606  sys = make_dual(sys, &st_sys, lunk, &lu, lvp);
2607 
2608  vu = list_to_base(lu);
2609 
2610  if (get_debug_level() > 5)
2611  {
2612  fprint_psysteme(stderr,sys);
2613  fprintf(stderr,"\nSysteme de contraintes :\n");
2614  fprint_psysteme(stderr,st_sys);
2615  fprintf(stderr,"\nVct d'inconnues = \n");
2616  pu_vect_fprint(stderr, vu);
2617  fprintf(stderr,"\nBase de psys: ");
2618  pu_vect_fprint(stderr,sys->base);
2619  fprintf(stderr,"\nBase de sys_cont:");
2620  pu_vect_fprint(stderr,st_sys->base);
2621  }
2622 
2623  qua = pip_solve_min_with_big(sys, st_sys, vu, "My_Own_Private_M");
2624 
2625  qua = compact_quast(qua, gen_length(lxe));
2626 
2627  if (get_debug_level() > 5)
2628  {
2629  fprintf(stderr,"\n\nQuast de PIP (n_dim):");
2630  imprime_quast(stderr,qua);
2631  }
2632 
2633  bt = analyze_quast(qua, stat, lunk, lsys, bt, lxe, me);
2634 
2635  if (get_debug_level() > 5)
2636  {
2637  fprintf(stderr,"\nBdt apres analyze :");
2638  fprint_bdt(stderr,bt);
2639  }
2640  }
2641  b = include_results_in_bdt(b, bt, new_lsol);
2642  }
2643  break;
2644  }
2645 
2646  return(b);
2647 }
2648 
2649 /*==================================================================*/
2650 /* bdt make_bdt_initial(stat, s): write the initial bdt with as a
2651  * predicate, the definition domaine of the node.
2652  *
2653  * 94/01/27
2654  */
2655 
2657 
2658  int stat;
2659  scc s;
2660 {
2661  bdt b;
2662  schedule st;
2663  predicate pred;
2664  Psysteme sc;
2665 
2666  sc = sc_dup(get_predicate_system_of_node(stat, s));
2667  pred = make_predicate(sc);
2668  st = make_schedule(stat, pred, NIL);
2669  b = make_bdt(CONS(SCHEDULE, st, NIL));
2670 
2671  return(b);
2672 }
2673 
2674 /*==================================================================*/
2675 /* bdt write_resulting_bdt(s, stat, bs, bg): simplify the bdt found
2676  * and update the hash table.
2677  *
2678  * AC 94/01/27
2679  */
2680 
2681 bdt write_resulting_bdt(s, stat, bs, bg)
2682 
2683  scc s;
2684  int stat;
2685  bdt bs, bg;
2686 {
2687  Pbdt_node node;
2688  list lsc;
2689 
2690  bs = simplify_bdt(bs, s);
2691  node = (Pbdt_node) hash_get(h_node, (char *) stat);
2692  node->n_bdt = true_copy_bdt(bs);
2693  lsc = bdt_schedules(true_copy_bdt(bs));
2694  if (bdt_undefined_p(bg)) bg = bs;
2695  else bdt_schedules(bg) = gen_nconc(bdt_schedules(bg), lsc);
2696 
2697  return(bg);
2698 }
2699 
2700 /*==================================================================*/
2701 /* bdt search_scc_bdt( (scc) s) : from a given scc, make for each
2702  * vertex the causality condition under its Farkas form and place it
2703  * in a system. Then build the primal problem, then the dual problem,
2704  * and finally solve it by PIP.
2705  *
2706  * AC 93/10/29
2707  */
2708 
2710 
2711  scc s;
2712 {
2713  Psysteme psys, psys_aux, sys_dest, sys_pred, sys;
2714  list lver, lpred, lsched, lexp, ldata, lu, lstat, ltrans;
2715  list lxe, lvp;
2716  Ppolynome poly_dest, poly_source;
2717  int stat_dest, stat_pred, count, stat, xcount, den;
2718  Pbdt_node node_dest, node_pred;
2719  schedule sched;
2720  predicate pred_dest, pred_pred;
2721  bdt bdt_pred, scc_bdt, stat_bdt;
2722  expression exp;
2723  vertex vert_pred;
2724  Pn_coef lunk, lunk2, lunkx;
2725  quast qua;
2726  Psyslist lbdt_pred = NULL;
2727  Psys_list lsys = NULL;
2728  entity xe, me;
2729  bool all_external = false;
2730  Pvecteur vu;
2731 
2732  psys = sc_new();
2733  lunk = NULL;
2734  lunk2 = NULL;
2735  lunkx = NULL;
2736  lstat = NIL;
2737  scc_bdt = bdt_undefined;
2738  xcount = 0;
2739  lxe = NIL;
2740  lvp = NIL;
2741 
2742  if (get_debug_level() > 5)
2743  {
2744  fprintf(stderr,"\nDEBUT DE CALCUL SUR UNE SCC :\n");
2745  fprintf(stderr,"\n=============================\n");
2746  }
2747 
2748  lver = scc_vertices(s);
2749  if (lver->cdr == NIL) all_external = true;
2750 
2751  /* for each node of the studied scc, get the characteristics of */
2752  /* the node we want the schedule */
2753  for (lver = scc_vertices(s); lver != NIL; lver = CDR(lver))
2754  {
2755  vertex ver = VERTEX(CAR(lver));
2756  stat_dest = vertex_int_stmt(ver);
2758  vertex_vertex_label(ver));
2759  sys_dest = sc_dup(predicate_to_system(pred_dest));
2760  node_dest = (Pbdt_node) hash_get(h_node, (char *) stat_dest);
2761  poly_dest = node_dest->n_poly;
2762  lunk = add_lcoef_to_lcoef(lunk, node_dest->n_var);
2763  ADD_ELEMENT_TO_LIST(lstat, INT, stat_dest);
2764 
2765  if (get_debug_level() > 5)
2766  {
2767  fprintf(stderr,"\nOn s'interesse au noeud n.%d",stat_dest);
2768  fprintf(stderr,"\n===========================\n");
2769  fprintf(stderr,"de predicat : ");
2770  fprint_psysteme(stderr,sys_dest);
2771  fprintf(stderr,"\nde polynome : ");
2772  my_polynome_fprint(stderr,poly_dest);
2773  }
2774 
2775  /* for each predecessor of the studied node, make the causality */
2776  /* condition under its Farkas form and write it in a Psystem */
2777  for (lpred=vertex_successors(ver); lpred!=NIL; lpred=CDR(lpred))
2778  {
2779  successor suc = SUCCESSOR(CAR(lpred));
2780  vert_pred = successor_vertex(suc);
2781  stat_pred = vertex_int_stmt(vert_pred);
2782  node_pred = (Pbdt_node)hash_get(h_node, (char *) stat_pred);
2783  count = 0;
2784  den = 1;
2786  successor_arc_label(suc));
2787 
2788  while (ldata != NIL)
2789  {
2790  /* test if the vertex has already its schedule, and if yes */
2791  /* convert it to use it in the causality condition */
2792  if (node_pred->n_bdt == (schedule)NIL)
2793  {
2794  /* this edge is an internal edge, so the predececssor */
2795  /* has not already a schedule */
2796  xcount++;
2797 
2798  if (get_debug_level() > 5)
2799  {
2800  fprintf(stderr,"\n\nPredecesseur n.%d:pas de\
2801  schedule\n", stat_pred);
2802  fprintf(stderr,"-------------------------------\n\n");
2803  }
2804 
2805  /* get the polynom of the source */
2806  poly_source = polynome_dup(node_pred->n_poly);
2807 
2808  psys_aux = make_causal_internal(stat_dest, sys_dest,\
2809  poly_dest, ldata, stat_pred, SC_RN,\
2810  poly_source, &count, xcount, &xe, den);
2811 
2812  all_external = false;
2813  ADD_ELEMENT_TO_LIST(lxe, ENTITY, xe);
2814  lsys = add_elt_to_sys_list(lsys, xcount, psys_aux);
2815  }
2816  else
2817  {
2818  /* the edge is an external edge, so the predecessor */
2819  /* has alredy a schedule. We only consider the first */
2820  /* dimension of this schedule in case of a multidimen- */
2821  /* sionnal one. */
2822  if (get_debug_level() > 5)
2823  {
2824  fprintf(stderr,"\n\nPredecesseur n.%d : schedule!!\n",\
2825  stat_pred);
2826  fprintf(stderr,"------------------------------\n");
2827  }
2828 
2829  psys_aux = SC_RN;
2830  /* get the list of schedules of the source */
2831  bdt_pred = true_copy_bdt(node_pred->n_bdt);
2832 
2833  if (get_debug_level() > 5)
2834  {
2835  fprintf(stderr,"\nBdt du predecesseur :\n");
2836  fprint_bdt(stderr,bdt_pred);
2837  }
2838 
2839  /* for each schedule, write the causality condition */
2840  for (lsched=bdt_schedules(bdt_pred); lsched!=NIL;lsched=CDR(lsched))
2841  {
2842  sched = SCHEDULE(CAR(lsched));
2843  pred_pred = schedule_predicate(sched);
2844  sys_pred = sc_dup(predicate_to_system(pred_pred));
2845  ltrans = dataflow_transformation(DATAFLOW(CAR(ldata)));
2846 
2847  if (!SC_UNDEFINED_P(sys_pred))
2848  {
2849  sys_pred = include_trans_in_sc(stat_pred, sys_pred,\
2850  ltrans);
2851  lbdt_pred = add_sc_to_sclist(sys_pred, lbdt_pred);
2852  }
2853 
2854  lexp = schedule_dims(sched);
2855  exp = EXPRESSION(CAR(lexp));
2856  analyze_expression(&exp,&den);
2857 
2858  poly_source = expression_to_polynome(exp);
2859 
2860  if (get_debug_level() > 5)
2861  {
2862  fprint_list_of_exp(stderr,lexp);
2863  fprintf(stderr,"\nPsystem du predecesseur: \n");
2864  fprint_psysteme(stderr,sys_pred);
2865  }
2866 
2867  if (all_external)
2868  {
2869  /* this is a particular case where we introduce */
2870  /* an Xe if we want the primal problem to be */
2871  /* consistent with the theory. */
2872  xcount++;
2873  sys = make_causal_internal(stat_dest, sys_dest,\
2874  poly_dest, ldata, stat_pred, sys_pred,\
2875  poly_source, &count, xcount, &xe, den);
2876 
2877  ADD_ELEMENT_TO_LIST(lxe, ENTITY, xe);
2878  lsys = add_elt_to_sys_list(lsys, xcount, sys);
2879  all_external = false;
2880  }
2881  else
2882  sys = make_causal_external(stat_dest, sys_dest,\
2883  poly_dest, ldata, stat_pred, sys_pred,\
2884  poly_source, &count, den);
2885  if (get_debug_level() > 5)
2886  {
2887  fprintf(stderr,"\nSysteme pour arc:\n");
2888  fprint_psysteme(stderr,sys);
2889  }
2890 
2891  psys_aux = sc_append(psys_aux, sys);
2892  }
2893  }
2894 
2895  if (get_debug_level() > 5)
2896  {
2897  fprintf(stderr,"\nSysteme:\n");
2898  fprint_psysteme(stderr,psys_aux);
2899  }
2900 
2901  psys = sc_append(psys, psys_aux);
2902  sc_rm(psys_aux);
2903  ldata = CDR(ldata);
2904  }
2905  }
2906  psys = erase_trivial_ineg(psys);
2907  }
2908 
2909  my_sc_normalize(psys);
2910  psys = sc_dup(psys);
2911 
2912  /* we have to add the constraints on the Xs: X<=1 */
2913  psys = add_constraint_on_x(psys, lxe);
2914 
2915  /* Now we have in "psys" the complete Psystem in mu-lambda to solve */
2916  /* We now transform it in the primal problem */
2917 
2918  make_list_of_unk(&lunk, &psys, &me, lxe);
2919  psys = make_primal(psys, &lu, &lvp, lxe);
2920 
2921  if (get_debug_level() > 5)
2922  {
2923  fprintf(stderr,"\nSysteme primal :\n");
2924  fprint_psysteme(stderr,psys);
2925  fprintf(stderr,"\nVariables :\n");
2926  fprint_coef_list(stderr,lunk);
2927  }
2928 
2929  for (; lstat != NIL; lstat = CDR(lstat))
2930  {
2931  psys_aux = sc_dup(sc_dup(psys));
2932  stat = INT(CAR(lstat));
2933  lunk2 = extract_stat_lunk(stat, lunk);
2934  psys_aux = make_dual(psys_aux, &sys_dest, lunk2, &lu, lvp);
2935  sys_dest = sc_dup(sys_dest);
2936  vu = list_to_base(lu);
2937 
2938  if (get_debug_level() > 5)
2939  {
2940  fprintf(stderr,"\nSysteme dual :\n");
2941  fprint_psysteme(stderr,psys_aux);
2942  fprintf(stderr,"\nSysteme de contraintes :\n");
2943  fprint_psysteme(stderr,sys_dest);
2944  fprintf(stderr,"\nVct d'inconnues = \n");
2945  pu_vect_fprint(stderr, vu);
2946  fprintf(stderr,"\nBase de psys: ");
2947  pu_vect_fprint(stderr,psys_aux->base);
2948  fprintf(stderr,"\nBase de sys_cont:");
2949  pu_vect_fprint(stderr,sys_dest->base);
2950  }
2951 
2952  qua = pip_solve_min_with_big(psys_aux, sys_dest, vu, "My_Own_Private_M");
2953 
2954  qua = compact_quast(qua, gen_length(lxe));
2955 
2956  if (get_debug_level() > 5)
2957  {
2958  fprintf(stderr,"\n\nQuast de PIP pour %d:", stat);
2959  imprime_quast(stderr,qua);
2960  }
2961 
2962  stat_bdt = make_bdt_initial(stat, s);
2963  stat_bdt = analyze_quast(qua, stat, lunk2, lsys, stat_bdt, lxe, me);
2964 
2965  if (get_debug_level() > 5)
2966  {
2967  fprintf(stderr,"\nBDT AVANT:\n");
2968  fprint_bdt(stderr, stat_bdt);
2969  }
2970 
2971  scc_bdt = write_resulting_bdt(s, stat, stat_bdt, scc_bdt);
2972 
2973  if (get_debug_level() > 5)
2974  {
2975  fprintf(stderr,"\nBDT APRES:\n");
2976  fprint_bdt(stderr, stat_bdt);
2977  }
2978 
2979  lu = CDR(lu);
2980  }
2981 
2982  if (get_debug_level() > 5)
2983  {
2984  fprintf(stderr,"\nBDT :\n");
2985  fprint_bdt(stderr,scc_bdt);
2986  }
2987 
2988  sc_rm(psys);
2989 
2990  return(scc_bdt);
2991 }
2992 
2993 /*==================================================================*/
2994 /* bdt search_graph_bdt( (sccs) rgraph ) : function that goes through
2995  * the reverse graph "rgraph" and search the set of bdt for each
2996  * reduced node.
2997  *
2998  * AC 93/10/27
2999  */
3000 
3002 
3003  sccs rgraph;
3004 {
3005  list lscc, lsched, lschedg;
3006  bdt bdt_graph, bdt_scc;
3007  bool no_pred;
3008 
3009  bdt_graph = bdt_undefined;
3011  make_proto(h_node, rgraph);
3012 
3013  for (lscc = sccs_sccs(rgraph); lscc != NIL; lscc = CDR(lscc))
3014  {
3015  scc scc_an = SCC(CAR(lscc));
3016  bdt_scc = bdt_undefined;
3017 
3018  /* test of the existence of a predecessor */
3019  no_pred = if_no_pred(scc_an, &bdt_scc);
3020 
3021  /* search the set of bdt for this scc */
3022  if (!no_pred) bdt_scc = search_scc_bdt(scc_an);
3023 
3024  /* add the found bdt to the already calculated ones */
3025  if (!bdt_undefined_p(bdt_graph))
3026  {
3027  lsched = bdt_schedules(bdt_scc);
3028  lschedg = bdt_schedules(bdt_graph);
3029  bdt_schedules(bdt_graph) = gen_nconc(lschedg, lsched);
3030  }
3031  else bdt_graph = bdt_scc;
3032  }
3033 
3035 
3036  return (bdt_graph);
3037 }
static void node(FILE *out, string name)
Build for module name a node and link to its successors.
Definition: graph.c:56
bdt make_bdt(list a)
Definition: paf_ri.c:54
void free_quast(quast p)
Definition: paf_ri.c:483
schedule make_schedule(intptr_t a1, predicate a2, list a3)
Definition: paf_ri.c:613
call make_call(entity a1, list a2)
Definition: ri.c:269
expression make_expression(syntax a1, normalized a2)
Definition: ri.c:886
predicate make_predicate(Psysteme a1)
Definition: ri.c:1820
syntax make_syntax(enum syntax_utype tag, void *val)
Definition: ri.c:2491
static int count
Definition: SDG.c:519
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
statement adg_number_to_statement(int in_nb)
======================================================================
Definition: adg_utils.c:461
#define VALUE_TO_INT(val)
#define value_negz_p(val)
int Value
#define value_abs(val)
#define value_mult(v, w)
whether the default is protected or not this define makes no sense any more...
#define value_div(v1, v2)
#define value_posz_p(val)
Value ppcm(Value, Value)
ppcm.c
Definition: ppcm.c:42
static list lexp
@ INT
Definition: atomic.c:48
Pbase base_add_variable(Pbase b, Variable var)
Pbase base_add_variable(Pbase b, Variable v): add variable v as a new dimension to basis b at the end...
Definition: base.c:88
bool base_contains_variable_p(Pbase b, Variable v)
bool base_contains_variable_p(Pbase b, Variable v): returns true if variable v is one of b's elements...
Definition: base.c:136
bdt base
Current expression.
Definition: bdt_read_paf.c:100
Psysteme my_sc_normalize(Psysteme ps)
==============================================================
Definition: bdt_utils.c:254
schedule true_copy_schedule(schedule s)
=================================================================
Definition: bdt_utils.c:318
entity create_named_entity(char *name)
=====================================================================
Definition: bdt_utils.c:85
void poly_chg_var(Ppolynome pp, Variable v_old, Variable v_new)
=================================================================
Definition: bdt_utils.c:399
Psysteme suppress_sc_in_sc(Psysteme in_ps1, Psysteme in_ps2)
======================================================================
Definition: bdt_utils.c:426
Psysteme predicate_to_system(predicate p)
=================================================================
Definition: bdt_utils.c:298
bool system_contains_var(Psysteme ps, Variable var)
=====================================================================
Definition: bdt_utils.c:382
bdt true_copy_bdt(bdt b)
=====================================================================
Definition: bdt_utils.c:354
bool exp_equals_p(expression e1, expression e2)
======================================================================
Definition: bdt_utils.c:820
void analyze_expression(expression *e, int *d)
=====================================================================
Definition: bdt_utils.c:480
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
Definition: alloc.c:73
#define SCC(x)
SCC.
Definition: dg.h:315
#define scc_vertices(x)
Definition: dg.h:345
#define sccs_sccs(x)
Definition: dg.h:311
Pdisjunct dj_system_complement(Psysteme in_ps)
Pdisjunct dj_system_complement( (Psystem) in_ps ) AL 26/10/93 Input : A Psysteme.
Definition: disjunct.c:254
if(!(yy_init))
Definition: genread_lex.c:1029
void * malloc(YYSIZE_T)
void free(void *)
#define successor_vertex(x)
Definition: graph.h:118
#define successor_arc_label(x)
Definition: graph.h:116
#define vertex_vertex_label(x)
Definition: graph.h:152
#define vertex_successors(x)
Definition: graph.h:154
#define SUCCESSOR(x)
SUCCESSOR.
Definition: graph.h:86
#define VERTEX(x)
VERTEX.
Definition: graph.h:122
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#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
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#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
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
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 hash_put(hash_table htp, const void *key, const void *val)
This functions stores a couple (key,val) in the hash table pointed to by htp.
Definition: hash.c:364
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327
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 ADD_ELEMENT_TO_LIST(_list, _type, _element)
Definition: icfg-local.h:50
list make_list_of_n(char *n, int c)
=================================================================
Definition: makebdt.c:473
list add_others_variables(list lvar, list n_lvar)
=================================================================
Definition: makebdt.c:1286
static void make_list_of_unk(Pn_coef *l, Psysteme *sc, entity *me, list lx)
=================================================================
Definition: makebdt.c:1904
bool if_no_pred(scc s, bdt *b)
=================================================================
Definition: makebdt.c:768
struct sys_list * Psys_list
int get_m_coef(expression *e, int *de)
=================================================================
Definition: makebdt.c:954
Ppolynome make_polynome_Xe(int xc, entity *xe)
=================================================================
Definition: makebdt.c:1260
list reorder_base(list l, list lu)
=================================================================
Definition: makebdt.c:308
static Pn_coef add_lcoef_to_lcoef(Pn_coef l1, Pn_coef l2)
=================================================================
Definition: makebdt.c:258
dfg_arc_label arc_label
C3 includes
Definition: makebdt.c:79
static Psysteme make_primal(Psysteme psys, list *lvar_u, list *lvp, list lxe)
=================================================================
Definition: makebdt.c:1731
list get_list_of_all_param(int s, int t)
=================================================================
Definition: makebdt.c:1168
bdt build_bdt_null(vertex v)
=================================================================
Definition: makebdt.c:733
hash_table h_node
Definition: makebdt.c:85
Psysteme system_new_var_subst(Psysteme sys, list l)
=================================================================
Definition: makebdt.c:1629
Psysteme make_causal_external(int stat_dest, Psysteme sys_dest, Ppolynome poly_dest, list ldata, int stat_pred, Psysteme sys_pred, Ppolynome poly_source, int *c, int den)
=================================================================
Definition: makebdt.c:1460
Psysteme include_trans_in_sc(int s, Psysteme sys, list l)
=================================================================
Definition: makebdt.c:1227
bdt write_resulting_bdt(scc s, int stat, bdt bs, bdt bg)
=================================================================
Definition: makebdt.c:2681
list simplify_dimension(list ld, Psysteme ps_eq, list l)
=================================================================
Definition: makebdt.c:2056
struct n_coef n_coef
bool is_uniform_rec(list l, Ppolynome p)
=================================================================
Definition: makebdt.c:1202
static Pn_coef add_n_coef_to_list(Pn_coef l1, Pn_coef l2)
=====================================================================
Definition: makebdt.c:213
static Psys_list add_elt_to_sys_list(Psys_list ls, int s, Psysteme ps)
=====================================================================
Definition: makebdt.c:136
list get_exp_schedule(expression e, entity me, int d)
=================================================================
Definition: makebdt.c:1788
static void clean_list_of_unk(Pn_coef *l, Psysteme *sc)
=================================================================
Definition: makebdt.c:440
static bdt search_scc_bdt(scc s)
=================================================================
Definition: makebdt.c:2709
Psyslist add_sc_to_sclist(Psysteme sc, Psyslist lsys)
=================================================================
Definition: makebdt.c:1985
bool is_mu_stat_in_sc(int stat, Psysteme sc)
=================================================================
Definition: makebdt.c:2411
quast compact_quast(quast q, int n)
======================================================================
Definition: makebdt.c:1080
#define my_polynome_fprint(fp, p)
Definition: makebdt.c:82
dfg_vertex_label vertex_label
Definition: makebdt.c:80
list make_sched_proto(matrice h, int lin, int col, list lu)
=================================================================
Definition: makebdt.c:1592
struct n_coef * Pn_coef
bdt make_bdt_initial(int stat, scc s)
=================================================================
Definition: makebdt.c:2656
Psysteme add_constraint_on_x(Psysteme psys, list lx)
=================================================================
Definition: makebdt.c:1691
Psysteme simplify_predicate(Psysteme ps, Psysteme ps_eq, list l)
=================================================================
Definition: makebdt.c:2008
struct sys_list sys_list
static Pn_coef add_lambda_list(Pn_coef lunk, list lvar)
=================================================================
Definition: makebdt.c:337
list make_x_list(int c)
=================================================================
Definition: makebdt.c:361
Psysteme make_causal_internal(int stat_dest, Psysteme sys_dest, Ppolynome poly_dest, list ldata, int stat_pred, Psysteme sys_pred, Ppolynome poly_source, int *c, int xc, entity *xe, int den)
=================================================================
Definition: makebdt.c:1317
bdt simplify_bdt(bdt b, scc s)
=================================================================
Definition: makebdt.c:2160
bool list_of_exp_equals_1n_p(list l1, list l2, int n)
======================================================================
Definition: makebdt.c:1037
static list extract_var_list(Pn_coef lc)
=================================================================
Definition: makebdt.c:421
static void create_farkas_poly(Psysteme Psys, char *Type, int source, int dest, Ppolynome *p, Pn_coef *l, int *c)
=====================================================================
Definition: makebdt.c:580
bdt include_results_in_bdt(bdt b, bdt baux, list lexp)
=================================================================
Definition: makebdt.c:2360
entity create_var_name(char *Type, int source, int dest, int count)
=====================================================================
Definition: makebdt.c:113
static Pn_coef make_n_coef(entity e, Pvecteur v)
=====================================================================
Definition: makebdt.c:191
list extract_lambda_list(list l)
=================================================================
Definition: makebdt.c:281
Psysteme erase_trivial_ineg(Psysteme p)
=================================================================
Definition: makebdt.c:796
Psysteme get_predicate_system_of_node(int st, scc s)
=================================================================
Definition: makebdt.c:1950
static void fprint_sys_list(FILE *fp, Psys_list ls)
=====================================================================
Definition: makebdt.c:171
Psysteme transform_in_ineq(Psysteme sc, list l)
=================================================================
Definition: makebdt.c:902
struct bdt_node bdt_node
static void fprint_coef_list(FILE *fp, Pn_coef l)
=====================================================================
Definition: makebdt.c:236
static Psysteme make_dual(Psysteme psys, Psysteme *pcont, Pn_coef l, list *lvar_u, list lvp)
=================================================================
Definition: makebdt.c:2246
bdt search_graph_bdt(sccs rgraph)
=================================================================
Definition: makebdt.c:3001
static void make_proto(hash_table h, sccs rg)
=================================================================
Definition: makebdt.c:687
bool coef_of_M_equal(expression *exp1, expression *exp2)
======================================================================
Definition: makebdt.c:1017
Psysteme include_parameters_in_sc(Psysteme sys, int source)
=====================================================================
Definition: makebdt.c:533
static Pn_coef add_x_list(Pn_coef lunk, list lvar, entity *me)
=================================================================
Definition: makebdt.c:391
struct bdt_node * Pbdt_node
Ppolynome include_trans_in_poly(int s, Ppolynome p, list l, int *d)
=================================================================
Definition: makebdt.c:832
static Pn_coef extract_stat_lunk(int stat, Pn_coef lunk)
=================================================================
Definition: makebdt.c:2322
bool is_stat_in_pred_list(int stat, list pred_list)
=====================================================================
Definition: makebdt.c:502
static bdt analyze_quast(quast q, int stat, Pn_coef lunk, Psys_list lsys, bdt b, list lxe, entity me)
=================================================================
Definition: makebdt.c:2446
static Psysteme get_unsatisfied_system(list lexp, Psys_list *lsys, list *lxe, Pn_coef *lunk, entity me, int de)
=================================================================
Definition: makebdt.c:1846
#define matrice_free(m)
Definition: matrice-local.h:78
#define ACCESS(matrix, column, i, j)
Macros d'acces aux elements d'une matrice.
Definition: matrice-local.h:86
#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
void matrice_transpose(matrice a, matrice a_t, int n, int m)
package matrice
Definition: matrice.c:48
void matrice_nulle(matrice Z, int n, int m)
void matrice_nulle(matrice Z, int n, int m): Initialisation de la matrice Z a la valeur matrice nulle
Definition: matrice.c:311
#define asprintf
Definition: misc-local.h:225
#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",...
@ hash_int
Definition: newgen_hash.h:32
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
Pcontrainte polynome_to_contrainte(Ppolynome)
========================================================================
Definition: utils.c:1095
bool is_entity_in_list_p(entity, list)
===========================================================================
Definition: utils.c:1281
int vertex_int_stmt(vertex)
===========================================================================
Definition: utils.c:866
Psysteme elim_var_with_eg(Psysteme, list *, list *)
===========================================================================
Definition: utils.c:1361
void pu_vect_fprint(FILE *, Pvecteur)
===========================================================================
Definition: print.c:446
list static_control_to_indices(static_control)
package mapping : Alexis Platonoff, july 1993
Definition: utils.c:1037
Psysteme find_implicit_equation(Psysteme)
========================================================================
Definition: utils.c:2350
Ppolynome vecteur_mult(Pvecteur, Pvecteur)
========================================================================
Definition: utils.c:2024
Pvecteur polynome_to_vecteur(Ppolynome)
========================================================================
Definition: utils.c:1063
list vecteur_to_list(Pvecteur)
===========================================================================
Definition: utils.c:1626
static_control get_stco_from_current_map(statement)
========================================================================
Definition: utils.c:2429
void imprime_quast(FILE *, quast)
===========================================================================
Definition: print.c:514
expression make_rational_exp(Pvecteur, Value)
=====================================================================
Definition: utils.c:2446
void fprint_psysteme(FILE *, Psysteme)
===========================================================================
Definition: print.c:302
Ppolynome prototype_var_subst(Ppolynome, Variable, Ppolynome)
=================================================================
Definition: utils.c:1978
void fprint_bdt(FILE *, bdt)
===========================================================================
Definition: print.c:352
Psysteme polynome_to_sc(Ppolynome, list)
===========================================================================
Definition: utils.c:1158
void pu_matrices_to_contraintes(Pcontrainte *, Pbase, matrice, matrice, int, int)
utils.c
Definition: utils.c:350
#define var_val_value(x)
Definition: paf_ri.h:795
#define conditional_true_quast(x)
Definition: paf_ri.h:302
#define var_val_variable(x)
Definition: paf_ri.h:793
#define DATAFLOW(x)
DATAFLOW.
Definition: paf_ri.h:308
#define dataflow_transformation(x)
Definition: paf_ri.h:342
#define quast_undefined
Definition: paf_ri.h:603
#define bdt_undefined_p(x)
Definition: paf_ri.h:205
#define quast_value_undefined
Definition: paf_ri.h:639
struct _newgen_struct_bdt_ * bdt
Definition: paf_ri.h:72
#define SCHEDULE(x)
SCHEDULE.
Definition: paf_ri.h:682
@ is_quast_value_quast_leaf
Definition: paf_ri.h:654
@ is_quast_value_conditional
Definition: paf_ri.h:655
#define dfg_arc_label_dataflows(x)
Definition: paf_ri.h:378
#define conditional_false_quast(x)
Definition: paf_ri.h:304
#define static_control_params(x)
Definition: paf_ri.h:755
#define quast_newparms(x)
Definition: paf_ri.h:629
#define quast_leaf_solution(x)
Definition: paf_ri.h:591
#define quast_value_tag(x)
Definition: paf_ri.h:672
#define schedule_predicate(x)
Definition: paf_ri.h:715
#define dataflow_governing_pred(x)
Definition: paf_ri.h:344
#define bdt_schedules(x)
Definition: paf_ri.h:226
#define dfg_vertex_label_statement(x)
Definition: paf_ri.h:413
#define schedule_dims(x)
Definition: paf_ri.h:717
#define VAR_VAL(x)
VAR_VAL.
Definition: paf_ri.h:763
#define schedule_statement(x)
Definition: paf_ri.h:713
#define quast_value_quast_leaf_p(x)
Definition: paf_ri.h:673
#define quast_value_quast_leaf(x)
Definition: paf_ri.h:675
#define quast_undefined_p(x)
Definition: paf_ri.h:604
#define quast_quast_value(x)
Definition: paf_ri.h:627
#define dfg_vertex_label_exec_domain(x)
Definition: paf_ri.h:415
#define quast_value_undefined_p(x)
Definition: paf_ri.h:640
#define conditional_predicate(x)
Definition: paf_ri.h:300
#define bdt_undefined
Definition: paf_ri.h:204
#define quast_value_conditional(x)
Definition: paf_ri.h:678
quast pip_solve_min_with_big(Psysteme ps_dep, Psysteme ps_context, Pvecteur pv_unknowns, char *big)
==========================================================================
Definition: pip.c:331
int sol_ppcm()
void unnormalize_expression(void *st)
void unnormalize_expression(expression exp): puts all the normalized field of expressions in "st" to ...
Definition: normalize.c:452
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
Ppolynome polynome_dup(Ppolynome pp)
Ppolynome polynome_dup(Ppolynome pp) creates and returns a copy of pp.
Definition: pnome-alloc.c:211
void polynome_rm(Ppolynome *ppp)
void polynome_rm(Ppolynome* ppp) frees space occupied by polynomial *ppp returns *ppp pointing to POL...
Definition: pnome-alloc.c:170
Ppolynome vecteur_to_polynome(Pvecteur pv)
===========================================================================
Definition: pnome-bin.c:406
void polynome_add(Ppolynome *ppp, Ppolynome pp2)
void polynome_add(Ppolynome* ppp, Ppolynome pp2) (*ppp) = (*ppp) + pp2.
Definition: pnome-bin.c:171
bool polynome_contains_var(Ppolynome pp, Variable var)
bool polynome_contains_var(Ppolynome pp, Variable var) PRIVATE returns true if variable var is in pol...
Definition: pnome-reduc.c:238
Ppolynome polynome_decr(Ppolynome pp)
Ppolynome polynome_decr(Ppolynome pp) returns pp - 1.
Definition: pnome-scal.c:246
void polynome_scalar_mult(Ppolynome *ppp, float factor)
void polynome_scalar_mult(Ppolynome* ppp, float factor) (*ppp) = factor * (*ppp) !...
Definition: pnome-scal.c:46
void polynome_negate(Ppolynome *ppp)
void polynome_negate(Ppolynome *ppp); changes sign of polynomial *ppp.
Definition: pnome-unaires.c:45
#define POLYNOME_UNDEFINED
#define POLYNOME_UNDEFINED_P(pp)
void fprint_list_of_exp(FILE *fp, list exp_l)
void fprint_list_of_exp(FILE *fp, list exp_l): prints in the file "fp" the list of expression "exp_l"...
Definition: expression.c:229
#define NORMALIZE_EXPRESSION(e)
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
expression make_vecteur_expression(Pvecteur pv)
make expression for vector (Pvecteur)
Definition: expression.c:1650
expression Pvecteur_to_expression(Pvecteur vect)
AP, sep 25th 95 : some usefull functions moved from static_controlize/utils.c.
Definition: expression.c:1825
int expression_to_int(expression exp)
================================================================
Definition: expression.c:2205
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
Definition: expression.c:1188
Ppolynome expression_to_polynome(expression exp)
===========================================================================
Definition: expression.c:3650
#define normalized_undefined
Definition: ri.h:1745
#define call_function(x)
Definition: ri.h:709
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
@ is_syntax_call
Definition: ri.h:2693
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define predicate_undefined
Definition: ri.h:2046
#define expression_normalized(x)
Definition: ri.h:1249
#define syntax_call(x)
Definition: ri.h:2736
#define expression_undefined_p(x)
Definition: ri.h:1224
#define call_arguments(x)
Definition: ri.h:711
#define normalized_linear(x)
Definition: ri.h:1781
#define expression_syntax(x)
Definition: ri.h:1247
#define predicate_system(x)
Definition: ri.h:2069
Psysteme sc_make(Pcontrainte leg, Pcontrainte lineg)
Psysteme sc_make(Pcontrainte leg, Pcontrainte lineg): allocation et initialisation d'un systeme d'equ...
Definition: sc.c:78
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
Psysteme sc_new(void)
Psysteme sc_new(): alloue un systeme vide, initialise tous les champs avec des valeurs nulles,...
Definition: sc_alloc.c:55
void sc_add_inegalite(Psysteme p, Pcontrainte i)
void sc_add_inegalite(Psysteme p, Pcontrainte i): macro ajoutant une inegalite i a un systeme p; la b...
Definition: sc_alloc.c:406
Psysteme sc_dup(Psysteme ps)
Psysteme sc_dup(Psysteme ps): should becomes a link.
Definition: sc_alloc.c:176
void sc_elim_empty_constraints(Psysteme ps, bool process_equalities)
void sc_elim_empty_constraints(Psysteme ps, bool process_equalities): elimination des "fausses" contr...
bool sc_rational_feasibility_ofl_ctrl(Psysteme sc, int ofl_ctrl, bool ofl_res)
Psysteme sc_append(Psysteme s1, Psysteme s2)
Psysteme sc_append(Psysteme s1, Psysteme s2): calcul de l'intersection des polyedres definis par s1 e...
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
#define G(j, a, b)
maybe most of them should be functions?
void sc_transform_eg_in_ineg(Psysteme sc)
Package sc.
void vect_chg_sgn(Pvecteur v)
void vect_chg_sgn(Pvecteur v): multiplie v par -1
Definition: scalaires.c:151
Pvecteur vect_multiply(Pvecteur v, Value x)
Pvecteur vect_multiply(Pvecteur v, Value x): multiplication du vecteur v par le scalaire x,...
Definition: scalaires.c:123
int aux
Definition: solpip.c:104
Pvecteur vect_aux
Definition: solpip.c:102
void sc_to_matrices(Psysteme, Pbase, matrice, matrice, int, int)
Creation de la matrice A correspondant au systeme lineaire et de la matrice correspondant a la partie...
static list lvect
Pvecteur vecteur
struct Scontrainte * succ
Warning! Do not modify this file that is automatically generated!
Definition: union-local.h:3
Psysteme psys
Definition: union-local.h:4
struct Ssyslist * succ
Definition: union-local.h:5
Pcontrainte inegalites
Definition: sc-local.h:71
Pcontrainte egalites
Definition: sc-local.h:70
Pbase base
Definition: sc-local.h:75
int dimension
Definition: sc-local.h:74
int nb_ineq
Definition: sc-local.h:73
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
Value val
Definition: vecteur-local.h:91
Variable var
Definition: vecteur-local.h:90
struct Svecteur * succ
Definition: vecteur-local.h:92
Pn_coef n_var
Definition: makebdt.c:96
bdt n_bdt
Definition: makebdt.c:95
Ppolynome n_poly
Definition: makebdt.c:94
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
struct cons * cdr
The pointer to the next element.
Definition: newgen_list.h:43
Definition: makebdt.c:87
Pvecteur n_vect
Definition: makebdt.c:89
struct n_coef * next
Definition: makebdt.c:90
entity n_ent
Definition: makebdt.c:88
Psysteme sys
Definition: makebdt.c:101
struct sys_list * next
Definition: makebdt.c:102
int nb
Definition: makebdt.c:100
struct Ssyslist * Psyslist
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.
#define NO_OFL_CTRL
#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 BASE_UNDEFINED
#define BASE_NULLE
MACROS SUR LES BASES.
#define VECTEUR_UNDEFINED_P(v)
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_add(Pvecteur v1, Pvecteur v2)
package vecteur - operations binaires
Definition: binaires.c:53
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2)
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2): allocation d'un vecteur v dont la valeur est la di...
Definition: binaires.c:75
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
void vect_chg_coeff(Pvecteur *ppv, Variable var, Value val)
void vect_chg_coeff(Pvecteur *ppv, Variable var, Value val): mise de la coordonnee var du vecteur *pp...
Definition: unaires.c:143
void vect_normalize(Pvecteur v)
void vect_normalize(Pvecteur v): division de tous les coefficients de v par leur pgcd; "normalisation...
Definition: unaires.c:59