PIPS
message-utils.c File Reference
#include "defines-local.h"
#include "access_description.h"
+ Include dependency graph for message-utils.c:

Go to the source code of this file.

Functions

Pvecteur the_index_of_vect (Pvecteur v0)
 Message Utilities. More...
 
list add_to_list_of_ranges_list (list l, range r)
 
list dup_list_of_ranges_list (list l)
 ??? the complexity of this function could be greatly improved More...
 
list dup_list_of_Pvecteur (list l)
 ??? the complexity of this function could be improved greatly... More...
 
list add_elem_to_list_of_Pvecteur (list l, int var, int val)
 caution, is initial list is destroyed. More...
 
range complementary_range (entity array, int dim, range r)
 range complementary_range(array, dim, r) More...
 
list generate_message_from_3_lists (entity array, list lcontent, list lneighbour, list ldomain)
 list generate_message_from_3_lists(array, lcontent, lneighbour, ldomain) More...
 
bool empty_section_p (list lr)
 
bool empty_range_p (range r)
 
char * sprint_lrange (string str, list l)
 
char * sprint_range (string str, range r)
 
list compute_receive_content (entity array, list lr, Pvecteur v)
 
list compute_receive_domain (list lr, Pvecteur v)
 
bool larger_message_in_list (message m, list l)
 
bool message_larger_p (message m1, message m2)
 bool message_larger_p(m1, m2) More...
 
bool lrange_larger_p (list lr1, list lr2)
 
list array_ranges_to_template_ranges (entity array, list lra)
 
list template_ranges_to_processors_ranges (entity template, list lrt)
 
list array_access_to_array_ranges (reference r, list lkref, list lvref)
 
statement generate_guarded_statement (statement stat, entity proc, list lr)
 
bool make_guard_expression (entity proc, list lrref, expression *pguard)
 bool make_guard_expression(proc, lr, pguard) More...
 
expression make_mypos_expression (int i, expression exp)
 
statement loop_nest_guard (statement stat, reference r, list lkref, list lvref)
 

Function Documentation

◆ add_elem_to_list_of_Pvecteur()

list add_elem_to_list_of_Pvecteur ( list  l,
int  var,
int  val 
)

caution, is initial list is destroyed.

else

Parameters
varar
valal

Definition at line 110 of file message-utils.c.

113 {
114  list result = NIL;
115 
116  if (ENDP(l))
117  return CONS(PVECTOR, (VECTOR) vect_new((Variable) (intptr_t)var,
118  int_to_value(val)), NIL);
119 
120  if ((var==0) || (val==0))
121  return l;
122 
123  /* else */
124 
125  MAPL(cv,
126  {
127  Pvecteur v = (Pvecteur) PVECTOR(CAR(cv));
128  pips_debug(9, "size of vector %p is %d\n", v, vect_size(v));
129  vect_add_elem(&v, (Variable) (intptr_t) var, int_to_value(val));
130  result = gen_nconc(result, CONS(PVECTOR, (VECTOR) v, NIL));
131  },
132  l);
133 
134  gen_free_list(l);
135 
136  return result;
137 }
#define int_to_value(i)
end LINEAR_VALUE_IS_INT
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#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 VECTOR
Definition: defines-local.h:73
#define PVECTOR(v)
Definition: defines-local.h:72
int vect_size(Pvecteur v)
package vecteur - reductions
Definition: reductions.c:47
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#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 Svecteur * Pvecteur
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
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_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

References CAR, CONS, ENDP, gen_free_list(), gen_nconc(), int_to_value, intptr_t, MAPL, NIL, pips_debug, PVECTOR, vect_add_elem(), vect_new(), vect_size(), and VECTOR.

Referenced by atomize_one_message().

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

◆ add_to_list_of_ranges_list()

list add_to_list_of_ranges_list ( list  l,
range  r 
)

first time

else

Definition at line 51 of file message-utils.c.

54 {
55  if (ENDP(l)) /* first time */
56  return CONS(LIST, CONS(RANGE, r, NIL), NIL);
57 
58  /* else */
59  MAPL(cc,
60  {
61  list lr = CONSP(CAR(cc));
62  assert(!ENDP(lr));
63  lr = gen_nconc(lr, CONS(RANGE, r, NIL));
64  },
65  l);
66 
67  return(l);
68 }
#define LIST(x)
Definition: genC.h:93
#define CONSP(x)
Definition: genC.h:88
#define assert(ex)
Definition: newgen_assert.h:41
#define RANGE(x)
RANGE.
Definition: ri.h:2257

References assert, CAR, CONS, CONSP, ENDP, gen_nconc(), LIST, MAPL, NIL, and RANGE.

Referenced by atomize_one_message().

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

◆ array_access_to_array_ranges()

list array_access_to_array_ranges ( reference  r,
list  lkref,
list  lvref 
)

