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

Go to the source code of this file.

Functions

void generate_c1_beta (statement stat, list *lhp, list *lnp)
 ??? this should work (but that is not the case yet), with every call with no write to distributed arrays. More...
 
void generate_c1_alpha (statement stat, list *lhp, list *lnp)
 generate_c1_alpha More...
 
void generate_update_values_on_nodes (reference ref, reference newref, list *lscompp, list *lsnotcompp)
 generate_update_values_on_nodes More...
 
void generate_read_of_ref_for_computer (syntax s, list *lcompp, list *lnotcompp)
 generate_read_of_ref_for_computer More...
 
void generate_read_of_ref_for_all (syntax s, list *lhp, list *lnp)
 generate_read_of_ref_for_all More...
 
void generate_compute_local_indices (reference ref, list *lsp, list *lindsp)
 generate_compute_local_indices More...
 
void generate_get_value_locally (reference ref, reference goal, list *lstatp)
 generate_get_value_locally More...
 
void generate_send_to_computer (reference ref, list *lstatp)
 generate_send_to_computer More...
 
void generate_receive_from_computer (reference ref, list *lstatp)
 
void generate_parallel_body (statement body, list *lstatp, list lw, list lr)
 
void generate_update_values_on_computer_and_nodes (reference ref, reference val, list *lscompp, list *lsnotcompp)
 generate_update_values_on_computer_and_nodes More...
 
void generate_update_distributed_value_from_host (syntax s, list *lhstatp, list *lnstatp)
 generate_update_distributed_value_from_host More...
 
void generate_update_private_value_from_host (syntax s, list *lhstatp, list *lnstatp)
 generate_update_private_value_from_host More...
 
statement st_get_value_locally_and_send (reference ref, reference goal)
 
statement st_compute_ith_local_index (entity array, int i, expression expr, syntax *sp)
 the returned expression is translated into variables of the node module. More...
 
statement st_send_to_host_and_nodes (reference ref, reference val)
 
statement st_send_to_computer_if_necessary (reference ref)
 
statement st_get_value_for_all (reference ref, reference goal)
 
statement st_get_value_for_computer (reference ref, reference goal)
 
statement st_receive_from (reference ref, reference goal)
 if ref is replicated: goal = Receive_From_Sender() More...
 

Function Documentation

◆ generate_c1_alpha()

void generate_c1_alpha ( statement  stat,
list lhp,
list lnp 
)

generate_c1_alpha

a distributed array variable is defined

read references to distributed arrays.

generation of the code to get the necessary values...

then the updated statement is to be added to node:

Update the values of the defined distributed variable if necessary...

the overall statements are generated.

Parameters
stattat
lhphp
lnpnp

Definition at line 121 of file generate.c.

