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

Go to the source code of this file.

Functions

static expression safe_static_domain_bound (entity array, int dim, expression e, int shift, bool lower)
 Messages handling. More...
 
static message generate_one_message (entity array, list li, list lk, list lv)
 message generate_one_message(array, li, lk, lv) More...
 
static list messages_generation (list Ro, list lRo)
 list messages_generation(Ro, lRo) More...
 
static list atomize_one_message (message m)
 
static list messages_atomization (list lm1)
 
static list keep_non_empty_messages_with_destination (list l)
 
static list keep_non_empty_domain_messages (list l)
 
static message shape_one_message (message m)
 message shape_one_message(m) More...
 
static list messages_shaping (list l)
 
static message one_message_guards_and_neighbour (message m)
 
static list messages_guards_and_neighbour (list l)
 
static message one_receive_message (message send)
 
static list receive_messages_generation (list lms)
 list receive_messages_generation(lms) More...
 
static statement st_one_message (message m, bool bsend)
 statement st_one_message(m, bsend) More...
 
static list generate_the_messages (list lm, bool bsend)
 
static list remove_stammering_messages (list lm)
 list remove_stammering_messages(lm) More...
 
statement messages_handling (list Ro, list lRo)
 every required conditions are supposed to be verified in this function. More...
 

Function Documentation

◆ atomize_one_message()

static list atomize_one_message ( message  m)
static

let's count in binary mode

Definition at line 351 of file messages.c.

353 {
354  entity
355  array = message_array(m);
356  list
357  content = message_content(m),
358  domain = message_dom(m),
359  lneighbour = NIL,
360  lcontent = NIL,
361  ldomain = NIL,
362  cnt = NIL,
363  dom = NIL,
364  lm = NIL;
365  Pvecteur
366  v = (Pvecteur) message_neighbour(m);
367  int
368  i = 1;
369 
370  ifdebug(9)
371  {
372  fprintf(stderr, "[atomize_one_message] ");
373  fprint_message(stderr, m);
374  }
375 
376  for (cnt=content, dom=domain ; cnt!=NIL ; cnt=CDR(cnt), dom=CDR(dom), i++)
377  {
378  int procdim;
379  range rcnt = RANGE(CAR(cnt)), rdom = RANGE(CAR(dom));
380  bool distributed = ith_dim_distributed_p(array, i, &procdim);
381  Value vn = distributed? vect_coeff((Variable) (intptr_t)procdim, v): VALUE_ZERO;
382  int neighbour = VALUE_TO_INT(vn);
383 
384  debug(9, "atomize_one_message", "dimension %d\n", i);
385 
386  if (neighbour==0)
387  {
388  lcontent = add_to_list_of_ranges_list(lcontent, rcnt);
389  ldomain = add_to_list_of_ranges_list(ldomain, rdom);
390  lneighbour = add_elem_to_list_of_Pvecteur(lneighbour, 0, 0);
391  }
392  else /* let's count in binary mode */
393  {
394  list
395  lc = dup_list_of_ranges_list(lcontent),
396  ld = dup_list_of_ranges_list(ldomain),
397  ln = dup_list_of_Pvecteur(lneighbour);
398 
399  lcontent =
401  complementary_range(array, i, rcnt));
402  ldomain = add_to_list_of_ranges_list(ldomain, rdom);
403  lneighbour = add_elem_to_list_of_Pvecteur(lneighbour, 0, 0);
404 
405  lc = add_to_list_of_ranges_list(lc, rcnt);
406  ld = add_to_list_of_ranges_list(ld, rdom);
407  ln = add_elem_to_list_of_Pvecteur(ln, procdim, neighbour);
408 
409  lcontent = gen_nconc(lcontent, lc);
410  ldomain = gen_nconc(ldomain, ld);
411  lneighbour = gen_nconc(lneighbour, ln);
412  }
413  }
414 
415  /*
416  * message generation from the lists
417  */
418 
419  lm = generate_message_from_3_lists(array, lcontent, lneighbour, ldomain);
420 
421  gen_free_list(lcontent);
422  gen_free_list(lneighbour);
423  gen_free_list(ldomain);
424 
425  return(lm);
426 }
#define VALUE_ZERO
#define VALUE_TO_INT(val)
int Value
void fprint_message(FILE *file, message m)
Definition: debug-util.c:217
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
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
bool ith_dim_distributed_p(entity array, int i, int *pprocdim)
whether a dimension is distributed or not.
Definition: hpfc-util.c:160
list add_elem_to_list_of_Pvecteur(list, int, int)
caution, is initial list is destroyed.
list dup_list_of_ranges_list(list)
??? the complexity of this function could be greatly improved
Definition: message-utils.c:72
list generate_message_from_3_lists(entity, list, list, list)
list generate_message_from_3_lists(array, lcontent, lneighbour, ldomain)
range complementary_range(entity, int, range)
range complementary_range(array, dim, r)
list add_to_list_of_ranges_list(list, range)
Definition: message-utils.c:51
list dup_list_of_Pvecteur(list)
??? the complexity of this function could be improved greatly...
Definition: message-utils.c:93
#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
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
#define RANGE(x)
RANGE.
Definition: ri.h:2257
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
#define ifdebug(n)
Definition: sg.c:47
static entity array
#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
A DOMAIN union describes the structure of a user type.
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
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 add_elem_to_list_of_Pvecteur(), add_to_list_of_ranges_list(), array, CAR, CDR, complementary_range(), debug(), dup_list_of_Pvecteur(), dup_list_of_ranges_list(), fprint_message(), fprintf(), gen_free_list(), gen_nconc(), generate_message_from_3_lists(), ifdebug, intptr_t, ith_dim_distributed_p(), message_array, message_content, message_dom, message_neighbour, NIL, RANGE, VALUE_TO_INT, VALUE_ZERO, and vect_coeff().

