PIPS
reductions.h File Reference
+ Include dependency graph for reductions.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define reduction_variable(r)   reference_variable(reduction_reference(r))
 Warning! Do not modify this file that is automatically generated! More...
 
#define reduction_none_p(r)   reduction_operator_none_p(reduction_op(r))
 
#define reduction_tag(r)   reduction_operator_tag(reduction_op(r))
 
#define make_none_reduction(var)
 
#define DEBUG_REDUCTION(level, msg, red)    ifdebug(level){pips_debug(level, msg); print_reduction(red);}
 quick debug macros More...
 
#define DEBUG_REDUCTIONS(level, msg, reds)
 

Functions

bool replace_reduction_with_atomic (string)
 end of it More...
 
bool flag_parallel_reduced_loops_with_atomic (string)
 Flag loop as parallel when replacement with atomic is possible without doing the replacement. More...
 
bool flag_parallel_reduced_loops_with_openmp_directives (const char *)
 Flag loop as parallel with OpenMP directives taking reductions into account. More...
 
bool old_reductions (string)
 stub.c More...
 
reductions load_summary_reductions (entity)
 reductions.c More...
 
bool summary_reductions (const char *)
 handler for pipsmake input: module name output: TRUE side effects: stores the summary reductions to pipsdbm More...
 
bool proper_reductions_undefined_p (void)
 
void reset_proper_reductions (void)
 
void error_reset_proper_reductions (void)
 
void set_proper_reductions (pstatement_reductions)
 
pstatement_reductions get_proper_reductions (void)
 
void init_proper_reductions (void)
 
void close_proper_reductions (void)
 
void store_proper_reductions (statement, reductions)
 
void update_proper_reductions (statement, reductions)
 
reductions load_proper_reductions (statement)
 
reductions delete_proper_reductions (statement)
 
bool bound_proper_reductions_p (statement)
 
void store_or_update_proper_reductions (statement, reductions)
 
bool proper_reductions (const char *)
 handler for pipsmake input: module name output: TRUE side effects: some More...
 
bool cumulated_reductions_undefined_p (void)
 
void reset_cumulated_reductions (void)
 
void error_reset_cumulated_reductions (void)
 
void set_cumulated_reductions (pstatement_reductions)
 
pstatement_reductions get_cumulated_reductions (void)
 
void init_cumulated_reductions (void)
 
void close_cumulated_reductions (void)
 
void store_cumulated_reductions (statement, reductions)
 
void update_cumulated_reductions (statement, reductions)
 
reductions load_cumulated_reductions (statement)
 
reductions delete_cumulated_reductions (statement)
 
bool bound_cumulated_reductions_p (statement)
 
void store_or_update_cumulated_reductions (statement, reductions)
 
bool cumulated_reductions (const char *)
 handler for pipsmake input: the module name output: TRUE side effects: some More...
 
entity reduction_operator_entity (reduction_operator)
 match a reduction operator against operator entity More...
 
bool same_reduction_p (reduction, reduction)
 
bool reduction_star_p (reduction)
 utils.c More...
 
void remove_variable_from_reduction (reduction, entity)
 
bool update_reduction_under_effect (reduction, effect)
 
bool update_compatible_reduction_with (reduction *, entity, reduction)
 update *pr according to r for variable var r is not touched. More...
 
bool update_compatible_reduction (reduction *, entity, list, reductions)
 what to do with reduction *pr for variable var under effects le and reductions reds. More...
 
bool pure_function_p (entity)
 extract the proper reduction of a call (instruction) if any. More...
 
bool no_other_effects_on_references (statement, list)
 checks that the references are the only touched within this statement. More...
 
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... More...
 
expression get_complement_expression (statement, reference)
 Return the "other part" of the reduction. More...
 
bool loop_reductions (string)
 transformation.c More...
 
list reductions_get_omp_pragma_expr (loop, statement, bool)
 pragma.c More...
 
string reductions_get_omp_pragma_str (loop, statement)
 
bool omp_pragma_expr_for_reduction (loop, statement, bool)
 generate pragma for a reduction as a list of expressions More...
 
bool omp_pragma_expr_for (loop, statement)
 generate "pragma omp for" as a list of expressions More...
 
bool printed_reductions_undefined_p (void)
 prettyprint.c More...
 
void reset_printed_reductions (void)
 
void error_reset_printed_reductions (void)
 
void set_printed_reductions (pstatement_reductions)
 
pstatement_reductions get_printed_reductions (void)
 
void init_printed_reductions (void)
 
void close_printed_reductions (void)
 
void store_printed_reductions (statement, reductions)
 
void update_printed_reductions (statement, reductions)
 
reductions load_printed_reductions (statement)
 
reductions delete_printed_reductions (statement)
 
bool bound_printed_reductions_p (statement)
 
void store_or_update_printed_reductions (statement, reductions)
 
string note_for_statement (statement)
 generates a short note to tell about the type of the statement being decorated. More...
 
string reduction_operator_tag_name (tag)
 returns a (static) string describing the tag t reduction More...
 
string reduction_operator_name (reduction_operator)
 allocates and returns the name of the operator More...
 
string reduction_name (reduction)
 returns the name of the reduction (!!! not allocated) More...
 
void print_reduction (reduction)
 
bool print_code_proper_reductions (const char *)
 Handlers for PIPSMAKE. More...
 
bool print_code_cumulated_reductions (const char *)
 
list summary_to_proper_reference (call, reference)
 call.c More...
 
list translate_reductions (call)
 of reduction More...
 
bool reduction_propagation (const char *)
 propagation.c More...
 
bool reduction_detection (const char *)
 

Macro Definition Documentation

◆ DEBUG_REDUCTION

#define DEBUG_REDUCTION (   level,
  msg,
  red 
)     ifdebug(level){pips_debug(level, msg); print_reduction(red);}

quick debug macros

Definition at line 45 of file reductions.h.

◆ DEBUG_REDUCTIONS

#define DEBUG_REDUCTIONS (   level,
  msg,
  reds 
)
Value:
gen_map(print_reduction, reductions_list(reds));}
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
void print_reduction(reduction)
Definition: prettyprint.c:137
#define reductions_list(x)
#define level
#define ifdebug(n)
Definition: sg.c:47

Definition at line 47 of file reductions.h.

◆ make_none_reduction

#define make_none_reduction (   var)
Value:
NIL, NIL)
reduction_operator make_reduction_operator(enum reduction_operator_utype tag, void *val)
reduction make_reduction(reference a1, reduction_operator a2, list a3, list a4)
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define UU
Definition: newgen_types.h:98
@ is_reduction_operator_none

Definition at line 38 of file reductions.h.

◆ reduction_none_p

#define reduction_none_p (   r)    reduction_operator_none_p(reduction_op(r))

Definition at line 36 of file reductions.h.

◆ reduction_tag

#define reduction_tag (   r)    reduction_operator_tag(reduction_op(r))

Definition at line 37 of file reductions.h.

◆ reduction_variable

#define reduction_variable (   r)    reference_variable(reduction_reference(r))

Warning! Do not modify this file that is automatically generated!

Modify src/Libs/reductions/reductions-local.h instead, to add your own modifications. header file built by cproto reductions-local.h shorthands for REDUCTION:

Definition at line 35 of file reductions.h.

Function Documentation

◆ bound_cumulated_reductions_p()

bool bound_cumulated_reductions_p ( statement  )

Referenced by build_reduction_of_variable(), and list_of_reduced_variables().

