PIPS
reductions.c File Reference
#include "local-header.h"
#include "control.h"
#include "semantics.h"
+ Include dependency graph for reductions.c:

Go to the source code of this file.

Functions

static void set_generic_effects_as_needed (void)
 for CONTROL_MAP() More...
 
reductions load_summary_reductions (entity f)
 Fortran 77 anti aliasing rules implies that sg that looks like a reduction within a subroutine can be perceived as so from outside because no aliasing may cause the accumulator to be linked to the rhs of the accumulation... More...
 
static reduction compute_one_summary_reduction (reduction model, list le)
 
static reductions compute_summary_reductions (entity f)
 
bool summary_reductions (const char *module_name)
 handler for pipsmake input: module name output: TRUE side effects: stores the summary reductions to pipsdbm More...
 
static list add_reduced_variables (list le, reductions rs)
 Function storing Proper Reductions. More...
 
static list list_of_reduced_variables (statement node, list ls)
 of entity More...
 
static reduction compatible_reduction_of_var (entity var, reductions rs)
 Returns NULL if not ok. More...
 
static list list_of_compatible_reductions (reductions rs)
 returns NIL on any problem More...
 
static list list_of_trusted_references (reductions rs)
 
static bool safe_effects_for_reductions (statement s, reductions rs)
 argh... More...
 
static void check_proper_reductions (statement s)
 must check that the found reductions are (1) without side effects (no W on any other than accumulators), MA: why? If the W doesn't conflict with the accumulators it should be safe ! safe_effects_for_reductions seems overkill to me (2) compatible one with respect to the other. More...
 
static bool pr_statement_flt (statement s)
 
static void pr_statement_wrt (statement s)
 
static bool pr_call_flt (call c)
 
static void compute_proper_reductions (statement s)
 performs the computation of proper reductions for statement s. More...
 
bool proper_reductions (const char *module_name)
 handler for pipsmake input: module name output: TRUE side effects: some More...
 
static bool build_reduction_of_variable (entity var, statement node, list ls, reduction *pr)
 Function storing Cumulated Reductions. More...
 
static void build_creductions_of_statement (statement node, list ls)
 builds cumulated reductions for node, depending on node and list of statement ls. More...
 
static void compute_cumulated_reductions (instruction i)
 Cumulated Reduction propagation functions for each possible instructions. More...
 
bool cumulated_reductions (const char *module_name)
 handler for pipsmake input: the module name output: TRUE side effects: some More...
 
entity reduction_operator_entity (reduction_operator op)
 match a reduction operator against operator entity More...
 
bool same_reduction_p (reduction r1, reduction r2)
 

Variables

static call last_translated_module_call = call_undefined
 hack: no check for direct translations ("call foo") thus in this case effects reductions will be okay... More...
 

Function Documentation

◆ add_reduced_variables()

static list add_reduced_variables ( list  le,
reductions  rs 
)
static

Function storing Proper Reductions.

list of entities that may be reduced of entity

Parameters
leof entity

Definition at line 144 of file reductions.c.

147 {
148  FOREACH (REDUCTION, r, reductions_list(rs)) {
149  le = gen_once(reduction_variable(r), le);
150  }
151  return le;
152 }
list gen_once(const void *vo, list l)
Prepend an item to a list only if it is not already in the list.
Definition: list.c:722
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
#define reduction_variable(r)
shorthands for REDUCTION:
#define REDUCTION(x)
REDUCTION.
#define reductions_list(x)

References FOREACH, gen_once(), REDUCTION, reduction_variable, and reductions_list.

Referenced by list_of_compatible_reductions(), and list_of_reduced_variables().

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

◆ build_creductions_of_statement()

static void build_creductions_of_statement ( statement  node,
list  ls 
)
static

builds cumulated reductions for node, depending on node and list of statement ls.

of entity

of reduction

list of candidate entities

for each candidate, extract the reduction if any

store the result

Parameters
lsof statement

Definition at line 451 of file reductions.c.