124 {
125  statement statcomputation, statcomputecomputer, statifcomputer;
126  expression writtenexpr, newreadexpr;
127  call the_call;
128  list
129  lupdatecomp = NIL,
130  lupdatenotcomp = NIL,
131  lreadreftodistarray = NIL,
132  lstatcomp = NIL,
133  lstatnotcomp = NIL,
134  lstat = NIL,
135  linds = NIL;
136  reference ref, newref;
137  entity newarray;
138 
139  (*lhp) = NIL;
140  (*lnp) = NIL;
141 
142  pips_assert("call", statement_call_p(stat));
143 
144  the_call = instruction_call(statement_instruction(stat));
145  pips_assert("assignment", ENTITY_ASSIGN_P(call_function(the_call)));
146 
147  writtenexpr = EXPRESSION(CAR(call_arguments(the_call)));
148  pips_assert("reference",
149  syntax_reference_p(expression_syntax(writtenexpr)) &&
152  (syntax_reference(expression_syntax(writtenexpr))))));
153 
154  /* read references to distributed arrays.
155  */
156  lreadreftodistarray =
158 
159  /* generation of the code to get the necessary values...
160  */
161  MAP(SYNTAX, s,
162  {
163  list lnotcomp;
164  list lcomp;
165 
166  pips_debug(8, "considering reference to %s\n",
168 
169  generate_read_of_ref_for_computer(s, &lcomp, &lnotcomp);
170 
171  lstatcomp = gen_nconc(lstatcomp, lcomp);
172  lstatnotcomp = gen_nconc(lstatnotcomp, lnotcomp);
173  },
174  lreadreftodistarray);
175 
176  gen_free_list(lreadreftodistarray);
177 
178  /* then the updated statement is to be added to node:
179  */
180  ref = syntax_reference(expression_syntax(writtenexpr));
181  newarray = load_new_node(reference_variable(ref));
182  generate_compute_local_indices(ref, &lstat, &linds);
183  newref = make_reference(newarray, linds);
184  newreadexpr = UpdateExpressionForModule
185  (node_module, EXPRESSION(CAR(CDR(call_arguments(the_call)))));
186 
187  statcomputation =
189  newreadexpr);
190 
191  lstatcomp = gen_nconc(lstatcomp, lstat);
192  lstatcomp = gen_nconc(lstatcomp, CONS(STATEMENT, statcomputation, NIL));
193 
194  /* Update the values of the defined distributed variable
195  * if necessary...
196  */
197  generate_update_values_on_nodes(ref, newref, &lupdatecomp, &lupdatenotcomp);
198 
199  lstatcomp = gen_nconc(lstatcomp, lupdatecomp);
200  lstatnotcomp = gen_nconc(lstatnotcomp, lupdatenotcomp);
201 
202  /* the overall statements are generated.
203  */
204  statcomputecomputer = st_compute_current_computer(ref);
205  statifcomputer = st_make_nice_test(condition_computerp(),
206  lstatcomp,
207  lstatnotcomp);
208 
209  DEBUG_STAT(8, entity_name(node_module), statifcomputer);
210 
211  (*lnp) = CONS(STATEMENT, statcomputecomputer,
212  CONS(STATEMENT, statifcomputer,
213  NIL));
214  (*lhp) = NIL;
215 
216  return;
217  }
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
entity node_module
Definition: compiler.c:47
void generate_compute_local_indices(reference ref, list *lsp, list *lindsp)
generate_compute_local_indices
Definition: generate.c:388
void generate_read_of_ref_for_computer(syntax s, list *lcompp, list *lnotcompp)
generate_read_of_ref_for_computer
Definition: generate.c:275
void generate_update_values_on_nodes(reference ref, reference newref, list *lscompp, list *lsnotcompp)
generate_update_values_on_nodes
Definition: generate.c:223
#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 CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
#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
bool statement_call_p(statement)
Definition: statement.c:364
statement make_assign_statement(expression, expression)
Definition: statement.c:583
statement st_make_nice_test(expression, list, list)
Definition: statement.c:1585
expression UpdateExpressionForModule(entity module, expression ex)
this function creates a new expression using the mapping of old to new variables map.
list FindRefToDistArray(void *obj)
Definition: hpfc-util.c:282
#define condition_computerp()
#define DEBUG_STAT(D, W, S)
entity load_new_node(entity)
statement st_compute_current_computer(reference)
Computes.
Definition: run-time.c:151
bool array_distributed_p(entity)
#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_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define ENTITY_ASSIGN_P(e)
expression reference_to_expression(reference r)
Definition: expression.c:196
#define syntax_reference_p(x)
Definition: ri.h:2728
#define syntax_reference(x)
Definition: ri.h:2730
#define call_function(x)
Definition: ri.h:709
#define reference_variable(x)
Definition: ri.h:2326
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define entity_name(x)
Definition: ri.h:2790
#define statement_instruction(x)
Definition: ri.h:2458
#define instruction_call(x)
Definition: ri.h:1529
#define call_arguments(x)
Definition: ri.h:711
#define expression_syntax(x)
Definition: ri.h:1247
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
#define SYNTAX(x)
SYNTAX.
Definition: ri.h:2670
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References array_distributed_p(), call_arguments, call_function, CAR, CDR, condition_computerp, CONS, DEBUG_STAT, ENTITY_ASSIGN_P, entity_name, EXPRESSION, expression_syntax, FindRefToDistArray(), gen_free_list(), gen_nconc(), generate_compute_local_indices(), generate_read_of_ref_for_computer(), generate_update_values_on_nodes(), instruction_call, load_new_node(), make_assign_statement(), make_reference(), MAP, NIL, node_module, pips_assert, pips_debug, ref, reference_to_expression(), reference_variable, st_compute_current_computer(), st_make_nice_test(), STATEMENT, statement_call_p(), statement_instruction, SYNTAX, syntax_reference, syntax_reference_p, and UpdateExpressionForModule().

Referenced by hpf_compile_call().

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

◆ generate_c1_beta()

void generate_c1_beta ( statement  stat,
list lhp,
list lnp 
)

??? this should work (but that is not the case yet), with every call with no write to distributed arrays.

generate.c

these conditions are to be verifyed, by calculating the proper effects of the statement.

to be corrected later on.

this shouldn't be necessary

references to distributed arrays: w(A(I)) = B(I) so the whole list is to be considered.

generation of the code

Parameters
stattat
lhphp
lnpnp

Definition at line 41 of file generate.c.

44 {
45  statement staths, statns;
46  expression w;
47  call the_call;
48  list lreftodistarray = NIL;
49 
50  (*lhp) = NIL;
51  (*lnp) = NIL;
52 
53  pips_assert("call", statement_call_p(stat));
54 
55  the_call = instruction_call(statement_instruction(stat));
56 
57  /* this shouldn't be necessary
58  */
59  pips_assert("assignment", ENTITY_ASSIGN_P(call_function(the_call)));
60 
61  w = EXPRESSION(CAR(call_arguments(the_call)));
62 
63  pips_assert("reference",
67 
68  /* references to distributed arrays:
69  * w(A(I)) = B(I)
70  * so the whole list is to be considered.
71  */
72  lreftodistarray = FindRefToDistArrayFromList(call_arguments(the_call));
73 
74  /* generation of the code
75  */
76  MAP(SYNTAX, s,
77  {
78  list lhost;
79  list lnode;
80 
81  pips_debug(8, "considering reference to %s\n",
83 
84  generate_read_of_ref_for_all(s, &lhost, &lnode);
85 
86  (*lhp) = gen_nconc((*lhp), lhost);
87  (*lnp) = gen_nconc((*lnp), lnode);
88  },
89  lreftodistarray);
90 
91  /*
92  * then updated statements are to be added to both host and nodes:
93  */
94 
97  make_call(call_function(the_call),
99  call_arguments(the_call)))));
100 
103  make_call(call_function(the_call),
105  call_arguments(the_call)))));
106 
107  DEBUG_STAT(9, entity_name(host_module), staths);
108  DEBUG_STAT(9, entity_name(node_module), statns);
109 
110  (*lhp) = gen_nconc((*lhp), CONS(STATEMENT, staths, NIL));
111  (*lnp) = gen_nconc((*lnp), CONS(STATEMENT, statns, NIL));
112 
113  gen_free_list(lreftodistarray);
114 }
call make_call(entity a1, list a2)
Definition: ri.c:269
instruction make_instruction(enum instruction_utype tag, void *val)
Definition: ri.c:1166
entity host_module
HPFC - Fabien Coelho, May 1993 and later...
Definition: compiler.c:47
void generate_read_of_ref_for_all(syntax s, list *lhp, list *lnp)
generate_read_of_ref_for_all
Definition: generate.c:316
statement instruction_to_statement(instruction)
Build a statement from a give instruction.
Definition: statement.c:597
list lUpdateExpr(entity module, list l)
list FindRefToDistArrayFromList(list lexpr)
FindRefToDistArrayFromList.
Definition: hpfc-util.c:262
@ is_instruction_call
Definition: ri.h:1474