+ Here is the caller graph for this function:

◆ bound_printed_reductions_p()

bool bound_printed_reductions_p ( statement  )

Referenced by statement_is_reduction(), and text_reductions().

+ Here is the caller graph for this function:

◆ bound_proper_reductions_p()

bool bound_proper_reductions_p ( statement  )

◆ call_proper_reduction_p()

bool call_proper_reduction_p ( statement  s,
call  c,
reduction red 
)

This function look for a reduction and return it if found mallocs are avoided if nothing is found...

looks for v = v OP y or v OP= y, where y is independent of v.

Returns
true if the call in s a reduction
Parameters
s
Parameters
cneeded to query about proper effects
redthe call of interest

Definition at line 633 of file utils.c.

637 {
638  tag op; // The operator tag (sum, mul ...)
639  list le = NIL; // list of expression
640  list lr = NIL; // list of reference
641  list lp = NIL; // list of Preference
642  bool comm = false; // The commutatity operator flag
643  bool assign_op = false; // The assign operator flag
644  bool update_op = false; // The reduction update operator flag;
645  bool unary_op = false; // The reduction unary update operator flag;
646  entity fct = call_function(c); // the call function to test for reduction
651 
652  pips_debug(7, "call to %s (%p)\n", entity_name(call_function(c)), s);
653 
654  // First init the operation flags
655  // only check the operator type if the previous test failed
656  if ((assign_op = ENTITY_ASSIGN_P (fct)) == false)
657  if ((update_op=extract_reduction_update_operator(fct, &op, &comm))==false)
658  unary_op = extract_reduction_unary_update_operator (fct, &op);
659 
660  // if no suitable operator has been found : return false
661  if ((unary_op == false) && (update_op == false) && (assign_op == false)) {
662  pips_debug(5,"No unary, nor update, no assign !\n");
663  return false;
664  }
665 
666  // get the left and right operands
667  le = call_arguments(c);
668  elhs = EXPRESSION(CAR(le));
669  //no right operand for unary operator
670  if (unary_op == false) erhs = EXPRESSION(CAR(CDR(le)));
671  if (syntax_reference_p(expression_syntax(elhs)) == false) {
672  pips_user_warning ("The left hand side of assignment is not a reference, "
673  "this is not handled and no reduction will be detected\n");
674  return false;
675  }
676  lhs = syntax_reference(expression_syntax(elhs));
677 
678  // the lhs and rhs (if exits) must be functionnal
679  // (same location on different evaluations)
680  if (!functional_object_p((gen_chunk *) lhs) ||
681  ((unary_op == false) && !functional_object_p((gen_chunk *) erhs))) {
682  pips_debug(5,"Lhs or Rhs not functional !\n");
683  return false;
684  }
685  pips_debug(8, "lhs and rhs are functional\n");
686 
687  // Check that the operation performed is valid for a reduction,
688  // The check is useless for reduction update and unary operator because
689  // already done previously by "extract_reduction_update_operator" and
690  // "extract_reduction_unary_update_operator"
691  if ((unary_op == false) && (update_op == false) &&
692  (extract_reduction_operator(erhs, &op, &comm) == false)) {
693  pips_debug(5,"extract_reduction_operator returned false !!\n");
694  return false;
695  }
696  pips_debug(8, "reduction operator %s\n", reduction_operator_tag_name(op));
697 
698  // there should be another direct reference to lhs if not unary
699  // !!! syntax is a call if extract_reduction_operator returned TRUE
700  if (unary_op == false) {
701  if (!equal_reference_in_expression_p(lhs, erhs, op, update_op, &other)) {
702  pips_debug(5,"!equal_reference_in_expression_p !!\n");
703  return false;
704  }
705  pips_debug(8, "matching reference found (%p)\n", other);
706  }
707 
708  // build the list of found reference to the reduced variable
709  if ((update_op == true) || (unary_op == true))
710  lr = CONS(REFERENCE, lhs, NIL);
711  else
712  lr = CONS(REFERENCE, lhs, CONS(REFERENCE, other, NIL));
713  pips_debug(7,"list lr is: %p and %p\n", other, lhs);
714  // there should be no extra effects on the reduced variable
715  if (!no_other_effects_on_references (s, lr)) {
716  pips_debug(5,"Other effects on references !!\n");
717  gen_free_list(lr);
718  return false;
719  }
720  pips_debug(8, "no other effects\n");
721 
722  FOREACH (REFERENCE, r, lr) {
723  lp = CONS(PREFERENCE, make_preference(r), lp);
724  }
725  gen_free_list(lr), lr = NIL;
726 
727  // well, it is ok for a reduction now!
728  *red = make_reduction(copy_reference(lhs),
731  lp);
732 
733  DEBUG_REDUCTION(7, "returning\n", *red);
734  return true;
735 }
reference copy_reference(reference p)
REFERENCE.
Definition: ri.c:2047
preference make_preference(reference a1)
Definition: ri.c:1862
void update_op(int op, char *error_msg)
UPDATE_OP checks whether the just read OPerator is compatible with the current one.
Definition: genspec_yacc.c:120
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#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 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 CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
#define pips_user_warning
Definition: misc-local.h:146
int tag
TAG.
Definition: newgen_types.h:92
#define DEBUG_REDUCTION(level, msg, red)
quick debug macros
string reduction_operator_tag_name(tag t)
returns a (static) string describing the tag t reduction
Definition: prettyprint.c:78
bool no_other_effects_on_references(statement s, list lr)
checks that the references are the only touched within this statement.
Definition: utils.c:596
static bool functional_object_p(gen_chunk *obj)
Definition: utils.c:379
static bool extract_reduction_update_operator(entity operator, tag *op_tag, bool *commutative)
Test if the operator is an update operator compatible with reduction This also returns the correspond...
Definition: utils.c:459
static list referenced_variables(reference r)
of entity
Definition: utils.c:65
static bool extract_reduction_operator(expression e, tag *op_tag, bool *commutative)
returns the possible operator of expression e if it is a reduction, and the operation commutative.
Definition: utils.c:437
static bool equal_reference_in_expression_p(reference r, expression e, tag rop, bool red_up_op, reference *pfound)
returned
Definition: utils.c:570
static bool extract_reduction_unary_update_operator(entity operator, tag *op_tag)
Test if the operator is an unary update operator compatible with reduction This also returns the corr...
Definition: utils.c:487
#define ENTITY_ASSIGN_P(e)
#define PREFERENCE(x)
PREFERENCE.
Definition: ri.h:2073
#define syntax_reference_p(x)
Definition: ri.h:2728
#define REFERENCE(x)
REFERENCE.
Definition: ri.h:2296
#define syntax_reference(x)
Definition: ri.h:2730
#define reference_undefined
Definition: ri.h:2302
#define call_function(x)
Definition: ri.h:709
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define expression_undefined
Definition: ri.h:1223
#define entity_name(x)
Definition: ri.h:2790
#define call_arguments(x)
Definition: ri.h:711
#define expression_syntax(x)
Definition: ri.h:1247
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
A gen_chunk is used to store every object.
Definition: genC.h:58

References call_arguments, call_function, CAR, CDR, CONS, copy_reference(), DEBUG_REDUCTION, ENTITY_ASSIGN_P, entity_name, equal_reference_in_expression_p(), EXPRESSION, expression_syntax, expression_undefined, extract_reduction_operator(), extract_reduction_unary_update_operator(), extract_reduction_update_operator(), FOREACH, functional_object_p(), gen_free_list(), make_preference(), make_reduction(), make_reduction_operator(), NIL, no_other_effects_on_references(), pips_debug, pips_user_warning, PREFERENCE, reduction_operator_tag_name(), REFERENCE, reference_undefined, referenced_variables(), syntax_reference, syntax_reference_p, update_op(), and UU.