454 {
455  list /* of entity */ le;
456  list /* of reduction */ lr=NIL;
457  reduction r;
458 
459  /* list of candidate entities */
461 
462  pips_debug(5, "stat %s %p: %td candidate(s)\n",
464 
465  /* for each candidate, extract the reduction if any */
466  FOREACH (ENTITY, var, le)
467  if (build_reduction_of_variable(var, node, ls, &r))
468  lr = CONS(REDUCTION, r, lr);
469 
470  /* store the result */
471  pips_debug(5, "stat %s %p -> %td reductions\n",
473 
475  gen_free_list(le);
476 }
static void node(FILE *out, string name)
Build for module name a node and link to its successors.
Definition: graph.c:56
reductions make_reductions(list a)
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
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
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
static bool build_reduction_of_variable(entity var, statement node, list ls, reduction *pr)
Function storing Cumulated Reductions.
Definition: reductions.c:410
static list list_of_reduced_variables(statement node, list ls)
of entity
Definition: reductions.c:155
string note_for_statement(statement s)
generates a short note to tell about the type of the statement being decorated.
Definition: prettyprint.c:55
void store_cumulated_reductions(statement, reductions)
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References build_reduction_of_variable(), CONS, ENTITY, FOREACH, gen_free_list(), gen_length(), list_of_reduced_variables(), make_reductions(), NIL, node(), note_for_statement(), pips_debug, REDUCTION, and store_cumulated_reductions().

Referenced by compute_cumulated_reductions().

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

◆ build_reduction_of_variable()

static bool build_reduction_of_variable ( entity  var,
statement  node,
list  ls,
reduction pr 
)
static

Function storing Cumulated Reductions.

returns a r reduction of any compatible with { node } u ls input: var, node and ls output: true and some *pr, or FALSE

Parameters
lsof statement

Definition at line 410 of file reductions.c.

415 {
416  *pr = make_reduction
419  NIL, NIL);
420 
424  {
425  free_reduction(*pr);
426  return false;
427  }
428 
429  FOREACH (STATEMENT, s, ls) {
433  {
434  free_reduction(*pr);
435  return false;
436  }
437  }
438  else {
439  pips_debug(5, "stat %s %p\n", note_for_statement(s), s);
440  pips_assert ("should not happen, all statements should have been visited for reduction", false);
441  }
442  }
443 
444  return true;
445 }
void free_reduction(reduction p)
reduction make_reduction(reference a1, reduction_operator a2, list a3, list a4)
reduction_operator make_reduction_operator_none(void)
effects load_proper_references(statement)
list load_rw_effects_list(statement)
#define effects_effects(x)
Definition: effects.h:710
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
bool update_compatible_reduction(reduction *, entity, list, reductions)
what to do with reduction *pr for variable var under effects le and reductions reds.
Definition: utils.c:285
bool bound_cumulated_reductions_p(statement)
reductions load_cumulated_reductions(statement)
reductions load_proper_reductions(statement)
#define reference_undefined
Definition: ri.h:2302
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413

References bound_cumulated_reductions_p(), effects_effects, FOREACH, free_reduction(), load_cumulated_reductions(), load_proper_reductions(), load_proper_references(), load_rw_effects_list(), make_reduction(), make_reduction_operator_none(), NIL, node(), note_for_statement(), pips_assert, pips_debug, reference_undefined, STATEMENT, and update_compatible_reduction().

Referenced by build_creductions_of_statement().

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

◆ check_proper_reductions()

static void check_proper_reductions ( statement  s)
static

must check that the found reductions are (1) without side effects (no W on any other than accumulators), MA: why? If the W doesn't conflict with the accumulators it should be safe ! safe_effects_for_reductions seems overkill to me (2) compatible one with respect to the other.

(3) not killed by other proper effects on accumulators. to avoid these checks, I can stop on expressions...

of reduction

all must be compatible, otherwise some side effect!

checks (2)

now lnr is the new list of reductions.

checks (1) and (3)

Definition at line 250 of file reductions.c.

250  {
252  list /* of reduction */ lr = reductions_list(rs), lnr;
253  if(ENDP(lr))
254  return;
255 
256  /* all must be compatible, otherwise some side effect!
257  */
258  lnr = list_of_compatible_reductions(rs); /* checks (2) */
259 
260  /* now lnr is the new list of reductions.
261  */
262  if(lnr && !safe_effects_for_reductions(s, rs)) { /* checks (1) and (3) */
263  gen_full_free_list(lnr);
264  lnr = NIL;
265  }
266 
267  gen_full_free_list(lr);
268  // update the reduction list
269  reductions_list(rs) = lnr;
270 }
void gen_full_free_list(list l)
Definition: genClib.c:1023
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
static list list_of_compatible_reductions(reductions rs)
returns NIL on any problem
Definition: reductions.c:187
static bool safe_effects_for_reductions(statement s, reductions rs)
argh...
Definition: reductions.c:222