References array_distributed_p(), call_arguments, call_function, CAR, CONS, DEBUG_STAT, ENTITY_ASSIGN_P, entity_name, EXPRESSION, expression_syntax, FindRefToDistArrayFromList(), gen_free_list(), gen_nconc(), generate_read_of_ref_for_all(), host_module, instruction_call, instruction_to_statement(), is_instruction_call, lUpdateExpr(), make_call(), make_instruction(), MAP, NIL, node_module, pips_assert, pips_debug, reference_variable, STATEMENT, statement_call_p(), statement_instruction, SYNTAX, syntax_reference, and syntax_reference_p.

Referenced by hpf_compile_call().

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

◆ generate_compute_local_indices()

void generate_compute_local_indices ( reference  ref,
list lsp,
list lindsp 
)

generate_compute_local_indices

this function generate the list of statement necessary to compute the local indices of the given reference. It gives back the new list of indices for the reference.

Parameters
refef
lspsp
lindspindsp

Definition at line 388 of file generate.c.

391 {
392  int i;
394  list inds = reference_indices(ref);
395 
396  pips_assert("distributed array", array_distributed_p(array));
397 
398  (*lsp) = NIL, (*lindsp) = NIL;
399 
400  pips_debug(9, "number of dimensions of %s to compute: %d\n",
402 
403  for(i=1; i<=NumberOfDimension(array); i++, inds = CDR(inds))
404  {
406  {
407  syntax s;
409  EXPRESSION(CAR(inds)), &s);
410 
412 
413  (*lsp) = gen_nconc((*lsp), CONS(STATEMENT, stat, NIL));
414  (*lindsp) =
415  gen_nconc((*lindsp), CONS(EXPRESSION,
417  }
418  else
419  {
420  expression expr =
422 
423  (*lindsp) =
424  gen_nconc((*lindsp),
425  CONS(EXPRESSION, expr, NIL));
426  }
427  }
428 
429  pips_debug(8, "result:\n");
430  ifdebug(8)
431  MAP(STATEMENT, s, DEBUG_STAT(8, entity_name(node_module), s), (*lsp));
432 }
expression make_expression(syntax a1, normalized a2)
Definition: ri.c:886
statement st_compute_ith_local_index(entity array, int i, expression expr, syntax *sp)
the returned expression is translated into variables of the node module.
Definition: generate.c:775
#define local_index_is_different_p(array, dim)
int NumberOfDimension(entity)
Definition: size.c:588
#define normalized_undefined
Definition: ri.h:1745
#define reference_indices(x)
Definition: ri.h:2328
#define ifdebug(n)
Definition: sg.c:47
static entity array

References array, array_distributed_p(), CAR, CDR, CONS, DEBUG_STAT, entity_name, EXPRESSION, gen_nconc(), ifdebug, local_index_is_different_p, make_expression(), MAP, NIL, node_module, normalized_undefined, NumberOfDimension(), pips_assert, pips_debug, ref, reference_indices, reference_variable, st_compute_ith_local_index(), STATEMENT, and UpdateExpressionForModule().

Referenced by generate_c1_alpha(), generate_get_value_locally(), generate_parallel_body(), generate_receive_from_computer(), generate_send_to_computer(), generate_update_distributed_value_from_host(), generate_update_values_on_computer_and_nodes(), generate_update_values_on_nodes(), and st_send_to_computer_if_necessary().

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

◆ generate_get_value_locally()

void generate_get_value_locally ( reference  ref,
reference  goal,
list lstatp 
)

generate_get_value_locally

put the local value of ref in the variable local.

for every indexes, if necessary, compute the local value of the indices, by calling RTR support function LOCAL_INDEX(array_number, dimension) then the assignment is performed.

tempi = LOCAL_INDEX(array_number, dimension, indexi) ... goal = ref_local(tempi...)

Parameters
refef
goaloal
lstatpstatp

Definition at line 446 of file generate.c.

449 {
450  statement stat;
451  expression expr;
453  newarray = load_new_node(array);
454  list ls = NIL, newinds = NIL;
455 
456  pips_assert("distributed array", array_distributed_p(array));
457 
458  generate_compute_local_indices(ref, &ls, &newinds);
459  expr = reference_to_expression(make_reference(newarray, newinds));
461 
463 
464  (*lstatp) = gen_nconc(ls, CONS(STATEMENT, stat, NIL));
465 }

References array, array_distributed_p(), CONS, DEBUG_STAT, entity_name, gen_nconc(), generate_compute_local_indices(), load_new_node(), make_assign_statement(), make_reference(), NIL, node_module, pips_assert, ref, reference_to_expression(), reference_variable, and STATEMENT.

Referenced by st_get_value_for_computer(), and st_get_value_locally_and_send().

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

◆ generate_parallel_body()

void generate_parallel_body ( statement  body,
list lstatp,
list  lw,
list  lr 
)

the first written or read distributed ref is chosen as the computer

we are sure that computer is one of the owners

Parameters
bodyody
lstatpstatp
lww
lrr

Definition at line 511 of file generate.c.

514 {
515  statement statcc, statbody;
516  list lcomp = NIL, lcompr = NIL, lcompw = NIL,
517  lnotcomp = NIL, lnotcompr = NIL, lnotcompw = NIL;
518  syntax comp;
519 
520  pips_assert("at leat one written or read",
521  (gen_length(lw)+gen_length(lr))>0);
522 
523  /* the first written or read distributed ref is chosen as the computer
524  */
525  comp = lw? SYNTAX(CAR(lw)): SYNTAX(CAR(lr));
527 
528  MAP(SYNTAX, s,
529  {
530  list lco = NIL;
531  list lnotco = NIL;
532 
533  generate_read_of_ref_for_computer(s, &lco, &lnotco);
534 
535  lcompr = gen_nconc(lcompr, lco);
536  lnotcompr = gen_nconc(lnotcompr, lnotco);
537  },
538  lr);
539 
540  MAP(SYNTAX, s,
541  {
542  list lco = NIL;
543  list lnotco = NIL;
545  entity var = reference_variable(r);
547  entity_basic(var));
548  entity tempn ;
549 
551  tempn = load_new_node( temp);
552 
553  if (comp == s)
554  {
555  /* we are sure that computer is one of the owners
556  */
557  list lstat = NIL;
558  list linds = NIL;
559  entity newarray = load_new_node(var);
560 
561  generate_compute_local_indices(r, &lstat, &linds);
562  lstat =
563  gen_nconc
564  (lstat,
565  CONS(STATEMENT,
568  linds)),
569  entity_to_expression(tempn)),
570  NIL));
571 
573  (r, make_reference(tempn, NIL), &lco, &lnotco);
574 
575  lco = gen_nconc(lstat, lco);
576  }
577  else
578  {
580  (r, make_reference(tempn, NIL), &lco, &lnotco);
581  }
582 
583  lcompw = gen_nconc(lcompw, lco);
584  lnotcompw = gen_nconc(lnotcompw, lnotco);
585 
586  syntax_reference(s) = make_reference(temp, NIL);
587  },
588  lw);
589 
590 
591  pips_debug(6, "%zd statements for computer write:\n", gen_length(lcompw));
592 
593  ifdebug(8)
594  {
595  MAP(STATEMENT, s, DEBUG_STAT(8, entity_name(node_module), s), lcompw);
596  }
597 
598  pips_debug(6, "%zd statements for not computer write:\n",
599  gen_length(lnotcompw));
600 
601  ifdebug(8)
602  {
604  lnotcompw);
605  }
606 
607  statbody = UpdateStatementForModule(node_module, body);
608  DEBUG_STAT(7, entity_name(node_module), statbody);
609 
610  lcomp = gen_nconc(lcompr, CONS(STATEMENT, statbody, lcompw));
611  lnotcomp = gen_nconc(lnotcompr, lnotcompw);
612 
613  (*lstatp) = CONS(STATEMENT, statcc,
615  lcomp,
616  lnotcomp),
617  NIL));
618 
619  ifdebug(6)
620  {
621  pips_debug(6, "final statement:\n");
622  MAP(STATEMENT, s, DEBUG_STAT(6, entity_name(node_module),s), (*lstatp));
623  }
624 }
void generate_update_values_on_computer_and_nodes(reference ref, reference val, list *lscompp, list *lsnotcompp)
generate_update_values_on_computer_and_nodes
Definition: generate.c:634
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
size_t gen_length(const list l)
Definition: list.c:150
statement UpdateStatementForModule(entity module, statement stat)
void AddEntityToHostAndNodeModules(entity e)
AddEntityToHostAndNodeModules.
Definition: hpfc-util.c:298
basic entity_basic(entity e)
return the basic associated to entity e if it's a function/variable/constant basic_undefined otherwis...
Definition: entity.c:1380
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
entity make_new_scalar_variable(entity, basic)
Definition: variable.c:741