Referenced by pr_call_flt().

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

◆ close_cumulated_reductions()

void close_cumulated_reductions ( void  )

◆ close_printed_reductions()

void close_printed_reductions ( void  )

◆ close_proper_reductions()

void close_proper_reductions ( void  )

◆ 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
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
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:

◆ cumulated_reductions_undefined_p()

bool cumulated_reductions_undefined_p ( void  )

◆ delete_cumulated_reductions()

reductions delete_cumulated_reductions ( statement  )

◆ delete_printed_reductions()

reductions delete_printed_reductions ( statement  )

◆ delete_proper_reductions()

reductions delete_proper_reductions ( statement  )

◆ error_reset_cumulated_reductions()

void error_reset_cumulated_reductions ( void  )

◆ error_reset_printed_reductions()

void error_reset_printed_reductions ( void  )

◆ error_reset_proper_reductions()

void error_reset_proper_reductions ( void  )

◆ flag_parallel_reduced_loops_with_atomic()

bool flag_parallel_reduced_loops_with_atomic ( string  mod_name)

Flag loop as parallel when replacement with atomic is possible without doing the replacement.

Parameters
mod_nameod_name

Definition at line 411 of file atomic.c.

411  {
412  debug_on("FLAG_PARALLEL_REDUCED_LOOPS_WITH_ATOMIC_DEBUG_LEVEL");
413 
414  bool result = process_reduced_loops(mod_name, DO_NOT_REPLACE);
415 
416  debug_off();
417 
418  return result;
419 
420 }
static bool process_reduced_loops(const char *mod_name, process_reductions_mode mode)
Definition: atomic.c:331
@ DO_NOT_REPLACE
Definition: atomic.c:99

References debug_off, debug_on, DO_NOT_REPLACE, and process_reduced_loops().

+ Here is the call graph for this function:

◆ flag_parallel_reduced_loops_with_openmp_directives()

bool flag_parallel_reduced_loops_with_openmp_directives ( const char *  mod_name)

Flag loop as parallel with OpenMP directives taking reductions into account.

Parameters
mod_nameod_name

Definition at line 426 of file atomic.c.

426  {
427  debug_on("FLAG_PARALLEL_REDUCED_LOOPS_WITH_ATOMIC_DEBUG_LEVEL");
428 
429  bool result = process_reduced_loops(mod_name, USE_OPENMP);
430 
431  debug_off();
432 
433  return result;
434 
435 }
@ USE_OPENMP
Definition: atomic.c:100

◆ get_complement_expression()

expression get_complement_expression ( statement  s,
reference  reduced 
)

Return the "other part" of the reduction.

If the statement is : sum = sum + a[i]; then we'll return a[i]

try to find out which of the two expression corresponds to the reduced reference. We'll return the other...

Parameters
reducededuced

Definition at line 743 of file utils.c.

743  {
744  expression complement = expression_undefined;
745  // We handle only trivial cases
746  if(statement_call_p(s)) {
747  call c = statement_call(s);
748  entity fct = call_function(c);
749  list le = call_arguments(c);
750  tag op;
751  bool comm = false; // Commutativity
752  // Differentiate unary && update && binary operators
753  if (ENTITY_ASSIGN_P (fct)){
754  // Normal case, binary expected
755  expression rhs = EXPRESSION(CAR(CDR(le)));
756  if(expression_call_p(rhs)) {
757  list args = call_arguments(expression_call(rhs));
758  pips_assert("Have a binary operator\n", gen_length(args)==2);
759  /* try to find out which of the two expression corresponds to the
760  * reduced reference. We'll return the other...
761  */
762  expression e1 = EXPRESSION(CAR(args));
763  expression e2 = EXPRESSION(CAR(CDR(args)));
764  if(expression_reference_p(e1) &&
765  same_ref_name_p(reduced,expression_reference(e1))) {
766  complement = e2;
767  } else if(expression_reference_p(e2) &&
768  same_ref_name_p(reduced,expression_reference(e2))) {
769  complement = e2;
770  } else {
771  pips_user_warning("Atomic operation replacement seems less general"
772  " than reduction detection. This merits a bug report !\n");
773  }
774  } else {
775  pips_user_warning("Atomic operation replacement seems less general than"
776  " reduction detection. This merits a bug report !\n");
777  }
778  } else if(extract_reduction_unary_update_operator(fct, &op)) {
779  // ++ or -- : we return 1
780  pips_debug(3,"We have an unary operator\n");
781  complement = int_to_expression(1);
782  } else if(extract_reduction_update_operator(fct, &op, &comm)) {
783  // += or similar, return directly rhs
784  pips_debug(3,"We have an update operator\n");
785  complement = EXPRESSION(CAR(CDR(le)));
786  } else {
787  pips_internal_error("We have a reduction, but the statement is neither an"
788  " unary nor a binary ? It's a bug, sorry no choice but abort !\n");
789  }
790  }
791  return complement;
792 }
size_t gen_length(const list l)
Definition: list.c:150
call statement_call(statement)
Get the call of a statement.
Definition: statement.c:1406
bool statement_call_p(statement)
Definition: statement.c:364
#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
bool same_ref_name_p(reference, reference)
Definition: same_names.c:75
bool expression_call_p(expression e)
Definition: expression.c:415
call expression_call(expression e)
Definition: expression.c:445
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 expression_reference_p(expression e)
Test if an expression is a reference.
Definition: expression.c:528
reference expression_reference(expression e)
Short cut, meaningful only if expression_reference_p(e) holds.
Definition: expression.c:1832

References call_arguments, call_function, CAR, CDR, ENTITY_ASSIGN_P, EXPRESSION, expression_call(), expression_call_p(), expression_reference(), expression_reference_p(), expression_undefined, extract_reduction_unary_update_operator(), extract_reduction_update_operator(), gen_length(), int_to_expression(), pips_assert, pips_debug, pips_internal_error, pips_user_warning, same_ref_name_p(), statement_call(), and statement_call_p().

Referenced by replace_reductions_in_statement().

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

◆ get_cumulated_reductions()

pstatement_reductions get_cumulated_reductions ( void  )

Referenced by cumulated_reductions().

+ Here is the caller graph for this function:

◆ get_printed_reductions()

pstatement_reductions get_printed_reductions ( void  )

◆ get_proper_reductions()

pstatement_reductions get_proper_reductions ( void  )

Referenced by proper_reductions().

+ Here is the caller graph for this function:

◆ init_cumulated_reductions()

void init_cumulated_reductions ( void  )

Referenced by cumulated_reductions().

+ Here is the caller graph for this function:

◆ init_printed_reductions()

void init_printed_reductions ( void  )

◆ init_proper_reductions()

void init_proper_reductions ( void  )

Referenced by proper_reductions().

+ Here is the caller graph for this function:

◆ load_cumulated_reductions()

◆ load_printed_reductions()

reductions load_printed_reductions ( statement  )

Referenced by reductions_get_omp_pragma_expr(), reductions_get_omp_pragma_str(), statement_is_reduction(), and text_reductions().

+ Here is the caller graph for this function:

◆ load_proper_reductions()

◆ load_summary_reductions()