this dimension shouldn't be used, so I put there whatever I want... ??? mouais, the information is in the vector, I think.

??? should check that it is ok

Parameters
lkrefkref
lvrefvref

Definition at line 569 of file message-utils.c.

572 {
574  int dim = 1;
575  list li = reference_indices(r), lk = lkref, lv = lvref, lra = NIL,
577 
578  pips_debug(7, "considering array %s\n", entity_name(array));
579 
580  for (; li; POP(li), POP(lk), POP(lv), POP(ldim), dim++)
581  {
582  access a = INT(CAR(lk));
583  Pvecteur v = (Pvecteur) PVECTOR(CAR(lv));
585 
586  pips_debug(8, "DIM=%d[%d]\n", dim, a);
587 
588  switch (access_tag(a))
589  {
590  case local_form_cst:
591  {
592  /* this dimension shouldn't be used,
593  * so I put there whatever I want...
594  * ??? mouais, the information is in the vector, I think.
595  */
596  lra = gen_nconc(lra,
597  CONS(RANGE,
601  NIL));
602 
603  break;
604  }
605  case aligned_constant:
606  case local_constant:
607  {
608  Value tc = vect_coeff(TCST, v);
609  expression arraycell = Value_to_expression(tc);
610 
611  lra = gen_nconc(lra,
612  CONS(RANGE,
613  make_range(arraycell, arraycell,
614  int_to_expression(1)),
615  NIL));
616  break;
617  }
618  case aligned_shift:
619  case local_shift:
620  {
621  range
622  /* ??? should check that it is ok */
624  ((entity) var_of(vect_del_var(v, TCST)));
625  expression
626  rl = range_lower(rg),
627  ru = range_upper(rg),
628  in = range_increment(rg),
632  int lb = -1, ub = -1, dt = VALUE_TO_INT(vdt);
633 
635  lb = HpfcExpressionToInt(rl),
636  al = int_to_expression(lb-dt);
637  else
639 
641  ub = HpfcExpressionToInt(ru),
642  au = int_to_expression(ub-dt);
643  else
645 
646  lra = gen_nconc(lra, CONS(RANGE, make_range(al, au, in), NIL));
647  break;
648  }
649  case aligned_affine:
650  case local_affine:
651  {
652  Pvecteur v2 = vect_del_var(v, TCST);
653  entity index = (entity) var_of(v2);
654  range rg = loop_index_to_range(index);
656  int rate = val_of(v2),
660  dt = VALUE_TO_INT(vdt);
661  expression
662  ai = int_to_expression(rate*in),
663  al = int_to_expression(rate*lb-dt),
664  au = int_to_expression(rate*ub-dt);
665 
666  lra = gen_nconc(lra, CONS(RANGE, make_range(al, au, ai), NIL));
667  break;
668  }
669  default:
670  pips_internal_error("unexpected but maybe legal access");
671  break;
672  }
673  }
674 
675  return(lra);
676 }
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
range make_range(expression a1, expression a2, expression a3)
Definition: ri.c:2041
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
#define local_affine
#define aligned_shift
#define access
#define aligned_affine
#define local_form_cst
#define aligned_constant
#define access_tag(a)
#define local_constant
#define local_shift
#define VALUE_TO_INT(val)
int Value
@ INT
Definition: atomic.c:48
range loop_index_to_range(entity index)
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
int HpfcExpressionToInt(expression e)
HpfcExpressionToInt(e)
Definition: hpfc-util.c:569
#define pips_internal_error
Definition: misc-local.h:149
static int tc
Internal variables
Definition: reindexing.c:107
bool expression_integer_constant_p(expression e)
Definition: expression.c:2417
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
expression Value_to_expression(Value v)
added interface for linear stuff.
Definition: expression.c:1251
#define reference_variable(x)
Definition: ri.h:2326
#define range_upper(x)
Definition: ri.h:2290
#define dimension_lower(x)
Definition: ri.h:980
#define type_variable(x)
Definition: ri.h:2949
#define range_increment(x)
Definition: ri.h:2292
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define expression_undefined
Definition: ri.h:1223
#define entity_name(x)
Definition: ri.h:2790
#define expression_normalized(x)
Definition: ri.h:1249
#define dimension_upper(x)
Definition: ri.h:982
#define reference_indices(x)
Definition: ri.h:2328
#define range_lower(x)
Definition: ri.h:2288
#define variable_dimensions(x)
Definition: ri.h:3122
#define entity_type(x)
Definition: ri.h:2792
#define normalized_linear(x)
Definition: ri.h:1781
static entity array
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
#define val_of(varval)
#define var_of(varval)
Pvecteur vect_del_var(Pvecteur v_in, Variable var)
Pvecteur vect_del_var(Pvecteur v_in, Variable var): allocation d'un nouveau vecteur egal a la project...
Definition: unaires.c:206
Value vect_coeff(Variable var, Pvecteur vect)
Variable vect_coeff(Variable var, Pvecteur vect): coefficient de coordonnee var du vecteur vect —> So...
Definition: unaires.c:228