References ENDP, gen_full_free_list(), list_of_compatible_reductions(), load_proper_reductions(), NIL, reductions_list, and safe_effects_for_reductions().

Referenced by pr_statement_wrt().

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

◆ compatible_reduction_of_var()

static reduction compatible_reduction_of_var ( entity  var,
reductions  rs 
)
static

Returns NULL if not ok.

Definition at line 174 of file reductions.c.

174  {
175  reduction rnew = make_none_reduction(var);
176 
178  if (!update_compatible_reduction_with(&rnew, var, r)) {
179  free_reduction(rnew);
180  return NULL;
181  }
182  }
183  return rnew;
184 }
#define make_none_reduction(var)
bool update_compatible_reduction_with(reduction *, entity, reduction)
update *pr according to r for variable var r is not touched.
Definition: utils.c:260

References FOREACH, free_reduction(), make_none_reduction, REDUCTION, reductions_list, and update_compatible_reduction_with().

Referenced by list_of_compatible_reductions().

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

◆ compute_cumulated_reductions()

static void compute_cumulated_reductions ( instruction  i)
static

Cumulated Reduction propagation functions for each possible instructions.

Statement s cumulated reduction computation involves :

  • its own proper reductions and effects
  • the cumulated reductions and effects of its sons the computation is performed by build_reductions_of_statement. the current statement is retrieved thru the crt_stat stack. Perform the bottom-up propagation of cumulated reductions

of control

it is important to return here

Definition at line 486 of file reductions.c.

487 {
489  list l = NIL;
490  bool tofree = true;
491  switch(instruction_tag(i)) {
493  tofree=false;
494  l=instruction_block(i);break;
495  case is_instruction_loop:
501  case is_instruction_test:
504  {
505  list /* of control */ lc = NIL;
508  gen_free_list(lc);
509  } ; break ;
510  case is_instruction_call:
513  pips_debug(5, "stat %s %p\n", note_for_statement(parent), parent);
514  return ; /* it is important to return here */
515  default:
516  pips_internal_error("should not happen");
517  };
519  if(tofree) gen_free_list(l);
520 }
reductions copy_reductions(reductions p)
REDUCTIONS.
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
list control_list_to_statement_list(list)
of statement
Definition: graph.c:103
#define CONTROL_MAP(ctl, code, c, list)
Macro to walk through all the controls reachable from a given control node of an unstructured.
gen_chunk * gen_get_ancestor(int, const void *)
return the first ancestor object found of the given type.
Definition: genClib.c:3560
#define pips_internal_error
Definition: misc-local.h:149
static void build_creductions_of_statement(statement node, list ls)
builds cumulated reductions for node, depending on node and list of statement ls.
Definition: reductions.c:451
#define unstructured_control
After the modification in Newgen: unstructured = entry:control x exit:control we have create a macro ...
#define instruction_block(i)
#define make_statement_list(stats...)
easy list constructor
#define loop_body(x)
Definition: ri.h:1644
#define instruction_loop(x)
Definition: ri.h:1520
#define test_false(x)
Definition: ri.h:2837
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362
#define CONTROL(x)
CONTROL.
Definition: ri.h:910
@ is_instruction_unstructured
Definition: ri.h:1475
@ is_instruction_whileloop
Definition: ri.h:1472
@ is_instruction_expression
Definition: ri.h:1478
@ is_instruction_test
Definition: ri.h:1470
@ is_instruction_call
Definition: ri.h:1474
@ is_instruction_sequence
Definition: ri.h:1469
@ is_instruction_forloop
Definition: ri.h:1477
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define test_true(x)
Definition: ri.h:2835
#define instruction_forloop(x)
Definition: ri.h:1538
#define instruction_whileloop(x)
Definition: ri.h:1523
#define whileloop_body(x)
Definition: ri.h:3162
#define instruction_test(x)
Definition: ri.h:1517
#define forloop_body(x)
Definition: ri.h:1372
#define instruction_unstructured(x)
Definition: ri.h:1532
return(s1)

References build_creductions_of_statement(), CONS, CONTROL, control_list_to_statement_list(), CONTROL_MAP, copy_reductions(), forloop_body, gen_free_list(), gen_get_ancestor(), instruction_block, instruction_forloop, instruction_loop, instruction_tag, instruction_test, instruction_unstructured, instruction_whileloop, is_instruction_call, is_instruction_expression, is_instruction_forloop, is_instruction_loop, is_instruction_sequence, is_instruction_test, is_instruction_unstructured, is_instruction_whileloop, load_proper_reductions(), loop_body, make_statement_list, NIL, note_for_statement(), pips_debug, pips_internal_error, return(), statement_domain, store_cumulated_reductions(), test_false, test_true, unstructured_control, and whileloop_body.

