PIPS
communications.c
Go to the documentation of this file.
1 /*
2 
3  $Id: communications.c 23372 2017-05-05 15:35:30Z lossing $
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 /* Computation of communications needed
28  * for generating distributed code in PUMA
29  *
30  * Corinne Ancourt
31  */
32 #include <stdio.h>
33 #include <stdlib.h>
34 #include <string.h>
35 
36 #include "genC.h"
37 
38 #include "linear.h"
39 #include "ri.h"
40 #include "effects.h"
41 
42 #include "matrice.h"
43 #include "tiling.h"
44 #include "database.h"
45 #include "text.h"
46 
47 #include "dg.h"
50 #include "graph.h"
51 
52 #include "misc.h"
53 #include "text-util.h"
54 #include "ri-util.h"
55 #include "prettyprint.h"
56 #include "effects-util.h"
57 #include "resources.h"
58 #include "movements.h"
59 #include "constants.h"
60 #include "wp65.h"
61 
62 /* This function associates to each variable in the call statement the statement
63  * where it should be communicated (this statement is often external to the call)
64 */
65 
66 void
68  statement s,
69  statement st_level1,
70  statement st_level2,
71  list *lwr,
72  list *lwr_local,
73  statement_mapping *fetch_map,
74  statement_mapping *store_map,
75  hash_table r_to_ud,
76  list *lpv)
77 {
78  pips_assert("true", r_to_ud==r_to_ud);
79 
80  if(assignment_statement_p(s)) {
81  reference r;
82  entity rv;
83  list lexpr =
85  /* first reference in statement s */
86  bool first_reference = true;
87 
88  for(; !ENDP(lexpr); POP(lexpr)) {
89  expression e = EXPRESSION(CAR(lexpr));
91  if (lr != NIL) {
92  list consr = lr;
93  ifdebug(2) {
94  (void) fprintf(stderr, "reference list:");
96  (void) fprintf(stderr, "first_reference=%s\n",
97  bool_to_string(first_reference));
98  }
99  for(consr = lr; !ENDP(consr) ; POP(consr)) {
100  r = REFERENCE(CAR(consr));
101  rv = reference_variable(r);
102  if (first_reference) {
103  ifdebug(2) {
104  (void) fprintf(stderr,"list lwr_local:");
105  reference_list_print(*lwr_local);}
106  reference_list_update(lwr_local,r);
107  update_map(*store_map,st_level2,r);
108  first_reference = false;
109  }
110  else {
111  if(!entity_is_argument_p(rv, *lpv)) {
112  debug(8,"loop_nest_to_local_variables",
113  "Variable %s is not private\n",
114  entity_local_name(rv));
115  ifdebug(2) {
116  (void) fprintf(stderr,"list lwr_local:");
117  reference_list_print(*lwr_local);
118  (void) fprintf(stderr,"list lwr : ");
119  reference_list_print(*lwr);}
120 
121  if (reference_scalar_p(r)) {
122  if (!reference_in_list_p(r,*lwr_local))
123  update_map(*fetch_map,st_level1,r);
124  }
125  else {
126  if (array_indice_in_list_p(r,*lwr_local))
127  update_map(*fetch_map,s,r);
128  else if (array_indice_in_list_p(r,*lwr))
129  update_map(*fetch_map,st_level2,r);
130  else update_map(*fetch_map,st_level1,r);
131  }
132  }
133  }
134  }
135  }
136  }
137  }
138  else {
139  ifdebug(9)
140  (void) fprintf(stderr,
141  "call-communications - not assignment\n");
142  }
143 }
144 
145 /* This function associates to each variable in the loop the statement
146  * where it should be communicated (this statement may be external to the loop).
147 */
148 
149 
151  statement st_level2, list *lwr, list *lwr_local,
152  statement_mapping *fetch_map,statement_mapping *store_map,
153  hash_table r_to_ud,list *lpv)
154 {
158  reference_list_add(lwr, lwr_local);
161  NIL));
162  *lwr_local = NIL;
163  *lpv=loop_locals(instruction_loop(inst));
164 
165  switch(instruction_tag(inst2)) {
166  case is_instruction_block:
167  st_level2 = STATEMENT(CAR(instruction_block(inst)));
168  break;
169  case is_instruction_call:
170  st_level2 =b;
171  break;
172  default:
173  (void) fprintf(stderr,
174  "loop_instruction_to_communications: non implemented case \n");
175  break;
176  }
177  statement_to_communications(b,st_level1, st_level2,
178  lwr,lwr_local,
179  fetch_map,store_map,r_to_ud,lpv);
180 
181 }
182 
183 /* This function associates to each variable in stmt the
184  * statement where it should be communicated.
185  * The lwr list corresponds to the list of variables that have
186  * been updated before the current statement bloc.
187  * The lwr_local list corresponds to the list of variables
188  * that are updated in the current statement bloc.
189 */
190 
192  list * lwr,list * lwr_local,
193  statement_mapping *fetch_map,
194  statement_mapping * store_map,
195  hash_table r_to_ud, list *lpv)
196 {
198 
199  debug(8, "statement_to_communications", "begin with tag %d\n",
200  instruction_tag(inst));
201 
202  switch(instruction_tag(inst)) {
203  case is_instruction_block: {
204  ifdebug(7)
205  (void) fprintf(stderr,
206  "statement_to_communications-instruction block- begin\n");
207  st_level2 = STATEMENT(CAR(instruction_block(inst)));
208  MAPL( sts, {
209  statement s = STATEMENT(CAR(sts));
210  statement_to_communications(s,st_level1, st_level2,
211  lwr,lwr_local,
212  fetch_map,store_map,
213  r_to_ud,lpv);
214  }, instruction_block(inst));
215  ifdebug(7)
216  (void) fprintf(stderr,
217  "statement_to_communications-instruction block- end\n");
218  break;
219  }
220  case is_instruction_test:
221  (void) fprintf(stderr,"not implemented\n");
222  break;
223  case is_instruction_loop: {
224  ifdebug(7)
225  (void) fprintf(stderr,
226  "statement_to_communications-instruction loop- begin\n");
228  lwr, lwr_local,
229  fetch_map,store_map,
230  r_to_ud,lpv);
231  reference_list_add(lwr, lwr_local);
232  ifdebug(7)
233  (void) fprintf(stderr,
234  "statement_to_communications-instruction loop- end\n");
235  break;
236  }
237  case is_instruction_call: {
238  ifdebug(7)
239  (void) fprintf(stderr,"statement_to_communications-instruction call- begin\n");
240  call_instruction_to_communications(stmt, st_level1, st_level2,
241  lwr, lwr_local,
242  fetch_map,store_map,r_to_ud,lpv);
243  ifdebug(7)
244  (void) fprintf(stderr,"statement_to_communications-instruction call- end\n");
245  break;
246  }
247  case is_instruction_goto: {
248  pips_internal_error("Unexpected goto");
249  break;}
251  pips_internal_error("Sorry: unstructured not implemented");
252  break;}
253  default:
254  pips_internal_error("Bad instruction tag");
255  }
256 }
257 
258 ␌
259 /* This function associates to each variable the statement in l where it should be communicated
260  * Fecth_map contains for each statement the list of variables having to be communicated
261  * before its execution.
262  * Store_map contains for each statement the list of variables having to be communicated
263  * after its execution.
264 */
265 
266 void
268 {
269  list lwr=NIL; /* list of written variables */
270  list lwr_local= NIL; /* list of variables written in a local
271  instruction block */
272  list lpv = NIL; /* list of privates variables */
274  statement first_stmt = STATEMENT(CAR(l));
275  MAPL(pm,{
276  statement s1 = STATEMENT(CAR(pm));
277  statement_to_communications(s1,first_stmt,s1,&lwr, &lwr_local,
278  fetch_map,store_map, r_to_ud1,&lpv);
279  },l);
280 
281 }
282 
283 static list
285  entity compute_or_memory_module,list lrefs,
286  bool load_code,entity var_id)
287 {
288  /* bool load_code is true if the generated computational code
289  must be a RECEIVE, false if it must be a SEND*/
290 
291  list lrs;
292  list ccode = NIL; /* movements for the scalar variables
293  for the compute module or the memory module */
294  for (lrs =lrefs ; !ENDP(lrs) ; POP(lrs)) {
295  reference r = REFERENCE(CAR(lrs));
296  statement sblock=
297  make_movement_scalar_wp65(compute_or_memory_module,load_code,
298  r,var_id);
299  ccode = gen_nconc(ccode,CONS(STATEMENT, sblock, NIL));
300  }
301  return ccode;
302 }
303 
304 void
306  entity compute_or_memory_module,list lrefs,
307  bool load_code,statement computational_or_emulator,
308  entity var_id)
309 {
310  instruction i;
311  list ccode = constant_symbolic_communication(compute_or_memory_module,lrefs,
312  load_code,var_id);
313  /* Add data movements to the appropriated module */
314  i = statement_instruction(computational_or_emulator);
316 }
317 
318 static list
320  entity compute_or_memory_module,
321  Pbase bank_indices,
322  int bn,
323  int ls,
324  list lrefs,
325  bool load_code,
326  entity var_id,
327  Pbase loop_indices,
328  tiling tile,
329  Pvecteur tile_delay,
330  Pvecteur tile_indices,
331  Pvecteur tile_local_indices)
332 {
333  pips_assert("true",compute_or_memory_module==compute_or_memory_module
334  && load_code==load_code);
335  list gcode =NIL;
336  list icode = NIL;
337  list ind=NIL;
338  list lrs = NIL;
339  statement stat;
340  Pbase bas_var[3];
341  Pvecteur pv1,pv2,pv,pvi;
342  int i,j;
343  Value coef;
344 
345  /* movements for the scalar variables
346  for the compute module or the memory module */
347  bas_var[1] = VECTEUR_NUL;
348  bas_var[2] = VECTEUR_NUL;
349  for (lrs = lrefs; !ENDP(lrs); POP(lrs)) {
350  reference r = REFERENCE(CAR(lrs));
351  Variable vbank,vligne,vofs;
352  expression exp1,exp2,exp3,exp4;
353  list lex2;
354  type t;
355  Value ms=VALUE_ZERO;
356  for(ind= reference_indices(r),i=1 ; !ENDP(ind);POP(ind),i++) {
357  expression e = EXPRESSION(CAR(ind));
360  bas_var[i]=vect_dup((Pvecteur) normalized_linear(norm));
362  bas_var[i]=vect_dup((Pvecteur) normalized_linear(norm));
363  fprintf(stderr,
364  "[array_indices_communication ERROR]--> NON LINEAR funct.\n");
365  }
366  }
367 
369  if (type_variable_p(t)) {
370  variable var = type_variable(t);
371  cons * dims = variable_dimensions(var);
372  dimension dim1 = DIMENSION(CAR(dims));
373  expression lower= dimension_lower(dim1);
374  normalized norm1 = NORMALIZE_EXPRESSION(lower);
375  expression upper= dimension_upper(dim1);
376  normalized norm2 = NORMALIZE_EXPRESSION(upper);
377  Value min_ms = VALUE_ZERO;
378  Value max_ms = VALUE_ZERO;
379  if (normalized_linear_p(norm1) && normalized_linear_p(norm2)) {
380  min_ms=vect_coeff(TCST,(Pvecteur) normalized_linear(norm1));
381  max_ms=vect_coeff(TCST,(Pvecteur) normalized_linear(norm2));
382  }
383  ms = value_minus(max_ms,min_ms);
384  value_increment(ms);
385  }
386 
387  vbank = (Variable) var_id;
388  vligne = vecteur_var(bank_indices->succ);
389  vofs = vecteur_var(bank_indices->succ->succ);
390  if (VECTEUR_NUL_P(bas_var[2]))
391  bas_var[2] = vect_new(TCST,VALUE_ONE);
392  for (i=1;i<=2;i++) {
393  for (pvi = loop_indices,j=1; !VECTEUR_NUL_P(pvi);
394  pvi = pvi->succ,j++) {
395  if (value_notzero_p(coef = vect_coeff(pvi->var,
396  bas_var[i])))
397  {
399  (loop_indices,tile, tile_delay,
400  tile_indices,tile_local_indices,j);
401  vect_add_elem(&bas_var[i],pvi->var,value_uminus(coef));
402 
403  bas_var[i] =vect_add(bas_var[i],vect_multiply(pv,coef));
404  }
405  }
406  }
407 
408  /* building equality L = [(var1 -1) +(var2-1)*ms]/bn*ls] */
409  pv1 = vect_dup(bas_var[2]);
410  pv1 = vect_multiply(pv1,ms);
411  pv2 = vect_dup(bas_var[1]);
412  pv2 = vect_add(pv2,pv1);
414  exp1= make_vecteur_expression(pv2);
415  exp2 = int_to_expression(bn*ls);
416  lex2 =CONS(EXPRESSION,exp2,NIL);
417  exp3 = make_div_expression(exp1,lex2);
419  stat = make_assign_statement(exp4,exp3);
420 
421  icode = CONS(STATEMENT,stat,NIL);
422  gcode = gen_nconc(gcode,icode);
423  /* building equality B = [(var1 -1) +(var2-1)*ms -bn*ls*L ]/ls+1 */
424  pv1 = vect_dup(bas_var[2]);
425  pv1 = vect_multiply(pv1,ms);
426  pv2 = vect_dup(bas_var[1]);
427  pv2 = vect_add(pv2,pv1);
428  vect_add_elem(&pv2,vligne,int_to_value((-bn*ls)));
430  exp1= make_vecteur_expression(pv2);
431  exp2 = int_to_expression(ls);
432  lex2 =CONS(EXPRESSION,exp2,NIL);
433  exp3 = make_div_expression(exp1,lex2);
435  stat = make_assign_statement(exp4,exp3);
436  icode = CONS(STATEMENT,stat,NIL);
437  gcode = gen_nconc(gcode,icode);
438  /* building equality O = [(var1 -1) +(var2-1)*ms -bn*ls*L -ls*B */
439  pv1 = vect_dup(bas_var[2]);
440  pv1 = vect_multiply(pv1,ms);
441  pv2 = vect_dup(bas_var[1]);
442  pv2 = vect_add(pv2,pv1);
443  vect_add_elem(&pv2,vligne,int_to_value((-bn*ls)));
444  vect_add_elem(&pv2,vbank,int_to_value((-ls)));
446  exp1= make_vecteur_expression(pv2);
448  stat = make_assign_statement(exp4,exp1);
449  icode = CONS(STATEMENT,stat,NIL);
450  gcode = gen_nconc(gcode,icode);
451  }
452  return (gcode);
453 }
454 
455 
456 static list
458  entity compute_module,Pbase bank_indices,
459  int bn,int ls,list lt,
460  bool load_code,entity proc_id,
461  entity var_id,bool fully_sequential,
462  Pbase loop_indices,tiling tile,Pvecteur tile_delay,
463  Pvecteur tile_indices,Pvecteur tile_local_indices)
464 {
465 
466  list icode,lst;
467  icode = array_indices_communication(compute_module,bank_indices,
468  bn,ls,lt,
469  load_code,var_id,loop_indices,tile,
470  tile_delay,
471  tile_indices,tile_local_indices);
472  lst = CONS(REFERENCE,make_reference(var_id,NIL),
473  CONS(REFERENCE,
474  make_reference((entity) bank_indices->succ->var,
475  NIL),
476  CONS(REFERENCE,
477  make_reference((entity) bank_indices->succ->succ->var,NIL),
478  NIL)));
479 
480  if (!fully_sequential) {
481  /* Generation of the compute code corresponding to the transfer
482  of a scalar array element :
483  L = (-101+100*L_J+P)/400
484  X3 = (-101+100*L_J+P-400*L)/100
485  O = -101+100*L_J+P-400*L-100*X3
486  DOALL BANK_ID = 0, 3
487  CALL WP65_SEND_4(BANK_ID, X3, 1)
488  CALL WP65_SEND_4(BANK_ID, L, 1)
489  CALL WP65_SEND_4(BANK_ID, O, 1)
490  ENDDO
491  CALL WP65_RECEIVE_4(X3, L_B_0_0(P,L_J), 1)
492  */
493  entity ent1 = make_new_module_variable(compute_module,100);
494 
495  list ccode= constant_symbolic_communication(compute_module,lst,
496  !load_code,ent1);
497  range looprange = make_range(int_to_expression(0),
498  int_to_expression(bn-1),
499  int_to_expression(1));
500  statement loopbody = make_block_statement(ccode);
501  entity looplabel = make_loop_label(9000, compute_module);
502 
503  loop newloop = make_loop(ent1,
504  looprange,
505  loopbody,
506  looplabel,
508  NIL);
509 
510  statement stat = loop_to_statement(newloop);
511  AddEntityToDeclarations(ent1,compute_module);
512  icode = gen_nconc(icode,CONS(STATEMENT,stat,NIL));
513  ccode = constant_symbolic_communication(compute_module,lt,load_code,var_id);
514  icode = gen_nconc(icode,ccode);
515  return icode;
516  }
517  else {
518 
519  list ccode = constant_symbolic_communication(compute_module,lst,!load_code,proc_id);
520  ccode = gen_nconc(icode,ccode);
521  icode = constant_symbolic_communication(compute_module,lt,load_code,proc_id);
522  ccode = gen_nconc(ccode,icode);
523  return ccode;
524  }
525 }
526 ␌
528  int bn,int ls, list lt,bool load_code,
529  entity proc_id,entity var_id,bool fully_sequential)
530 {
531  pips_assert("true", ls==ls);
532 
533  reference ref1 = make_reference((entity) bank_indices->succ->var,NIL);
534  reference ref2 = make_reference((entity) bank_indices->succ->succ->var,NIL);
535  list lst = CONS(REFERENCE,make_reference(var_id,NIL),
536  CONS(REFERENCE,ref1, CONS(REFERENCE,ref2,NIL)));
537  if (!fully_sequential) {
538  /*
539  Generation of the emulated shared memory code corresponding to
540  the transfer of a scalar array element :
541 
542  CALL BANK_RECEIVE_4(PROC_ID, X1, 1)
543  CALL BANK_RECEIVE_4(PROC_ID, L, 1)
544  CALL BANK_RECEIVE_4(PROC_ID, O, 1)
545  IF (BANK_ID = X1) THEN
546  CALL BANK_SEND_4(PROC_ID, ES_B(O,L), 1)
547  ENDIF
548  */
549  list ccode= constant_symbolic_communication(memory_module,
550  lst,!load_code,proc_id);
551  list tcode = constant_symbolic_communication(memory_module,
552  lt,load_code,proc_id);
553  expression exp1 =make_vecteur_expression(vect_new(bank_indices->var,
554  VALUE_ONE));
556  VALUE_ONE));
558  statement testbody = make_block_statement(tcode);
559  statement stat = make_test_statement(test_bound,testbody,
561  return (gen_nconc(ccode,CONS(STATEMENT,stat,NIL)));
562  }
563  else {
564  entity ent1 = make_new_module_variable(memory_module,100);
565  list ccode= constant_symbolic_communication(memory_module,lst,
566  !load_code,(entity) bank_indices->var);
567  list icode= constant_symbolic_communication(memory_module,lt,
568  load_code,ent1);
569  range looprange = make_range(int_to_expression(0),
570  int_to_expression(bn-1),
571  int_to_expression(1));
572  statement loopbody = make_block_statement(icode);
573  entity looplabel = make_loop_label(9000, memory_module);
574 
575  loop newloop = make_loop(ent1,looprange, loopbody, looplabel,
577 
578  statement stat = loop_to_statement(newloop);
579  AddEntityToDeclarations(ent1,memory_module);
580  icode = gen_nconc(ccode,CONS(STATEMENT,stat,NIL));
581  return icode;
582  }
583 }
584 
585 static list
586 build_esv_list(list lt, hash_table v_to_esv, Pbase bank_indices)
587 {
588  list newlt=NIL;
589  MAPL(ref, {
591  entity esv = (entity) hash_get(v_to_esv, (char *) var1);
593  (vect_new((char *) bank_indices->succ->var, VALUE_ONE));
595  (vect_new((char *) bank_indices->succ->succ->var, VALUE_ONE));
596  list args = CONS(EXPRESSION,expr2, CONS(EXPRESSION,expr1,NIL));
597  reference ref1 = make_reference((Variable) esv,args);
598  newlt=CONS(REFERENCE,ref1,newlt);
599  },lt);
600  return gen_nreverse(newlt);
601 
602 }
603 
604 static void insert_array_scalar_access_movement(entity compute_module,entity memory_module,
605  Pbase bank_indices, int bn,int ls,entity proc_id,entity ent1,
606  list lt, statement stat,bool load,hash_table v_to_esv,
607  list *new_slst,list *new_blist, bool fully_sequential,
608  Pbase loop_indices,tiling tile,Pvecteur tile_delay,
609  Pvecteur tile_indices, Pvecteur tile_local_indices)
610 {
611  list ccode ;
612  ifdebug(8) {
613  fprintf(stderr,
614  " communication to be inserted at run time stat no %"PRIdPTR": ",
615  statement_number(stat));
617 
618  }
619 
620  /* creation d'une nouvelle entite pour servir de temporaire au
621  numero de banc memoire contenant la variable scalaire */
622  ccode =array_scalar_access_to_compute_communication(compute_module,
623  bank_indices,bn,
624  ls,lt,load,proc_id,
625  ent1,fully_sequential,
626  loop_indices,tile, tile_delay,tile_indices,
627  tile_local_indices);
628 
629  *new_slst = gen_nconc(*new_slst,ccode);
630  lt = build_esv_list(lt,v_to_esv,bank_indices);
631  ccode =array_scalar_access_to_bank_communication(memory_module, bank_indices,bn,
632  ls,lt,!load, proc_id,
633  ent1,fully_sequential);
634 
635  *new_blist = gen_nconc(*new_blist,ccode);
636 }
637 ␌
638 
639 void insert_run_time_communications(entity compute_module,entity memory_module,
640  Pbase bank_indices, int bn,int ls,entity proc_id,
641  list list_statement_block,
642  statement_mapping fetch_map,statement_mapping store_map,
643  list *new_slst,list *new_blist,hash_table v_to_esv,
644  bool fully_sequential,
645  Pbase loop_indices,tiling tile,Pvecteur tile_delay,
646  Pvecteur tile_indices, Pvecteur tile_local_indices)
647 {
648  int nbcall=0;
649  entity ent1=entity_undefined;
650 
651  MAPL(st1,
653  switch(instruction_tag(inst)) {
654  case is_instruction_block: {
655 
656  list new_slst1 = NIL;
657  nbcall = 0;
658  MAPL(st2, {
659  insert_run_time_communications(compute_module,memory_module,
660  bank_indices,bn,ls,proc_id,
661  CONS(STATEMENT,
662  STATEMENT(CAR(st2)),NIL),
663  fetch_map,store_map,
664  &new_slst1,new_blist,
665  v_to_esv,fully_sequential,
666  loop_indices,tile, tile_delay,
667  tile_indices,tile_local_indices);
668 
669 
670 },
671  instruction_block(inst));
672  instruction_block(inst)= new_slst1;
673  break; }
674  case is_instruction_loop: {
675  statement lbody = loop_body(instruction_loop(inst));
677  lbody,NIL));
678  cons *nbody=(instruction_call_p(statement_instruction(lbody))) ?
679  CONS(STATEMENT,sbody,NIL) :
680  CONS(STATEMENT,lbody,NIL);
681  insert_run_time_communications(compute_module,memory_module,
682  bank_indices,bn,ls,proc_id,
683  nbody,fetch_map,store_map,new_slst,
684  new_blist,
685  v_to_esv,fully_sequential,
686  loop_indices,tile, tile_delay,
687  tile_indices,tile_local_indices);
688  *new_slst = gen_nconc(*new_slst,
689  CONS(STATEMENT,STATEMENT(CAR(st1)),NIL));
690  break;
691  }
692  case is_instruction_call: {
693  list lt;
694 
695  if ((lt= (list)
696  GET_STATEMENT_MAPPING(fetch_map,STATEMENT(CAR(st1))))
697  != (list) HASH_UNDEFINED_VALUE && nbcall ) {
698 
699  ent1 = make_new_module_variable(compute_module,100);
700  AddEntityToDeclarations(ent1,compute_module);
701 
702  insert_array_scalar_access_movement(compute_module,memory_module,bank_indices,
703  bn,ls,proc_id,ent1,lt,STATEMENT(CAR(st1)),true,
704  v_to_esv,new_slst,new_blist,fully_sequential,
705  loop_indices,tile, tile_delay,tile_indices,
706  tile_local_indices
707  );
708  }
709  if ((lt=(list) GET_STATEMENT_MAPPING(store_map,
710  STATEMENT(CAR(st1))))
711  != (list) HASH_UNDEFINED_VALUE && nbcall )
712  {
713  ent1 = make_new_module_variable(compute_module,100);
714  AddEntityToDeclarations(ent1,compute_module);
715 
716  insert_array_scalar_access_movement(compute_module,memory_module,bank_indices,
717  bn,ls,proc_id,ent1,lt,STATEMENT(CAR(st1)),false,
718  v_to_esv,new_slst,new_blist,fully_sequential,
719  loop_indices,tile, tile_delay,tile_indices,
720  tile_local_indices);
721  }
722  *new_slst = gen_nconc(*new_slst,CONS(STATEMENT,STATEMENT(CAR(st1)),NIL));
723  nbcall ++;
724  break;
725  }
726  default:
727  break;
728  }
729  }, list_statement_block);
730 }
731 ␌
732 bool
733 test_run_time_communications(list list_statement_block,
734  statement_mapping fetch_map,statement_mapping store_map)
735 {
736  bool ok ;
737  int nbcall =0;
738  MAPL(st1,
740  switch(instruction_tag(inst)) {
741  case is_instruction_block: {
742  ok = false;
743  MAPL(st2, {
744  ok = (ok) ? ok :
746  STATEMENT(CAR(st2)),
747  NIL),
748  fetch_map,store_map);
749  },
750  instruction_block(inst));
751  return ok;
752  break; }
753  case is_instruction_loop: {
756  NIL),
757  fetch_map,store_map));
758  break;}
759  case is_instruction_call: {
760  list lt = (list) GET_STATEMENT_MAPPING(fetch_map,STATEMENT(CAR(st1)));
761  if (lt != (list) HASH_UNDEFINED_VALUE) {
762  nbcall ++;
763  return (true);
764  } else
765  return(false);
766  break;
767  }
768  default:
769  break;
770  }
771  },
772  list_statement_block);
773  /* just to avoid warning */
774  return (true);
775 }
776 ␌
execution make_execution(enum execution_utype tag, void *val)
Definition: ri.c:838
loop make_loop(entity a1, range a2, statement a3, entity a4, execution a5, list a6)
Definition: ri.c:1301
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
range make_range(expression a1, expression a2, expression a3)
Definition: ri.c:2041
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
bool entity_is_argument_p(entity e, cons *args)
Definition: arguments.c:150
#define VALUE_ZERO
#define value_increment(ref)
#define int_to_value(i)
end LINEAR_VALUE_IS_INT
#define value_minus(v1, v2)
#define value_notzero_p(val)
#define value_uminus(val)
unary operators on values
#define VALUE_MONE
int Value
#define value_plus(v1, v2)
binary operators on values
#define VALUE_ONE
Pvecteur make_loop_indice_equation(Pbase loop_indices, tiling tile, Pvecteur tile_delay, Pvecteur tile_indices, Pvecteur tile_local_indices, int rank)
PACKAGE MOVEMENTS.
Definition: build_sc_tile.c:51
void insert_run_time_communications(entity compute_module, entity memory_module, Pbase bank_indices, int bn, int ls, entity proc_id, list list_statement_block, statement_mapping fetch_map, statement_mapping store_map, list *new_slst, list *new_blist, hash_table v_to_esv, bool fully_sequential, Pbase loop_indices, tiling tile, Pvecteur tile_delay, Pvecteur tile_indices, Pvecteur tile_local_indices)
bool test_run_time_communications(list list_statement_block, statement_mapping fetch_map, statement_mapping store_map)
void include_constant_symbolic_communication(entity compute_or_memory_module, list lrefs, bool load_code, statement computational_or_emulator, entity var_id)
static list array_indices_communication(entity compute_or_memory_module, Pbase bank_indices, int bn, int ls, list lrefs, bool load_code, entity var_id, Pbase loop_indices, tiling tile, Pvecteur tile_delay, Pvecteur tile_indices, Pvecteur tile_local_indices)
void loop_instruction_to_communications(statement stmt, statement st_level1, statement st_level2, list *lwr, list *lwr_local, statement_mapping *fetch_map, statement_mapping *store_map, hash_table r_to_ud, list *lpv)
This function associates to each variable in the loop the statement where it should be communicated (...
void call_instruction_to_communications(statement s, statement st_level1, statement st_level2, list *lwr, list *lwr_local, statement_mapping *fetch_map, statement_mapping *store_map, hash_table r_to_ud, list *lpv)
This function associates to each variable in the call statement the statement where it should be comm...
static void insert_array_scalar_access_movement(entity compute_module, entity memory_module, Pbase bank_indices, int bn, int ls, entity proc_id, entity ent1, list lt, statement stat, bool load, hash_table v_to_esv, list *new_slst, list *new_blist, bool fully_sequential, Pbase loop_indices, tiling tile, Pvecteur tile_delay, Pvecteur tile_indices, Pvecteur tile_local_indices)
static list constant_symbolic_communication(entity compute_or_memory_module, list lrefs, bool load_code, entity var_id)
dg_vertex_label vertex_label
void statement_to_communications(statement stmt, statement st_level1, statement st_level2, list *lwr, list *lwr_local, statement_mapping *fetch_map, statement_mapping *store_map, hash_table r_to_ud, list *lpv)
This function associates to each variable in stmt the statement where it should be communicated.
list array_scalar_access_to_bank_communication(entity memory_module, Pbase bank_indices, int bn, int ls, list lt, bool load_code, entity proc_id, entity var_id, bool fully_sequential)
dg_arc_label arc_label
Computation of communications needed for generating distributed code in PUMA.
void compute_communications(list l, statement_mapping *fetch_map, statement_mapping *store_map)
This function associates to each variable the statement in l where it should be communicated Fecth_ma...
static list build_esv_list(list lt, hash_table v_to_esv, Pbase bank_indices)
static list array_scalar_access_to_compute_communication(entity compute_module, Pbase bank_indices, int bn, int ls, list lt, bool load_code, entity proc_id, entity var_id, bool fully_sequential, Pbase loop_indices, tiling tile, Pvecteur tile_delay, Pvecteur tile_indices, Pvecteur tile_local_indices)
statement make_block_statement(list)
Make a block statement from a list of statement.
Definition: statement.c:616
statement make_empty_block_statement(void)
Build an empty statement (block/sequence)
Definition: statement.c:625
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#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
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
Definition: newgen_list.h:203
statement make_assign_statement(expression, expression)
Definition: statement.c:583
bool assignment_statement_p(statement)
Test if a statement is an assignment.
Definition: statement.c:135
statement make_test_statement(expression, statement, statement)
Definition: statement.c:1248
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
void * hash_get(const hash_table htp, const void *key)
this function retrieves in the hash table pointed to by htp the couple whose key is equal to key.
Definition: hash.c:449
static entity(* load)(entity)
statement make_movement_scalar_wp65(entity module, bool receive_code, reference r, entity var_id)
statement make_movement_scalar_wp65(receive_code,r)
#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
expression make_div_expression(expression, cons *)
operation.c
Definition: operation.c:42
#define GET_STATEMENT_MAPPING(map, stat)
Definition: newgen-local.h:49
string bool_to_string(bool)
Definition: string.c:243
@ hash_pointer
Definition: newgen_hash.h:32
#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
#define UU
Definition: newgen_types.h:98
struct cons * list
Definition: newgen_types.h:106
normalized NormalizeSyntax(syntax s)
Definition: normalize.c:94
void print_reference_list(list lr)
Definition: expression.c:147
static void norm(struct rproblem *RR)
cette procedure normalise la fonction cout, calcule les valeurs des seconds membres resultant d'une n...
Definition: r1.c:271
list expression_to_operand_list(expression e, list lr)
This function gives the list of operands belonging to Expression e.
Definition: references.c:96
void reference_list_print(list l)
This function prints the references belonging to l.
Definition: references.c:186
void reference_list_add(list *l1, list *l2)
This function adds all the references of l2 to l1 if they don't appear in l1.
Definition: references.c:175
void reference_list_update(list *l, reference r)
This function add Reference r to List l, if r doesn't belong to l.
Definition: references.c:161
bool array_indice_in_list_p(reference r, list lwr)
Definition: references.c:140
bool reference_in_list_p(reference r, list lwr)
This function tests whether at least one array indice of Reference r belongs to List lwr or not.
Definition: references.c:130
void update_map(statement_mapping m, statement st, reference r)
Definition: references.c:68
#define loop_to_statement(l)
#define EQUAL_OPERATOR_NAME
#define NORMALIZE_EXPRESSION(e)
#define is_instruction_block
soft block->sequence transition
#define instruction_block(i)
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
entity make_loop_label(int __attribute__((unused)) desired_number, entity module)
Definition: entity.c:370
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
expression make_vecteur_expression(Pvecteur pv)
make expression for vector (Pvecteur)
Definition: expression.c:1650
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
Definition: expression.c:354
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_scalar_p(reference r)
This function returns true if Reference r is scalar.
Definition: expression.c:3530
entity make_new_module_variable(entity, int)
Make a new module integer variable of name X<d>.
Definition: variable.c:830
void AddEntityToDeclarations(entity, entity)
END_EOLE.
Definition: variable.c:108
#define loop_body(x)
Definition: ri.h:1644
#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 instruction_loop(x)
Definition: ri.h:1520
#define dimension_lower(x)
Definition: ri.h:980
#define type_variable(x)
Definition: ri.h:2949
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define entity_undefined
Definition: ri.h:2761
@ is_instruction_goto
Definition: ri.h:1473
@ is_instruction_unstructured
Definition: ri.h:1475
@ is_instruction_test
Definition: ri.h:1470
@ is_instruction_call
Definition: ri.h:1474
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define dimension_upper(x)
Definition: ri.h:982
#define reference_indices(x)
Definition: ri.h:2328
struct _newgen_struct_instruction_ * instruction
Definition: ri.h:207
#define instruction_call_p(x)
Definition: ri.h:1527
#define loop_locals(x)
Definition: ri.h:1650
#define variable_dimensions(x)
Definition: ri.h:3122
#define statement_instruction(x)
Definition: ri.h:2458
#define instruction_call(x)
Definition: ri.h:1529
@ is_execution_parallel
Definition: ri.h:1190
#define call_arguments(x)
Definition: ri.h:711
#define entity_type(x)
Definition: ri.h:2792
#define statement_number(x)
Definition: ri.h:2452
#define normalized_linear(x)
Definition: ri.h:1781
#define expression_syntax(x)
Definition: ri.h:1247
#define type_variable_p(x)
Definition: ri.h:2947
#define loop_index(x)
Definition: ri.h:1640
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
Pvecteur vect_multiply(Pvecteur v, Value x)
Pvecteur vect_multiply(Pvecteur v, Value x): multiplication du vecteur v par le scalaire x,...
Definition: scalaires.c:123
s1
Definition: set.c:247
#define ifdebug(n)
Definition: sg.c:47
static bool ok
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
Variable var
Definition: vecteur-local.h:90
struct Svecteur * succ
Definition: vecteur-local.h:92
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
Definition: statement.c:54
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
#define vecteur_var(v)
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.
#define VECTEUR_NUL_P(v)
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Definition: vecteur-local.h:60
Pvecteur vect_dup(Pvecteur v_in)
Pvecteur vect_dup(Pvecteur v_in): duplication du vecteur v_in; allocation de et copie dans v_out;.
Definition: alloc.c:51
Pvecteur vect_new(Variable var, Value coeff)
Pvecteur vect_new(Variable var,Value coeff): allocation d'un vecteur colineaire au vecteur de base va...
Definition: alloc.c:110
Pvecteur vect_add(Pvecteur v1, Pvecteur v2)
package vecteur - operations binaires
Definition: binaires.c:53
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