Referenced by messages_atomization().

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

◆ generate_one_message()

static message generate_one_message ( entity  array,
list  li,
list  lk,
list  lv 
)
static

message generate_one_message(array, li, lk, lv)

generate one message after the reference given,

I think I don't need to store the to where value... that's rather interesting since I do not know where I could put it...

no neighbour concerned

content:

domain:

note that rate==1

neighbour to send to

content, on the sender point of view...

(shift>0)

shift == 0

content: send it all?

assert(gen_consistent_p(rg));

domain

??? why 1

??? bug if there is a declaration shift...

no neighbour concerned

content:

domain:

no neighbour

content: all shifted space indexed

??? false if declaration shift

domain

??? why 1

no neighbour

content: all shifted space indexed

??? false if declaration shift

domain

no neighbour concerned

content:

domain:

Definition at line 62 of file messages.c.

65 {
66  int i = 1, len = gen_length(li);
67  list lip = li, lkp = lk, lvp = lv, lr = NIL, ldom = NIL;
68  entity newarray = load_new_node(array);
69  Pvecteur procv = VECTEUR_NUL;
70 
71  assert(len==(int)gen_length(lk) && len==(int)gen_length(lv));
72 
73  for ( ; i<=len ; i++, lip=CDR(lip), lkp=CDR(lkp), lvp=CDR(lvp))
74  {
75  tag at = access_tag(INT(CAR(lkp)));
76  Pvecteur v = (Pvecteur) PVECTOR(CAR(lvp));
77  expression indice = EXPRESSION(CAR(lip));
78  dimension newdim = FindIthDimension(newarray, i);
79  int
80  arraylo = HpfcExpressionToInt(dimension_lower(newdim)),
81  arrayup = HpfcExpressionToInt(dimension_upper(newdim));
82 
83  pips_debug(9, "array %s, dimension %d, access considered is %d\n",
84  entity_local_name(newarray), i, at);
85 
86  switch (at)
87  {
88  case aligned_constant:
89  {
90  /* I think I don't need to store the to where value...
91  * that's rather interesting since I do not know where I could
92  * put it...
93  */
94  Value cst = vect_coeff(TCST, v), vt = vect_coeff(TEMPLATEV, v);
95  int tpl = VALUE_TO_INT(vt),
96  localarraycell = template_cell_local_mapping(array, i, tpl);
97 
98  /* no neighbour concerned */
99  /* content: */
100  lr = gen_nconc(lr,
101  CONS(RANGE,
102  make_range(int_to_expression(localarraycell),
103  int_to_expression(localarraycell),
104  int_to_expression(1)),
105  NIL));
106  /* domain: */
107  ldom = gen_nconc(ldom,
108  CONS(RANGE,
110  Value_to_expression(cst),
111  int_to_expression(1)),
112  NIL));
113  break;
114  }
115  case aligned_shift:
116  /*
117  * note that rate==1
118  */
119  {
120  Pvecteur vindex = the_index_of_vect(v);
121  entity index = (entity) var_of(vindex);
122  range rg = loop_index_to_range(index);
123  Value vs = vect_coeff(TSHIFTV, v), vi = vect_coeff(TCST, v);
124  int procdim,
125  shift = VALUE_TO_INT(vs),
126  ishft = VALUE_TO_INT(vi),
127  n = DistributionParameterOfArrayDim(array, i, &procdim);
128  expression dom_lb, dom_ub;
129 
130  debug(10, "generate_one_message",
131  "n = %d, just to avoid a gcc warning:-)\n", n);
132 
133  if (shift!=0)
134  {
135  /* neighbour to send to */
136  procv = vect_add(procv,
137  vect_new((Variable) (intptr_t)procdim,
138  (shift<0)?(VALUE_ONE):(VALUE_MONE)));
139 
140  /* content, on the sender point of view... */
141  if (shift<0)
142  {
143  lr = gen_nconc
144  (lr,
145  CONS(RANGE,
146  make_range(int_to_expression(arrayup+shift+1),
147  int_to_expression(arrayup),
148  int_to_expression(1)),
149  NIL));
150  }
151  else /* (shift>0) */
152  {
153  lr = gen_nconc
154  (lr,
155  CONS(RANGE,
156  make_range(int_to_expression(arraylo),
157  int_to_expression(arraylo+shift-1),
158  int_to_expression(1)),
159  NIL));
160  }
161  }
162  else /* shift == 0 */
163  {
164  /* content: send it all? */
165  lr = gen_nconc(lr,
166  CONS(RANGE,
167  make_range(int_to_expression(arraylo),
168  int_to_expression(arrayup),
169  int_to_expression(1)),
170  NIL));
171  }
172 
173  /* assert(gen_consistent_p(rg)); */
174 
175  dom_lb = safe_static_domain_bound(array, i,
176  range_lower(rg), ishft, true);
177  dom_ub = safe_static_domain_bound(array, i,
178  range_upper(rg), ishft, false);
179 
180  /* domain */
181  ldom =
182  gen_nconc(ldom,
183  CONS(RANGE,
184  make_range(dom_lb,
185  dom_ub,
186  int_to_expression(1)), /* ??? why 1 */
187  NIL));
188 
189  break;
190  }
191  case local_constant:
192  {
193  Value
194  /* ??? bug if there is a declaration shift... */
195  arraycell = vect_coeff(TCST, v);
196 
197  /* no neighbour concerned */
198  /* content: */
199  lr = gen_nconc(lr,
200  CONS(RANGE,
201  make_range(Value_to_expression(arraycell),
202  Value_to_expression(arraycell),
203  int_to_expression(1)),
204  NIL));
205  /* domain: */
206  ldom = gen_nconc(ldom,
207  CONS(RANGE,
208  make_range(Value_to_expression(arraycell),
209  Value_to_expression(arraycell),
210  int_to_expression(1)),
211  NIL));
212  break;
213  }
214  case local_shift:
215  {
216  Pvecteur vindex = the_index_of_vect(v);
217  entity index = (entity) var_of(vindex);
218  range rg = loop_index_to_range(index);
219  Value vs = vect_coeff(TCST, v);
220  int shift = VALUE_TO_INT(vs),
221  ishft = shift,
224 
225  /* no neighbour */
226  /* content: all shifted space indexed */
227  /* ??? false if declaration shift */
228  lr =
229  gen_nconc(lr,
230  CONS(RANGE,
231  make_range(int_to_expression(lb+shift),
232  int_to_expression(ub+shift),
233  int_to_expression(1)),
234  NIL));
235 
236  /* domain */
237  ldom =
238  gen_nconc(ldom,
239  CONS(RANGE,
240  make_range(int_to_expression(lb+ishft),
241  int_to_expression(ub+ishft),
242  int_to_expression(1)),/* ??? why 1 */
243  NIL));
244 
245 
246  break;
247  }
248  case local_affine:
249  {
250  Pvecteur
251  vindex = the_index_of_vect(v);
252  entity
253  index = (entity) var_of(vindex);
254  range
255  rg = loop_index_to_range(index);
256  Value vs = vect_coeff(TCST, v);
257  int
258  rate = VALUE_TO_INT(val_of(vindex)),
259  shift = VALUE_TO_INT(vs),
260  ishft = shift,
264 
265  /* no neighbour */
266  /* content: all shifted space indexed */
267  /* ??? false if declaration shift */
268  lr = gen_nconc(lr,
269  CONS(RANGE,
270  make_range(int_to_expression(rate*lb+shift),
271  int_to_expression(rate*ub+shift),
272  int_to_expression(in*rate)),
273  NIL));
274 
275  /* domain */
276  ldom = gen_nconc(ldom,
277  CONS(RANGE,
278  make_range(int_to_expression(rate*lb+ishft),
279  int_to_expression(rate*ub+ishft),
280  int_to_expression(in*rate)),
281  NIL));
282 
283 
284  break;
285  }
286  case local_form_cst:
287  {
288  /* no neighbour concerned */
289  /* content: */
290  lr = gen_nconc(lr,
291  CONS(RANGE,
292  make_range(indice,
293  indice,
294  int_to_expression(1)),
295  NIL));
296  /* domain: */
297  ldom = gen_nconc(ldom,
298  CONS(RANGE,
299  make_range(indice,
300  indice,
301  int_to_expression(1)),
302  NIL));
303  break;
304  }
305  default:
306  pips_internal_error("access tag not welcomed here (%d)", at);
307  break;
308  }
309  }
310 
311  return(make_message(array, lr, procv, ldom));
312 }
message make_message(entity a1, list a2, Pvecteur a3, list a4)
Definition: message.c:54
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 local_form_cst
#define aligned_constant
#define access_tag(a)
#define local_constant
#define local_shift
#define VALUE_MONE
#define VALUE_ONE
@ INT
Definition: atomic.c:48
range loop_index_to_range(entity index)
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
int template_cell_local_mapping(entity array, int dim, int tc)
int template_cell_local_mapping(array, dim, tc)
Definition: hpfc-util.c:532
int DistributionParameterOfArrayDim(entity array, int dim, int *pprocdim)
Definition: hpfc-util.c:472
int HpfcExpressionToInt(expression e)
HpfcExpressionToInt(e)
Definition: hpfc-util.c:569
#define TEMPLATEV
Definition: defines-local.h:80
#define TSHIFTV
Definition: defines-local.h:81
#define PVECTOR(v)
Definition: defines-local.h:72
entity load_new_node(entity)
Pvecteur the_index_of_vect(Pvecteur)
message-utils.c
Definition: message-utils.c:37
static expression safe_static_domain_bound(entity array, int dim, expression e, int shift, bool lower)
Messages handling.
Definition: messages.c:37
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define pips_internal_error
Definition: misc-local.h:149
#define assert(ex)
Definition: newgen_assert.h:41
int tag
TAG.
Definition: newgen_types.h:92
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 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
dimension FindIthDimension(entity, int)
Definition: type.c:1180
#define range_upper(x)
Definition: ri.h:2290
#define dimension_lower(x)
Definition: ri.h:980
#define range_increment(x)
Definition: ri.h:2292
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define dimension_upper(x)
Definition: ri.h:982
#define range_lower(x)
Definition: ri.h:2288
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
#define val_of(varval)
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.
#define var_of(varval)
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
Pvecteur vect_add(Pvecteur v1, Pvecteur v2)
package vecteur - operations binaires
Definition: binaires.c:53