Referenced by cumulated_reductions().

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

◆ compute_one_summary_reduction()

static reduction compute_one_summary_reduction ( reduction  model,
list  le 
)
static

keep the entities that are exported...

Parameters
leof effect

Definition at line 63 of file reductions.c.

64 {
65  reduction r = copy_reduction(model);
66 
67  /* keep the entities that are exported... */
71  }
72 
75 
76  DEBUG_REDUCTION(3, "result\n", r);
77  return r;
78 }
reduction copy_reduction(reduction p)
REDUCTION.
bool effects_may_read_or_write_memory_paths_from_entity_p(list l_eff, entity e)
tests whether the input effects list may contain effects with a memory path from the input entity e; ...
Definition: conflicts.c:1130
#define DEBUG_REDUCTION(level, msg, red)
quick debug macros
void remove_variable_from_reduction(reduction, entity)
Definition: utils.c:130
#define reduction_dependences(x)

References copy_reduction(), DEBUG_REDUCTION, effects_may_read_or_write_memory_paths_from_entity_p(), ENTITY, FOREACH, gen_free_list(), NIL, reduction_dependences, and remove_variable_from_reduction().

Referenced by compute_summary_reductions().

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

◆ compute_proper_reductions()

static void compute_proper_reductions ( statement  s)
static

performs the computation of proper reductions for statement s.

this is a direct computation, throught gen_multi_recurse.

Definition at line 342 of file reductions.c.

343 {
344  make_crt_stat_stack();
348  NULL);
349  free_crt_stat_stack();
350 }
void gen_multi_recurse(void *o,...)
Multi recursion visitor function.
Definition: genClib.c:3428
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
static bool pr_call_flt(call c)
Definition: reductions.c:309
static void pr_statement_wrt(statement s)
Definition: reductions.c:298
static bool pr_statement_flt(statement s)
Definition: reductions.c:288
#define call_domain
newgen_callees_domain_defined
Definition: ri.h:58

References call_domain, gen_multi_recurse(), gen_null(), pr_call_flt(), pr_statement_flt(), pr_statement_wrt(), and statement_domain.

Referenced by proper_reductions().

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

◆ compute_summary_reductions()

static reductions compute_summary_reductions ( entity  f)
static

of effect

of reduction

Definition at line 81 of file reductions.c.

82 {
83  list /* of effect */ le = load_summary_effects(f);
84  list /* of reduction */ lr = NIL, lc;
85 
86  lc = reductions_list
88 
89  pips_debug(3, "module %s: %td cumulated reductions\n",
90  entity_name(f), gen_length(lc));
91 
92  FOREACH(REDUCTION, r,lc) {
93  DEBUG_REDUCTION(4, "considering\n", r);
96  }
97 
98  return make_reductions(lr);
99 }
list load_summary_effects(entity e)
FI->FI, FI->BC: these two functions should be moved into effects-util or effects-simple.
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
static reduction compute_one_summary_reduction(reduction model, list le)
Definition: reductions.c:63
#define entity_name(x)
Definition: ri.h:2790

References compute_one_summary_reduction(), CONS, DEBUG_REDUCTION, effects_may_read_or_write_memory_paths_from_entity_p(), entity_name, f(), FOREACH, gen_length(), get_current_module_statement(), load_cumulated_reductions(), load_summary_effects(), make_reductions(), NIL, pips_debug, REDUCTION, reduction_variable, and reductions_list.

Referenced by summary_reductions().

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

◆ cumulated_reductions()

bool cumulated_reductions ( const char *  module_name)

handler for pipsmake input: the module name output: TRUE side effects: some

  • requires CODE, PROPER_{EFFECTS,REDUCTIONS} and CUMULATED_EFFECTS
  • returns CUMULATED_REDUCTIONS to pips dbm

gets what is needed from PIPS DBM

do the job here

returns the result to the DBM...

Parameters
module_nameodule_name

Definition at line 529 of file reductions.c.