References access, access_tag, aligned_affine, aligned_constant, aligned_shift, array, CAR, CONS, copy_expression(), DIMENSION, dimension_lower, dimension_upper, entity_name, entity_type, EXPRESSION, expression_integer_constant_p(), expression_normalized, expression_undefined, gen_nconc(), HpfcExpressionToInt(), INT, int_to_expression(), local_affine, local_constant, local_form_cst, local_shift, loop_index_to_range(), make_range(), NIL, normalized_linear, pips_debug, pips_internal_error, POP, PVECTOR, RANGE, range_increment, range_lower, range_upper, reference_indices, reference_variable, tc, TCST, type_variable, val_of, Value_to_expression(), VALUE_TO_INT, var_of, variable_dimensions, vect_coeff(), and vect_del_var().

Referenced by loop_nest_guard().

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

◆ array_ranges_to_template_ranges()

list array_ranges_to_template_ranges ( entity  array,
list  lra 
)

scratched

replication

non distributed dimension, so not used...

Parameters
arrayrray
lrara

Definition at line 426 of file message-utils.c.

429 {
431  entity template = align_template(a);
432  list la = align_alignment(a), lrt = NIL;
433  int i = 1;
434 
435  for (i=1 ; i<=NumberOfDimension(template) ; i++)
436  {
438  int arraydim = alignment_undefined_p(al)? -1: alignment_arraydim(al);
439 
440  if (arraydim==-1) /* scratched */
441  {
442  dimension d = FindIthDimension(template, i);
443  lrt = gen_nconc(lrt,
444  CONS(RANGE,
447  int_to_expression(1)), NIL));
448  }
449  else if (arraydim==0) /* replication */
450  {
452 
453  lrt = gen_nconc(lrt,
454  CONS(RANGE,
455  make_range(b, b, int_to_expression(1)),
456  NIL));
457  }
458  else
459  {
460  range rg = RANGE(gen_nth(arraydim-1, lra));
461 
463  {
464  /* non distributed dimension, so not used...
465  */
466  lrt = gen_nconc(lrt, CONS(RANGE,
470  NIL));
471  }
472  else
473  {
474  int
477  lb, ub, in;
478  expression tl, tu, ti;
479 
483  tl = int_to_expression(a*lb+b);
484  tu = int_to_expression(a*ub+b);
485  ti = int_to_expression(a*in);
486 
487  lrt = gen_nconc(lrt,
488  CONS(RANGE,
489  make_range(tl, tu, ti),
490  NIL));
491  }
492  }
493  }
494 
495  return(lrt);
496 }
gen_chunk gen_nth(int n, const list l)
to be used as ENTITY(gen_nth(3, l))...
Definition: list.c:710
#define alignment_constant(x)
Definition: hpf.h:140
#define align_template(x)
Definition: hpf.h:98
#define align_alignment(x)
Definition: hpf.h:96
#define alignment_rate(x)
Definition: hpf.h:138
#define alignment_undefined_p(x)
Definition: hpf.h:109
#define alignment_arraydim(x)
Definition: hpf.h:134
alignment FindAlignmentOfTemplateDim(list lal, int dim)
Definition: hpfc-util.c:389
align load_hpf_alignment(entity)
dimension FindIthDimension(entity, int)
Definition: type.c:1180
int NumberOfDimension(entity)
Definition: size.c:588
#define expression_undefined_p(x)
Definition: ri.h:1224

References align_alignment, align_template, alignment_arraydim, alignment_constant, alignment_rate, alignment_undefined_p, array, CONS, copy_expression(), dimension_lower, dimension_upper, expression_undefined, expression_undefined_p, FindAlignmentOfTemplateDim(), FindIthDimension(), gen_nconc(), gen_nth(), HpfcExpressionToInt(), int_to_expression(), load_hpf_alignment(), make_range(), NIL, NumberOfDimension(), RANGE, range_increment, range_lower, and range_upper.

Referenced by loop_nest_guard(), and one_message_guards_and_neighbour().

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

◆ complementary_range()

range complementary_range ( entity  array,
int  dim,
range  r 
)

range complementary_range(array, dim, r)

just to avoid a gcc warning

Parameters
arrayrray
dimim

Definition at line 141 of file message-utils.c.