reductions load_summary_reductions ( entity  f)

reductions.c

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 }
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
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:

◆ loop_reductions()

bool loop_reductions ( string  module)

transformation.c

Parameters
moduleodule

Definition at line 35 of file transformation.c.

36 {
37  debug_on("REDUCTIONS_DEBUG_LEVEL");
38  pips_debug(1, "considering module %s\n", module);
39 
40  pips_assert ("not implemented yet\n", false);
41 
42  debug_off();
43  return true;
44 }
static char * module
Definition: pips.c:74

References debug_off, debug_on, module, pips_assert, and pips_debug.

◆ no_other_effects_on_references()

bool no_other_effects_on_references ( statement  s,
list  lr 
)

checks that the references are the only touched within this statement.

I trust the proper effects to store all references...

of effect

Parameters
lrof reference on the same variable

Definition at line 596 of file utils.c.

599 {
600  list /* of effect */ le;
601  entity var;
602  if (ENDP(lr)) return true;
603 
605  var = reference_variable(REFERENCE(CAR(lr)));
606 
607  pips_debug(7,"entity name: %s\n", entity_name(var));
608 
609  FOREACH (EFFECT, e, le) {
610  if(!store_effect_p(e)) continue;
612  if (!gen_in_list_p(r, lr) && store_effect_p(e) &&
614  pips_debug(7,"Effect may touch variable : ");print_effect(e);
615  return false;
616  }
617  pips_debug(7,"refrence r: %p of entity: %s\n", r, entity_name (reference_variable(r)));
618  }
619 
620  return true;
621 }
effects load_proper_references(statement)
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
bool store_effect_p(effect)
Definition: effects.c:1062
#define effects_effects(x)
Definition: effects.h:710
#define EFFECT(x)
EFFECT.
Definition: effects.h:608
bool entities_may_conflict_p(entity e1, entity e2)
Check if two entities may conflict.
Definition: conflicts.c:984
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
bool gen_in_list_p(const void *vo, const list lx)
tell whether vo belongs to lx
Definition: list.c:734
#define print_effect(e)
Definition: print.c:336
#define reference_variable(x)
Definition: ri.h:2326

References CAR, EFFECT, effect_any_reference, effects_effects, ENDP, entities_may_conflict_p(), entity_name, FOREACH, gen_in_list_p(), load_proper_references(), pips_debug, print_effect, REFERENCE, reference_variable, and store_effect_p().

Referenced by call_proper_reduction_p().

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

◆ note_for_statement()

string note_for_statement ( statement  s)

generates a short note to tell about the type of the statement being decorated.

Definition at line 55 of file prettyprint.c.

56 {
58  switch (instruction_tag(i))
59  {
60  case is_instruction_sequence: return "seq ";
61  case is_instruction_loop: return "loop ";
62  case is_instruction_test: return "test ";
63  case is_instruction_call: return "call ";
64  case is_instruction_unstructured: return "unst ";
65  case is_instruction_whileloop: return "while ";
66  case is_instruction_goto: return "goto ";
67  case is_instruction_forloop: return "for ";
68  case is_instruction_expression: return "expr ";
69  default:
70  pips_internal_error("unexpected instruction tag");
71  break;
72  }
73  return "";
74 }
@ is_instruction_goto
Definition: ri.h:1473
@ 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 statement_instruction(x)
Definition: ri.h:2458

References instruction_tag, is_instruction_call, is_instruction_expression, is_instruction_forloop, is_instruction_goto, is_instruction_loop, is_instruction_sequence, is_instruction_test, is_instruction_unstructured, is_instruction_whileloop, pips_internal_error, and statement_instruction.

Referenced by build_creductions_of_statement(), build_reduction_of_variable(), compute_cumulated_reductions(), list_of_reduced_variables(), and text_reductions().

+ Here is the caller graph for this function:

◆ old_reductions()

bool old_reductions ( string  mod_name)

stub.c

true or FALSE? After all, it's just a user warning, not an error

Parameters
mod_nameod_name

Definition at line 63 of file stub.c.

64 {
65  string program_name = db_get_current_workspace_name() ;
66  char *command ;
67  struct stat buf ;
68  char *options ;
70 
71  if( stat( LISP, &buf ) != 0 ) {
72  user_warning("reductions",
73  "No lisp! Skipping reduction detection\n") ;
74  /* true or FALSE? After all, it's just a user warning, not an error */
75  return false;
76  }
77  debug_on("REDUCTIONS_DEBUG_LEVEL");
78  db_close_workspace(false) ;
79  options = (get_debug_level() <= 5) ? " -batch" : "" ;
80  asprintf(&command,
81  "(echo \"(defparameter files-directory \\\"%s\\\")\
82  (load (concatenate %s files-directory \\\"/init\\\"))\
83  (load (concatenate %s files-directory \\\"/top\\\"))\
84  (reductions t \\\"%s\\\" \\\"%s\\\")\") | %s%s",
86  "'string",
87  "'string",
88  program_name,
89  mod_name,
90  LISP,
91  options ) ;
92  debug( 5, "reductions", "\ncommand = %s\n", command ) ;
93 
94  if( (system( command ) >> 8) != 0 ) {
95  pips_internal_error("Lisp process died unexpectedly" ) ;
96  }
97  free(command);
98  debug_off();
99  db_open_workspace( program_name ) ;
100  mod_stat = (statement)
101  db_get_memory_resource(DBR_CODE, mod_name, true);
103  DB_PUT_MEMORY_RESOURCE(DBR_CODE, strdup(mod_name), mod_stat);
104 
105  return true;
106 }
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
void free(void *)
static statement mod_stat
We want to keep track of the current statement inside the recurse.
Definition: impact_check.c:41
#define asprintf
Definition: misc-local.h:225
#define user_warning(fn,...)
Definition: misc-local.h:262
int get_debug_level(void)
GET_DEBUG_LEVEL returns the current debugging level.
Definition: debug.c:67
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
bool db_close_workspace(bool)
Definition: workspace.c:367
bool db_open_workspace(const char *)
Definition: workspace.c:380
string db_get_current_workspace_name(void)
the function is used to check that there is some current workspace...
Definition: workspace.c:82
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
Definition: reorder.c:244
char * strdup()
static char buf[BSZ]
Definition: split_file.c:157
#define LISP
Definition: stub.c:58
#define REDUCTIONS_SOURCE_DIRECTORY
Definition: stub.c:60

References asprintf, buf, db_close_workspace(), db_get_current_workspace_name(), db_get_memory_resource(), db_open_workspace(), DB_PUT_MEMORY_RESOURCE, debug(), debug_off, debug_on, free(), get_debug_level(), LISP, mod_stat, module_reorder(), pips_internal_error, REDUCTIONS_SOURCE_DIRECTORY, strdup(), and user_warning.

+ Here is the call graph for this function:

◆ omp_pragma_expr_for()

bool omp_pragma_expr_for ( loop  l,
statement  stmt 
)

generate "pragma omp for" as a list of expressions

Returns
true if a pragma has been generated
Parameters
l,theloop to analyze for omp for
stmt,thestatament where the pragma should be attached
Parameters
stmttmt

Definition at line 366 of file pragma.c.