References access_tag, aligned_constant, aligned_shift, array, assert, CAR, CDR, CONS, debug(), dimension_lower, dimension_upper, DistributionParameterOfArrayDim(), entity_local_name(), EXPRESSION, FindIthDimension(), gen_length(), gen_nconc(), HpfcExpressionToInt(), INT, int_to_expression(), intptr_t, load_new_node(), local_affine, local_constant, local_form_cst, local_shift, loop_index_to_range(), make_message(), make_range(), NIL, pips_debug, pips_internal_error, PVECTOR, RANGE, range_increment, range_lower, range_upper, safe_static_domain_bound(), TCST, template_cell_local_mapping(), TEMPLATEV, the_index_of_vect(), TSHIFTV, val_of, VALUE_MONE, VALUE_ONE, Value_to_expression(), VALUE_TO_INT, var_of, vect_add(), vect_coeff(), vect_new(), and VECTEUR_NUL.

Referenced by messages_generation().

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

◆ generate_the_messages()

static list generate_the_messages ( list  lm,
bool  bsend 
)
static

Definition at line 689 of file messages.c.

692 {
693  list l = NIL;
694 
695  MAP(MESSAGE, m, l = CONS(STATEMENT, st_one_message(m, bsend), l), lm);
696 
697  return l;
698 }
#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
#define MESSAGE(x)
newgen_message_domain_defined
Definition: message.h:43
static statement st_one_message(message m, bool bsend)
statement st_one_message(m, bsend)
Definition: messages.c:645
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413