145 {
146  entity newarray = load_new_node(array);
147  dimension d = FindIthDimension(newarray, dim);
148  int rlo = HpfcExpressionToInt(range_lower(r)),
153 
154  assert(rin==1);
155 
156  if (dup==rup)
157  return(make_range(int_to_expression(dlo),
158  int_to_expression(rlo-1),
159  int_to_expression(1)));
160 
161  if (dlo==rlo)
162  return(make_range(int_to_expression(rup+1),
163  int_to_expression(dup),
164  int_to_expression(1)));
165 
166  pips_internal_error("well, there is a problem here around");
167 
168  return(range_undefined); /* just to avoid a gcc warning */
169 }
entity load_new_node(entity)
#define range_undefined
Definition: ri.h:2263

References array, assert, dimension_lower, dimension_upper, FindIthDimension(), HpfcExpressionToInt(), int_to_expression(), load_new_node(), make_range(), pips_internal_error, range_increment, range_lower, range_undefined, and range_upper.

Referenced by atomize_one_message().

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

◆ compute_receive_content()

list compute_receive_content ( entity  array,
list  lr,
Pvecteur  v 
)

shared!

Parameters
arrayrray
lrr

Definition at line 268 of file message-utils.c.

272 {
273  list content = NIL, l = lr;
274  int i = 1;
275 
277 
278  for (; l; i++, POP(l))
279  {
280  int procdim = 0;
281  bool distributed_dim = ith_dim_distributed_p(array, i, &procdim);
282  Value vn = distributed_dim?
283  vect_coeff((Variable) (intptr_t)procdim, v): VALUE_ZERO;
284  int neighbour = VALUE_TO_INT(vn);
285  range r = RANGE(CAR(l));
286 
287  if (neighbour!=0)
288  {
289  entity newarray = load_new_node(array);
290  dimension nadim = FindIthDimension(newarray, i);
291  expression incr = range_increment(r);
292  int lom1 = HpfcExpressionToInt(dimension_lower(nadim))-1,
293  upp1 = HpfcExpressionToInt(dimension_upper(nadim))+1,
294  width = (HpfcExpressionToInt(range_upper(r)) -
296 
297  content =
298  gen_nconc(content,
299  CONS(RANGE,
300  (neighbour<0)?
302  int_to_expression(upp1+width),
303  incr):
304  make_range(int_to_expression(lom1-width),
305  int_to_expression(lom1),
306  incr),
307  NIL));
308  }
309  else
310  {
311  content = gen_nconc(content, CONS(RANGE, r, NIL)); /* shared! */
312  }
313  }
314 
315  return(content);
316 }
#define VALUE_ZERO
size_t gen_length(const list l)
Definition: list.c:150
bool ith_dim_distributed_p(entity array, int i, int *pprocdim)
whether a dimension is distributed or not.
Definition: hpfc-util.c:160

References array, assert, CAR, CONS, dimension_lower, dimension_upper, FindIthDimension(), gen_length(), gen_nconc(), HpfcExpressionToInt(), int_to_expression(), intptr_t, ith_dim_distributed_p(), load_new_node(), make_range(), NIL, NumberOfDimension(), POP, RANGE, range_increment, range_lower, range_upper, VALUE_TO_INT, VALUE_ZERO, and vect_coeff().

Referenced by one_receive_message().

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

◆ compute_receive_domain()

list compute_receive_domain ( list  lr,
Pvecteur  v 
)

shared!

Parameters
lrr

Definition at line 318 of file message-utils.c.

321 {
322  list l = lr, domain = NIL;
323  int i = 1;
324 
325  for ( ; l!=NIL ; i++, l=CDR(l))
326  {
327  range r = RANGE(CAR(l));
328  Value vn = vect_coeff((Variable) (intptr_t)i, v);
329  int neighbour = VALUE_TO_INT(vn);
330 
331  if (neighbour==0)
332  domain = gen_nconc(domain, CONS(RANGE, r, NIL)); /* shared! */
333  else
334  {
335  int lo = HpfcExpressionToInt(range_lower(r)),
337 
338  domain =
339  gen_nconc(domain,
340  CONS(RANGE,
341  make_range(int_to_expression(lo+neighbour),
342  int_to_expression(up+neighbour),
343  range_increment(r)),
344  NIL));
345  }
346  }
347 
348  return(domain);
349 }
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
A DOMAIN union describes the structure of a user type.

References CAR, CDR, CONS, gen_nconc(), HpfcExpressionToInt(), int_to_expression(), intptr_t, make_range(), NIL, RANGE, range_increment, range_lower, range_upper, VALUE_TO_INT, and vect_coeff().

Referenced by one_receive_message().

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

◆ dup_list_of_Pvecteur()

list dup_list_of_Pvecteur ( list  l)

??? the complexity of this function could be improved greatly...

Definition at line 93 of file message-utils.c.

95 {
96  list result = NIL;
97 
98  MAPL(cv,
99  {
100  Pvecteur v = (Pvecteur) PVECTOR(CAR(cv));
101  result = gen_nconc(result, CONS(PVECTOR, (VECTOR) vect_dup(v), NIL));
102  },
103  l);
104 
105  return result;
106 }
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