530 {
531  debug_on("REDUCTIONS_DEBUG_LEVEL");
532  pips_debug(1, "considering module %s\n", module_name);
533 
536 
537  /* gets what is needed from PIPS DBM
538  */
541  db_get_memory_resource(DBR_CODE, module_name, true));
543  db_get_memory_resource(DBR_PROPER_REFERENCES, module_name, true));
545  db_get_memory_resource(DBR_CUMULATED_EFFECTS, module_name, true));
547  db_get_memory_resource(DBR_PROPER_REDUCTIONS, module_name, true));
548 
549  /* do the job here
550  */
552 
553  /* returns the result to the DBM...
554  */
556  (DBR_CUMULATED_REDUCTIONS, module_name, get_cumulated_reductions());
557 
565 
566  debug_off();
567  return true;
568 }
void set_rw_effects(statement_effects)
void set_proper_references(statement_effects)
void reset_proper_references(void)
void generic_effects_reset_all_methods(void)
void reset_rw_effects(void)
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
#define gen_recurse(start, domain_number, flt, rwt)
Definition: genC.h:283
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
void reset_current_module_statement(void)
Reset the current module statement.
Definition: static.c:221
statement set_current_module_statement(statement)
Set the current module statement.
Definition: static.c:165
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
Definition: genClib.c:2780
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160
static void compute_cumulated_reductions(instruction i)
Cumulated Reduction propagation functions for each possible instructions.
Definition: reductions.c:486
static void set_generic_effects_as_needed(void)
for CONTROL_MAP()
Definition: reductions.c:41
void reset_cumulated_reductions(void)
void init_cumulated_reductions(void)
void reset_proper_reductions(void)
pstatement_reductions get_cumulated_reductions(void)
void set_proper_reductions(pstatement_reductions)
entity local_name_to_top_level_entity(const char *n)
This function try to find a top-level entity from a local name.
Definition: entity.c:1450
#define instruction_domain
newgen_functional_domain_defined
Definition: ri.h:202

References compute_cumulated_reductions(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, gen_recurse, gen_true(), generic_effects_reset_all_methods(), get_cumulated_reductions(), get_current_module_statement(), init_cumulated_reductions(), instruction_domain, local_name_to_top_level_entity(), module_name(), pips_debug, reset_cumulated_reductions(), reset_current_module_entity(), reset_current_module_statement(), reset_proper_reductions(), reset_proper_references(), reset_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_generic_effects_as_needed(), set_proper_reductions(), set_proper_references(), and set_rw_effects().

+ Here is the call graph for this function:

◆ list_of_compatible_reductions()

static list list_of_compatible_reductions ( reductions  rs)
static

returns NIL on any problem

Definition at line 187 of file reductions.c.

187  {
188  list lnr=NIL, le = add_reduced_variables(NIL, rs);
189 
190  FOREACH(ENTITY, var,le) {
192  if (r) {
193  lnr = CONS(REDUCTION, r, lnr);
194  } else {
195  gen_free_list(le);
196  gen_full_free_list(lnr);
197  return NIL;
198  }
199  }
200  gen_free_list(le);
201 
202  return lnr;
203 }
static list add_reduced_variables(list le, reductions rs)
Function storing Proper Reductions.
Definition: reductions.c:144
static reduction compatible_reduction_of_var(entity var, reductions rs)
Returns NULL if not ok.
Definition: reductions.c:174

References add_reduced_variables(), compatible_reduction_of_var(), CONS, ENTITY, FOREACH, gen_free_list(), gen_full_free_list(), NIL, and REDUCTION.

Referenced by check_proper_reductions().

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

◆ list_of_reduced_variables()

static list list_of_reduced_variables ( statement  node,
list  ls 
)
static

of entity

of entity

Parameters
lsof statement

Definition at line 155 of file reductions.c.

158 {
159  list /* of entity */ le = NIL;
161  FOREACH (STATEMENT, s, ls) {
164  else {
165  pips_debug(5, "stat %s %p\n", note_for_statement(s), s);
166  pips_assert ("should not happen, all statements should have been visited for reduction", false);
167  }
168  }
169  return le;
170 }

References add_reduced_variables(), bound_cumulated_reductions_p(), FOREACH, load_cumulated_reductions(), load_proper_reductions(), NIL, node(), note_for_statement(), pips_assert, pips_debug, and STATEMENT.

Referenced by build_creductions_of_statement().

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

◆ list_of_trusted_references()

static list list_of_trusted_references ( reductions  rs)
static

???

Definition at line 205 of file reductions.c.

205  {
206  list lr = NIL;
209  lr = CONS(REFERENCE, preference_reference(p), lr);
210  }
211  lr = CONS(REFERENCE, reduction_reference(r), lr); /* ??? */
212  }
213  return lr;
214 }
#define reduction_reference(x)
#define reduction_trusted(x)
#define PREFERENCE(x)
PREFERENCE.
Definition: ri.h:2073
#define REFERENCE(x)
REFERENCE.
Definition: ri.h:2296
#define preference_reference(x)
Definition: ri.h:2102