References CONS, MAP, MESSAGE, NIL, st_one_message(), and STATEMENT.

Referenced by messages_handling().

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

◆ keep_non_empty_domain_messages()

static list keep_non_empty_domain_messages ( list  l)
static

??? else memory leak

Definition at line 455 of file messages.c.

457 {
458  list
459  result = NIL;
460 
461  MAP(MESSAGE, m,
462  {
463  if (!empty_section_p(message_dom(m)))
464  result = CONS(MESSAGE, m, result);
465  /* ??? else memory leak */
466  },
467  l);
468 
469  return(result);
470 }
bool empty_section_p(list)

References CONS, empty_section_p(), MAP, MESSAGE, message_dom, and NIL.

Referenced by messages_handling().

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

◆ keep_non_empty_messages_with_destination()

static list keep_non_empty_messages_with_destination ( list  l)
static

??? else memory leak

Definition at line 438 of file messages.c.

440 {
441  list result = NIL;
442 
443  MAP(MESSAGE, m,
444  {
447  result = CONS(MESSAGE, m, result);
448  /* ??? else memory leak */
449  },
450  l);
451 
452  return(result);
453 }
#define VECTEUR_NUL_P(v)

References CONS, empty_section_p(), MAP, MESSAGE, message_content, message_neighbour, NIL, and VECTEUR_NUL_P.

Referenced by messages_handling().

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

◆ messages_atomization()

static list messages_atomization ( list  lm1)
static

Definition at line 428 of file messages.c.

430 {
431  list lm2 = NIL;
432 
433  MAP(MESSAGE, m, lm2 = gen_nconc(atomize_one_message(m), lm2), lm1);
434 
435  return lm2;
436 }
static list atomize_one_message(message m)
Definition: messages.c:351

References atomize_one_message(), gen_nconc(), MAP, MESSAGE, and NIL.

Referenced by messages_handling().

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

◆ messages_generation()

static list messages_generation ( list  Ro,
list  lRo 
)
static