References AddEntityToHostAndNodeModules(), CAR, condition_computerp, CONS, DEBUG_STAT, entity_basic(), entity_name, entity_to_expression(), gen_length(), gen_nconc(), generate_compute_local_indices(), generate_read_of_ref_for_computer(), generate_update_values_on_computer_and_nodes(), generate_update_values_on_nodes(), get_current_module_entity(), ifdebug, load_new_node(), make_assign_statement(), make_new_scalar_variable(), make_reference(), MAP, NIL, node_module, pips_assert, pips_debug, reference_to_expression(), reference_variable, st_compute_current_computer(), st_make_nice_test(), STATEMENT, SYNTAX, syntax_reference, and UpdateStatementForModule().

Referenced by hpf_compile_parallel_body().

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

◆ generate_read_of_ref_for_all()

void generate_read_of_ref_for_all ( syntax  s,
list lhp,
list lnp 
)

generate_read_of_ref_for_all

this function organise the read of the given reference for all the nodes, and for host.

the receive statement is built for host:

COMPUTE_CURRENT_OWNERS(ref) temp = RECEIVEFROMSENDER(...)

a receive from sender is generated, however replicated the variable is FC 930623 (before was a call to st_receive_from(ref, ...))

the code for node is built, in order that temp has the wanted value.