366  {
367  list exprs = NULL;
369  // the list of expression to generate initialized with
370  // pragma "omp parallel for"
372  exprs = omp_append_private_clause (l, exprs);
373  // insert the pragma as an expression to the current statement
375  pips_debug (5, "new for pragma as an extension added\n");
376  }
377  return (exprs != NULL);
378 }
static list omp_append_private_clause(loop l, list exprs)
Definition: pragma.c:293
void add_pragma_expr_to_statement(statement st, list l)
Add a pragma as a list of expression to a statement.
Definition: pragma.c:460
list pragma_omp_parallel_for_as_exprs(void)
Definition: pragma.c:236
#define loop_execution(x)
Definition: ri.h:1648
#define execution_parallel_p(x)
Definition: ri.h:1211
Definition: statement.c:54

References add_pragma_expr_to_statement(), execution_parallel_p, loop_execution, omp_append_private_clause(), pips_debug, and pragma_omp_parallel_for_as_exprs().

Referenced by process_reductions_in_openmp_loop().

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

◆ omp_pragma_expr_for_reduction()

bool omp_pragma_expr_for_reduction ( loop  l,
statement  stmt,
bool  strict 
)

generate pragma for a reduction as a list of expressions

Returns
true if a pragma has been generated
Parameters
l,theloop to analyze for omp reduction
stmt,thestatament where the pragma should be attached
strict,ifset to true, only one-liner statements with reductions are handled
Parameters
stmttmt
stricttrict

Definition at line 346 of file pragma.c.

346  {
347  // the list of expression to generate
348  list exprs = NULL;
349  exprs = reductions_get_omp_pragma_expr(l, stmt, strict);
350  // insert the pragma (if any) as an expression to the current statement
351  if (exprs != NULL) {
352  // remove any previous openmp expression to make sure we do not introduce inconsistency
354  // check if a private clause is needed on top of the reduction clause
355  exprs = omp_append_private_clause (l, exprs);
357  pips_debug (5, "new reduction pragma as an extension added\n");
358  }
359  return (exprs != NULL);
360 }
list reductions_get_omp_pragma_expr(loop l, statement stmt, bool strict)
pragma.c
Definition: pragma.c:227
static void statement_remove_omp_clauses(statement stmt)
Definition: pragma.c:304

References add_pragma_expr_to_statement(), omp_append_private_clause(), pips_debug, reductions_get_omp_pragma_expr(), and statement_remove_omp_clauses().

Referenced by process_reductions_in_openmp_loop().

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

◆ print_code_cumulated_reductions()

bool print_code_cumulated_reductions ( const char *  module_name)
Parameters
module_nameodule_name

Definition at line 258 of file prettyprint.c.

259 {
261  DBR_CUMULATED_REDUCTIONS,
262  CUMU_DECO,
263  DBR_SUMMARY_REDUCTIONS,
264  CUMU_SUFFIX);
265 }
static bool print_any_reductions(const char *module_name, string resource_name, string decoration_name, string summary_name, string file_suffix)
handles the required prettyprint ??? what about summary reductions? should be pprinted with cumulated...
Definition: prettyprint.c:203
#define CUMU_SUFFIX
Definition: prettyprint.c:40
#define CUMU_DECO
Definition: prettyprint.c:43

References CUMU_DECO, CUMU_SUFFIX, module_name(), and print_any_reductions().

+ Here is the call graph for this function:

◆ print_code_proper_reductions()

bool print_code_proper_reductions ( const char *  module_name)

Handlers for PIPSMAKE.

Parameters
module_nameodule_name

Definition at line 249 of file prettyprint.c.

250 {
252  DBR_PROPER_REDUCTIONS,
253  PROP_DECO,
254  NULL,
255  PROP_SUFFIX);
256 }
#define PROP_SUFFIX
Definition: prettyprint.c:39
#define PROP_DECO
Definition: prettyprint.c:42

References module_name(), print_any_reductions(), PROP_DECO, and PROP_SUFFIX.

+ Here is the call graph for this function:

◆ print_reduction()

void print_reduction ( reduction  r)

Definition at line 137 of file prettyprint.c.

138 {
140  fprintf(stderr, "reduction is %s[",
144  fprintf(stderr, "]\n");
145 }
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
void print_reference(reference r)
Definition: expression.c:142
#define reduction_operator_tag(x)
#define reduction_op(x)
#define reduction_reference(x)
#define reference_undefined_p(x)
Definition: ri.h:2303
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...

References fprintf(), print_reference(), reduction_op, reduction_operator_tag, reduction_operator_tag_name(), reduction_reference, ref, and reference_undefined_p.

Referenced by replace_reductions_in_statement().

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

◆ printed_reductions_undefined_p()

bool printed_reductions_undefined_p ( void  )

prettyprint.c

◆ 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
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:

◆ proper_reductions_undefined_p()

bool proper_reductions_undefined_p ( void  )

◆ pure_function_p()

bool pure_function_p ( entity  f)

extract the proper reduction of a call (instruction) if any.

I trust intrinsics (operations?) and summary effects...

else

a side effect!?

LUNS

Definition at line 343 of file utils.c.

344 {
345  value v = entity_initial(f);
346 
348  return true;
349  /* else */
350 
351  if (entity_module_p(f))
352  {
354  if(!store_effect_p(e)) continue;
355  if (effect_write_p(e)) /* a side effect!? */
356  return false;
357  if (io_effect_entity_p(effect_variable(e))) /* LUNS */
358  return false;
359  }
360  }
361 
362  return true;
363 }
list load_summary_effects(entity e)
FI->FI, FI->BC: these two functions should be moved into effects-util or effects-simple.
#define effect_write_p(eff)
#define effect_variable(e)
For COMPATIBILITY purpose only - DO NOT USE anymore.
bool io_effect_entity_p(entity)
Definition: effects.c:496
#define value_intrinsic_p(x)
Definition: ri.h:3074
#define value_constant_p(x)
Definition: ri.h:3071
#define value_symbolic_p(x)
Definition: ri.h:3068
#define entity_initial(x)
Definition: ri.h:2796

References EFFECT, effect_variable, effect_write_p, entity_initial, entity_module_p(), f(), FOREACH, io_effect_entity_p(), load_summary_effects(), store_effect_p(), value_constant_p, value_intrinsic_p, and value_symbolic_p.

Referenced by call_flt().

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

◆ reduction_detection()

bool reduction_detection ( const char *  mod_name)

get the resources

do the job

validate computation

update/release resources

Parameters
mod_nameod_name

Definition at line 245 of file propagation.c.

245  {
246  /* get the resources */
247  statement mod_stmt = (statement)
248  db_get_memory_resource(DBR_CODE, mod_name, true);
249 
250  set_current_module_statement(mod_stmt);
252  set_ordering_to_statement(mod_stmt);
254  (graph) db_get_memory_resource(DBR_DG, mod_name, true);
255 
256  /* do the job */
257  debug_on("REDUCTION_DETECTION_DEBUG_LEVEL");
259  debug_off();
260  if(res) {
261  /* validate computation */
262  module_reorder(mod_stmt);
263  DB_PUT_MEMORY_RESOURCE(DBR_CODE, mod_name, mod_stmt);
264  }
265 
266  /* update/release resources */
270  return res;
271 }
static graph dependence_graph
Definition: delay.c:93
struct _newgen_struct_graph_ * graph
Definition: graph.h:31
hash_table set_ordering_to_statement(statement s)
To be used instead of initialize_ordering_to_statement() to make sure that the hash table ots is in s...
Definition: ordering.c:172
void reset_ordering_to_statement(void)
Reset the mapping from ordering to statement.
Definition: ordering.c:185
static bool do_reduction_detection(graph dg)
sg: this function does a huge pattern matching :) and is not very smart
Definition: propagation.c:187
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, dependence_graph, do_reduction_detection(), module_name_to_entity(), module_reorder(), reset_current_module_entity(), reset_current_module_statement(), reset_ordering_to_statement(), set_current_module_entity(), set_current_module_statement(), and set_ordering_to_statement().