list messages_generation(Ro, lRo)

first kind of messages generation (the overlap management is handled in message_manageable_p())

Definition at line 319 of file messages.c.

321 {
322  list
323  lm = NIL,
324  lr = NIL,
325  lp = NIL;
326 
327  for (lr=Ro, lp=lRo ; lr!=NIL ; lr=CDR(lr), lp=CDR(lp))
328  {
329  reference
330  r = syntax_reference(SYNTAX(CAR(lr)));
331  entity
333  list
334  li = reference_indices(r),
335  lkv = CONSP(CAR(lp)),
336  lk = CONSP(CAR(lkv)),
337  lv = CONSP(CAR(CDR(lkv)));
338  int
339  len = gen_length(li);
340 
341  assert(len==(int)gen_length(lk) && len==(int)gen_length(lv));
342 
343  lm = CONS(MESSAGE,
344  generate_one_message(array, li, lk, lv),
345  lm);
346  }
347 
348  return(lm);
349 }
#define CONSP(x)
Definition: genC.h:88
static message generate_one_message(entity array, list li, list lk, list lv)
message generate_one_message(array, li, lk, lv)
Definition: messages.c:62
#define syntax_reference(x)
Definition: ri.h:2730
#define reference_variable(x)
Definition: ri.h:2326
#define reference_indices(x)
Definition: ri.h:2328
#define SYNTAX(x)
SYNTAX.
Definition: ri.h:2670

References array, assert, CAR, CDR, CONS, CONSP, gen_length(), generate_one_message(), MESSAGE, NIL, reference_indices, reference_variable, SYNTAX, and syntax_reference.

Referenced by messages_handling().

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

◆ messages_guards_and_neighbour()

static list messages_guards_and_neighbour ( list  l)
static

Definition at line 588 of file messages.c.

590 {
591  list result = NIL;
592 
593  MAP(MESSAGE, m,
594  result = CONS(MESSAGE, one_message_guards_and_neighbour(m), result),
595  l);
596 
597  return result;
598 }
static message one_message_guards_and_neighbour(message m)
Definition: messages.c:545

References CONS, MAP, MESSAGE, NIL, and one_message_guards_and_neighbour().

Referenced by messages_handling().

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

◆ messages_handling()

statement messages_handling ( list  Ro,
list  lRo 
)

every required conditions are supposed to be verified in this function.

messages.c

first kind of messages generation

a message is an array, a mixed content on the local array, a set of neighbours (in a Pvecteur) and an array section concerned.

here should be performed some message coalescing and/or aggregation: a first simple version could check for messages sent twice, and so on.

RECEIVE

Parameters
Roo
lRoRo

Definition at line 724 of file messages.c.