References CAR, CONS, gen_nconc(), MAPL, NIL, PVECTOR, vect_dup(), and VECTOR.

Referenced by atomize_one_message().

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

◆ dup_list_of_ranges_list()

list dup_list_of_ranges_list ( list  l)

??? the complexity of this function could be greatly improved

Definition at line 72 of file message-utils.c.

74 {
75  list result = NIL;
76 
77  MAPL(cc,
78  {
79  list lr = CONSP(CAR(cc));
80  list lrp = NIL;
81  MAP(RANGE, r, lrp = gen_nconc(lrp, CONS(RANGE, r, NIL)), lr);
82  assert(gen_length(lrp)==gen_length(lr));
83  result = gen_nconc(result, CONS(LIST, lrp, NIL));
84  },
85  l);
86 
87  assert(gen_length(l)==gen_length(result));
88  return result;
89 }
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
Definition: newgen_list.h:226

References assert, CAR, CONS, CONSP, gen_length(), gen_nconc(), LIST, MAP, MAPL, NIL, and RANGE.

Referenced by atomize_one_message().

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

◆ empty_range_p()

bool empty_range_p ( range  r)

if we cannot decide, the range is supposed not to be empty

Definition at line 203 of file message-utils.c.

205 {
206  int lo, up;
207 
208  /* if we cannot decide, the range is supposed not to be empty
209  */
212  return false;
213  else
214  return lo>up;
215 }
bool hpfc_integer_constant_expression_p(expression e, int *pi)

References hpfc_integer_constant_expression_p(), range_lower, and range_upper.

Referenced by empty_section_p().

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

◆ empty_section_p()

bool empty_section_p ( list  lr)
Parameters
lrr

Definition at line 195 of file message-utils.c.

197 {
198  return((ENDP(lr))?
199  (false):
200  (empty_range_p(RANGE(CAR(lr))) || empty_section_p(CDR(lr))));
201 }
bool empty_range_p(range r)
bool empty_section_p(list lr)

References CAR, CDR, empty_range_p(), empty_section_p(), ENDP, and RANGE.

Referenced by empty_section_p(), keep_non_empty_domain_messages(), and keep_non_empty_messages_with_destination().

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

◆ generate_guarded_statement()

statement generate_guarded_statement ( statement  stat,
entity  proc,
list  lr 
)
Parameters
stattat
procroc
lrr

Definition at line 680 of file message-utils.c.

684 {
685  expression guard;
686 
687  return((make_guard_expression(proc, lr, &guard))?
690  make_test(guard,
691  stat,
693  (entity_empty_label()))))):
694  stat);
695 }
test make_test(expression a1, statement a2, statement a3)
Definition: ri.c:2607
instruction make_instruction(enum instruction_utype tag, void *val)
Definition: ri.c:1166
statement instruction_to_statement(instruction)
Build a statement from a give instruction.
Definition: statement.c:597
statement make_continue_statement(entity)
Definition: statement.c:953
bool make_guard_expression(entity proc, list lrref, expression *pguard)
bool make_guard_expression(proc, lr, pguard)
entity entity_empty_label(void)
Definition: entity.c:1105
@ is_instruction_test
Definition: ri.h:1470

References entity_empty_label(), instruction_to_statement(), is_instruction_test, make_continue_statement(), make_guard_expression(), make_instruction(), and make_test().

Referenced by loop_nest_guard(), and st_one_message().

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

◆ generate_message_from_3_lists()

list generate_message_from_3_lists ( entity  array,
list  lcontent,
list  lneighbour,
list  ldomain 
)

list generate_message_from_3_lists(array, lcontent, lneighbour, ldomain)

Parameters
arrayrray
lcontentcontent
lneighbourneighbour
ldomaindomain

Definition at line 173 of file message-utils.c.

176 {
177  list lc = lcontent, ln = lneighbour, ld = ldomain, lm = NIL;
178  int len = gen_length(lcontent);
179 
180  assert(len==(int)gen_length(lneighbour) && len==(int)gen_length(ldomain));
181 
182  for ( ; lc!=NIL ; lc=CDR(lc), ln=CDR(ln), ld=CDR(ld))
183  {
184  lm = CONS(MESSAGE,
186  CONSP(CAR(lc)),
187  (Pvecteur)PVECTOR(CAR(ln)),
188  CONSP(CAR(ld))),
189  lm);
190  }
191 
192  return(lm);
193 }
message make_message(entity a1, list a2, Pvecteur a3, list a4)
Definition: message.c:54
#define MESSAGE(x)
newgen_message_domain_defined
Definition: message.h:43

References array, assert, CAR, CDR, CONS, CONSP, gen_length(), make_message(), MESSAGE, NIL, and PVECTOR.

Referenced by atomize_one_message().

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

◆ larger_message_in_list()