COMPUTE_CURRENT_OWNERS(ref) IF OWNERP(ME) THEN local_ref = COMPUTE_LOCAL(ref) temp = (local_ref) IF SENDERP(ME) // this protection in case of replicated arrays. THEN SENDTOHOST(temp) SENDTONODE(ALL-OWNERS,temp) ENDIF ELSE temp = RECEIVEFROM(SENDER(...)) ENDIF

the new variable is inserted in the expression...

Parameters
lhphp
lnpnp

Definition at line 316 of file generate.c.

319 {
320  statement stathco, stathrcv, statnco, statngv;
322  entity temph, tempn,
323  var = reference_variable(ref),
325  entity_basic(var));
326 
327  pips_assert("distributed array", array_distributed_p(var));
328 
330  temph = load_new_host(temp);
331  tempn = load_new_node(temp);
332 
333  /* the receive statement is built for host:
334  *
335  * COMPUTE_CURRENT_OWNERS(ref)
336  * temp = RECEIVEFROMSENDER(...)
337  */
338  stathco = st_compute_current_owners(ref);
339 
340  /* a receive from sender is generated, however replicated the variable is
341  * FC 930623 (before was a call to st_receive_from(ref, ...))
342  */
343  stathrcv = st_receive_from(ref, make_reference(temph, NIL));
344 
345  (*lhp) = CONS(STATEMENT, stathco,
346  CONS(STATEMENT, stathrcv,
347  NIL));
348 
349  DEBUG_STAT(9, entity_name(host_module), stathco);
350  DEBUG_STAT(9, entity_name(host_module), stathrcv);
351 
352  /* the code for node is built, in order that temp has the
353  * wanted value.
354  *
355  * COMPUTE_CURRENT_OWNERS(ref)
356  * IF OWNERP(ME)
357  * THEN
358  * local_ref = COMPUTE_LOCAL(ref)
359  * temp = (local_ref)
360  * IF SENDERP(ME) // this protection in case of replicated arrays.
361  * THEN
362  * SENDTOHOST(temp)
363  * SENDTONODE(ALL-OWNERS,temp)
364  * ENDIF
365  * ELSE
366  * temp = RECEIVEFROM(SENDER(...))
367  * ENDIF
368  */
369  statnco = st_compute_current_owners(ref);
370  statngv = st_get_value_for_all(ref, make_reference(tempn, NIL));
371 
372  (*lnp) = CONS(STATEMENT, statnco, CONS(STATEMENT, statngv, NIL));
373 
374  DEBUG_STAT(9, entity_name(node_module), statnco);
375  DEBUG_STAT(9, entity_name(node_module), statngv);
376 
377  /* the new variable is inserted in the expression...
378  */
379  syntax_reference(s) = make_reference(temp, NIL);
380 }
statement st_get_value_for_all(reference ref, reference goal)
Definition: generate.c:842
statement st_receive_from(reference ref, reference goal)
if ref is replicated: goal = Receive_From_Sender()
Definition: generate.c:865
statement st_compute_current_owners(reference)
Definition: run-time.c:173
entity load_new_host(entity)

References AddEntityToHostAndNodeModules(), array_distributed_p(), CONS, DEBUG_STAT, entity_basic(), entity_name, get_current_module_entity(), host_module, load_new_host(), load_new_node(), make_new_scalar_variable(), make_reference(), NIL, node_module, pips_assert, ref, reference_variable, st_compute_current_owners(), st_get_value_for_all(), st_receive_from(), STATEMENT, and syntax_reference.

Referenced by generate_c1_beta().

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

◆ generate_read_of_ref_for_computer()

void generate_read_of_ref_for_computer ( syntax  s,
list lcompp,
list lnotcompp 
)

generate_read_of_ref_for_computer

en cours d'adaptation...

the new variable is inserted in the expression...

Parameters
lcomppcompp
lnotcomppnotcompp

Definition at line 275 of file generate.c.

278 {
279  statement statcompco, statcompgv, statnotcompco, statnotcompmaysend;
281  entity tempn,
282  var = reference_variable(ref),
284  entity_basic(var));
285 
286  pips_assert("distributed array", array_distributed_p(var));
287 
289  tempn = load_new_node(temp);
290 
291  statcompco = st_compute_current_owners(ref);
292  statcompgv = st_get_value_for_computer(ref, make_reference(tempn, NIL));
293 
294  (*lcompp) = CONS(STATEMENT, statcompco,
295  CONS(STATEMENT, statcompgv, NIL));
296 
297  statnotcompco = st_compute_current_owners(ref);
298  statnotcompmaysend = st_send_to_computer_if_necessary(ref);
299 
300 
301  (*lnotcompp) =
302  CONS(STATEMENT, statnotcompco,
303  CONS(STATEMENT, statnotcompmaysend,
304  NIL));
305 
306  /* the new variable is inserted in the expression...
307  */
308  syntax_reference(s) = make_reference(temp, NIL);
309 }
statement st_send_to_computer_if_necessary(reference ref)
Definition: generate.c:817
statement st_get_value_for_computer(reference ref, reference goal)
Definition: generate.c:850

References AddEntityToHostAndNodeModules(), array_distributed_p(), CONS, entity_basic(), get_current_module_entity(), load_new_node(), make_new_scalar_variable(), make_reference(), NIL, pips_assert, ref, reference_variable, st_compute_current_owners(), st_get_value_for_computer(), st_send_to_computer_if_necessary(), STATEMENT, and syntax_reference.

Referenced by generate_c1_alpha(), and generate_parallel_body().

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

◆ generate_receive_from_computer()