726 {
727  list
728  lm1 = NIL,
729  lm2 = NIL,
730  lm2p = NIL,
731  lm3 = NIL,
732  lm3p = NIL,
733  lm4 = NIL,
734  lms = NIL,
735  lmr = NIL,
736  lsend = NIL,
737  lreceive = NIL;
738  int
739  len = gen_length(Ro);
740 
741  assert(len==(int)gen_length(lRo) && len>=1);
742 
743  /* first kind of messages generation
744  *
745  * a message is
746  * an array,
747  * a mixed content on the local array,
748  * a set of neighbours (in a Pvecteur) and
749  * an array section concerned.
750  */
751  lm1 = messages_generation(Ro, lRo);
752 
753  debug(6, "messages_handling", "lm1 length is %d\n", gen_length(lm1));
754  ifdebug(8)
755  {
756  fprint_lmessage(stderr, lm1);
757  }
758 
759  /*
760  * second kind of messages generation
761  *
762  * messages are atomized to real messages:
763  * a message is
764  * an array,
765  * a content (on the local array),
766  * a neighbour to send to (in a Pvecteur),
767  * a domain of the array concerned.
768  */
769  lm2 = messages_atomization(lm1);
770  gen_free_list(lm1);
771 
772  debug(6, "messages_handling",
773  "lm2 length is %d\n", gen_length(lm2));
774  ifdebug(8)
775  {
776  fprint_lmessage(stderr, lm2);
777  }
778 
780  gen_free_list(lm2);
781 
782  debug(6, "messages_handling",
783  "lm2p length is %d\n", gen_length(lm2p));
784  ifdebug(8)
785  {
786  fprint_lmessage(stderr, lm2p);
787  }
788 
789 
790  /*
791  * third kind of messages generation
792  *
793  * the domain is restricted to what is necessary for the
794  * given message, and this on every distributed dimension...
795  * this is important for the guards generation later on.
796  */
797  lm3 = messages_shaping(lm2p);
798  gen_free_list(lm2p);
799 
800  debug(6, "messages_handling",
801  "lm3 length is %d\n", gen_length(lm3));
802  ifdebug(8)
803  {
804  fprint_lmessage(stderr, lm3);
805  }
806 
807 
808  lm3p = keep_non_empty_domain_messages(lm3);
809  gen_free_list(lm3);
810 
811  debug(6, "messages_handling", "lm3p length is %d\n", gen_length(lm3p));
812  ifdebug(8) fprint_lmessage(stderr, lm3p);
813 
814  /*
815  * fourth kind of messages generation
816  *
817  * the array section domain is translated into a processors section,
818  * and the neighbour shift is computed for the linearized processors
819  * arrangement considered in the runtime resolution.
820  */
821  lm4 = messages_guards_and_neighbour(lm3p);
822  gen_free_list(lm3p);
823 
824  debug(6, "messages_handling", "lm4 length is %d\n", gen_length(lm4));
825  ifdebug(8) fprint_lmessage(stderr, lm4);
826 
827  /* here should be performed some message coalescing and/or aggregation:
828  * a first simple version could check for messages sent twice, and so on.
829  */
830  hpfc_warning("messages coalescing and aggregation not implemented\n");
831 
832  lms = remove_stammering_messages(lm4);
833 
834  /* RECEIVE
835  */
836  lmr = receive_messages_generation(lms);
837 
838  assert(gen_length(lmr)==gen_length(lms));
839 
840  ifdebug(8)
841  {
842  fprintf(stderr, "[message handling] lmr and lms\n");
843  fprint_lmessage(stderr, lmr);
844  fprint_lmessage(stderr, lms);
845  }
846 
847  lsend = generate_the_messages(lms, SEND);
848  lreceive = generate_the_messages(lmr, RECEIVE);
849 
850  return(make_block_statement(gen_nconc(lsend, lreceive)));
851 }
void fprint_lmessage(FILE *file, list l)
Definition: debug-util.c:231
statement make_block_statement(list)
Make a block statement from a list of statement.
Definition: statement.c:616
#define RECEIVE
#define hpfc_warning
WARNING.
#define SEND
static list keep_non_empty_messages_with_destination(list l)
Definition: messages.c:438
static list messages_guards_and_neighbour(list l)
Definition: messages.c:588
static list keep_non_empty_domain_messages(list l)
Definition: messages.c:455
static list messages_generation(list Ro, list lRo)
list messages_generation(Ro, lRo)
Definition: messages.c:319
static list generate_the_messages(list lm, bool bsend)
Definition: messages.c:689
static list receive_messages_generation(list lms)
list receive_messages_generation(lms)
Definition: messages.c:623
static list remove_stammering_messages(list lm)
list remove_stammering_messages(lm)
Definition: messages.c:704
static list messages_shaping(list l)
Definition: messages.c:535
static list messages_atomization(list lm1)
Definition: messages.c:428
statement messages_handling(list Ro, list lRo)
every required conditions are supposed to be verified in this function.
Definition: messages.c:724

References assert, debug(), fprint_lmessage(), fprintf(), gen_free_list(), gen_length(), gen_nconc(), generate_the_messages(), hpfc_warning, ifdebug, keep_non_empty_domain_messages(), keep_non_empty_messages_with_destination(), make_block_statement(), messages_atomization(), messages_generation(), messages_guards_and_neighbour(), messages_shaping(), NIL, RECEIVE, receive_messages_generation(), remove_stammering_messages(), and SEND.

Referenced by Overlap_Analysis().

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

◆ messages_shaping()

static list messages_shaping ( list  l)
static

Definition at line 535 of file messages.c.

537 {
538  list result = NIL;
539 
540  MAP(MESSAGE, m, result = CONS(MESSAGE, shape_one_message(m), result), l);
541 
542  return(result);
543 }
static message shape_one_message(message m)
message shape_one_message(m)
Definition: messages.c:476

References CONS, MAP, MESSAGE, NIL, and shape_one_message().

Referenced by messages_handling().

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

◆ one_message_guards_and_neighbour()

static message one_message_guards_and_neighbour ( message  m)
static

now the neighbour computation in the linearized processor arrangment named NODETIDS() of common /HPFC_PARAM/. the code is similar to the runtime support function HPFC_PROCLID().

Definition at line 545 of file messages.c.

547 {
548  Pvecteur
549  v = (Pvecteur) message_neighbour(m);
550  entity
551  array = message_array(m),
552  template = array_to_template(array),
553  processor = template_to_processors(template);
554  list
555  lra = message_dom(m),
557  lrp = template_ranges_to_processors_ranges(template, lrt);
558  int
559  i = 1, t = 0, procndim = NumberOfDimension(processor);
560  Value vt;
561 
562  gen_free_list(lra);
563  gen_free_list(lrt);
564 
565  message_dom(m) = lrp;
566 
567  /* now the neighbour computation in the linearized processor
568  * arrangment named NODETIDS() of common /HPFC_PARAM/.
569  * the code is similar to the runtime support function HPFC_PROCLID().
570  */
571 
572  assert(procndim>=1);
573 
574  vt = vect_coeff((Variable) 1, v);
575  t = VALUE_TO_INT(vt);
576  for (i=2 ; i<=NumberOfDimension(processor) ; i++)
577  {
578  Value vi = vect_coeff((Variable) (intptr_t) i, v);
579  t = t*SizeOfIthDimension(processor, i) + VALUE_TO_INT(vi) ;
580  }
581 
582  message_neighbour_(m) =
584 
585  return(m);
586 }
#define int_to_value(i)
end LINEAR_VALUE_IS_INT
#define newgen_Pvecteur(p)
Definition: compsec.h:26
#define array_to_template(array)
#define template_to_processors(template)
list template_ranges_to_processors_ranges(entity, list)
list array_ranges_to_template_ranges(entity, list)
#define message_neighbour_(x)
Definition: message.h:78
int SizeOfIthDimension(entity, int)
this function returns the size of the ith dimension of a variable e.
Definition: size.c:453
int NumberOfDimension(entity)
Definition: size.c:588