bool larger_message_in_list ( message  m,
list  l 
)

Definition at line 351 of file message-utils.c.

354 {
355  MAP(MESSAGE, mp, if (message_larger_p(mp, m)) return true, l);
356  return(false);
357 }
bool message_larger_p(message m1, message m2)
bool message_larger_p(m1, m2)

References MAP, MESSAGE, and message_larger_p().

Referenced by remove_stammering_messages().

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

◆ loop_nest_guard()

statement loop_nest_guard ( statement  stat,
reference  r,
list  lkref,
list  lvref 
)

??? memory leak of some expressions

Parameters
stattat
lkrefkref
lvrefvref

Definition at line 793 of file message-utils.c.

797 {
798  entity
800  template = array_to_template(array),
801  proc = template_to_processors(template);
802  list
803  lra = array_access_to_array_ranges(r, lkref, lvref),
805  lrp = template_ranges_to_processors_ranges(template, lrt);
806  statement
807  result = generate_guarded_statement(stat, proc, lrp);
808 
809  gen_free_list(lra); /* ??? memory leak of some expressions */
810  gen_free_list(lrt);
811  gen_free_list(lrp);
812 
813  return(result);
814 }
#define array_to_template(array)
#define template_to_processors(template)
list array_access_to_array_ranges(reference r, list lkref, list lvref)
list template_ranges_to_processors_ranges(entity template, list lrt)
statement generate_guarded_statement(statement stat, entity proc, list lr)
list array_ranges_to_template_ranges(entity array, list lra)

References array, array_access_to_array_ranges(), array_ranges_to_template_ranges(), array_to_template, gen_free_list(), generate_guarded_statement(), reference_variable, template_ranges_to_processors_ranges(), and template_to_processors.

Referenced by Overlap_Analysis().

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

◆ lrange_larger_p()

bool lrange_larger_p ( list  lr1,
list  lr2 
)

can look for formal equality...

??? something more intelligent could be expected

Parameters
lr1r1
lr2r2

Definition at line 381 of file message-utils.c.

383 {
384  list l1 = lr1, l2 = lr2;
385 
386  assert(gen_length(lr1) == gen_length(lr2));
387 
388  for ( ; l1; POP(l1), POP(l2))
389  {
390  range r1 = RANGE(CAR(l1)), r2 = RANGE(CAR(l2));
391  int lo1, up1, in1, lo2, up2, in2;
392  bool
399  bcst = (blo1 && bup1 && bin1 && blo2 && bup2 && bin2);
400 
401  if (!bcst) /* can look for formal equality... */
402  {
403  return(expression_equal_p(range_lower(r1), range_lower(r2)) &&
406  }
407 
408  if (in1!=in2) return(false);
409 
410  /* ??? something more intelligent could be expected */
411  if ((in1!=1) && ((lo1!=lo2) || (up1!=up2)))
412  return(false);
413 
414  if ((in1==1) && ((lo1>lo2) || (up1<up2)))
415  return(false);
416  }
417 
418  pips_debug(7, "returning TRUE\n");
419 
420  return true;
421 }
bool expression_equal_p(expression e1, expression e2)
Syntactic equality e1==e2.
Definition: expression.c:1347

References assert, CAR, expression_equal_p(), gen_length(), hpfc_integer_constant_expression_p(), pips_debug, POP, RANGE, range_increment, range_lower, and range_upper.

Referenced by message_larger_p().

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

◆ make_guard_expression()

bool make_guard_expression ( entity  proc,
list  lrref,
expression pguard 
)

bool make_guard_expression(proc, lr, pguard)

compute the expression for the processors ranges lr guard. return true if not empty, false if empty.

empty match case

??? memory leak with the content of conjonction

MYPOS(i, procnum).EQ.nn

MYPOS(i, procnum).GE.(rloexpr)

MYPOS(i, procnum).LE.(rupexpr)

use of conjonction

no guard

Parameters
procroc
lrrefrref
pguardguard

Definition at line 702 of file message-utils.c.

706 {
707  int i, len = -1;
709  list lr = lrref, conjonction = NIL;
710 
711  for (i=1 ; i<=NumberOfDimension(proc) ; i++, lr=CDR(lr))
712  {
713  range rg = RANGE(CAR(lr));
714  expression
715  rloexpr = range_lower(rg),
716  rupexpr = range_upper(rg);
717  dimension d = FindIthDimension(proc, i);
718  int
721  sz = up-lo+1,
722  rlo = HpfcExpressionToInt(rloexpr),
723  rup = HpfcExpressionToInt(rupexpr);
724 
725  if (rlo>rup) /* empty match case */
726  {
727  (*pguard) = entity_to_expression(entity_intrinsic(".FALSE."));
728  return(true); /* ??? memory leak with the content of conjonction */
729  }
730 
731  if ((rlo==rup) && (sz!=1) && (rlo>=lo) && (rup<=up))
732  {
733  /* MYPOS(i, procnum).EQ.nn
734  */
735  conjonction =
737  eq_expression(make_mypos_expression(i, procnum), rloexpr),
738  conjonction);
739  }
740  else
741  {
742  if (rlo>lo)
743  {
744  /* MYPOS(i, procnum).GE.(rloexpr)
745  */
746  conjonction =
748  ge_expression(make_mypos_expression(i, procnum), rloexpr),
749  conjonction);
750  }
751 
752  if (rup<up)
753  {
754  /* MYPOS(i, procnum).LE.(rupexpr)
755  */
756  conjonction =
758  le_expression(make_mypos_expression(i, procnum), rupexpr),
759  conjonction);
760  }
761  }
762  }
763 
764  /* use of conjonction
765  */
766 
767  len = gen_length(conjonction);
768 
769  if (len==0) /* no guard */
770  {
771  (*pguard) = expression_undefined;
772  return(false);
773  }
774  else
775  {
776  (*pguard) = expression_list_to_conjonction(conjonction);
777  gen_free_list(conjonction);
778  return(true);
779  }
780 }
intptr_t load_hpf_number(entity)
expression make_mypos_expression(int i, expression exp)
#define ge_expression(e1, e2)
#define le_expression(e1, e2)
#define eq_expression(e1, e2)
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
expression expression_list_to_conjonction(list l)
Definition: expression.c:1937