void generate_receive_from_computer ( reference  ref,
list lstatp 
)
Parameters
refef
lstatpstatp

Definition at line 491 of file generate.c.

494 {
495  statement statrcv;
496  entity
498  newarray = load_new_node(array);
499  list ls = NIL, newinds = NIL;
500 
501  pips_assert("distributed array", array_distributed_p(array));
502 
503  generate_compute_local_indices(ref, &ls, &newinds);
504  statrcv = st_receive_from_computer(make_reference(newarray, newinds));
505 
506  DEBUG_STAT(9, entity_name(node_module), statrcv);
507 
508  (*lstatp) = gen_nconc(ls, CONS(STATEMENT, statrcv, NIL));
509 }
#define st_receive_from_computer(goal)

References array, array_distributed_p(), CONS, DEBUG_STAT, entity_name, gen_nconc(), generate_compute_local_indices(), load_new_node(), make_reference(), NIL, node_module, pips_assert, ref, reference_variable, st_receive_from_computer, and STATEMENT.

+ Here is the call graph for this function:

◆ generate_send_to_computer()

void generate_send_to_computer ( reference  ref,
list lstatp 
)

generate_send_to_computer

sends the local value of ref to the current computer

Parameters
refef
lstatpstatp

Definition at line 471 of file generate.c.

474 {
475  statement statsnd;
476  entity
478  newarray = load_new_node(array);
479  list ls = NIL, newinds = NIL;
480 
481  pips_assert("distributed array", array_distributed_p(array));
482 
483  generate_compute_local_indices(ref, &ls, &newinds);
484  statsnd = st_send_to_computer(make_reference(newarray, newinds));
485 
486  DEBUG_STAT(9, entity_name(node_module), statsnd);
487 
488  (*lstatp) = gen_nconc(ls, CONS(STATEMENT, statsnd, NIL));
489 }
#define st_send_to_computer(val)
SND.

References array, array_distributed_p(), CONS, DEBUG_STAT, entity_name, gen_nconc(), generate_compute_local_indices(), load_new_node(), make_reference(), NIL, node_module, pips_assert, ref, reference_variable, st_send_to_computer, and STATEMENT.

+ Here is the call graph for this function:

◆ generate_update_distributed_value_from_host()

void generate_update_distributed_value_from_host ( syntax  s,
list lhstatp,
list lnstatp 
)

generate_update_distributed_value_from_host

call the necessary communication function

Parameters
lhstatphstatp
lnstatpnstatp

Definition at line 691 of file generate.c.