+ Here is the call graph for this function:

◆ reduction_name()

string reduction_name ( reduction  r)

returns the name of the reduction (!!! not allocated)

Definition at line 110 of file prettyprint.c.

111 {
113 }
#define reduction_tag(r)

References reduction_operator_tag_name(), and reduction_tag.

+ 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
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:

◆ reduction_operator_name()

string reduction_operator_name ( reduction_operator  o)

allocates and returns the name of the operator

Definition at line 103 of file prettyprint.c.

104 {
106 }

References reduction_operator_tag, reduction_operator_tag_name(), and strdup().

Referenced by words_reduction().

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

◆ reduction_operator_tag_name()

string reduction_operator_tag_name ( tag  t)

returns a (static) string describing the tag t reduction

Definition at line 78 of file prettyprint.c.

79 {
80  switch(t)
81  {
82  case is_reduction_operator_none: return "none";
83  case is_reduction_operator_sum: return "sum";
84  case is_reduction_operator_csum: return "csum";
85  case is_reduction_operator_prod: return "prod";
86  case is_reduction_operator_min: return "min";
87  case is_reduction_operator_max: return "max";
88  case is_reduction_operator_and: return "and";
89  case is_reduction_operator_or: return "or";
90  case is_reduction_operator_bitwise_or: return "bitwise_or";
91  case is_reduction_operator_bitwise_xor: return "bitwise_xor";
92  case is_reduction_operator_bitwise_and: return "bitwise_and";
93  case is_reduction_operator_eqv: return "eqv";
94  case is_reduction_operator_neqv: return "neqv";
95  default: pips_internal_error("unexpected reduction operator tag!");
96  }
97 
98  return NULL;
99 }

References 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_none, is_reduction_operator_or, is_reduction_operator_prod, is_reduction_operator_sum, and pips_internal_error.

Referenced by call_proper_reduction_p(), print_reduction(), reduction_name(), reduction_operator_name(), remove_variable_from_reduction(), and update_reduction_under_effect().

+ Here is the caller graph for this function:

◆ reduction_propagation()

bool reduction_propagation ( const char *  mod_name)

propagation.c

propagation.c

the pattern checked is a = b + c; r = r + a; which should become r = r +b ; r = r +c ;

get the resources

do the job

validate computation

update/release resources

Parameters
mod_nameod_name

Definition at line 125 of file propagation.c.

125  {
126  /* get the resources */
127  statement mod_stmt = (statement)
128  db_get_memory_resource(DBR_CODE, mod_name, true);
129 
130  set_current_module_statement(mod_stmt);
131  set_proper_reductions((pstatement_reductions) db_get_memory_resource(DBR_PROPER_REDUCTIONS, mod_name, true));
133  set_ordering_to_statement(mod_stmt);
135  (graph) db_get_memory_resource(DBR_DG, mod_name, true);
136 
138 
139  /* do the job */
141 
142  /* validate computation */
143  module_reorder(mod_stmt);
144  DB_PUT_MEMORY_RESOURCE(DBR_CODE, mod_name, mod_stmt);
145 
146  /* update/release resources */
151  return true;
152 }
void simplify_c_operator(statement)
replace PLUS_C_OPERATOR_NAME by PLUS_OPERATOR_NAME when relevant
Definition: simplify.c:621
static void do_reduction_propagation(graph dg)
sg: this function does a huge pattern matching :) and is not very smart
Definition: propagation.c:57

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, dependence_graph, do_reduction_propagation(), get_current_module_statement(), module_name_to_entity(), module_reorder(), reset_current_module_entity(), reset_current_module_statement(), reset_ordering_to_statement(), reset_proper_reductions(), set_current_module_entity(), set_current_module_statement(), set_ordering_to_statement(), set_proper_reductions(), and simplify_c_operator().

+ Here is the call graph for this function:

◆ reduction_star_p()

bool reduction_star_p ( reduction  r)

utils.c

Definition at line 46 of file utils.c.

46  {
52  return true;
53  }
54  return false;
55 }
#define range_upper(x)
Definition: ri.h:2290
#define syntax_range(x)
Definition: ri.h:2733
#define reference_indices(x)
Definition: ri.h:2328
#define expression_undefined_p(x)
Definition: ri.h:1224
#define syntax_range_p(x)
Definition: ri.h:2731
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207

References exp, EXPRESSION, expression_syntax, expression_undefined_p, FOREACH, range_upper, reduction_reference, ref, reference_indices, syntax_range, and syntax_range_p.

Referenced by rename_statement_reductions().

+ Here is the caller graph for this function:

◆ reductions_get_omp_pragma_expr()

list reductions_get_omp_pragma_expr ( loop  l,
statement  stmt,
bool  strict 
)

pragma.c

Parameters
stmttmt
stricttrict

Definition at line 227 of file pragma.c.

227  {
228  list exprs = NIL;
229  // check that reduction as been detected at loop level
230  if (statement_is_reduction (stmt) == true) {
232  // check that the reductions are done on scalars and not arrays
233  if (reductions_on_scalar (rs) == true) {
234  // reset the all reduction flag
236  // check that all the statements of the loop are reductions otherwise, do
237  // not generate omp reduction pragma
238  // the test is too restrictive so need to be improved
239  if(strict)
241  if (all_reduction) {
243  FOREACH (REDUCTION, red, reductions_list(rs)) {
244  exprs = gen_expression_cons (reduction_as_expr (red), exprs);
245  }
246  //secondly get "omp parallel for" as an expr and concatenate
247  list parallel_for = pragma_omp_parallel_for_as_exprs ();
248  exprs = gen_nconc (exprs, parallel_for);
249  }
250  }
251  }
252  pips_debug(5, "finish with pragma\n");
253  return exprs;
254 }
list gen_expression_cons(expression p, list l)
Definition: ri.c:866
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
static bool statement_is_reduction(statement stmt)
Definition: pragma.c:32
static bool all_reduction
Definition: pragma.c:20
static expression reduction_as_expr(reduction r)
Definition: pragma.c:121
static void compute_all_reduction(statement stmt)
remenber if all the statement analazed are reduction since the last reset
Definition: pragma.c:43
static bool reductions_on_scalar(reductions reds)
Definition: pragma.c:49
static void reset_all_reduction(void)
reset the all_reduction flag
Definition: pragma.c:26
reductions load_printed_reductions(statement)
#define REDUCTION(x)
REDUCTION.
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362

References all_reduction, compute_all_reduction(), FOREACH, gen_expression_cons(), gen_nconc(), gen_recurse, gen_true(), load_printed_reductions(), NIL, pips_debug, pragma_omp_parallel_for_as_exprs(), REDUCTION, reduction_as_expr(), reductions_list, reductions_on_scalar(), reset_all_reduction(), statement_domain, and statement_is_reduction().

Referenced by omp_pragma_expr_for_reduction().

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

◆ reductions_get_omp_pragma_str()

string reductions_get_omp_pragma_str ( loop  l,
statement  stmt 
)
Returns
a string with omp pragma for reductions
Parameters
l,theloop associated with the statement
stmt,thestatement to analyzed for reductions, must be a loop
Parameters
stmttmt