References CAR, CDR, CONS, dimension_lower, dimension_upper, entity_intrinsic(), entity_to_expression(), eq_expression, EXPRESSION, expression_list_to_conjonction(), expression_undefined, FindIthDimension(), ge_expression, gen_free_list(), gen_length(), HpfcExpressionToInt(), int_to_expression(), le_expression, load_hpf_number(), make_mypos_expression(), NIL, NumberOfDimension(), RANGE, range_lower, and range_upper.

Referenced by generate_guarded_statement().

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

◆ make_mypos_expression()

expression make_mypos_expression ( int  i,
expression  exp 
)
Parameters
expxp

Definition at line 782 of file message-utils.c.

785 {
790  NIL)))));
791 }
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
#define MYPOS
entity hpfc_name_to_entity(const char *)
Definition: run-time.c:817
expression reference_to_expression(reference r)
Definition: expression.c:196
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207

References CONS, exp, EXPRESSION, hpfc_name_to_entity(), int_to_expression(), make_reference(), MYPOS, NIL, and reference_to_expression().

Referenced by make_guard_expression().

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

◆ message_larger_p()

bool message_larger_p ( message  m1,
message  m2 
)

bool message_larger_p(m1, m2)

true if m1>=m2... (caution, it is only a partial order)

Parameters
m11
m22

Definition at line 363 of file message-utils.c.

365 {
366  if (message_array(m1)!=message_array(m2))
367  return(false);
368 
371  return(false);
372 
373  /*
374  * same array and same destination, let's look at the content and domain...
375  */
376 
379 }
#define value_ne(v1, v2)
bool lrange_larger_p(list lr1, list lr2)
#define message_array(x)
Definition: message.h:75
#define message_dom(x)
Definition: message.h:81
#define message_neighbour(x)
Definition: message.h:79
#define message_content(x)
Definition: message.h:77

References lrange_larger_p(), message_array, message_content, message_dom, message_neighbour, TCST, value_ne, and vect_coeff().

Referenced by larger_message_in_list().

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

◆ sprint_lrange()

char* sprint_lrange ( string  str,
list  l 
)
Parameters
strtr

Definition at line 217 of file message-utils.c.

220 {
221  string s = str;
222  bool firstrange = true;
223 
224  MAP(RANGE, r,
225  {
226  if (!firstrange)
227  {
228  sprintf(s, ", ");
229  s += strlen(s);
230  }
231  else
232  firstrange = false;
233 
234  sprint_range(s, r);
235  s += strlen(s);
236  },
237  l);
238 
239  return str;
240 }
char * sprint_range(string str, range r)

References MAP, RANGE, and sprint_range().

Referenced by st_one_message().

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

◆ sprint_range()

char* sprint_range ( string  str,
range  r 
)
Parameters
strtr

Definition at line 242 of file message-utils.c.

243 {
244  int lo, up, in;
245  bool
249 
250  if (blo && bup && bin)
251  {
252  if (in==1)
253  {
254  if (lo==up)
255  sprintf(str, "%d", lo);
256  else
257  sprintf(str, "%d:%d", lo, up);
258  }
259  else
260  sprintf(str, "%d:%d:%d", lo, up, in);
261  }
262  else
263  sprintf(str, "X");
264 
265  return str+strlen(str);
266 }

References hpfc_integer_constant_expression_p(), range_increment, range_lower, and range_upper.