694 {
696  entity array, newarray, temp, temph;
697  statement statnco, stathco, stnrcv, stnif, sthsnd;
698  list linds = NIL, lnstat = NIL;
699 
700  pips_assert("distrivuted reference",
702 
704  newarray = load_new_node(array);
705 
708 
710  temph = load_new_host(temp);
711 
712  generate_compute_local_indices(r, &lnstat, &linds);
713  stnrcv = st_receive_from_host(make_reference(newarray, linds));
715  gen_nconc(lnstat,
716  CONS(STATEMENT, stnrcv, NIL)),
717  NIL);
718 
719  /* call the necessary communication function
720  */
721 
722  sthsnd = (replicated_p(array) ?
725 
726  syntax_reference(s) = make_reference(temp, NIL);
727 
728  statnco = st_compute_current_owners(r);
729  stathco = st_compute_current_owners(r);
730 
731  (*lhstatp) = CONS(STATEMENT, stathco, CONS(STATEMENT, sthsnd, NIL));
732  (*lnstatp) = CONS(STATEMENT, statnco, CONS(STATEMENT, stnif, NIL));
733 
734 }
bool replicated_p(entity e)
replicated_p
Definition: hpfc-util.c:96
#define condition_ownerp()
#define st_receive_from_host(goal)
#define st_send_to_owners(val)
#define st_send_to_owner(val)

References AddEntityToHostAndNodeModules(), array, array_distributed_p(), condition_ownerp, CONS, entity_basic(), gen_nconc(), generate_compute_local_indices(), get_current_module_entity(), load_new_host(), load_new_node(), make_new_scalar_variable(), make_reference(), NIL, pips_assert, reference_variable, replicated_p(), st_compute_current_owners(), st_make_nice_test(), st_receive_from_host, st_send_to_owner, st_send_to_owners, STATEMENT, and syntax_reference.

+ Here is the call graph for this function:

◆ generate_update_private_value_from_host()

void generate_update_private_value_from_host ( syntax  s,
list lhstatp,
list lnstatp 
)

generate_update_private_value_from_host

Parameters
lhstatphstatp
lnstatpnstatp

Definition at line 738 of file generate.c.

740 {
741  entity
743  varn = load_new_node(var),
744  varh = load_new_host(var);
745 
746  pips_assert("not distributed reference",
748 
749  (*lhstatp) = CONS(STATEMENT,
751  NIL);
752 
753  (*lnstatp) = CONS(STATEMENT,
755  NIL);
756 }
#define st_receive_mcast_from_host(goal)
#define st_host_send_to_all_nodes(val)

References array_distributed_p(), CONS, load_new_host(), load_new_node(), make_reference(), NIL, pips_assert, reference_variable, st_host_send_to_all_nodes, st_receive_mcast_from_host, STATEMENT, and syntax_reference.

+ Here is the call graph for this function:

◆ generate_update_values_on_computer_and_nodes()

void generate_update_values_on_computer_and_nodes ( reference  ref,
reference  val,
list lscompp,
list lsnotcompp 
)

generate_update_values_on_computer_and_nodes

inside a loop, a variable is defined, and the values have to be updated on the computer node itself, and on the other owners of the given variable.

computer is doing the job

all values have to be updated...

Parameters
refef
valal
lscomppscompp
lsnotcomppsnotcompp

Definition at line 634 of file generate.c.

637 {
638  entity
640  newarray = load_new_node(array);
641  statement
642  statif, statcompif, statco, statcompco, statcompassign,
643  statsndtoO, statsndtoOO, statrcvfromcomp;
644  list lstat, lstatcomp, linds, lindscomp;
645 
646  /* all values have to be updated...
647  */
648  statcompco = st_compute_current_owners(ref);
649  generate_compute_local_indices(ref, &lstatcomp, &lindscomp);
650 
651  statcompassign =
653  (reference_to_expression(make_reference(newarray, lindscomp)),
655 
656  if (replicated_p(array))
657  {
658  statsndtoOO = st_send_to_other_owners(val);
659  statsndtoO = st_send_to_owners(val);
660  }
661  else
662  {
664  statsndtoO = st_send_to_owner(val);
665  }
666  statcompif = st_make_nice_test
667  (condition_ownerp(),
668  gen_nconc(lstatcomp, CONS(STATEMENT, statcompassign,
669  CONS(STATEMENT, statsndtoOO,
670  NIL))),
671  CONS(STATEMENT, statsndtoO,
672  NIL));
673 
674  statco = st_compute_current_owners(ref);
675  generate_compute_local_indices(ref, &lstat, &linds);
676  statrcvfromcomp =
677  st_receive_from_computer(make_reference(newarray,linds));
679  gen_nconc(lstat, CONS(STATEMENT, statrcvfromcomp,
680  NIL)),
681  NIL);
682 
683  (*lscompp) = CONS(STATEMENT, statcompco,
684  CONS(STATEMENT, statcompif, NIL));
685  (*lsnotcompp) = CONS(STATEMENT, statco,
686  CONS(STATEMENT, statif, NIL));
687 }
statement make_continue_statement(entity)
Definition: statement.c:953
#define st_send_to_other_owners(val)
#define entity_undefined
Definition: ri.h:2761

References array, condition_ownerp, CONS, entity_undefined, gen_nconc(), generate_compute_local_indices(), load_new_node(), make_assign_statement(), make_continue_statement(), make_reference(), NIL, ref, reference_to_expression(), reference_variable, replicated_p(), st_compute_current_owners(), st_make_nice_test(), st_receive_from_computer, st_send_to_other_owners, st_send_to_owner, st_send_to_owners, and STATEMENT.

Referenced by generate_parallel_body().

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

◆ generate_update_values_on_nodes()

void generate_update_values_on_nodes ( reference  ref,
reference  newref,
list lscompp,
list lsnotcompp 
)

generate_update_values_on_nodes

computer is doing the job

remote values have to be updated

the computer has to compute the owners in order to call the send to other owners function, because the owners are used to define the owners set, which was quite obvious:-)

bug fixed by FC, 930629

Parameters
refef
newrefewref
lscomppscompp
lsnotcomppsnotcompp

Definition at line 223 of file generate.c.

226 {
228 
229  if (replicated_p(array))
230  {
231  statement statif, statco, statco2, statsndtoon, statrcvfromcomp;
232  list lstat, linds;
233 
234  /* remote values have to be updated
235  */
236  statco = st_compute_current_owners(ref);
237 
238  /* the computer has to compute the owners in order to call
239  * the send to other owners function, because the owners
240  * are used to define the owners set, which was quite obvious:-)
241  *
242  * bug fixed by FC, 930629
243  */
244  statco2 = st_compute_current_owners(ref);
245  statsndtoon = st_send_to_other_owners(newref);
246  generate_compute_local_indices(ref, &lstat, &linds);
247  statrcvfromcomp =
249  linds));
251  gen_nconc(lstat,
252  CONS(STATEMENT,
253  statrcvfromcomp,
254  NIL)),
255  NIL);
256 
257  (*lscompp) = CONS(STATEMENT, statco2,
258  CONS(STATEMENT, statsndtoon,
259  NIL));
260  (*lsnotcompp) = CONS(STATEMENT, statco,
261  CONS(STATEMENT, statif,
262  NIL));
263  }
264  else
265  {
266  (*lscompp) = NIL;
267  (*lsnotcompp) = NIL;
268  }
269 }

References array, condition_ownerp, CONS, gen_nconc(), generate_compute_local_indices(), make_reference(), NIL, ref, reference_variable, replicated_p(), st_compute_current_owners(), st_make_nice_test(), st_receive_from_computer, st_send_to_other_owners, and STATEMENT.

Referenced by generate_c1_alpha(), and generate_parallel_body().

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

◆ st_compute_ith_local_index()

statement st_compute_ith_local_index ( entity  array,
int  i,
expression  expr,
syntax sp 
)

the returned expression is translated into variables of the node module.

the necessity is not checked, but it could be done, looking that the new declaration of the given array is smaller or not on the given dimension...

Parameters
arrayrray
exprxpr
spp

Definition at line 775 of file generate.c.