References CONS, FOREACH, NIL, PREFERENCE, preference_reference, REDUCTION, reduction_reference, reduction_trusted, reductions_list, and REFERENCE.

Referenced by safe_effects_for_reductions().

+ Here is the caller graph for this function:

◆ load_summary_reductions()

reductions load_summary_reductions ( entity  f)

Fortran 77 anti aliasing rules implies that sg that looks like a reduction within a subroutine can be perceived as so from outside because no aliasing may cause the accumulator to be linked to the rhs of the accumulation...

reductions.c

thus summary reductions can be propagated with no harm... just the usual conditions must be checked (no other effect on the variable)

Definition at line 55 of file reductions.c.

56 {
57  pips_assert("is a module", entity_module_p(f));
59  (DBR_SUMMARY_REDUCTIONS, module_local_name(f), true);
60 }
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
bool entity_module_p(entity e)
Definition: entity.c:683

References db_get_memory_resource(), entity_module_p(), f(), module_local_name(), and pips_assert.

Referenced by translate_reductions().

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

◆ pr_call_flt()

static bool pr_call_flt ( call  c)
static

Definition at line 309 of file reductions.c.

310 {
311  statement head = crt_stat_head();
312  reductions reds = load_proper_reductions(head);
313  reduction red;
314 
315  pips_debug(9, "considering call to %s\n", entity_name(call_function(c)));
316 
317  if (call_proper_reduction_p(head, c, &red)) {
318  // direct proper reduction
319  reductions_list(reds) =
320  CONS(REDUCTION, red, reductions_list(reds));
321  }
322  else if (entity_module_p(call_function(c)))
323  {
325  reductions_list(reds) =
327  } else {
328  ifdebug(4) {
329  pips_debug(4,"Reductions for statement are:\n");
330  FOREACH(REDUCTION, r,reductions_list(reds)) {
331  DEBUG_REDUCTION(0, "considering\n", r);
332  }
333  }
334  }
335 
336  return true;
337 }
list translate_reductions(call c)
of reduction
Definition: call.c:112
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
static call last_translated_module_call
hack: no check for direct translations ("call foo") thus in this case effects reductions will be okay...
Definition: reductions.c:279
bool call_proper_reduction_p(statement, call, reduction *)
This function look for a reduction and return it if found mallocs are avoided if nothing is found....
Definition: utils.c:633
#define call_function(x)
Definition: ri.h:709
#define ifdebug(n)
Definition: sg.c:47

References call_function, call_proper_reduction_p(), CONS, DEBUG_REDUCTION, entity_module_p(), entity_name, FOREACH, gen_nconc(), ifdebug, last_translated_module_call, load_proper_reductions(), pips_debug, REDUCTION, reductions_list, and translate_reductions().

Referenced by compute_proper_reductions().

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

◆ pr_statement_flt()

static bool pr_statement_flt ( statement  s)
static

Definition at line 288 of file reductions.c.

289 {
291  // crt_stat_filter simply push on the stack and return true
292  return crt_stat_filter(s);
293 }
void store_proper_reductions(statement, reductions)

References make_reductions(), NIL, and store_proper_reductions().

Referenced by compute_proper_reductions().

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

◆ pr_statement_wrt()

static void pr_statement_wrt ( statement  s)
static

Definition at line 298 of file reductions.c.