References array, array_ranges_to_template_ranges(), array_to_template, assert, gen_free_list(), int_to_value, intptr_t, message_array, message_dom, message_neighbour, message_neighbour_, newgen_Pvecteur, NumberOfDimension(), SizeOfIthDimension(), TCST, template_ranges_to_processors_ranges(), template_to_processors, VALUE_TO_INT, vect_add(), vect_coeff(), and vect_new().

Referenced by messages_guards_and_neighbour().

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

◆ one_receive_message()

static message one_receive_message ( message  send)
static

Definition at line 601 of file messages.c.

603 {
604  entity
605  array = message_array(send);
606  Pvecteur
607  sendneighbour = (Pvecteur) message_neighbour(send),
608  neighbour = vect_new(TCST,
609  value_uminus(vect_coeff(TCST, sendneighbour)));
610  list
612  sendneighbour),
613  domain = compute_receive_domain(message_dom(send), sendneighbour);
614 
615  return(make_message(array, content, neighbour, domain));
616 }
#define value_uminus(val)
unary operators on values
list compute_receive_domain(list, Pvecteur)
list compute_receive_content(entity, list, Pvecteur)

References array, compute_receive_content(), compute_receive_domain(), make_message(), message_array, message_content, message_dom, message_neighbour, TCST, value_uminus, vect_coeff(), and vect_new().

Referenced by receive_messages_generation().

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

◆ receive_messages_generation()

static list receive_messages_generation ( list  lms)
static

list receive_messages_generation(lms)

this function must warranty that all messages send will be received, so the messages are symetric.

Definition at line 623 of file messages.c.

625 {
626  list lmr = NIL;
627 
628  MAP(MESSAGE, send,
629  {
630  lmr = gen_nconc(lmr, CONS(MESSAGE,
631  one_receive_message(send),
632  NIL));
633  },
634  lms);
635 
636  return(lmr);
637 }
static message one_receive_message(message send)
Definition: messages.c:601

References CONS, gen_nconc(), MAP, MESSAGE, NIL, and one_receive_message().

Referenced by messages_handling().

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

◆ remove_stammering_messages()

static list remove_stammering_messages ( list  lm)
static

list remove_stammering_messages(lm)

remove messages that are contained in another message

Definition at line 704 of file messages.c.

706 {
707  list kept = NIL;
708 
709  MAPL(cm,
710  {
711  message m = MESSAGE(CAR(cm));
712 
713  if (!larger_message_in_list(m, kept) &&
714  !larger_message_in_list(m, CDR(cm)))
715  kept = CONS(MESSAGE, m, kept);
716  },
717  lm);
718 
719  return kept;
720 }
#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
bool larger_message_in_list(message, list)

References CAR, CDR, CONS, larger_message_in_list(), MAPL, MESSAGE, and NIL.

Referenced by messages_handling().

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

◆ safe_static_domain_bound()

static expression safe_static_domain_bound ( entity  array,
int  dim,
expression  e,
int  shift,
bool  lower 
)
static

Messages handling.

Fabien Coelho, August 1993 ????

Definition at line 37 of file messages.c.

43 {
44  expression result;
45  int l=0, u=0, tmp=-1;
46 
48  result = int_to_expression(tmp+shift);
49  else
50  {
51  get_entity_dimensions(array, dim, &l, &u);
52  result = int_to_expression(lower ? l : u);
53  }
54 
55  return(result);
56 }
bool hpfc_integer_constant_expression_p(expression e, int *pi)
void get_entity_dimensions(entity e, int dim, int *plow, int *pup)
Definition: hpfc-util.c:651

References array, get_entity_dimensions(), hpfc_integer_constant_expression_p(), and int_to_expression().

Referenced by generate_one_message().

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

◆ shape_one_message()

static message shape_one_message ( message  m)
static

message shape_one_message(m)

caution, rate==1 is assumed.

??? is that all ?

message content isn't empty

Definition at line 476 of file messages.c.