Definition at line 259 of file pragma.c.

259  {
261  // check that reduction as been detected at loop level
262  if (statement_is_reduction (stmt) == true) {
264  // check that the reductions are done on scalars and not arrays
265  if (reductions_on_scalar (rs) == true) {
266  // reset the all reduction flag
268  // check that all the statements of the loop are reductions otherwise, do
269  // not generate omp reduction pragma
270  // the test is too restrictive so need to be improved
272  if (all_reduction == true) {
273  string header = (prettyprint_language_is_fortran_p ()
276  string_buffer_append (buf, strdup (header));
278  FOREACH (REDUCTION, red, reductions_list(rs)) {
280  }
281  }
282  }
283  }
284  string result = string_buffer_to_string (buf);
285  pips_debug(5, "finish with pragma: %s\n", result);
287  return result;
288 }
bool prettyprint_language_is_fortran_p()
Definition: language.c:75
void string_buffer_free_all(string_buffer *)
free string buffer structure and force string freeing
Definition: string_buffer.c:94
void string_buffer_append(string_buffer, const string)
append string s (if non empty) to string buffer sb, the duplication is done if needed according to th...
string string_buffer_to_string(const string_buffer)
return malloc'ed string from string buffer sb
string_buffer string_buffer_make(bool dup)
allocate a new string buffer
Definition: string_buffer.c:58
static const string OMP_PRAGMA_FOR_HEADER_C
Definition: pragma.c:15
static const string OMP_PRAGMA_FOR_HEADER_F
Definition: pragma.c:16
static string reduction_as_str(reduction r)
allocates and returns a string for reduction r
Definition: pragma.c:207
internally defined structure.
Definition: string_buffer.c:47

References all_reduction, buf, compute_all_reduction(), FOREACH, gen_recurse, gen_true(), load_printed_reductions(), OMP_PRAGMA_FOR_HEADER_C, OMP_PRAGMA_FOR_HEADER_F, pips_debug, prettyprint_language_is_fortran_p(), REDUCTION, reduction_as_str(), reductions_list, reductions_on_scalar(), reset_all_reduction(), statement_domain, statement_is_reduction(), strdup(), string_buffer_append(), string_buffer_free_all(), string_buffer_make(), and string_buffer_to_string().

+ Here is the call graph for this function:

◆ remove_variable_from_reduction()

void remove_variable_from_reduction ( reduction  red,
entity  var 
)
Parameters
reded
varar

Definition at line 130 of file utils.c.

133 {
134  variable_to_remove = var;
136  first_encountered_call = NULL;
137  make_ref_exprs_stack();
138 
139  pips_debug(8, "removing %s from %s[%s]\n",
140  entity_name(var),
144 
148  NULL);
149 
151  free_ref_exprs_stack();
152 }
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
#define reduction_variable(r)
shorthands for REDUCTION:
static void expr_rwt(expression e)
Definition: utils.c:103
static list dead_expressions
list of expressions to be deleted (at rwt)
Definition: utils.c:85
static expression first_encountered_call
the first expression encountered which is a function call, so as to avoid "*+J" results
Definition: utils.c:89
static entity variable_to_remove
must be able to remove a modified variable from a reduction:
Definition: utils.c:82
static bool ref_flt(reference r)
Definition: utils.c:117
static bool expr_flt(expression e)
stack of reference expressions (if there is no call)
Definition: utils.c:94
#define expression_domain
newgen_execution_domain_defined
Definition: ri.h:154
#define reference_domain
newgen_range_domain_defined
Definition: ri.h:338

References dead_expressions, entity_name, expr_flt(), expr_rwt(), expression_domain, first_encountered_call, gen_free_list(), gen_multi_recurse(), gen_null(), NIL, pips_debug, reduction_op, reduction_operator_tag, reduction_operator_tag_name(), reduction_reference, reduction_variable, ref_flt(), reference_domain, and variable_to_remove.

Referenced by compute_one_summary_reduction(), update_compatible_reduction(), and update_reduction_under_effect().

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

◆ replace_reduction_with_atomic()

bool replace_reduction_with_atomic ( string  mod_name)

end of it

cproto-generated files atomic.c

end of it

Parameters
mod_nameod_name

Definition at line 397 of file atomic.c.

397  {
398  debug_on("REPLACE_REDUCTION_WITH_ATOMIC_DEBUG_LEVEL");
399 
400  bool result = process_reduced_loops(mod_name, DO_REPLACE);
401 
402  debug_off();
403 
404  return result;
405 }
@ DO_REPLACE
Definition: atomic.c:98

References debug_off, debug_on, DO_REPLACE, and process_reduced_loops().

+ Here is the call graph for this function:

◆ reset_cumulated_reductions()

void reset_cumulated_reductions ( void  )

Referenced by cumulated_reductions(), reduction_atomization(), simd_remove_reductions(), and summary_reductions().

+ Here is the caller graph for this function:

◆ reset_printed_reductions()

void reset_printed_reductions ( void  )

Referenced by print_any_reductions(), and process_reduced_loops().

+ Here is the caller graph for this function:

◆ reset_proper_reductions()

void reset_proper_reductions ( void  )

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

+ 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 }
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_cumulated_reductions()

void set_cumulated_reductions ( pstatement_reductions  )

Referenced by reduction_atomization(), simd_remove_reductions(), and summary_reductions().

+ Here is the caller graph for this function:

◆ set_printed_reductions()

void set_printed_reductions ( pstatement_reductions  )

Referenced by print_any_reductions(), and process_reduced_loops().

+ Here is the caller graph for this function:

◆ set_proper_reductions()

void set_proper_reductions ( pstatement_reductions  )

Referenced by cumulated_reductions(), and reduction_propagation().

+ Here is the caller graph for this function:

◆ store_cumulated_reductions()

void store_cumulated_reductions ( statement  ,
reductions   
)

Referenced by build_creductions_of_statement(), compute_cumulated_reductions(), and do_expression_reduction().

+ Here is the caller graph for this function:

◆ store_or_update_cumulated_reductions()

void store_or_update_cumulated_reductions ( statement  ,
reductions   
)

◆ store_or_update_printed_reductions()

void store_or_update_printed_reductions ( statement  ,
reductions   
)

◆ store_or_update_proper_reductions()

void store_or_update_proper_reductions ( statement  ,
reductions   
)

◆ store_printed_reductions()

void store_printed_reductions ( statement  ,
reductions   
)

◆ store_proper_reductions()

void store_proper_reductions ( statement  ,
reductions   
)

Referenced by pr_statement_flt().

+ 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:

◆ summary_to_proper_reference()

list summary_to_proper_reference ( call  c,
reference  r 
)

call.c

call.c

thus it is similar to summary effects call translations. I do reuse some functions there by generating fake effects... I think they should be cleaned so as to offer reference plus predicate translations, and then would be used by reductions and effects. Fabien. translation of a reference, based on effect translations... such an interface should be available? of reference

persistent!

of effect

of reference

Definition at line 45 of file call.c.