780 {
781  /* the necessity is not checked, but it could be done,
782  * looking that the new declaration of the given array
783  * is smaller or not on the given dimension...
784  */
785 
788  statement stat;
790 
792 
797  i,
799  expr))));
800 
801  return(stat);
802 }
syntax make_syntax(enum syntax_utype tag, void *val)
Definition: ri.c:2491
instruction make_assign_instruction(expression l, expression r)
Definition: instruction.c:87
expression expr_compute_local_index(entity, int, expression)
new index computation formula, derived from the new declarations made for the given dimension.
Definition: run-time.c:198
basic MakeBasic(int)
END_EOLE.
Definition: type.c:128
void AddEntityToCurrentModule(entity)
Add a variable entity to the current module declarations.
Definition: variable.c:260
@ is_basic_int
Definition: ri.h:571
@ is_syntax_reference
Definition: ri.h:2691

References AddEntityToCurrentModule(), array, expr_compute_local_index(), instruction_to_statement(), is_basic_int, is_syntax_reference, make_assign_instruction(), make_new_scalar_variable(), make_reference(), make_syntax(), MakeBasic(), NIL, node_module, reference_to_expression(), and UpdateExpressionForModule().

Referenced by generate_compute_local_indices().

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

◆ st_get_value_for_all()

statement st_get_value_for_all ( reference  ref,
reference  goal 
)
Parameters
refef
goaloal

Definition at line 842 of file generate.c.

843 {
844  return
848 }
statement st_get_value_locally_and_send(reference ref, reference goal)
Definition: generate.c:760

References condition_ownerp, CONS, NIL, ref, st_get_value_locally_and_send(), st_make_nice_test(), st_receive_from(), and STATEMENT.

Referenced by generate_read_of_ref_for_all().

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

◆ st_get_value_for_computer()

statement st_get_value_for_computer ( reference  ref,
reference  goal 
)
Parameters
refef
goaloal

Definition at line 850 of file generate.c.

852 {
853  list ltrue=NIL, lfalse=NIL;
854  generate_get_value_locally(ref,goal,&ltrue);
856  return st_make_nice_test(condition_ownerp(),ltrue,lfalse);
857 }
void generate_get_value_locally(reference ref, reference goal, list *lstatp)
generate_get_value_locally
Definition: generate.c:446
#define st_receive_from_sender(goal)

References condition_ownerp, CONS, generate_get_value_locally(), NIL, ref, st_make_nice_test(), st_receive_from_sender, and STATEMENT.

Referenced by generate_read_of_ref_for_computer().

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

◆ st_get_value_locally_and_send()

statement st_get_value_locally_and_send ( reference  ref,
reference  goal 
)
Parameters
refef
goaloal

Definition at line 760 of file generate.c.

761 {
762  list ls=NIL;
763 
766  NIL));
767 
768  return(make_block_statement(ls));
769 }
statement st_send_to_host_and_nodes(reference ref, reference val)
Definition: generate.c:804
statement make_block_statement(list)
Make a block statement from a list of statement.
Definition: statement.c:616

References CONS, gen_nconc(), generate_get_value_locally(), make_block_statement(), NIL, ref, st_send_to_host_and_nodes(), and STATEMENT.

Referenced by st_get_value_for_all().

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

◆ st_receive_from()

statement st_receive_from ( reference  ref,
reference  goal 
)

if ref is replicated: goal = Receive_From_Sender()

if ref is not replicated goal = Receive_Multi_Cast_From_Sender()

Parameters
refef
goaloal

Definition at line 865 of file generate.c.

867 {
869  return st_receive_from_sender(goal);
870  else
871  return st_receive_mcast_from_sender(goal);
872 }
#define st_receive_mcast_from_sender(goal)

References ref, reference_variable, replicated_p(), st_receive_from_sender, and st_receive_mcast_from_sender.

Referenced by generate_read_of_ref_for_all(), and st_get_value_for_all().

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

◆ st_send_to_computer_if_necessary()

statement st_send_to_computer_if_necessary ( reference  ref)
Parameters
refef

Definition at line 817 of file generate.c.

818 {
819  entity
821  newarray = load_new_node(array);
822  expression
823  condition=((replicated_p(array))?
828  (condition_senderp()));
829  list lstat = NIL, lnewinds = NIL;
830 
831  generate_compute_local_indices(ref, &lstat, &lnewinds);
832 
833  return
834  st_make_nice_test(condition,
835  gen_nconc(lstat,
836  CONS(STATEMENT,
837  st_send_to_computer(make_reference(newarray, lnewinds)),
838  NIL)),
839  NIL);
840 }
#define condition_not_computer_in_owners()
#define condition_senderp()
#define AND_OPERATOR_NAME
FI: intrinsics are defined at a third place after bootstrap and effects! I guess the name should be d...
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
Definition: expression.c:354

References AND_OPERATOR_NAME, array, condition_not_computer_in_owners, condition_senderp, CONS, entity_intrinsic(), gen_nconc(), generate_compute_local_indices(), load_new_node(), make_reference(), MakeBinaryCall(), NIL, ref, reference_variable, replicated_p(), st_make_nice_test(), st_send_to_computer, and STATEMENT.

Referenced by generate_read_of_ref_for_computer().

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

◆ st_send_to_host_and_nodes()

statement st_send_to_host_and_nodes ( reference  ref,
reference  val 
)
Parameters
refef
valal

Definition at line 804 of file generate.c.

806 {
809  CONS(STATEMENT,
811  NIL),
812  NIL));
813  else
814  return st_send_to_host_and_all_nodes(val);
815 }
#define st_send_to_host_and_not_owners(val)
#define st_send_to_host_and_all_nodes(val)

References condition_senderp, CONS, NIL, ref, reference_variable, replicated_p(), st_make_nice_test(), st_send_to_host_and_all_nodes, st_send_to_host_and_not_owners, and STATEMENT.

Referenced by st_get_value_locally_and_send().

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