299 {
301  if (instruction_call_p(i) &&
304  // crt_stat_rewrite pops from the stack and chek that s
305  // was the latest pushed object
306  crt_stat_rewrite(s);
307 }
static void check_proper_reductions(statement s)
must check that the found reductions are (1) without side effects (no W on any other than accumulator...
Definition: reductions.c:250
#define instruction_call_p(x)
Definition: ri.h:1527
#define statement_instruction(x)
Definition: ri.h:2458
#define instruction_call(x)
Definition: ri.h:1529

References check_proper_reductions(), instruction_call, instruction_call_p, last_translated_module_call, and statement_instruction.

Referenced by compute_proper_reductions().

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

◆ proper_reductions()

bool proper_reductions ( const char *  module_name)

handler for pipsmake input: module name output: TRUE side effects: some

  • requires CODE PROPER_EFFECTS and callees' SUMMARY_{EFFECTS,REDUCTIONS}
  • returns PROPER_REDUCTIONS to pips dbm

gets what is needed from PIPS DBM

do the job

returns the result to the DBM...

Parameters
module_nameodule_name

Definition at line 359 of file reductions.c.

360 {
361  entity module;
362 
363  debug_on("REDUCTIONS_DEBUG_LEVEL");
364  pips_debug(1, "considering module %s\n", module_name);
365 
368 
369  /* gets what is needed from PIPS DBM
370  */
374  ((statement) db_get_memory_resource(DBR_CODE, module_name, true));
376  db_get_memory_resource(DBR_PROPER_REFERENCES, module_name, true));
377 
378  /* do the job
379  */
381 
382  /* returns the result to the DBM...
383  */
385  (DBR_PROPER_REDUCTIONS, module_name, get_proper_reductions());
386 
392 
393  debug_off();
394  return true;
395 }
static void compute_proper_reductions(statement s)
performs the computation of proper reductions for statement s.
Definition: reductions.c:342
static char * module
Definition: pips.c:74
void init_proper_reductions(void)
pstatement_reductions get_proper_reductions(void)

References compute_proper_reductions(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, generic_effects_reset_all_methods(), get_current_module_statement(), get_proper_reductions(), init_proper_reductions(), local_name_to_top_level_entity(), module, module_name(), pips_debug, reset_current_module_entity(), reset_current_module_statement(), reset_proper_reductions(), reset_proper_references(), set_current_module_entity(), set_current_module_statement(), set_generic_effects_as_needed(), and set_proper_references().

+ Here is the call graph for this function:

◆ reduction_operator_entity()

entity reduction_operator_entity ( reduction_operator  op)

match a reduction operator against operator entity

Parameters
opreduction operator
Returns
entity representing corresponding operator
Parameters
opp

Definition at line 577 of file reductions.c.

578 {
579  string opname = string_undefined;
580  switch( reduction_operator_tag(op) ) {
602  opname=OR_OPERATOR_NAME;break;
605  default:
606  pips_internal_error("unhandled case");
607  }
608  return entity_intrinsic(opname);
609 }
#define string_undefined
Definition: newgen_types.h:40
@ is_reduction_operator_bitwise_xor
@ is_reduction_operator_min
@ is_reduction_operator_bitwise_and
@ is_reduction_operator_neqv
@ is_reduction_operator_max
@ is_reduction_operator_bitwise_or
@ is_reduction_operator_csum
@ is_reduction_operator_eqv
@ is_reduction_operator_prod
@ is_reduction_operator_or
@ is_reduction_operator_and
@ is_reduction_operator_sum
#define reduction_operator_tag(x)
static const char * opname(const char *s)
#define BITWISE_OR_OPERATOR_NAME
#define MAX_OPERATOR_NAME
#define BITWISE_XOR_OPERATOR_NAME
#define EQUIV_OPERATOR_NAME
#define PLUS_OPERATOR_NAME
#define NON_EQUIV_OPERATOR_NAME
#define AND_OPERATOR_NAME
FI: intrinsics are defined at a third place after bootstrap and effects! I guess the name should be d...
#define MULTIPLY_OPERATOR_NAME
#define BITWISE_AND_OPERATOR_NAME
#define OR_OPERATOR_NAME
#define PLUS_C_OPERATOR_NAME
#define MIN_OPERATOR_NAME
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292

References AND_OPERATOR_NAME, BITWISE_AND_OPERATOR_NAME, BITWISE_OR_OPERATOR_NAME, BITWISE_XOR_OPERATOR_NAME, entity_intrinsic(), EQUIV_OPERATOR_NAME, is_reduction_operator_and, is_reduction_operator_bitwise_and, is_reduction_operator_bitwise_or, is_reduction_operator_bitwise_xor, is_reduction_operator_csum, is_reduction_operator_eqv, is_reduction_operator_max, is_reduction_operator_min, is_reduction_operator_neqv, is_reduction_operator_or, is_reduction_operator_prod, is_reduction_operator_sum, MAX_OPERATOR_NAME, MIN_OPERATOR_NAME, MULTIPLY_OPERATOR_NAME, NON_EQUIV_OPERATOR_NAME, opname(), OR_OPERATOR_NAME, pips_internal_error, PLUS_C_OPERATOR_NAME, PLUS_OPERATOR_NAME, reduction_operator_tag, and string_undefined.

Referenced by do_expression_reduction(), do_reduction_atomization(), and do_reduction_propagation().

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

◆ safe_effects_for_reductions()

static bool safe_effects_for_reductions ( statement  s,
reductions  rs 
)
static

argh...

what about side effect related reductions ??? There are no relevant pointer to trust in such a case... What I can do as a (temporary) fix is not to check direct side effects (that is "call foo" ones) because they do not need to be checked...

of effect

of reference

Definition at line 222 of file reductions.c.

222  {
223  list /* of effect */ le = effects_effects(load_proper_references(s)),
224  /* of reference */ lr = list_of_trusted_references(rs);
225 
226  FOREACH(EFFECT, e,le) {
229  pips_debug(8, "effect on %s (ref %p) not trusted\n",
232 
233  gen_free_list(lr);
234  return false;
235  }
236  }
237 
238  gen_free_list(lr);
239  return true;
240 }
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
#define effect_write_p(eff)
#define effect_variable(e)
For COMPATIBILITY purpose only - DO NOT USE anymore.
bool store_effect_p(effect)
Definition: effects.c:1062
bool io_effect_entity_p(entity)
Definition: effects.c:496
#define EFFECT(x)
EFFECT.
Definition: effects.h:608
bool gen_in_list_p(const void *vo, const list lx)
tell whether vo belongs to lx
Definition: list.c:734
static list list_of_trusted_references(reductions rs)
Definition: reductions.c:205

References EFFECT, effect_any_reference, effect_variable, effect_write_p, effects_effects, entity_name, FOREACH, gen_free_list(), gen_in_list_p(), io_effect_entity_p(), list_of_trusted_references(), load_proper_references(), pips_debug, and store_effect_p().

Referenced by check_proper_reductions().

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

◆ same_reduction_p()

bool same_reduction_p ( reduction  r1,
reduction  r2 
)
Parameters
r11
r22

Definition at line 611 of file reductions.c.

612 {
615 }
#define reduction_op(x)
bool reference_equal_p(reference r1, reference r2)
Definition: expression.c:1500

References reduction_op, reduction_operator_tag, reduction_reference, and reference_equal_p().

Referenced by add_reduction().

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

◆ set_generic_effects_as_needed()

static void set_generic_effects_as_needed ( void  )
static

for CONTROL_MAP()

for load_summary_effects()

Definition at line 41 of file reductions.c.

42 {
44 }
effect(* effect_dup_func)(effect eff)
effect simple_effect_dup(effect)

References effect_dup_func, and simple_effect_dup().

Referenced by cumulated_reductions(), proper_reductions(), and summary_reductions().

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

◆ summary_reductions()

bool summary_reductions ( const char *  module_name)

handler for pipsmake input: module name output: TRUE side effects: stores the summary reductions to pipsdbm

Parameters
module_nameodule_name

Definition at line 106 of file reductions.c.

107 {
108  reductions red;
109 
110  debug_on("REDUCTIONS_DEBUG_LEVEL");
111  pips_debug(1, "considering module %s\n", module_name);
112 
116  db_get_memory_resource(DBR_CODE, module_name, true));
118  db_get_memory_resource(DBR_CUMULATED_REDUCTIONS, module_name, true));
119 
121 
122  DB_PUT_MEMORY_RESOURCE(DBR_SUMMARY_REDUCTIONS, module_name, red);
123 
128 
129  debug_off();
130  return true;
131 }
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
static reductions compute_summary_reductions(entity f)
Definition: reductions.c:81
void set_cumulated_reductions(pstatement_reductions)

References compute_summary_reductions(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, generic_effects_reset_all_methods(), get_current_module_entity(), local_name_to_top_level_entity(), module_name(), pips_debug, reset_cumulated_reductions(), reset_current_module_entity(), reset_current_module_statement(), set_cumulated_reductions(), set_current_module_entity(), set_current_module_statement(), and set_generic_effects_as_needed().

+ Here is the call graph for this function:

Variable Documentation

◆ last_translated_module_call

call last_translated_module_call = call_undefined
static

hack: no check for direct translations ("call foo") thus in this case effects reductions will be okay...

the reason for the patch is that I do not know how to preserve easily such "invisible" reductions against proper effects. FC.

Definition at line 279 of file reductions.c.

Referenced by pr_call_flt(), and pr_statement_wrt().