48 {
49  effect e = make_simple_effect(r, /* persistent! */
52  list /* of effect */ lef, /* of reference */ lref = NIL;
53 
54  pips_debug(7, "reference to %s\n", entity_name(reference_variable(r)));
55 
57 
58  FOREACH (EFFECT, ef, lef) {
59  lref = CONS(REFERENCE, effect_any_reference(ef), lref);
60  }
61 
63  gen_free_list(lef);
64  return lref;
65 }
approximation make_approximation(enum approximation_utype tag, void *val)
Definition: effects.c:176
list summary_effect_to_proper_effect(call, effect)
#define make_simple_effect(reference, action, approximation)
action make_action_write_memory(void)
To ease the extension of action with action_kind.
Definition: effects.c:1011
@ is_approximation_exact
Definition: effects.h:343
void gen_free(gen_chunk *obj)
version without shared_pointers.
Definition: genClib.c:992
void gen_map(gen_iter_func_t fp, const list l)
Definition: list.c:172
void(* gen_iter_func_t)(void *)
Definition: newgen_types.h:116

References CONS, EFFECT, effect_any_reference, entity_name, FOREACH, gen_free(), gen_free_list(), gen_map(), is_approximation_exact, make_action_write_memory(), make_approximation(), make_simple_effect, NIL, pips_debug, REFERENCE, reference_variable, summary_effect_to_proper_effect(), and UU.

Referenced by translate_reduction().

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

◆ translate_reductions()

list translate_reductions ( call  c)

of reduction

Returns
the list of proper reduction applicable to the call according to the summary reduction computed earlier.
Parameters
c,thecall to check for proper reductions

of reduction

Definition at line 112 of file call.c.

114 {
115  entity fun = call_function(c);
116  list /* of reduction */ lr = NIL;
117 
118  if (!entity_module_p(fun))
119  return NIL;
120 
122  lr = gen_nconc(translate_reduction(c, r), lr);
123  }
124 
125  return lr;
126 }
static list translate_reduction(call c, reduction external_red)
of reduction
Definition: call.c:68
reductions load_summary_reductions(entity f)
Fortran 77 anti aliasing rules implies that sg that looks like a reduction within a subroutine can be...
Definition: reductions.c:55

References call_function, entity_module_p(), FOREACH, gen_nconc(), load_summary_reductions(), NIL, REDUCTION, reductions_list, and translate_reduction().

Referenced by pr_call_flt().

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

◆ update_compatible_reduction()

bool update_compatible_reduction ( reduction pr,
entity  var,
list  le,
reductions  reds 
)

what to do with reduction *pr for variable var under effects le and reductions reds.

returns whether worth to go on. conditions:

some reduction already available

must update the reduction with the encountered effects

else now no new reduction waas found, must check *pr against effects

some reduction

stores for latter cleaning

Parameters
prr
varar
leof effect
redseds

Definition at line 285 of file utils.c.

290 {
291  reduction found = NULL;
292 
293  if (!find_reduction_of_var(var, reds, &found))
294  return false;
295 
296  if (found)
297  {
298  if (!reduction_none_p(*pr)) /* some reduction already available */
299  return merge_two_reductions(*pr, found);
300  else { /* must update the reduction with the encountered effects */
303  }
304  free_reduction(*pr); *pr = found;
305  return true;
306  }
307  }
308  /* else
309  * now no new reduction waas found, must check *pr against effects
310  */
311  if (!reduction_none_p(*pr)) /* some reduction */
312  {
313  FOREACH (EFFECT, e, le) {
314  if(!store_effect_p(e)) continue;
315  if (!update_reduction_under_effect(*pr, e)) {
316  DEBUG_REDUCTION(8, "kill of ", *pr);
317  pips_debug(8, "under effect to %s\n",
319  return false;
320  }
321  }
322  }
323  else
324  {
325  FOREACH (EFFECT, e, le) {
326  if(!store_effect_p(e)) continue;
328  return false;
329  else if (effect_write_p(e)) /* stores for latter cleaning */
331  reduction_dependences(*pr));
332  }
333  }
334  return true;
335 }
void free_reduction(reduction p)
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 reduction_none_p(r)
static bool find_reduction_of_var(entity var, reductions reds, reduction *pr)
looks for a reduction about var in reds, and returns it.
Definition: utils.c:209
bool update_reduction_under_effect(reduction red, effect eff)
Definition: utils.c:155
void remove_variable_from_reduction(reduction red, entity var)
Definition: utils.c:130
static bool merge_two_reductions(reduction first, reduction second)
merge two reductions into first so as to be compatible with both.
Definition: utils.c:231
#define reduction_dependences(x)
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755

References DEBUG_REDUCTION, EFFECT, effect_variable, effect_write_p, entities_may_conflict_p(), ENTITY, entity_name, find_reduction_of_var(), FOREACH, free_reduction(), gen_once(), merge_two_reductions(), pips_debug, reduction_dependences, reduction_none_p, remove_variable_from_reduction(), store_effect_p(), and update_reduction_under_effect().

Referenced by build_reduction_of_variable().

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

◆ update_compatible_reduction_with()

bool update_compatible_reduction_with ( reduction pr,
entity  var,
reduction  r 
)

update *pr according to r for variable var r is not touched.

else same var and no conflict

else are they compatible?

ok, let us merge them

Parameters
prr
varar

Definition at line 260 of file utils.c.

260  {
261  if(reduction_variable(r) != var)
263 
264  /* else same var and no conflict */
265  if(reduction_none_p(*pr)) {
266  free_reduction(*pr);
267  *pr = copy_reduction(r);
268  return true;
269  }
270  /* else are they compatible?
271  */
272  if(reduction_tag(*pr) != reduction_tag(r))
273  return false;
274  /* ok, let us merge them
275  */
276  return merge_two_reductions(*pr, copy_reduction(r));
277 }
reduction copy_reduction(reduction p)
REDUCTION.

References copy_reduction(), entities_may_conflict_p(), free_reduction(), merge_two_reductions(), reduction_none_p, reduction_tag, and reduction_variable.

Referenced by compatible_reduction_of_var().

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

◆ update_cumulated_reductions()

void update_cumulated_reductions ( statement  ,
reductions   
)

◆ update_printed_reductions()

void update_printed_reductions ( statement  ,
reductions   
)

◆ update_proper_reductions()

void update_proper_reductions ( statement  ,
reductions   
)

◆ update_reduction_under_effect()

bool update_reduction_under_effect ( reduction  red,
effect  eff 
)

REDUCTION is dead if the reduction variable is affected

else

now var is written

Parameters
reded
effff

Definition at line 155 of file utils.c.

158 {
159  entity var = effect_variable(eff);
160  bool updated = false;
161 
162  pips_debug(7, "reduction %s[%s] under effect %s on %s\n",
166  effect_write_p(eff)? "W": "R",
168 
169  if(!store_effect_p(eff)) {
170  return true;
171  }
172 
173 
174  /* REDUCTION is dead if the reduction variable is affected
175  */
177  {
180  return false;
181  }
182  /* else */
183 
184  if (effect_read_p(eff)) return true;
185 
186  /* now var is written */
188  if (entities_may_conflict_p(var, e)) {
189  updated = true;
191  }
192  }
193 
194  if (updated)
195  {
197  reduction_dependences(red) =
199  }
200 
201  return true;
202 }
#define effect_read_p(eff)
#define effect_scalar_p(eff) entity_scalar_p(effect_entity(eff))

References effect_read_p, effect_variable, effect_write_p, entities_may_conflict_p(), ENTITY, entity_name, FOREACH, gen_free_list(), is_reduction_operator_none, pips_debug, reduction_dependences, reduction_op, reduction_operator_tag, reduction_operator_tag_name(), reduction_reference, reduction_variable, referenced_variables(), remove_variable_from_reduction(), and store_effect_p().

Referenced by update_compatible_reduction().

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