Referenced by sprint_lrange().

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

◆ template_ranges_to_processors_ranges()

list template_ranges_to_processors_ranges ( entity  template,
list  lrt 
)

??? another increment could be computed?

Parameters
templateemplate
lrtrt

Definition at line 498 of file message-utils.c.

501 {
502  distribute d = load_hpf_distribution(template);
503  entity proc = distribute_processors(d);
504  list ld = distribute_distribution(d), lrp = NIL;
505  int i = 1;
506 
507  for (i=1 ; i<=NumberOfDimension(proc) ; i++)
508  {
509  int tdim = 0;
510  distribution di = FindDistributionOfProcessorDim(ld, i, &tdim);
511  style s = distribution_style(di);
512  range rg = RANGE(gen_nth(tdim-1, lrt));
513  int p = 0,
517 
518  switch (style_tag(s))
519  {
520  case is_style_block:
521  {
522  expression
523  pl = int_to_expression(processor_number(template, tdim, tl, &p)),
524  pu = int_to_expression(processor_number(template, tdim, tu, &p));
525 
526  /* ??? another increment could be computed?
527  */
528  lrp = gen_nconc(lrp,
529  CONS(RANGE,
531  NIL));
532  break;
533  }
534  case is_style_cyclic:
535  {
536  dimension dp = FindIthDimension(proc, i);
537  int sz = dimension_size(dp);
538  expression
539  pl = int_to_expression(processor_number(template, tdim, tl, &p)),
540  pu = int_to_expression(processor_number(template, tdim, tu, &p));
541 
542  if (((tu-tl)>n*sz) || (pl>pu) || ((pl==pu) && ((tu-tl)>n)))
543  lrp = gen_nconc(lrp,
544  CONS(RANGE,
546  dimension_upper(dp),
547  int_to_expression(1)),
548  NIL));
549  else
550  lrp = gen_nconc(lrp,
551  CONS(RANGE,
552  make_range(pl, pu,
553  int_to_expression(1)),
554  NIL));
555 
556  break;
557  }
558  case is_style_none:
559  pips_internal_error("unexpected none style distribution");
560  break;
561  default:
562  pips_internal_error("unexpected style tag (%d)",
563  style_tag(s));
564  }
565  }
566  return(lrp);
567 }
#define distribution_style(x)
Definition: hpf.h:210
#define distribute_distribution(x)
Definition: hpf.h:174
#define style_tag(x)
Definition: hpf.h:258
#define distribute_processors(x)
Definition: hpf.h:176
#define distribution_parameter(x)
Definition: hpf.h:212
@ is_style_cyclic
Definition: hpf.h:239
@ is_style_block
Definition: hpf.h:238
@ is_style_none
Definition: hpf.h:237
distribution FindDistributionOfProcessorDim(list ldi, int dim, int *tdim)
Definition: hpfc-util.c:421
int processor_number(entity template, int tdim, int tcell, int *pprocdim)
int processor_number(template, tdim, tcell, pprocdim)
Definition: hpfc-util.c:492
distribute load_hpf_distribution(entity)
static hash_table pl
properties are stored in this hash table (string -> property) for fast accesses.
Definition: properties.c:783
int dimension_size(dimension)
this function computes the size of a dimension.
Definition: size.c:491

References CONS, dimension_lower, dimension_size(), dimension_upper, distribute_distribution, distribute_processors, distribution_parameter, distribution_style, FindDistributionOfProcessorDim(), FindIthDimension(), gen_nconc(), gen_nth(), HpfcExpressionToInt(), int_to_expression(), is_style_block, is_style_cyclic, is_style_none, load_hpf_distribution(), make_range(), NIL, NumberOfDimension(), pips_internal_error, pl, processor_number(), RANGE, range_lower, range_upper, and style_tag.

Referenced by loop_nest_guard(), and one_message_guards_and_neighbour().

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

◆ the_index_of_vect()

Pvecteur the_index_of_vect ( Pvecteur  v0)

Message Utilities.

message-utils.c

Fabien Coelho, August 1993 returns the index of an affine vector

Parameters
v00

Definition at line 37 of file message-utils.c.

39 {
40  Pvecteur v1 = vect_del_var(v0, TCST);
41 
42  vect_erase_var(&v1, DELTAV);
44  vect_erase_var(&v1, TSHIFTV);
45 
46  assert(vect_size(v1)==1);
47 
48  return v1;
49 }
#define TEMPLATEV
Definition: defines-local.h:80
#define TSHIFTV
Definition: defines-local.h:81
#define DELTAV
??? very beurk!
Definition: defines-local.h:79
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

References assert, DELTAV, TCST, TEMPLATEV, TSHIFTV, vect_del_var(), vect_erase_var(), and vect_size().

Referenced by generate_one_message(), and update_indices_for_local_computation().

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