478 {
479  entity
480  array = message_array(m);
481  list
482  lr = message_content(m),
483  ld = message_dom(m),
484  lnewdomain = NIL;
485  int
486  procdim = 0,
487  i = 1;
488 
489  for ( ; lr!=NIL ; i++, lr=CDR(lr), ld=CDR(ld))
490  {
491  range
492  d = RANGE(CAR(ld)),
493  r = RANGE(CAR(lr));
494 
495  if (ith_dim_distributed_p(array, i, &procdim)) /* ??? is that all ? */
496  {
497  int
498  newdlo = 0,
499  newdup = 0,
504  n = DistributionParameterOfArrayDim(array, i, &procdim),
505  localdlo = global_array_cell_to_local_array_cell(array, i, dlo),
506  localdup = global_array_cell_to_local_array_cell(array, i, dup);
507 
508  assert(rlo<=rup); /* message content isn't empty */
509 
510  /*
511  * I thought a long time about it, just for these two formulas:
512  */
513  newdlo = dlo+(rlo-localdlo)+((localdlo>rup)?(n):(0));
514  newdup = dup+(rup-localdup)-((localdup<rlo)?(n):(0));
515 
516  lnewdomain = gen_nconc(lnewdomain,
517  CONS(RANGE,
519  int_to_expression(newdup),
520  int_to_expression(1)),
521  NIL));
522  }
523  else
524  {
525  lnewdomain = gen_nconc(lnewdomain, CONS(RANGE, d, NIL));
526  }
527  }
528 
530  message_dom(m) = lnewdomain;
531 
532  return(m);
533 }
int global_array_cell_to_local_array_cell(entity array, int dim, int acell)
int global_array_cell_to_local_array_cell(array, dim, acell)
Definition: hpfc-util.c:550

References array, assert, CAR, CDR, CONS, DistributionParameterOfArrayDim(), gen_free_list(), gen_nconc(), global_array_cell_to_local_array_cell(), HpfcExpressionToInt(), int_to_expression(), ith_dim_distributed_p(), make_range(), message_array, message_content, message_dom, NIL, RANGE, range_lower, and range_upper.

Referenced by messages_shaping().

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

◆ st_one_message()

static statement st_one_message ( message  m,
bool  bsend 
)
static

statement st_one_message(m, bsend)

this function will have to be modified in order to include message coalescing and aggregation. Here, a direct call to a function that packs and passes the message is made.

comment generation to improve readibility of the code

Definition at line 645 of file messages.c.

648 {
649  char buffer[100], *buf = buffer;
651  processor = array_to_processors(array);
652  list content = message_content(m),
653  domain = message_dom(m);
655  int neighbour = VALUE_TO_INT(vn);
656  statement
657  cmpneighbour = st_compute_neighbour(neighbour),
658  pass = (bsend ? st_send_to_neighbour() : st_receive_from_neighbour()),
659  pack = st_generate_packing(array, content, bsend);
660  list interm = CONS(STATEMENT,
661  cmpneighbour,
662  (bsend ?
663  CONS(STATEMENT, pack, CONS(STATEMENT, pass, NIL)) :
664  CONS(STATEMENT, pass, CONS(STATEMENT, pack, NIL))));
665  statement
667  processor,
668  domain);
669 
670  /* comment generation to improve readibility of the code
671  */
672  sprintf(buf, "! %s(", entity_local_name(processor));
673  buf += strlen(buf);
675  buf += strlen(buf);
676  sprintf(buf, ") %s %s(", bsend ? "send" : "receive",
678  buf += strlen(buf);
679  sprint_lrange(buf, content);
680  buf += strlen(buf);
681  sprintf(buf, ") %s (%s%d)\n", bsend ? "to" : "from",
682  neighbour>0 ? "+" : "-", abs(neighbour));
683  buf += strlen(buf);
684 
686  return result;
687 }
void insert_comments_to_statement(statement, const char *)
Insert a comment string (if non empty) at the beginning of the comments of a statement.
Definition: statement.c:1916
#define array_to_processors(array)
#define st_receive_from_neighbour()
RCV.
#define st_send_to_neighbour()
statement generate_guarded_statement(statement, entity, list)
statement st_compute_neighbour(int)
call to the runtime support function HPFC_CMPNEIGHBOUR(d)
Definition: run-time.c:394
char * sprint_lrange(string, list)
statement st_generate_packing(entity, list, bool)
statement st_generate_packing_and_passing(array, content, bsend)
Definition: run-time.c:422
static char buf[BSZ]
Definition: split_file.c:157
static string buffer
Definition: string.c:113
#define abs(v)
Definition: syntax-local.h:48

References abs, array, array_to_processors, buf, buffer, CONS, entity_local_name(), generate_guarded_statement(), insert_comments_to_statement(), make_block_statement(), message_array, message_content, message_dom, message_neighbour, NIL, sprint_lrange(), st_compute_neighbour(), st_generate_packing(), st_receive_from_neighbour, st_send_to_neighbour, STATEMENT, TCST, VALUE_TO_INT, and vect_coeff().

Referenced by generate_the_messages().

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