PIPS
variable.c
Go to the documentation of this file.
1 /*
2 
3  $Id: variable.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  /* Code Generation for Distributed Memory Machines
28  *
29  * Define and allocate local variables as well as emulated shared variables
30  *
31  * File: variable.c
32  *
33  * PUMA, ESPRIT contract 2701
34  *
35  * Francois Irigoin, Corinne Ancourt, Lei Zhou
36  * 1991
37  */
38 
39 #include <stdlib.h>
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <math.h>
43 
44 #include <limits.h>
45 #include <string.h>
46 
47 #include "genC.h"
48 #include "misc.h"
49 
50 #include "linear.h"
51 #include "ri.h"
52 #include "effects.h"
53 #include "dg.h"
56 #include "graph.h"
57 
58 #include "ri-util.h"
59 #include "prettyprint.h"
60 #include "effects-util.h"
61 #include "text-util.h"
62 /* for the phi variable */
63 #include "effects-generic.h"
64 #include "effects-convex.h"
65 #include "arithmetique.h"
66 
67 #include "matrice.h"
68 #include "tiling.h"
69 
70 #include "wp65.h"
71 
72 /* loop_nest_to_local_variables():
73  *
74  * Key function allocating local copies according to interferences between
75  * references. It also gather information about references (which is also
76  * indirectly available in the effect information), allocate emulated
77  * shared variables, and create different mappings between local variables
78  * and references.
79  */
81  initial_module, compute_module, memory_module,
82  llv_to_lcr, r_to_llv, v_to_lllv, r_to_ud,
83  v_to_esv, v_to_nlv,
84  lpv, body, indices, dg, bn, ls, pd, tile)
85 entity initial_module; /* initial module: achtung, this arg. is not used!?! */
86 entity compute_module; /* compute module */
87 entity memory_module; /* memory module */
88 hash_table llv_to_lcr; /* local variable to list of conflicting references */
89 hash_table r_to_llv; /* reference to list of local variables */
90 hash_table v_to_lllv; /* variable to list of lists of local variables */
91 hash_table r_to_ud; /* reference to use def */
92 hash_table v_to_esv; /* variable to emulated shared variable */
93 hash_table v_to_nlv; /* variable to number of associated local
94  variables (local to this procedure) */
95 list lpv; /* private variables */
96 statement body;
98 graph dg;
99 int bn;
100 int ls;
101 int pd;
102 tiling tile;
103 {
104  pips_assert("true", initial_module==initial_module);
105  list block;
106  instruction instr = statement_instruction(body);
107 
108  debug(6,"loop_nest_to_local_variables","begin\n");
109 
110  ifdebug(5) {
111  (void) fprintf(stderr,"Private variables:");
112  print_entities(lpv);
113  }
114 
115 /* pips_assert("loop_nest_to_local_variables",
116  instruction_block_p(instr));*/
117 
118  if (instruction_call_p(instr))
119  block = CONS(STATEMENT,body,NIL);
120  else block = instruction_block(instr);
121 
122  for( ;!ENDP(block); POP(block)) {
124 
125  if(assignment_statement_p(s)) {
127  /* first reference in statement s */
128  bool first_reference = true;
129  /* there are only two expressions to loop over: the lhs and the
130  rhs */
131  for(; !ENDP(lexpr); POP(lexpr)) {
132  expression e = EXPRESSION(CAR(lexpr));
134  list consr;
135 
136  ifdebug(7) {
137  (void) fprintf(stderr, "reference list:");
139  (void) fprintf(stderr, "first_reference=%s\n",
140  bool_to_string(first_reference));
141  }
142 
143  for(consr = lr; !ENDP(consr) ; POP(consr)) {
144  reference r = REFERENCE(CAR(consr));
145  entity rv = reference_variable(r);
146 
147  if(entity_is_argument_p(rv, lpv) || reference_indices(r) ==NIL) {
148  debug(7,"loop_nest_to_local_variables",
149  "Variable %s is private\n",
150  entity_local_name(rv));
151 
152  first_reference = false;
153  }
154  else {
155  hash_put(r_to_ud, r,
156  (void*)(intptr_t)(first_reference?
158  first_reference = false;
160  v_to_lllv,
161  llv_to_lcr,
162  r_to_llv,
163  r_to_ud)) {
164  entity v = reference_variable(r);
165  intptr_t n;
166  list llv;
167  (void) find_or_create_emulated_shared_variable(v, memory_module,
168  v_to_esv,
169  bn, ls);
170  if((n = (intptr_t) hash_get(v_to_nlv, (char *) v))
172  n = 0;
173  llv = make_new_local_variables(v, compute_module, n, pd,
174  v_to_lllv);
175  hash_put(llv_to_lcr, llv,
176  CONS(REFERENCE, r, NIL));
177  hash_put(r_to_llv, r, llv);
178  hash_put(v_to_nlv, v, (void*)(n+1));
179  }
180  }
181  }
182  gen_free_list(lr);
183  }
184  }
185  }
186  /* FI: local variable dimensions should be set later by the caller
187  so as to use the clustering performed here to compute space
188  complexity, to use space complexity to define the tiling and
189  to use the tiling to define the dimensions */
190  set_dimensions_of_local_variables(v_to_lllv, indices, tile, llv_to_lcr);
191 
192  debug(6,"loop_nest_to_local_variables","end\n");
193 }
194 ␌
195 entity make_emulated_shared_variable(v, memory_module, bn, ls)
196 entity v;
197 entity memory_module;
198 int bn;
199 int ls;
200 {
201  string esv_name = strdup(concatenate(entity_local_name(memory_module),
205  NULL));
206  entity esv = gen_find_tabulated(esv_name, entity_domain);
207  type tv = entity_type(v);
210  entity a;
211  int number_of_elements = 1;
212 
215  debug(8,"make_emulated_shared_variable", "begin\n");
216 
217  pips_assert("make_emulated_shared_variable", esv == entity_undefined );
218  pips_assert("make_emulated_shared_variable", type_variable_p(tv));
219 
220 
221 
222  esv = make_entity(esv_name,
223  type_undefined, /* filled in the following */
225  value_undefined ); /* filled in the following */
226 
227  /* generate the proper type; basic is preserved but the array is made
228  two dimensional */
229 
230  for( ; !ENDP(ldv); POP(ldv)) {
231  dimension d = DIMENSION(CAR(ldv));
232  int size = dimension_size(d);
233  number_of_elements *= size;
234  }
235 
236  ifdebug(8) {
237  (void) fprintf(stderr,"number of elements for %s: %d\n",
239  }
240 
241  /* In two sprintf , -1 is added once seperately by LZ
242  * make_expression_1 takes the place of the make_expression_1
243  * 12/11/91
244  */
245  if(number_of_elements > 1) {
247  int_to_expression(ls-1),
248  NIL);
250  int_to_expression((number_of_elements+ls*bn-1)/(ls*bn)),
251  NIL);
252 
254  CONS(DIMENSION, esvd1,
255  CONS(DIMENSION, esvd2, NIL)));
256  }
257  else {
258  /* FI->CA, LZ: what should we do with scalar variables? Put a copy
259  on each memory bank? Take into account memory bank conflicts
260  shown in thresholding (PUMA WP 6.1 and 6.7) */
262  }
263 
265 
266  a = FindEntity(module_local_name(memory_module),
269  (make_ram(memory_module,
270  a,
272  esv),
273  NIL)));
274 
275  AddEntityToDeclarations(esv,memory_module);
276 
277  debug(8,"make_emulated_shared_variable", "esv_name=%s\n", entity_name(esv));
278  ifdebug(8) print_sentence(stderr,Sentence_Variable(esv));
279  debug(8,"make_emulated_shared_variable", "end\n");
280 
281  return(esv);
282 }
283 ␌
284 entity find_or_create_emulated_shared_variable(v, memory_module, v_to_esv, bn,ls)
285 entity v;
286 entity memory_module;
287 hash_table v_to_esv;
288 int bn;
289 int ls;
290 {
291  entity esv = entity_undefined;
292 
293  if ( (esv = gen_find_tabulated(concatenate(entity_local_name(memory_module),
297  NULL),
299  /* nothing to do */
300  ;
301  else {
302  esv = make_emulated_shared_variable(v, memory_module, bn, ls);
303  hash_put(v_to_esv, (char *) v, (char *) esv);
304  }
305  return (esv);
306 }
307 
308 ␌
309 
310 list make_new_local_variables(v, compute_module, number, pd, v_to_lllv)
311 entity v;
312 entity compute_module;
313 int number; /* local copy number */
314 int pd; /* pipeline depth */
315 hash_table v_to_lllv;
316 {
317  /* Local variables cannot be immediately dimensionned because this
318  will depend on *all* associated references.
319 
320  To avoid a possible "fusion" between references connected in the dg,
321  local variable declarations should be delayed to that point. */
322 
323  /* concatenate cannot be used (directly) because of n and s conversions */
324  char *local_variable_name;
325  int s;
326  list llv = NIL;
327  list lllv = NIL;
328  const char* computational_name = entity_local_name(compute_module);
329 
330  type tv = entity_type(v);
331  entity a;
332 
333  debug(7,"make_new_local_variables","begin v=%s, number=%d, pd=%d\n",
334  entity_name(v), number, pd);
335 
336  for(s=0; s<pd; s++) {
337  entity lv;
338  /* a new btv is necessary for each variable because CONS cannot
339  be shared under NewGen rules */
341 
342  (void) asprintf(&local_variable_name,"%s%s%s%s%s%d%s%d",
343  computational_name,
348  number,
350  s);
351 
352  /* FI->LZ: the type should be v's type, except for the dimensions,
353  the storage should be RAM and allocated in the dynamic
354  area of module_name, and the value is undefined;
355  the actual dimensions will be updated later */
356  lv = make_entity(local_variable_name,
357  MakeTypeVariable(btv, NIL),
360 
361  a = FindEntity(module_local_name(compute_module),
363  pips_assert("make_new_local_variables",!entity_undefined_p(a));
364 
366  (make_ram(compute_module, a,
367  add_variable_to_area(a, lv),
368  NIL)));
369 
370 
371  AddEntityToDeclarations( lv,compute_module);
372  llv = gen_nconc(llv, CONS(ENTITY, lv, NIL));
373  }
374 
375  if((lllv = (list) hash_get(v_to_lllv, (char *) v))
376  == (list) HASH_UNDEFINED_VALUE) {
377  lllv = CONS(LIST, llv, NIL);
378  hash_put(v_to_lllv, (char *) v, (char *) lllv);
379  }
380  else {
381  /* update v_to_lllv by side effect */
382  lllv = gen_nconc(lllv, CONS(LIST, llv, NIL));
383  }
384 
385 
386  debug(7,"make_new_local_variables","end\n");
387 
388  return llv;
389 }
390 ␌
391 /* reference_conflicting_test_and_update():
392  *
393  * Build, incrementally, connected component in the dependence graph.
394  * Input dependences *should* be used to save local memory space.
395  * Mappings are updated.
396  *
397  * Too many local variables might be created if two connected components
398  * had to be fused. This is not likely to happen with real code. In that
399  * case, the function would stop with pips_error().
400  */
402  v_to_lllv, llv_to_lcr,
403  r_to_llv, r_to_ud)
404 reference r;
405 graph dg;
406 hash_table v_to_lllv;
407 hash_table llv_to_lcr;
408 hash_table r_to_llv;
409 hash_table r_to_ud;
410 {
411  list current_llv = list_undefined;
412  entity rv; /* referenced variable */
413  list lllv;
414  list cllv;
415  bool conflicting = false;
416 
417  debug(8,"reference_conflicting_test_and_update", "begin\n");
418 
419  rv = reference_variable(r);
420 
421  ifdebug(8) {
422  (void) fprintf(stderr, "reference %p to %s:",
423  r, entity_local_name(rv));
424  print_reference(r);
425  (void) putc('\n', stderr);
426  }
427 
428  if((lllv = (list) hash_get(v_to_lllv, (char *) rv))
429  == (list) HASH_UNDEFINED_VALUE) {
430  debug(8, "reference_conflicting_test_and_update",
431  "no local variables for reference %p to %s\n",
432  r, entity_local_name(rv));
433 
434  debug(8,"reference_conflicting_test_and_update", "return FALSE\n");
435  return false;
436  }
437 
438  for(cllv = lllv; !ENDP(cllv); POP(cllv)) {
439  list llv = LIST(CAR(cllv));
440  list lcr = (list) hash_get(llv_to_lcr, (char *) llv);
441  list ccr;
442 
443  for(ccr = lcr; !ENDP(ccr); POP(ccr)) {
444  reference r2 = REFERENCE(CAR(ccr));
445  entity rv2 = reference_variable(r2);
446 
447  ifdebug(8) {
448  (void) fprintf(stderr, "conflict_p with reference %p to %s:",
449  r2, entity_local_name(rv2));
450  print_reference(r2);
451  (void) putc('\n', stderr);
452  }
453 
454  if(reference_equal_p(r, r2)) {
455  if(hash_get(r_to_ud,(char*) r)==hash_get(r_to_ud,(char*) r2)){
456  /* short cut for identical references; not necessarily a good
457  idea for the body translation process; design to save
458  time in transfer code generation */
459  /* should go one step forwards and take care of use-def,
460  easier by introducing a "use and def" value or by adding
461  the new reference directly */
462 
463  debug(8,"reference_conflicting_test_and_update",
464  "reference equality and same use, return TRUE\n");
465  }
466  else {
467  /* we need to remember there is a use and a def */
468  /* this is very clumsy as we may keep a large number
469  of identical def after one use and vice-versa;
470  we need a use-and-def value or we have to keep
471  all references and filter them for data movements */
472  /* update llv_to_lcr by side-effect */
473  lcr = gen_nconc(lcr, CONS(REFERENCE, r, NIL));
474  debug(8,"reference_conflicting_test_and_update",
475  "reference equality and same use, return TRUE\n");
476  }
477  hash_put(r_to_llv, (char *) r, (char *) llv);
478  return true;
479  }
480  else if(reference_conflicting_p(r, r2, dg)) {
481  if(conflicting) {
482  /* should not happen too often: the regions associated
483  with two references do not intersect together but
484  each of them intersect a third one on which we bump
485  afterwards; the two initial llv's should be merged...
486  */
487  pips_assert("reference_conflicting_test_and_update",
488  current_llv != llv);
489  pips_internal_error("local variable merge not implemented");
490  }
491  else {
492  conflicting = true;
493  /* update llv_to_lcr by side-effect */
494  lcr = gen_nconc(lcr, CONS(REFERENCE, r, NIL));
495  hash_put(r_to_llv, (char *) r, (char *) llv);
496  /* save current_llv for a future (?) merge */
497  current_llv = llv;
498  /* no need to study conflicts with other references
499  in the *same* connected component */
500  debug(8,"reference_conflicting_test_and_update",
501  "Conflict! Look for conflicts with other components\n");
502  break;
503  }
504  }
505  }
506  }
507 
508  debug(8,"reference_conflicting_test_and_update", "return %d\n",
509  conflicting);
510  return conflicting;
511 }
512 ␌
514 reference r1,r2;
515 graph dg;
516 {
517  /*
518  graph = vertices:vertex* ;
519  successor = arc_label x vertex ;
520  vertex = vertex_label x successors:successor* ;
521  */
522  list ver1 = graph_vertices(dg);
523 
524  debug(8,"reference_conflicting_p","begin\n");
525  ifdebug(8) {
526  (void) fprintf(stderr,"Reference 1 %p: ", r1);
527  print_reference(r1);
528  (void) fprintf(stderr,"\nReference 2 %p: ", r2);
529  print_reference(r2);
530  (void) fputc('\n',stderr);
531  }
532 
533  MAPL(pm1,{
534  vertex v1 = VERTEX(CAR(pm1));
535  list ver2 = vertex_successors(v1);
536  MAPL(pm2,{
537  successor su = SUCCESSOR(CAR(pm2));
538 
540  list conf_list = dg_arc_label_conflicts(dal);
541 
542  MAPL(pm3,{
543  conflict conf2 = CONFLICT(CAR(pm3));
544 
545  effect e_source = conflict_source(conf2);
546  effect e_sink = conflict_sink(conf2);
547 
548  reference r11 = effect_any_reference(e_source);
549  reference r21 = effect_any_reference(e_sink);
550 
551  ifdebug(8) {
552  (void) fprintf(stderr,"Test with reference 1 %p: ", r1);
553  print_reference(r1);
554  (void) fprintf(stderr," and reference 2 %p: ", r2);
555  print_reference(r2);
556  (void) fputc('\n',stderr);
557  (void) fprintf(stderr,"Test with reference 11 %p: ", r11);
558  print_reference(r11);
559  (void) fprintf(stderr," and reference 21 %p: ", r21);
560  print_reference(r21);
561  (void) fputc('\n',stderr);
562  (void) fputc('\n',stderr);
563  }
564 
565  if( (reference_equal_p(r11,r1) && reference_equal_p(r21,r2))
566  || (reference_equal_p(r11,r2) && reference_equal_p(r21,r1)) ) {
567  debug(8,"reference_conflicting_p","return TRUE\n");
568  return true;
569  }
570  },conf_list);
571  },ver2);
572  },ver1);
573 
574  debug(8,"reference_conflicting_p","return FALSE\n");
575  return false;
576 }
577 ␌
578 /* Psysteme make_tile_constraints(P, b):
579  *
580  * convert a partitioning matrice into a system of linear constraints
581  * for a tile whose origin is 0, i.e. generate constraints over local
582  * indices:
583  *
584  * -> -1 -> ---->
585  * 0 <= k P b <= (k-1)
586  *
587  * where k is the denominator of P inverse.
588  *
589  * FI: such functions should be put together in a file, linear.c
590  */
592 matrice P;
593 Pbase b;
594 {
595  Psysteme tc = sc_new();
596 
597  int d = base_dimension(b);
598  Value k = DENOMINATOR(P);
599  int i,j;
600 
601  matrice IP = matrice_new(d,d);
602  Pcontrainte c1;
603 
604  debug(8,"make_tile_constraints", "begin\n");
605 
606  pips_assert("make_tile_constraints", value_one_p(k));
607 
608  ifdebug(8) {
609  (void) fprintf(stderr,"Partitioning matrix P:\n");
610  matrice_fprint(stderr, P, d, d);
611  }
612 
613  matrice_general_inversion(P, IP, d);
614  matrice_normalize(IP, d, d);
615  k = DENOMINATOR(IP);
616 
617  /* pips_assert("make_tile_constraints", k > 1); */
618 
619  ifdebug(8) {
620  (void) fprintf(stderr,"Inverse of partitioning matrix, IP:\n");
621  matrice_fprint(stderr, IP, d, d);
622  }
623 
624  for ( i=1; i<=d; i++) {
626 
627  for ( j=1; j<=d; j++) {
629  variable_of_rank(b,i),
630  value_uminus(ACCESS(IP, d, j, i)));
631 
632  }
633  sc_add_inegalite(tc, c);
634  c1 = contrainte_dup(c);
635  contrainte_chg_sgn(c1);
637  sc_add_inegalite(tc, c1);
638  }
639 
640  sc_creer_base(tc);
641  matrice_free(IP);
642 
643  ifdebug(8) {
644  sc_fprint(stderr, tc, (string(*)(Variable))entity_local_name);
645  }
646 
647  debug(8,"make_tile_constraints", "end\n");
648 
649  return (tc);
650 }
651 ␌
652 void set_dimensions_of_local_variables(v_to_lllv, basis, tile, llv_to_lcr)
653 hash_table v_to_lllv;
654 Pbase basis;
655 tiling tile;
656 hash_table llv_to_lcr;
657 {
658  Psysteme tc = SC_UNDEFINED;
659  matrice P = (matrice) tiling_tile(tile);
660 
661  debug(8,"set_dimensions_of_local_variables","begin\n");
662 
663  tc = make_tile_constraints(P, basis);
664 
665  HASH_MAP(v, clllv, {
666  list cllv;
667  for(cllv = (list) clllv; !ENDP(cllv); POP(cllv)) {
668  list llv = LIST(CAR(cllv));
669  list lr = (list) hash_get(llv_to_lcr, (char *) llv);
671  }
672  }, v_to_lllv);
673 
674  sc_rm(tc);
675 
676  debug(8,"set_dimensions_of_local_variables","end\n");
677 }
678 ␌
679 /* void set_dimensions_of_local_variable_family(llv, tc, lr):
680  *
681  * The algorithm used is not general; references are assumed equal up to
682  * a translation;
683  *
684  * A general algorithm, as would be necessary for instance if a dependence
685  * was detected in the transposition algorithm between M(I,J) and M(J,I),
686  * would preserve some translation information for each reference in lr
687  * so as to generate proper new references to the local variable.
688  */
690 list llv; /* list of local variables with same dimensions used at
691  different pipeline stages */
692 Psysteme tc;
693 list lr; /* non-empty list of associated references */
694 tiling tile;
695 int dimn;
696 {
697  /* let's use the first reference to find out the number of dimensions */
698  reference r;
699  entity rv; /* referenced variable */
700  type rvt; /* referenced variable type */
701  list rvld; /* referenced variable dimension list */
702  int d = -1; /* dimension number */
703  list lvd = NIL; /* dimensions for the local variables */
704  bool first_ref;
705  matrice P = (matrice) tiling_tile(tile);
706  debug(8,"set_dimensions_of_local_variable_family","begin\n");
707 
708  r = REFERENCE(CAR(lr));
709  rv = reference_variable(r);
710  rvt = entity_type(rv);
711  rvld = variable_dimensions(type_variable(rvt));
712 
713  debug(8,"set_dimensions_of_local_variable_family","entity=%s\n",
714  entity_name(rv));
715 
716  for( d = 1; !ENDP(rvld); POP(rvld), d++) {
717  Value imax = VALUE_MIN;
718  Value gmin = VALUE_MAX;
719  Value gmax = VALUE_MIN;
720  list cr = list_undefined;
722 
723 
724  /* computation of the initial bounds of Entity rv */
725  dimension dim1 = DIMENSION(CAR(rvld));
726  expression lower= dimension_lower(dim1);
727  normalized norm1 = NORMALIZE_EXPRESSION(lower);
728  expression upper= dimension_upper(dim1);
729  normalized norm2 = NORMALIZE_EXPRESSION(upper);
730  if (normalized_linear_p(norm1) && normalized_linear_p(norm2)) {
731  gmin = vect_coeff(TCST,(Pvecteur) normalized_linear(norm1));
732  value_decrement(gmin);
733  gmax = vect_coeff(TCST,(Pvecteur) normalized_linear(norm2));
734  value_decrement(gmax);
735  imax = gmax;
736  }
737  first_ref = true;
738  for(cr = lr; !ENDP(cr); POP(cr)) {
739  entity phi = make_phi_entity(d);
740  expression e;
741  normalized n;
742  Pvecteur vec;
743  Pcontrainte eg;
744  Psysteme s;
745  Value min, max, coef;
746  r = REFERENCE(CAR(cr));
748  n = NORMALIZE_EXPRESSION(e);
749 
750  /* pips_assert("set_dimensions_of_local_variable_family", */
751  if (normalized_linear_p(n)) {
752  vec = vect_dup((Pvecteur) normalized_linear(n));
753  vect_add_elem(&vec, (Variable) phi, VALUE_MONE);
754  eg = contrainte_make(vec);
755 
756  /* pour tenir compte des offsets numeriques dans les
757  fonctions d'acces */
758  coef =vect_coeff(TCST,vec);
759  if (value_pos_p(coef)) value_addto(gmax,coef);
760  else value_addto(gmin,coef);
761 
762  s = sc_dup(tc);
763  sc_add_egalite(s, eg);
764  vect_add_variable(sc_base(s), (Variable) phi);
765 
766  s = sc_normalize(s);
767  ifdebug(8) {
768  (void) fprintf(stderr,
769  "System on phi for dimension %d:\n", d);
770  sc_fprint(stderr, s, (string(*)(Variable))entity_local_name);
771  }
772 
773 
774  if(!sc_minmax_of_variable(s, (Variable) phi,
775  &min, &max))
776  pips_internal_error("empty domain for phi");
777 
778  if(value_min_p(min) || value_max_p(max)) {
779  Value divis= ACCESS(P,dimn,d,d);
780  /* parameter ==> min = max = 1 */
781  /*pips_internal_error("unbounded domain for phi, %s",
782  "check tile bounds and subscript expressions"); */
783  min= VALUE_ZERO;
784  max= value_lt(divis,VALUE_CONST(999)) &&
785  value_gt(divis,VALUE_ONE)? value_div(imax,divis): imax;
786  }
787 
788  debug(8,"set_dimensions_of_local_variable_family",
789  "bounds for dimension %d: [%d:%d]\n", d, min, max);
790 
791  gmin = first_ref? value_max(gmin, min): value_min(gmin, min);
792  gmax = first_ref? value_min(gmax, max): value_max(gmax, max);
793 
794  if (value_gt(gmin,gmax)) gmax = gmin;
795  first_ref=false;
796  }
797  }
800  NIL);
801 
802  debug(8,"set_dimensions_of_local_variable_family",
803  "bounds for dimension %d: [%d:%d]\n", d, gmin, gmax);
804 
805  lvd = gen_nconc(lvd, CONS(DIMENSION, dimd, NIL));
806  }
807 
808  /* update types */
809  MAPL(clv,
810  {
811  entity lv = ENTITY(CAR(clv));
812  type tlv = entity_type(lv);
813  variable tv = type_variable(tlv);
814 
815  /* sharing is not legal under NewGen rules; to avoid
816  it lvd is duplicated at the CONS level, except the first time */
817  if(clv!=llv)
818  lvd = gen_copy_seq(lvd);
819  variable_dimensions(tv) = lvd;
820  },
821  llv);
822 
823  ifdebug(8) {
824  MAPL(clv,
825  {
826  entity lv = ENTITY(CAR(clv));
827  print_sentence(stderr,Sentence_Variable(lv));
828  },
829  llv);
830  }
831 
832  pips_debug(8,"end\n");
833 }
value make_value_unknown(void)
Definition: ri.c:2847
basic copy_basic(basic p)
BASIC.
Definition: ri.c:104
storage make_storage(enum storage_utype tag, void *val)
Definition: ri.c:2273
ram make_ram(entity a1, entity a2, intptr_t a3, list a4)
Definition: ri.c:1999
dimension make_dimension(expression a1, expression a2, list a3)
Definition: ri.c:565
bool entity_is_argument_p(entity e, cons *args)
Definition: arguments.c:150
#define value_pos_p(val)
#define VALUE_ZERO
#define value_minus(v1, v2)
#define value_gt(v1, v2)
#define value_min(v1, v2)
#define value_decrement(ref)
#define VALUE_TO_INT(val)
#define VALUE_CONST(val)
#define value_uminus(val)
unary operators on values
#define value_one_p(val)
#define VALUE_MIN
#define VALUE_MONE
#define value_min_p(val)
int Value
#define value_max(v1, v2)
#define value_addto(ref, val)
#define VALUE_MAX
#define value_max_p(val)
#define VALUE_ONE
#define value_lt(v1, v2)
#define value_div(v1, v2)
Pbase vect_add_variable(Pbase b, Variable v)
package vecteur - routines sur les bases
Definition: base.c:61
static graph dg
dg is the dependency graph ; FIXME : should not be static global ?
Definition: chains.c:124
#define contrainte_vecteur(c)
passage au champ vecteur d'une contrainte "a la Newgen"
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
Definition: alloc.c:73
Pcontrainte contrainte_dup(Pcontrainte c_in)
Pcontrainte contrainte_dup(Pcontrainte c_in): allocation d'une contrainte c_out prenant la valeur de ...
Definition: alloc.c:132
Pcontrainte contrainte_new(void)
package contrainte - allocations et desallocations
Definition: alloc.c:47
void contrainte_chg_sgn(Pcontrainte)
void contrainte_chg_sgn(Pcontrainte eq): changement de signe d'une contrainte, i.e.
Definition: unaires.c:56
struct _newgen_struct_dg_arc_label_ * dg_arc_label
Definition: dg.h:60
#define conflict_sink(x)
Definition: dg.h:167
#define CONFLICT(x)
CONFLICT.
Definition: dg.h:134
#define dg_arc_label_conflicts(x)
Definition: dg.h:201
#define conflict_source(x)
Definition: dg.h:165
#define min(a, b)
#define max(a, b)
entity make_phi_entity(int)
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
@ is_action_write
Definition: effects.h:293
@ is_action_read
Definition: effects.h:292
bool number_of_elements(list, intptr_t *)
flint_utils.c
Definition: flint_utils.c:50
#define LIST(x)
Definition: genC.h:93
#define successor_arc_label(x)
Definition: graph.h:116
#define vertex_successors(x)
Definition: graph.h:154
#define SUCCESSOR(x)
SUCCESSOR.
Definition: graph.h:86
#define graph_vertices(x)
Definition: graph.h:82
#define VERTEX(x)
VERTEX.
Definition: graph.h:122
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
#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 MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
Definition: newgen_list.h:203
#define list_undefined
Undefined list definition :-)
Definition: newgen_list.h:69
bool assignment_statement_p(statement)
Test if a statement is an assignment.
Definition: statement.c:135
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
static list indices
Definition: icm.c:204
int vect_size(Pvecteur v)
package vecteur - reductions
Definition: reductions.c:47
#define DENOMINATOR(matrix)
int DENOMINATEUR(matrix): acces au denominateur global d'une matrice matrix La combinaison *(&()) est...
Definition: matrice-local.h:93
#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_general_inversion(matrice a, matrice inv_a, int n)
void matrice_general_inversion(matrice a; matrice inv_a; int n) calcul de l'inversion du matrice gene...
Definition: inversion.c:222
void matrice_normalize(matrice a, int n, int m)
void matrice_normalize(matrice a, int n, int m)
Definition: matrice.c:125
void matrice_fprint(FILE *, matrice, int, int)
matrice_io.c
Definition: matrice_io.c:62
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define asprintf
Definition: misc-local.h:225
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define pips_internal_error
Definition: misc-local.h:149
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
#define DYNAMIC_AREA_LOCAL_NAME
Definition: naming-local.h:69
#define MODULE_SEP_STRING
Definition: naming-local.h:30
string bool_to_string(bool)
Definition: string.c:243
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
#define HASH_MAP(k, v, code, ht)
Definition: newgen_hash.h:60
#define HASH_UNDEFINED_VALUE
value returned by hash_get() when the key is not found; could also be called HASH_KEY_NOT_FOUND,...
Definition: newgen_hash.h:56
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
struct cons * list
Definition: newgen_types.h:106
void AddEntityToDeclarations(entity e, entity module)
END_EOLE.
Definition: variable.c:108
int add_variable_to_area(entity a, entity v)
Definition: variable.c:1376
void set_dimensions_of_local_variables(hash_table v_to_lllv, Pbase basis, tiling tile, hash_table llv_to_lcr)
Definition: variable.c:652
void loop_nest_to_local_variables(entity initial_module, entity compute_module, entity memory_module, hash_table llv_to_lcr, hash_table r_to_llv, hash_table v_to_lllv, hash_table r_to_ud, hash_table v_to_esv, hash_table v_to_nlv, list lpv, statement body, Pbase indices, graph dg, int bn, int ls, int pd, tiling tile)
for the phi variable
Definition: variable.c:80
list make_new_local_variables(entity v, entity compute_module, int number, int pd, hash_table v_to_lllv)
Definition: variable.c:310
bool reference_conflicting_test_and_update(reference r, graph dg, hash_table v_to_lllv, hash_table llv_to_lcr, hash_table r_to_llv, hash_table r_to_ud)
reference_conflicting_test_and_update():
Definition: variable.c:401
dg_vertex_label vertex_label
Definition: variable.c:55
entity make_emulated_shared_variable(entity v, entity memory_module, int bn, int ls)
Definition: variable.c:195
Psysteme make_tile_constraints(matrice P, Pbase b)
Psysteme make_tile_constraints(P, b):
Definition: variable.c:591
dg_arc_label arc_label
Code Generation for Distributed Memory Machines.
Definition: variable.c:54
void set_dimensions_of_local_variable_family(list llv, Psysteme tc, list lr, tiling tile, int dimn)
void set_dimensions_of_local_variable_family(llv, tc, lr):
Definition: variable.c:689
entity find_or_create_emulated_shared_variable(entity v, entity memory_module, hash_table v_to_esv, int bn, int ls)
Definition: variable.c:284
bool reference_conflicting_p(reference r1, reference r2, graph dg)
Definition: variable.c:513
sentence Sentence_Variable(entity e)
Definition: declarations.c:583
void print_reference_list(list lr)
Definition: expression.c:147
void print_reference(reference r)
Definition: expression.c:142
static int tc
Internal variables
Definition: reindexing.c:107
#define NORMALIZE_EXPRESSION(e)
#define make_entity(n, t, s, i)
#define instruction_block(i)
entity FindEntity(const char *package, const char *name)
Retrieve an entity from its package/module name and its local name.
Definition: entity.c:1503
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
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
void print_entities(list l)
Definition: entity.c:167
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
bool reference_equal_p(reference r1, reference r2)
Definition: expression.c:1500
expression find_ith_expression(list le, int r)
find_ith_expression() is obsolet; use find_ith_argument() instead
Definition: expression.c:1161
list expression_to_reference_list(expression e, list lr)
conversion of an expression into a list of references; references are appended to list lr as they are...
Definition: expression.c:1263
int dimension_size(dimension)
this function computes the size of a dimension.
Definition: size.c:491
type MakeTypeVariable(basic, cons *)
BEGIN_EOLE.
Definition: type.c:116
#define value_undefined
Definition: ri.h:3016
#define REFERENCE(x)
REFERENCE.
Definition: ri.h:2296
#define normalized_linear_p(x)
Definition: ri.h:1779
#define reference_variable(x)
Definition: ri.h:2326
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define dimension_lower(x)
Definition: ri.h:980
#define type_variable(x)
Definition: ri.h:2949
#define entity_storage(x)
Definition: ri.h:2794
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
@ is_storage_ram
Definition: ri.h:2492
#define entity_undefined_p(x)
Definition: ri.h:2762
#define entity_undefined
Definition: ri.h:2761
#define entity_name(x)
Definition: ri.h:2790
#define dimension_upper(x)
Definition: ri.h:982
#define reference_indices(x)
Definition: ri.h:2328
#define dimension_undefined
Definition: ri.h:955
#define instruction_call_p(x)
Definition: ri.h:1527
#define variable_dimensions(x)
Definition: ri.h:3122
#define statement_instruction(x)
Definition: ri.h:2458
#define type_undefined
Definition: ri.h:2883
#define instruction_call(x)
Definition: ri.h:1529
#define call_arguments(x)
Definition: ri.h:711
#define entity_type(x)
Definition: ri.h:2792
#define normalized_linear(x)
Definition: ri.h:1781
#define type_variable_p(x)
Definition: ri.h:2947
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
#define variable_basic(x)
Definition: ri.h:3120
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
#define storage_undefined
Definition: ri.h:2476
#define entity_initial(x)
Definition: ri.h:2796
void sc_creer_base(Psysteme ps)
void sc_creer_base(Psysteme ps): initialisation des parametres dimension et base d'un systeme lineair...
Definition: sc_alloc.c:129
void sc_rm(Psysteme ps)
void sc_rm(Psysteme ps): liberation de l'espace memoire occupe par le systeme de contraintes ps;
Definition: sc_alloc.c:277
void sc_add_egalite(Psysteme p, Pcontrainte e)
void sc_add_egalite(Psysteme p, Pcontrainte e): macro ajoutant une egalite e a un systeme p; la base ...
Definition: sc_alloc.c:389
Psysteme sc_new(void)
Psysteme sc_new(): alloue un systeme vide, initialise tous les champs avec des valeurs nulles,...
Definition: sc_alloc.c:55
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
bool sc_minmax_of_variable(Psysteme ps, Variable var, Value *pmin, Value *pmax)
void sc_minmax_of_variable(Psysteme ps, Variable var, Value *pmin, *pmax): examine un systeme pour tr...
Definition: sc_eval.c:143
Variable variable_of_rank()
void sc_fprint(FILE *fp, Psysteme ps, get_variable_name_t nom_var)
void sc_fprint(FILE * f, Psysteme ps, char * (*nom_var)()): cette fonction imprime dans le fichier po...
Definition: sc_io.c:220
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
char * strdup()
Psysteme sc_normalize(Psysteme ps)
Psysteme sc_normalize(Psysteme ps): normalisation d'un systeme d'equation et d'inequations lineaires ...
#define ifdebug(n)
Definition: sg.c:47
#define intptr_t
Definition: stdint.in.h:294
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
struct block block
void print_sentence(FILE *fd, sentence s)
FI: just to make sure that text.h is built; pips-makemake -l does not tale into account a library who...
Definition: print.c:53
#define tiling_tile(x)
Definition: tiling.h:68
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
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_dimension(b)
Pvecteur vect_dup(Pvecteur v_in)
Pvecteur vect_dup(Pvecteur v_in): duplication du vecteur v_in; allocation de et copie dans v_out;.
Definition: alloc.c:51
void vect_add_elem(Pvecteur *pvect, Variable var, Value val)
void vect_add_elem(Pvecteur * pvect, Variable var, Value val): addition d'un vecteur colineaire au ve...
Definition: unaires.c:72
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
#define EMULATED_SHARED_MEMORY_PREFIX
Header File for WP65.
Definition: wp65-local.h:34
#define LOCAL_MEMORY_SEPARATOR
Definition: wp65-local.h:36
#define LOCAL_MEMORY_PREFIX
Definition: wp65-local.h:35