PIPS
dynamic.c File Reference
#include "defines-local.h"
#include "control.h"
#include "effects-generic.h"
#include "effects-simple.h"
#include "effects-convex.h"
+ Include dependency graph for dynamic.c:

Go to the source code of this file.

Macros

#define RETAL(msg, res)    { pips_debug(7, "%d because %s\n", res, msg); return res;}
 
#define RET(msg, what)    { pips_debug(6, "not similar because %s\n", msg); return what;}
 
#define ret(why, what)    { pips_debug(9, "ret %d because %s\n", what, why); return what; }
 true if not a remapping for old. More...
 
#define elst_ifdef(what, name, s)
 

Functions

entity safe_load_primary_entity (entity e)
 HPFC module by Fabien COELHO. More...
 
bool same_primary_entity_p (entity e1, entity e2)
 
void init_dynamic_status ()
 DYNAMIC STATUS management. More...
 
void reset_dynamic_status ()
 
dynamic_status get_dynamic_status ()
 
void set_dynamic_status (dynamic_status d)
 
void close_dynamic_status ()
 
void set_entity_as_dynamic (entity e)
 a new dynamic entity is stored. More...
 
static void add_dynamic_synonym (entity new_e, entity e)
 what: new_e is stored as a synonym of e. More...
 
void set_similar_mappings_for_updates (void)
 
static entity new_synonym (entity e)
 builds a synonym for entity e. More...
 
static void check_for_similarity (entity a, list others)
 
void hpfc_check_for_similarities (list le)
 check all dynamic arrays for some similars... More...
 
static entity new_synonym_array (entity a, align al)
 builds a new synonym for array a, the alignment of which will be al. More...
 
static entity new_synonym_template (entity t, distribute di)
 builds a new synonym for template t, the distribution of which will be di. More...
 
static bool conformant_entities_p (entity e1, entity e2)
 
static bool same_distribute_p (distribute d1, distribute d2)
 comparison of DISTRIBUTE. More...
 
static bool same_alignment_in_list_p (alignment a, list l)
 comparison of ALIGN. More...
 
bool conformant_templates_p (entity t1, entity t2)
 
static bool same_align_p (align a1, align a2)
 
entity array_synonym_aligned_as (entity array, align a)
 entity array_synonym_aligned_as(array, a) entity array; align a; More...
 
align new_align_with_template (align a, entity t)
 
entity template_synonym_distributed_as (entity temp, distribute d)
 what: finds or creates a new entity distributed as needed. More...
 
static bool same_distribution_p (distribution d1, distribution d2)
 array_distribution_similar_p More...
 
static bool same_alignment_p (entity e1, entity t1, alignment a1, entity e2, entity t2, alignment a2)
 
bool array_distribution_similar_p (entity a1, entity a2)
 
bool hpfc_call_with_distributed_args_p (call c)
 whether call c inplies a distributed argument More...
 
static list add_once_to_renaming_list (list l, entity o, entity n)
 of renaming More...
 
void hpfc_translate_call_with_distributed_args (statement s, call c)
 ??? only simple calls are handled. More...
 
void init_dynamic_locals ()
 DYNAMIC LOCAL DATA. More...
 
void close_dynamic_locals ()
 
static void lazy_initialize_for_statement (statement s)
 starting point More...
 
static void add_as_a_closing_statement (statement s)
 
static void add_as_a_used_variable (entity e)
 
void add_as_a_used_dynamic_to_statement (statement s, entity e)
 
static void add_as_a_modified_variable (entity e)
 
static void add_alive_synonym (statement s, entity a)
 
static void ref_rwt (reference r)
 
static void simple_switch_old_to_new (statement s)
 
static bool rename_directive_p (entity f)
 
static bool continue_propagation_p (statement s)
 
void propagate_synonym (statement s, entity old, entity new, bool is_array)
 
static void initialize_reaching_propagation (statement s)
 for statement s More...
 
static void remove_not_remapped_leavings (statement s)
 
static void initialize_maybeuseful_mappings (statement s)
 must be called after useless leaving mappings removal More...
 
static void reinitialize_reaching_mappings (statement s)
 
static list propagation_on_remapping_graph (statement s, list ls, entities(*built)(statement), entities(*condition)(statement), bool local, bool forward)
 more options, such as may or must? More...
 
static list propagate_used_arrays (statement s, list ls)
 of statements More...
 
static list propagate_maybeuseful_mappings (statement s, list ls)
 of statements More...
 
static void remove_from_entities (entity primary, entities es)
 
static void remove_unused_remappings (statement s)
 
static void regenerate_renamings (statement s)
 regenerate the renaming structures after the optimizations performed on the remapping graph. More...
 
static list list_of_remapping_statements ()
 of statements More...
 
static void print_control_ordering (control c)
 functions used for debug. More...
 
static void dump_remapping_graph_info (statement s)
 
static void dump_remapping_graph (string when, list ls)
 
void dump_current_remapping_graph (string when)
 
void simplify_remapping_graph (void)
 void simplify_remapping_graph() More...
 
list alive_arrays (statement s, entity t)
 what: returns the list of alive arrays for statement s and template t. More...
 
statement generate_copy_loop_nest (entity src, entity trg)
 statement generate_copy_loop_nest(src, trg) entity src, trg; More...
 

Variables

bool(* dynamic_entity_p )(entity) = bound_dynamic_hpf_p
 as expected, true if entity e is dynamic. More...
 
static entity old_variable = entity_undefined
 void propagate_synonym(s, old, new) statement s; entity old, new; More...
 
static entity new_variable = entity_undefined
 entity to be replaced, the primary? More...
 
static bool array_propagation
 replacement More...
 
static bool array_used
 true if an array is propagated, false if template More...
 
static bool array_modified
 true if the array was actually used More...
 
static statement initial_statement = statement_undefined
 true if the array may be modified... More...
 

Macro Definition Documentation

◆ elst_ifdef

#define elst_ifdef (   what,
  name,
 
)
Value:
if (bound_##name##_p(s)){DEBUG_ELST(1, what, entities_list(load_##name(s)));}\
else pips_debug(1, "no " what "\n");
#define entities_list(x)
Definition: hpf_private.h:414
#define DEBUG_ELST(D, W, L)
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145

Definition at line 1406 of file dynamic.c.

◆ RET

#define RET (   msg,
  what 
)     { pips_debug(6, "not similar because %s\n", msg); return what;}

Definition at line 574 of file dynamic.c.

◆ ret

#define ret (   why,
  what 
)     { pips_debug(9, "ret %d because %s\n", what, why); return what; }

true if not a remapping for old.

if it is a remapping, operates the switch.

Definition at line 986 of file dynamic.c.

◆ RETAL

#define RETAL (   msg,
  res 
)     { pips_debug(7, "%d because %s\n", res, msg); return res;}

Definition at line 531 of file dynamic.c.

Function Documentation

◆ add_alive_synonym()

static void add_alive_synonym ( statement  s,
entity  a 
)
static

lazy initialization

Definition at line 916 of file dynamic.c.

919 {
920  entities es;
921 
922  /* lazy initialization
923  */
924  if (!bound_alive_synonym_p(s))
925  store_alive_synonym(s, make_entities(NIL));
926 
927  es = load_alive_synonym(s);
928  entities_list(es) = gen_once(a, entities_list(es));
929 }
entities make_entities(list a)
Definition: hpf_private.c:250
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
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

References entities_list, gen_once(), make_entities(), and NIL.

Referenced by continue_propagation_p().

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

◆ add_as_a_closing_statement()

static void add_as_a_closing_statement ( statement  s)
static

Definition at line 882 of file dynamic.c.

883 {
884  control
885  c = load_remapping_graph(initial_statement),
886  n = (lazy_initialize_for_statement(s), load_remapping_graph(s));
887 
888  what_stat_debug(6, s);
889 
890  control_successors(c) =
891  gen_once(load_remapping_graph(s), control_successors(c));
893  gen_once(load_remapping_graph(initial_statement),
895 }
static void lazy_initialize_for_statement(statement s)
starting point
Definition: dynamic.c:870
static statement initial_statement
true if the array may be modified...
Definition: dynamic.c:866
#define what_stat_debug(level, stat)
#define control_predecessors(x)
Definition: ri.h:943
#define control_successors(x)
Definition: ri.h:945

References control_predecessors, control_successors, gen_once(), initial_statement, lazy_initialize_for_statement(), and what_stat_debug.

Referenced by continue_propagation_p().

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

◆ add_as_a_modified_variable()

static void add_as_a_modified_variable ( entity  e)
static

Definition at line 910 of file dynamic.c.

911 {
912  entities es = load_modified_dynamics(initial_statement);
914 }
entity load_primary_entity(entity)

References entities_list, gen_once(), initial_statement, and load_primary_entity().

Referenced by propagate_synonym().

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

◆ add_as_a_used_dynamic_to_statement()

void add_as_a_used_dynamic_to_statement ( statement  s,
entity  e 
)

Definition at line 904 of file dynamic.c.

905 {
906  entities es = load_used_dynamics(s);
908 }

References entities_list, gen_once(), and load_primary_entity().

Referenced by initial_alignment().

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

◆ add_as_a_used_variable()

static void add_as_a_used_variable ( entity  e)
static

Definition at line 897 of file dynamic.c.

898 {
899  entities es = load_used_dynamics(initial_statement);
901 }

References entities_list, gen_once(), initial_statement, and load_primary_entity().

Referenced by propagate_synonym().

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

◆ add_dynamic_synonym()

static void add_dynamic_synonym ( entity  new_e,
entity  e 
)
static

what: new_e is stored as a synonym of e.

Definition at line 149 of file dynamic.c.

152 {
153  entities es = load_dynamic_hpf(e);
154  pips_debug(3, "%s as %s synonyms\n", entity_name(new_e), entity_name(e));
155  pips_assert("dynamicity", dynamic_entity_p(e) && !dynamic_entity_p(new_e));
156  entities_list(es) = CONS(ENTITY, new_e, entities_list(es));
157  store_dynamic_hpf(new_e, es);
159 }
bool(* dynamic_entity_p)(entity)
as expected, true if entity e is dynamic.
Definition: dynamic.c:145
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
entities load_dynamic_hpf(entity)
void store_primary_entity(entity, entity)
void store_dynamic_hpf(entity, entities)
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define entity_name(x)
Definition: ri.h:2790

References CONS, dynamic_entity_p, entities_list, ENTITY, entity_name, load_dynamic_hpf(), load_primary_entity(), pips_assert, pips_debug, store_dynamic_hpf(), and store_primary_entity().

Referenced by new_synonym().

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

◆ add_once_to_renaming_list()

static list add_once_to_renaming_list ( list  l,
entity  o,
entity  n 
)
static

of renaming

Parameters
lof renaming

Definition at line 665 of file dynamic.c.

669 {
670  MAP(RENAMING, r,
671  {
672  if (renaming_old(r)==o)
673  {
674  pips_assert("same required mapping", renaming_new(r)==n);
675  return l;
676  }
677  },
678  l);
679 
680  return CONS(RENAMING, make_renaming(o, n), l);
681 }
renaming make_renaming(entity a1, entity a2)
Definition: hpf_private.c:881
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
Definition: newgen_list.h:226
#define renaming_old(x)
Definition: hpf_private.h:969
#define renaming_new(x)
Definition: hpf_private.h:971
#define RENAMING(x)
RENAMING.
Definition: hpf_private.h:939

References CONS, make_renaming(), MAP, pips_assert, RENAMING, renaming_new, and renaming_old.

Referenced by hpfc_translate_call_with_distributed_args().

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

◆ alive_arrays()

list alive_arrays ( statement  s,
entity  t 
)

what: returns the list of alive arrays for statement s and template t.

how: uses the alive_synonym, and computes the defaults. input: statement s and template t which are of interest. output: a list of entities which is allocated. side effects: none. of entities

of entities

to tag seen primaries.

??? well, it is not necessarily initialized, I guess...

first the alive list is scanned.

second the defaults are looked for. namely the primary entities.

Definition at line 1504 of file dynamic.c.

1507 {
1508  list /* of entities */ l = NIL, lseens = NIL; /* to tag seen primaries. */
1509 
1510  pips_assert("template", entity_template_p(t) && primary_entity_p(t));
1511  pips_debug(7, "for template %s\n", entity_name(t));
1512 
1513  /* ??? well, it is not necessarily initialized, I guess...
1514  */
1515  if (!bound_alive_synonym_p(s))
1516  store_alive_synonym(s, make_entities(NIL));
1517 
1518  /* first the alive list is scanned.
1519  */
1520  MAP(ENTITY, array,
1521  {
1523 
1524  if (safe_load_primary_entity(ta)==t)
1525  l = CONS(ENTITY, array, l);
1526 
1527  pips_debug(8, "adding %s as alive\n", entity_name(array));
1528 
1529  lseens = CONS(ENTITY, load_primary_entity(array), lseens);
1530  },
1531  entities_list(load_alive_synonym(s)));
1532 
1533  /* second the defaults are looked for. namely the primary entities.
1534  */
1535  MAP(ENTITY, array,
1536  {
1537  if (primary_entity_p(array) && !gen_in_list_p(array, lseens))
1538  {
1540  l = CONS(ENTITY, array, l);
1541 
1542  pips_debug(8, "adding %s as default\n", entity_name(array));
1543 
1544  lseens = CONS(ENTITY, array, lseens);
1545  }
1546  },
1548 
1549  DEBUG_ELST(9, "seen arrays", lseens);
1550  gen_free_list(lseens);
1551 
1552  DEBUG_ELST(7, "returned alive arrays", l);
1553  return l;
1554 }
entity safe_load_primary_entity(entity e)
HPFC module by Fabien COELHO.
Definition: dynamic.c:61
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
bool gen_in_list_p(const void *vo, const list lx)
tell whether vo belongs to lx
Definition: list.c:734
#define align_template(x)
Definition: hpf.h:98
#define primary_entity_p(a)
bool entity_template_p(entity)
align load_hpf_alignment(entity)
list list_of_distributed_arrays(void)
static entity array
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References align_template, array, CONS, DEBUG_ELST, entities_list, ENTITY, entity_name, entity_template_p(), gen_free_list(), gen_in_list_p(), list_of_distributed_arrays(), load_hpf_alignment(), load_primary_entity(), make_entities(), MAP, NIL, pips_assert, pips_debug, primary_entity_p, and safe_load_primary_entity().

Referenced by one_distribute_directive().

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

◆ array_distribution_similar_p()

bool array_distribution_similar_p ( entity  a1,
entity  a2 
)

conformant processors ??? could assume that P(1:1,1:n) is conformant to P'(1:n)?

considering ith dim of proc

conformant distributions

if the size is 1, whatever the distribution it is ok!

conformant alignments for that pe dim !!! the HPF mapping "semantics" insure that the corresponding dimension is distributed!

Parameters
a11
a22

Definition at line 578 of file dynamic.c.

579 {
580  align
581  al1 = load_hpf_alignment(a1),
582  al2 = load_hpf_alignment(a2);
583  entity
584  t1 = align_template(al1),
585  t2 = align_template(al2);
586  distribute
587  d1 = load_hpf_distribution(t1),
588  d2 = load_hpf_distribution(t2);
589  entity
590  p1 = distribute_processors(d1),
591  p2 = distribute_processors(d2);
592  int i, td1, td2,
593  ndimdist = NumberOfDimension(p1);
594 
595  pips_assert("same primary",
597 
598  pips_debug(6, "comparing %s and %s\n", entity_name(a1), entity_name(a2));
599 
600  /* conformant processors
601  * ??? could assume that P(1:1,1:n) is conformant to P'(1:n)?
602  */
603  if (!conformant_entities_p(p1, p2))
604  RET("different processors", false);
605 
606  for (i=1; i<=ndimdist; i++) /* considering ith dim of proc */
607  {
608  /* conformant distributions
609  */
610  distribution
612  (distribute_distribution(d1), i, &td1),
614  (distribute_distribution(d2), i, &td2);
615  alignment at1, at2;
616  int dsize = SizeOfIthDimension(p1,i);
617 
618  /* if the size is 1, whatever the distribution it is ok! */
619  if (dsize!=1)
620  {
621  if (!same_distribution_p(x1, x2))
622  RET("different distribution", false);
623 
624  /* conformant alignments for that pe dim
625  * !!! the HPF mapping "semantics" insure that the corresponding
626  * dimension is distributed!
627  */
630 
631  if (!same_alignment_p(a1,t1,at1,a2,t2,at2))
632  RET("different alignment", false);
633  }
634  }
635 
636  pips_debug(6, "similar distributions!\n");
637  return true;
638 }
static bool same_distribution_p(distribution d1, distribution d2)
array_distribution_similar_p
Definition: dynamic.c:523
#define RET(msg, what)
Definition: dynamic.c:574
static bool same_alignment_p(entity e1, entity t1, alignment a1, entity e2, entity t2, alignment a2)
Definition: dynamic.c:535
static bool conformant_entities_p(entity e1, entity e2)
Definition: dynamic.c:329
#define align_alignment(x)
Definition: hpf.h:96
#define distribute_distribution(x)
Definition: hpf.h:174
#define distribute_processors(x)
Definition: hpf.h:176
distribution FindDistributionOfProcessorDim(list ldi, int dim, int *tdim)
Definition: hpfc-util.c:421
alignment FindAlignmentOfTemplateDim(list lal, int dim)
Definition: hpfc-util.c:389
distribute load_hpf_distribution(entity)
int SizeOfIthDimension(entity, int)
this function returns the size of the ith dimension of a variable e.
Definition: size.c:453
int NumberOfDimension(entity)
Definition: size.c:588

References align_alignment, align_template, conformant_entities_p(), distribute_distribution, distribute_processors, entity_name, FindAlignmentOfTemplateDim(), FindDistributionOfProcessorDim(), load_hpf_alignment(), load_hpf_distribution(), load_primary_entity(), NumberOfDimension(), pips_assert, pips_debug, RET, same_alignment_p(), same_distribution_p(), and SizeOfIthDimension().

Referenced by check_for_similarity().

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

◆ array_synonym_aligned_as()

entity array_synonym_aligned_as ( entity  array,
align  a 
)

entity array_synonym_aligned_as(array, a) entity array; align a;

what: finds or creates a new entity aligned as needed. input: an array (which must be dynamic) and an align output: returns an array aligned as specified by align a side effects:

  • creates a new entity if necessary.
  • this entity is stored as a synonym of array, and tagged as dynamic.
  • the align is freed if not used. bugs or features:

the one found is returned

else no compatible array does exist, so one must be created

Parameters
arrayrray

Definition at line 449 of file dynamic.c.

452 {
453  ifdebug(8)
454  {
455  pips_debug(8, "array %s\n", entity_name(array));
456  print_align(a);
457  }
458 
459  MAP(ENTITY, ar,
460  {
461  if (same_align_p(load_hpf_alignment(ar), a))
462  {
463  free_align(a);
464  return ar; /* the one found is returned */
465  }
466  },
468 
469  /* else no compatible array does exist, so one must be created
470  */
471  return new_synonym_array(array, a);
472 }
void free_align(align p)
Definition: hpf.c:19
void print_align(align a)
this is a set of functions to help hpfc debugging
Definition: debug-util.c:38
static entity new_synonym_array(entity a, align al)
builds a new synonym for array a, the alignment of which will be al.
Definition: dynamic.c:306
static bool same_align_p(align a1, align a2)
Definition: dynamic.c:418
#define ifdebug(n)
Definition: sg.c:47

References array, entities_list, ENTITY, entity_name, free_align(), ifdebug, load_dynamic_hpf(), load_hpf_alignment(), MAP, new_synonym_array(), pips_debug, print_align(), and same_align_p().

Referenced by hpfc_translate_call_with_distributed_args(), one_align_directive(), and one_distribute_directive().

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

◆ check_for_similarity()

static void check_for_similarity ( entity  a,
list  others 
)
static

no templates!

job already done

look for copies with similar mappings for latter update

a -> init[e] for storage purposes

Parameters
othersarray a to be compared against its similars of entity

Definition at line 230 of file dynamic.c.

233 {
234  bool similar_found = false;
235 
236  pips_debug(3, "of %s\n", entity_name(a));
237 
238  if (!array_distributed_p(a)) /* no templates! */
239  return;
240 
241  if (bound_similar_mapping_p(a)) /* job already done */
242  return;
243 
244  /* look for copies with similar mappings for latter update
245  */
246  MAP(ENTITY, e,
247  {
248  pips_debug(7, "%s against %s\n", entity_name(a), entity_name(e));
249  if (a!=e && array_distribution_similar_p(e, a))
250  {
251  /* a -> init[e] for storage purposes
252  */
253  pips_debug(8, "found similar: %s -> %s\n",
254  entity_name(a), entity_name(e));
256  similar_found = true;
257  break;
258  }
259  },
260  others);
261 
262  if (!similar_found) store_similar_mapping(a, a);
263 
264  return;
265 }
bool array_distribution_similar_p(entity a1, entity a2)
Definition: dynamic.c:578
entity load_similar_mapping(entity)
void store_similar_mapping(entity, entity)
bool bound_similar_mapping_p(entity)
bool array_distributed_p(entity)

References array_distributed_p(), array_distribution_similar_p(), bound_similar_mapping_p(), ENTITY, entity_name, load_similar_mapping(), MAP, pips_debug, and store_similar_mapping().

Referenced by hpfc_check_for_similarities().

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

◆ close_dynamic_locals()

void close_dynamic_locals ( void  )

can't close it directly...

Definition at line 817 of file dynamic.c.

818 {
819  close_alive_synonym();
820  close_used_dynamics();
821  close_modified_dynamics();
822  close_reaching_mappings();
823  close_leaving_mappings();
824  close_remapped();
825 
826  /* can't close it directly...
827  */
828  CONTROLMAP_MAP(s, c,
829  {
830  what_stat_debug(9, s);
831 
835  },
836  get_remapping_graph());
837 
838  close_remapping_graph();
839 }
#define CONTROLMAP_MAP(k, v, c, f)
Definition: ri.h:900
#define control_statement(x)
Definition: ri.h:941
#define statement_undefined
Definition: ri.h:2419

References control_predecessors, control_statement, control_successors, CONTROLMAP_MAP, gen_free_list(), NIL, statement_undefined, and what_stat_debug.

Referenced by handle_hpf_directives().

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

◆ close_dynamic_status()

void close_dynamic_status ( void  )

Definition at line 117 of file dynamic.c.

118 {
121  close_renamings();
124 }
void close_dynamic_hpf(void)
void close_similar_mapping(void)
void close_primary_entity(void)
void close_maybeuseful_mappings(void)
void close_renamings(void)

References close_dynamic_hpf(), close_maybeuseful_mappings(), close_primary_entity(), close_renamings(), and close_similar_mapping().

+ Here is the call graph for this function:

◆ conformant_entities_p()

static bool conformant_entities_p ( entity  e1,
entity  e2 
)
static

Definition at line 329 of file dynamic.c.

332 {
333  int ndim;
334  if (e1==e2) return true;
335 
336  ndim = NumberOfDimension(e1);
337 
338  if (ndim!=NumberOfDimension(e2)) return false;
339 
340  for (; ndim>0; ndim--)
341  {
342  int l1, u1, l2, u2;
343  get_entity_dimensions(e1, ndim, &l1, &u1);
344  get_entity_dimensions(e2, ndim, &l2, &u2);
345  if (l1!=l2 || u1!=u2) return false;
346  }
347 
348  return true;
349 }
void get_entity_dimensions(entity e, int dim, int *plow, int *pup)
Definition: hpfc-util.c:651

References get_entity_dimensions(), and NumberOfDimension().

Referenced by array_distribution_similar_p(), conformant_templates_p(), hpfc_translate_call_with_distributed_args(), and same_distribute_p().

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

◆ conformant_templates_p()

bool conformant_templates_p ( entity  t1,
entity  t2 
)
Parameters
t11
t22

Definition at line 405 of file dynamic.c.

408 {
409  if (t1==t2)
410  return true;
411  else if (!conformant_entities_p(t1, t2))
412  return false;
413  else
414  return same_distribute_p
416 }
static bool same_distribute_p(distribute d1, distribute d2)
comparison of DISTRIBUTE.
Definition: dynamic.c:353

References conformant_entities_p(), load_hpf_distribution(), and same_distribute_p().

Referenced by align_check(), and same_align_p().

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

◆ continue_propagation_p()

static bool continue_propagation_p ( statement  s)
static

up to the template!

the variable is realigned.

else it may be a call because of ALIGN () WITH T()X...

up to the processor, stop

if template t is redistributed...

Definition at line 990 of file dynamic.c.

991 {
993 
994  what_stat_debug(8, s);
995  DEBUG_STAT(9, "current", s);
996 
997  if (!instruction_call_p(i))
998  {
999  ret("not a call", true);
1000  }
1001  else
1002  {
1003  call c = instruction_call(i);
1004  entity fun = call_function(c);
1005 
1007  {
1008  entity
1010  array;
1011 
1012  DEBUG_STAT(8, "rename directive", s);
1013 
1015 
1016  if (safe_load_primary_entity(array)==primary)
1017  {
1020  ret("rename to the same", false);
1021  }
1022  }
1023  else if (realign_directive_p(fun) && array_propagation)
1024  {
1026  int nbofargs = gen_length(call_arguments(c));
1027 
1028  DEBUG_STAT(8, "realign directive", s);
1029 
1030  MAP(EXPRESSION, e,
1031  {
1032  nbofargs--;
1033  if (expression_reference_p(e))
1034  {
1036  entity var = reference_variable(r);
1037 
1038  if (nbofargs==0) /* up to the template! */
1039  ret("template of realign", true);
1040 
1041  if (safe_load_primary_entity(var)==primary)
1042  {
1043  /* the variable is realigned.
1044  */
1047  ret("realign array", false);
1048  }
1049  }
1050  /* else it may be a call because of ALIGN () WITH T()::X...
1051  */
1052  },
1053  call_arguments(c));
1054  }
1055  else if (redistribute_directive_p(fun))
1056  {
1059 
1060  DEBUG_STAT(8, "redistribute directive", s);
1061 
1062  MAP(EXPRESSION, e,
1063  {
1065 
1066  if (!entity_template_p(v)) /* up to the processor, stop */
1067  ret("processors of distribute", true);
1068 
1069  /* if template t is redistributed...
1070  */
1071  if (safe_load_primary_entity(v)==t)
1072  {
1073  if (array_propagation)
1076 
1077  ret("redistribute template", false);
1078  }
1079  },
1080  call_arguments(c));
1081  }
1082  else if (dead_fcd_directive_p(fun) && array_propagation)
1083  {
1085 
1086  MAP(EXPRESSION, e,
1087  if (primary==expression_to_entity(e)) ret("dead array", false),
1088  call_arguments(c));
1089  }
1090 
1091  ret("default", true);
1092  }
1093 }
static entity new_variable
entity to be replaced, the primary?
Definition: dynamic.c:860
static void add_alive_synonym(statement s, entity a)
Definition: dynamic.c:916
#define ret(why, what)
true if not a remapping for old.
Definition: dynamic.c:986
static entity old_variable
void propagate_synonym(s, old, new) statement s; entity old, new;
Definition: dynamic.c:859
static bool rename_directive_p(entity f)
Definition: dynamic.c:978
static bool array_propagation
replacement
Definition: dynamic.c:862
static void add_as_a_closing_statement(statement s)
Definition: dynamic.c:882
size_t gen_length(const list l)
Definition: list.c:150
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define DEBUG_STAT(D, W, S)
reference expression_to_reference(expression e)
Definition: expression.c:212
bool expression_reference_p(expression e)
Test if an expression is a reference.
Definition: expression.c:528
entity expression_to_entity(expression e)
just returns the entity of an expression, or entity_undefined
Definition: expression.c:3140
bool realign_directive_p(entity f)
Definition: hpfc.c:62
bool dead_fcd_directive_p(entity f)
Definition: hpfc.c:74
bool redistribute_directive_p(entity f)
Definition: hpfc.c:68
#define call_function(x)
Definition: ri.h:709
#define reference_variable(x)
Definition: ri.h:2326
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define instruction_call_p(x)
Definition: ri.h:1527
#define statement_instruction(x)
Definition: ri.h:2458
#define instruction_call(x)
Definition: ri.h:1529
#define call_arguments(x)
Definition: ri.h:711

References add_alive_synonym(), add_as_a_closing_statement(), align_template, array, array_propagation, call_arguments, call_function, CAR, dead_fcd_directive_p(), DEBUG_STAT, entity_template_p(), EXPRESSION, expression_reference_p(), expression_to_entity(), expression_to_reference(), gen_length(), instruction_call, instruction_call_p, load_hpf_alignment(), MAP, new_variable, old_variable, realign_directive_p(), redistribute_directive_p(), reference_variable, rename_directive_p(), ret, safe_load_primary_entity(), statement_instruction, and what_stat_debug.

Referenced by propagate_synonym().

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

◆ dump_current_remapping_graph()

void dump_current_remapping_graph ( string  when)
Parameters
whenhen

Definition at line 1440 of file dynamic.c.

1441 {
1443 }
static void dump_remapping_graph(string when, list ls)
Definition: dynamic.c:1431
static list list_of_remapping_statements()
of statements
Definition: dynamic.c:1383

References dump_remapping_graph(), and list_of_remapping_statements().

Referenced by handle_hpf_directives().

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

◆ dump_remapping_graph()

static void dump_remapping_graph ( string  when,
list  ls 
)
static
Parameters
lsof statement

Definition at line 1431 of file dynamic.c.

1434 {
1435  fprintf(stderr, "[dump_remapping_graph] for %s\n", when);
1437  fprintf(stderr, "[dump_remapping_graph] done\n");
1438 }
static void dump_remapping_graph_info(statement s)
Definition: dynamic.c:1410
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
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...

References dump_remapping_graph_info(), fprintf(), and gen_map().

Referenced by dump_current_remapping_graph(), and simplify_remapping_graph().

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

◆ dump_remapping_graph_info()

static void dump_remapping_graph_info ( statement  s)
static

Definition at line 1410 of file dynamic.c.

1411 {
1412  control c = load_remapping_graph(s);
1413 
1414  what_stat_debug(1, s);
1415 
1416  fprintf(stderr, "predecessors: ");
1418  fprintf(stderr, "\nsuccessors: ");
1420  fprintf(stderr, "\n");
1421 
1422  elst_ifdef("remapped", remapped, s);
1423  elst_ifdef("used", used_dynamics, s);
1424  elst_ifdef("modified", modified_dynamics, s);
1425  elst_ifdef("reaching", reaching_mappings, s);
1426  elst_ifdef("leaving", leaving_mappings, s);
1427  elst_ifdef("maybe useful", maybeuseful_mappings, s);
1428 }
static void print_control_ordering(control c)
functions used for debug.
Definition: dynamic.c:1397
#define elst_ifdef(what, name, s)
Definition: dynamic.c:1406

References control_predecessors, control_successors, elst_ifdef, fprintf(), gen_map(), print_control_ordering(), and what_stat_debug.

Referenced by dump_remapping_graph().

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

◆ generate_copy_loop_nest()

statement generate_copy_loop_nest ( entity  src,
entity  trg 
)

statement generate_copy_loop_nest(src, trg) entity src, trg;

what: generates a parallel loop nest that copies src in trg. how: by building the corresponding AST. input: the two entities, which should be arrays with the same shape. output: a statement containing the loop nest. side effects:

  • adds a few new variables for the loop indexes. bugs or features:
  • could be more general?

of entities

of expressions

of dimensions

???

builds the set of indexes needed to scan the dimensions.

builds the assign statement to put in the body. TRG(indexes) = SRC(indexes)

builds the copy loop nest

Parameters
srcrc
trgrg

Definition at line 1568 of file dynamic.c.

1571 {
1572  type t = entity_type(src);
1573  list /* of entities */ indexes = NIL,
1574  /* of expressions */ idx_expr,
1575  /* of dimensions */ dims;
1577  entity module;
1578  int ndims, i;
1579 
1580  if (src==trg) return make_empty_statement();
1581 
1582  pips_assert("valid arguments",
1584  type_variable_p(t) &&
1585  load_primary_entity(src)==load_primary_entity(trg)); /* ??? */
1586 
1588  ndims = gen_length(dims);
1589 
1590  /* builds the set of indexes needed to scan the dimensions.
1591  */
1592  for(module=get_current_module_entity(), i=ndims; i>0; i--)
1593  indexes = CONS(ENTITY,
1595  indexes);
1596 
1597  idx_expr = entities_to_expressions(indexes);
1598 
1599  /* builds the assign statement to put in the body.
1600  * TRG(indexes) = SRC(indexes)
1601  */
1603  (reference_to_expression(make_reference(trg, idx_expr)),
1605 
1606  /* builds the copy loop nest
1607  */
1608  for(; ndims>0; POP(dims), POP(indexes), ndims--)
1609  {
1610  dimension d = DIMENSION(CAR(dims));
1611 
1613  (make_loop(ENTITY(CAR(indexes)),
1616  int_to_expression(1)),
1617  current,
1620  NIL));
1621  }
1622 
1623  DEBUG_STAT(7, concatenate(entity_name(src), " -> ", entity_name(trg), NULL),
1624  current);
1625 
1626  return current;
1627 }
execution make_execution(enum execution_utype tag, void *val)
Definition: ri.c:838
loop make_loop(entity a1, range a2, statement a3, entity a4, execution a5, list a6)
Definition: ri.c:1301
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
range make_range(expression a1, expression a2, expression a3)
Definition: ri.c:2041
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
statement make_assign_statement(expression, expression)
Definition: statement.c:583
#define src(name, suf)
HPFC by Fabien Coelho, May 1993 and later...
Definition: compile.c:41
entity hpfc_new_variable(entity module, basic b)
Definition: compile.c:632
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
#define UU
Definition: newgen_types.h:98
static char * module
Definition: pips.c:74
#define loop_to_statement(l)
#define make_empty_statement
An alias for make_empty_block_statement.
list entities_to_expressions(list l_ent)
build a list of expressions from a list of entities
Definition: entity.c:2703
entity entity_empty_label(void)
Definition: entity.c:1105
expression reference_to_expression(reference r)
Definition: expression.c:196
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
basic MakeBasic(int)
END_EOLE.
Definition: type.c:128
@ is_basic_int
Definition: ri.h:571
#define dimension_lower(x)
Definition: ri.h:980
#define type_variable(x)
Definition: ri.h:2949
#define dimension_upper(x)
Definition: ri.h:982
#define variable_dimensions(x)
Definition: ri.h:3122
@ is_execution_parallel
Definition: ri.h:1190
#define entity_type(x)
Definition: ri.h:2792
#define type_variable_p(x)
Definition: ri.h:2947
static size_t current
Definition: string.c:115

References array_distributed_p(), CAR, concatenate(), CONS, copy_expression(), current, DEBUG_STAT, DIMENSION, dimension_lower, dimension_upper, entities_to_expressions(), ENTITY, entity_empty_label(), entity_name, entity_type, gen_copy_seq(), gen_length(), get_current_module_entity(), hpfc_new_variable(), int_to_expression(), is_basic_int, is_execution_parallel, load_primary_entity(), loop_to_statement, make_assign_statement(), make_empty_statement, make_execution(), make_loop(), make_range(), make_reference(), MakeBasic(), module, NIL, pips_assert, POP, reference_to_expression(), src, type_variable, type_variable_p, UU, and variable_dimensions.

Referenced by clean_statement().

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

◆ get_dynamic_status()

dynamic_status get_dynamic_status ( void  )

get_similar_mapping()

Definition at line 99 of file dynamic.c.

100 {
103  get_renamings(),
105  /* get_similar_mapping() */
106 }
dynamic_status make_dynamic_status(entity_entities a1, entitymap a2, statement_renamings a3, statement_entities a4)
Definition: hpf_private.c:208
statement_entities get_maybeuseful_mappings(void)
statement_renamings get_renamings(void)
entity_entities get_dynamic_hpf(void)
entitymap get_primary_entity(void)

References get_dynamic_hpf(), get_maybeuseful_mappings(), get_primary_entity(), get_renamings(), and make_dynamic_status().

Referenced by init_hpfc_status(), and save_hpfc_status().

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

◆ hpfc_call_with_distributed_args_p()

bool hpfc_call_with_distributed_args_p ( call  c)

whether call c inplies a distributed argument

no intrinsics

else checks for distributed arguments

Definition at line 645 of file dynamic.c.

646 {
647  entity f = call_function(c);
648  int len = gen_length(call_arguments(c));
649 
650  /* no intrinsics */
652  hpf_directive_entity_p(f)) return false;
653 
654  /* else checks for distributed arguments */
655  for (; len>0; len--)
656  {
657  entity arg = find_ith_parameter(f, len);
658  if (array_distributed_p(arg)) return true;
659  }
660 
661  return false;
662 }
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
bool hpf_directive_entity_p(entity e)
Definition: hpfc.c:56
entity find_ith_parameter(entity, int)
Definition: util.c:93
#define value_intrinsic_p(x)
Definition: ri.h:3074
#define entity_initial(x)
Definition: ri.h:2796

References array_distributed_p(), call_arguments, call_function, entity_initial, f(), find_ith_parameter(), gen_length(), hpf_directive_entity_p(), and value_intrinsic_p.

Referenced by prescription_filter().

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

◆ hpfc_check_for_similarities()

void hpfc_check_for_similarities ( list  le)

check all dynamic arrays for some similars...

of entity

similar bases

Parameters
leof entity

Definition at line 269 of file dynamic.c.

270 {
271  MAP(ENTITY, array,
272  {
274  {
275  list /* of entity */
276  seens = CONS(ENTITY, array, NIL); /* similar bases */
277 
278  pips_assert("is a primary!", primary_entity_p(array));
279 
281 
282  MAP(ENTITY, a,
283  {
284  if (!gen_in_list_p(a, seens))
285  {
286  entity similar;
287  check_for_similarity(a, seens);
288  similar = load_similar_mapping(a);
289  pips_debug(1, "%s similar to %s\n",
290  entity_name(a), entity_name(similar));
291 
292  seens = gen_once(similar, seens);
293  }
294  },
296 
297  gen_free_list(seens);
298  }
299  },
300  le);
301 }
static void check_for_similarity(entity a, list others)
Definition: dynamic.c:230

References array, array_distributed_p(), check_for_similarity(), CONS, entities_list, ENTITY, entity_name, gen_free_list(), gen_in_list_p(), gen_once(), load_dynamic_hpf(), load_similar_mapping(), MAP, NIL, pips_assert, pips_debug, and primary_entity_p.

Referenced by handle_hpf_directives().

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

◆ hpfc_translate_call_with_distributed_args()

void hpfc_translate_call_with_distributed_args ( statement  s,
call  c 
)

??? only simple calls are handled.

imbrication may cause problems. ??? should recurse thru all the calls at a call instruction... the call. (not necessarily an instruction)

of remapping

of expression

the substitution in the call will be performed at the propagation phase of dynamic arrays, later on.

add the renaming in the list. ??? should be added only once! what about call(A,A)...

should always be the case

of statement

Do not forget to move forbidden information associated with block:

Parameters
cthe statement the call belongs to

Definition at line 687 of file dynamic.c.

690 {
691  list /* of remapping */ lr = NIL,
692  /* of expression */ args;
693  int len, i;
694  entity f;
695 
696  f = call_function(c);
697  args = call_arguments(c);
698  len = gen_length(args);
699 
700  pips_debug(1, "function %s\n", entity_name(f));
701 
702  for (i=1; i<=len; i++, POP(args))
703  {
704  entity arg = find_ith_parameter(f, i);
705  pips_debug(7, "considering argument %d\n", i);
706 
707  if (array_distributed_p(arg))
708  {
709  align al;
710  entity passed, copy;
711  expression e = EXPRESSION(CAR(args));
712 
713  passed = expression_to_entity(e);
714 
715  pips_debug(8, "passed:%s, arg:%s\n",
716  entity_name(passed), entity_name(arg));
717  pips_assert("distributed and conformant",
718  array_distributed_p(passed) &&
719  conformant_entities_p(passed, arg));
720 
721  set_entity_as_dynamic(passed);
722  add_a_dynamic(passed);
723 
724  al = copy_align(load_hpf_alignment(arg));
725  copy = array_synonym_aligned_as(passed, al);
726 
727  pips_debug(3, "%s (arg %d) %s -> %s\n", entity_name(arg), i,
728  entity_name(passed), entity_name(copy));
729 
730  /* the substitution in the call will be performed at the
731  * propagation phase of dynamic arrays, later on.
732  */
733  /* add the renaming in the list.
734  * ??? should be added only once! what about call(A,A)...
735  */
736  lr = add_once_to_renaming_list(lr, passed, copy);
737  }
738  }
739 
740  if (lr) /* should always be the case */
741  {
742  list /* of statement */ lpre = NIL, lpos = NIL;
744 
745  lpre = CONS(STATEMENT,
747  NIL);
748 
749  MAP(RENAMING, r,
750  {
751  entity passed = renaming_old(r);
752  entity copied = renaming_new(r);
753 
754  lpre = CONS(STATEMENT, call_to_statement(make_call(rename,
756  CONS(EXPRESSION, entity_to_expression(copied), NIL)))),
757  lpre);
758 
759  lpos = CONS(STATEMENT, call_to_statement(make_call(rename,
761  CONS(EXPRESSION, entity_to_expression(passed), NIL)))),
762  lpos);
763  },
764  lr);
765 
767  make_instruction_block(gen_nconc(lpre, lpos));
768  /* Do not forget to move forbidden information associated with
769  block: */
771 
772  DEBUG_STAT(3, "out", s);
773  }
774 }
align copy_align(align p)
ALIGN.
Definition: hpf.c:16
call make_call(entity a1, list a2)
Definition: ri.c:269
static list add_once_to_renaming_list(list l, entity o, entity n)
of renaming
Definition: dynamic.c:665
void set_entity_as_dynamic(entity e)
a new dynamic entity is stored.
Definition: dynamic.c:130
entity array_synonym_aligned_as(entity array, align a)
entity array_synonym_aligned_as(array, a) entity array; align a;
Definition: dynamic.c:449
statement instruction_to_statement(instruction)
Build a statement from a give instruction.
Definition: statement.c:597
instruction make_instruction_block(list statements)
Build an instruction block from a list of statements.
Definition: instruction.c:106
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
void fix_sequence_statement_attributes(statement)
Since blocks are not represented in Fortran, they cannot carry a label.
Definition: statement.c:2016
#define RENAME_SUFFIX
void add_a_dynamic(entity c)
local primary dynamics
Definition: directives.c:99
entity hpfc_name_to_entity(const char *)
Definition: run-time.c:817
#define HPF_PREFIX
moved here because needed by syntax:-(
#define call_to_statement(c)
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413

References add_a_dynamic(), add_once_to_renaming_list(), array_distributed_p(), array_synonym_aligned_as(), call_arguments, call_function, call_to_statement, CAR, conformant_entities_p(), CONS, copy_align(), DEBUG_STAT, entity_name, entity_to_expression(), EXPRESSION, expression_to_entity(), f(), find_ith_parameter(), fix_sequence_statement_attributes(), gen_length(), gen_nconc(), HPF_PREFIX, hpfc_name_to_entity(), instruction_to_statement(), load_hpf_alignment(), make_call(), make_instruction_block(), MAP, NIL, pips_assert, pips_debug, POP, RENAME_SUFFIX, RENAMING, renaming_new, renaming_old, set_entity_as_dynamic(), STATEMENT, and statement_instruction.

Referenced by prescription_filter().

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

◆ init_dynamic_locals()

void init_dynamic_locals ( void  )

DYNAMIC LOCAL DATA.

these static functions are used to store the remapping graph while it is built, or when optimizations are performed on it.

  • alive_synonym: used when building the remapping graph. synonym of a primary entity that has reached a given remapping statement. Used for both arrays and templates.
  • used_dynamics: from a remapping statement, the remapped arrays that are actually referenced in their new shape.
  • modified_dynamics: from a remapping statement, the remapped arrays that may be modified in their new shape.
  • remapping_graph: the remapping graph, based on the control domain. the control_statement is the remapping statement in the code. predecessors and successors are the possible remapping statements for the arrays remapped at that vertex.
  • reaching_mappings: the mappings that may reached a vertex.
  • leaving_mappings: the mappings that may leave the vertex. (simplification assumption: only one per array)
  • remapped: the (primary) arrays remapped at the vertex.

Definition at line 806 of file dynamic.c.

807 {
808  init_alive_synonym();
809  init_used_dynamics();
810  init_modified_dynamics();
811  init_reaching_mappings();
812  init_leaving_mappings();
813  init_remapped();
814  init_remapping_graph();
815 }

Referenced by handle_hpf_directives().

+ Here is the caller graph for this function:

◆ init_dynamic_status()

void init_dynamic_status ( void  )

DYNAMIC STATUS management.

Definition at line 81 of file dynamic.c.

82 {
88 }
void init_maybeuseful_mappings(void)
void init_similar_mapping(void)
void init_renamings(void)
void init_primary_entity(void)
void init_dynamic_hpf(void)

References init_dynamic_hpf(), init_maybeuseful_mappings(), init_primary_entity(), init_renamings(), and init_similar_mapping().

Referenced by init_hpfc_status().

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

◆ initialize_maybeuseful_mappings()

static void initialize_maybeuseful_mappings ( statement  s)
static

must be called after useless leaving mappings removal

Definition at line 1194 of file dynamic.c.

1195 {
1196  store_maybeuseful_mappings(s, copy_entities(load_leaving_mappings(s)));
1197 }
entities copy_entities(entities p)
ENTITIES.
Definition: hpf_private.c:214
void store_maybeuseful_mappings(statement, entities)

References copy_entities(), and store_maybeuseful_mappings().

Referenced by simplify_remapping_graph().

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

◆ initialize_reaching_propagation()

static void initialize_reaching_propagation ( statement  s)
static

for statement s

  • remapped arrays
  • reaching mappings (1 per array, or more)
  • leaving mappings (1 per remapped array, to simplify)

of entities

Definition at line 1142 of file dynamic.c.

1144 {
1145  list /* of entities */ le = NIL, lp = NIL, ll = NIL;
1146  entity old, new;
1147 
1148  what_stat_debug(4, s);
1149 
1150  MAP(RENAMING, r,
1151  {
1152  old = renaming_old(r);
1153  new = renaming_new(r);
1154 
1155  le = gen_once(old, le);
1156  lp = gen_once(load_primary_entity(old), lp);
1157  ll = gen_once(new, ll);
1158  },
1159  load_renamings(s));
1160 
1161  store_reaching_mappings(s, make_entities(le));
1162  store_remapped(s, make_entities(lp));
1163  store_leaving_mappings(s, make_entities(ll));
1164 }
list load_renamings(statement)

References gen_once(), load_primary_entity(), load_renamings(), make_entities(), MAP, NIL, RENAMING, renaming_new, renaming_old, and what_stat_debug.

Referenced by simplify_remapping_graph().

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

◆ lazy_initialize_for_statement()

static void lazy_initialize_for_statement ( statement  s)
static

starting point

initialize both the remapping graph and the used dynamics for s

Definition at line 870 of file dynamic.c.

871 {
872  if (!bound_remapping_graph_p(s))
873  store_remapping_graph(s, make_control(s, NIL, NIL));
874 
875  if (!bound_used_dynamics_p(s))
876  store_used_dynamics(s, make_entities(NIL));
877 
878  if (!bound_modified_dynamics_p(s))
879  store_modified_dynamics(s, make_entities(NIL));
880 }
control make_control(statement a1, list a2, list a3)
Definition: ri.c:523

References make_control(), make_entities(), and NIL.

Referenced by add_as_a_closing_statement(), and propagate_synonym().

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

◆ list_of_remapping_statements()

static list list_of_remapping_statements ( )
static

of statements

of statements

Definition at line 1383 of file dynamic.c.

1384 {
1385  list /* of statements */ l = NIL;
1386  CONTROLMAP_MAP(s, c,
1387  {
1388  pips_debug(9, "%p -> %p\n", s, c);
1389  l = CONS(STATEMENT, s, l);
1390  },
1391  get_remapping_graph());
1392  return l;
1393 }

References CONS, CONTROLMAP_MAP, NIL, pips_debug, and STATEMENT.

Referenced by dump_current_remapping_graph(), and simplify_remapping_graph().

+ Here is the caller graph for this function:

◆ new_align_with_template()

align new_align_with_template ( align  a,
entity  t 
)

Definition at line 474 of file dynamic.c.

477 {
478  align b = copy_align(a);
479  align_template(b) = t;
480  return b;
481 }

References align_template, and copy_align().

Referenced by one_distribute_directive().

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

◆ new_synonym()

static entity new_synonym ( entity  e)
static

builds a synonym for entity e.

The name is based on e, plus an underscore and a number added. May be used for templates and arrays. the new synonym is added as a synonym of e.

syn. number

the new entity is rather local!

Definition at line 198 of file dynamic.c.

199 {
200  int n = gen_length(entities_list(load_dynamic_hpf(e))); /* syn. number */
201  entity primary = load_primary_entity(e), new_e;
202  const char* module = entity_module_name(e);
203  char new_name[100];
204 
205  sprintf(new_name, "%s_%x", entity_local_name(primary), (unsigned int) n);
206 
207  pips_debug(5, "building entity %s\n", new_name);
208 
209  new_e = FindOrCreateEntityLikeModel(module, new_name, primary);
210 
211  if (storage_formal_p(entity_storage(new_e)))
212  { /* the new entity is rather local! */
213  storage s = entity_storage(new_e);
215  entity_storage(new_e) =
217  make_ram(sub,
220  free_storage(s);
221  }
222 
224 
225  add_dynamic_synonym(new_e, e);
226  return new_e;
227 }
storage make_storage(enum storage_utype tag, void *val)
Definition: ri.c:2273
ram make_ram(entity a1, entity a2, intptr_t a3, list a4)
Definition: ri.c:1999
void free_storage(storage p)
Definition: ri.c:2231
static void add_dynamic_synonym(entity new_e, entity e)
what: new_e is stored as a synonym of e.
Definition: dynamic.c:149
#define DYNAMIC_AREA_LOCAL_NAME
Definition: naming-local.h:69
entity FindEntity(const char *package, const char *name)
Retrieve an entity from its package/module name and its local name.
Definition: entity.c:1503
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
const char * entity_module_name(entity e)
See comments about module_name().
Definition: entity.c:1092
entity FindOrCreateEntityLikeModel(const char *package, const char *name, entity model)
hmmm...
Definition: entity.c:3136
void AddEntityToDeclarations(entity, entity)
END_EOLE.
Definition: variable.c:108
#define storage_formal_p(x)
Definition: ri.h:2522
#define entity_storage(x)
Definition: ri.h:2794
@ is_storage_ram
Definition: ri.h:2492

References add_dynamic_synonym(), AddEntityToDeclarations(), DYNAMIC_AREA_LOCAL_NAME, entities_list, entity_local_name(), entity_module_name(), entity_storage, FindEntity(), FindOrCreateEntityLikeModel(), free_storage(), gen_length(), get_current_module_entity(), is_storage_ram, load_dynamic_hpf(), load_primary_entity(), make_ram(), make_storage(), module, NIL, pips_debug, and storage_formal_p.

Referenced by new_synonym_array(), and new_synonym_template().

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

◆ new_synonym_array()

static entity new_synonym_array ( entity  a,
align  al 
)
static

builds a new synonym for array a, the alignment of which will be al.

The new array is set as distributed.

Definition at line 306 of file dynamic.c.

309 {
310  entity new_a = new_synonym(a);
312  store_hpf_alignment(new_a, al);
313  return new_a;
314 }
static entity new_synonym(entity e)
builds a synonym for entity e.
Definition: dynamic.c:198
void store_hpf_alignment(entity, align)
void set_array_as_distributed(entity)

References new_synonym(), set_array_as_distributed(), and store_hpf_alignment().

Referenced by array_synonym_aligned_as().

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

◆ new_synonym_template()

static entity new_synonym_template ( entity  t,
distribute  di 
)
static

builds a new synonym for template t, the distribution of which will be di.

the new entity is set as a template, and/or as an array

Definition at line 319 of file dynamic.c.

322 {
323  entity new_t = new_synonym(t);
324  set_template(new_t);
325  store_hpf_distribution(new_t, di);
326  return new_t;
327 }
void store_hpf_distribution(entity, distribute)
void set_template(entity)

References new_synonym(), set_template(), and store_hpf_distribution().

Referenced by template_synonym_distributed_as().

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

◆ print_control_ordering()

static void print_control_ordering ( control  c)
static

functions used for debug.

Definition at line 1397 of file dynamic.c.

1398 {
1400  int so = statement_ordering(s);
1401  fprintf(stderr, "(%d:%d:%" PRIdPTR "), ",
1403  statement_ordering(s));
1404 }
#define ORDERING_NUMBER(o)
#define ORDERING_STATEMENT(o)
#define statement_ordering(x)
Definition: ri.h:2454

References control_statement, fprintf(), ORDERING_NUMBER, ORDERING_STATEMENT, and statement_ordering.

Referenced by dump_remapping_graph_info().

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

◆ propagate_maybeuseful_mappings()

static list propagate_maybeuseful_mappings ( statement  s,
list  ls 
)
static

of statements

Parameters
lsof statement

Definition at line 1286 of file dynamic.c.

1289 {
1291  (s, ls, load_maybeuseful_mappings, load_modified_dynamics, true, false);
1292 }
static list propagation_on_remapping_graph(statement s, list ls, entities(*built)(statement), entities(*condition)(statement), bool local, bool forward)
more options, such as may or must?
Definition: dynamic.c:1223
entities load_maybeuseful_mappings(statement)

References load_maybeuseful_mappings(), and propagation_on_remapping_graph().

Referenced by simplify_remapping_graph().

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

◆ propagate_synonym()

void propagate_synonym ( statement  s,
entity  old,
entity  new,
bool  is_array 
)
Parameters
oldstarting statement for the propagation
newentity to be replaced
is_arrayreplacement for the entity true if array, false if template

Definition at line 1096 of file dynamic.c.

1101 {
1103 
1104  what_stat_debug(3, s);
1105  pips_debug(3, "%s -> %s (%s)\n", entity_name(old), entity_name(new),
1106  is_array? "array": "template");
1107  DEBUG_STAT(7, "before propagation", get_current_module_statement());
1108 
1110  array_propagation = is_array;
1111  array_used = false;
1112  array_modified = false;
1113  initial_statement = s;
1114 
1116 
1118 
1121 
1123 
1126 
1129 
1130  DEBUG_STAT(7, "after propagation", get_current_module_statement());
1131 
1132  pips_debug(4, "out\n");
1133 }
bool next_ctrl_graph_travel(statement *)
Definition: graph.c:325
void init_ctrl_graph_travel(statement, bool(*)(statement))
Definition: graph.c:315
void close_ctrl_graph_travel(void)
Definition: graph.c:340
static bool continue_propagation_p(statement s)
Definition: dynamic.c:990
static void simple_switch_old_to_new(statement s)
Definition: dynamic.c:941
static void add_as_a_modified_variable(entity e)
Definition: dynamic.c:910
static void add_as_a_used_variable(entity e)
Definition: dynamic.c:897
static bool array_used
true if an array is propagated, false if template
Definition: dynamic.c:863
static bool array_modified
true if the array was actually used
Definition: dynamic.c:864
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
#define entity_undefined
Definition: ri.h:2761

References add_as_a_modified_variable(), add_as_a_used_variable(), array_modified, array_propagation, array_used, close_ctrl_graph_travel(), continue_propagation_p(), current, DEBUG_STAT, entity_name, entity_undefined, get_current_module_statement(), init_ctrl_graph_travel(), initial_statement, lazy_initialize_for_statement(), new_variable, next_ctrl_graph_travel(), old_variable, pips_debug, safe_load_primary_entity(), simple_switch_old_to_new(), and what_stat_debug.

Referenced by handle_prescriptive_directive(), initial_alignment(), one_align_directive(), and one_distribute_directive().

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

◆ propagate_used_arrays()

static list propagate_used_arrays ( statement  s,
list  ls 
)
static

of statements

Parameters
lsof statements

Definition at line 1277 of file dynamic.c.

1280 {
1282  (s, ls, load_reaching_mappings, load_used_dynamics, false, true);
1283 }

References propagation_on_remapping_graph().

Referenced by simplify_remapping_graph().

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

◆ propagation_on_remapping_graph()

static list propagation_on_remapping_graph ( statement  s,
list  ls,
entities(*)(statement built,
entities(*)(statement condition,
bool  local,
bool  forward 
)
static

more options, such as may or must?

of statement backward or forward

of entity

of entity

idem

if the built set was modified, must propagate at next step...

Parameters
lsof statement
forwardlocal or remote condition

Definition at line 1223 of file dynamic.c.

1230 {
1231  bool modified = false;
1232  entities built_set = built(s);
1233  list /* of entity */
1234  lrem = entities_list(load_remapped(s)),
1235  lbuilt = entities_list(built_set);
1236  control current = load_remapping_graph(s);
1237 
1238  MAP(CONTROL, c,
1239  {
1240  statement sc = control_statement(c);
1241  list /* of entity */ lp_rem = entities_list(load_remapped(sc));
1242  list /* idem */ lp_cond = entities_list(condition(local?s:sc));
1243 
1244  MAP(ENTITY, e,
1245  {
1246  entity prim = load_primary_entity(e);
1247 
1248  if (gen_in_list_p(prim, lrem) &&
1249  gen_in_list_p(prim, lp_rem) &&
1250  !gen_in_list_p(prim, lp_cond) &&
1251  !gen_in_list_p(e, lbuilt))
1252  {
1253  what_stat_debug(5, s);
1254  pips_debug(5, "adding %s from\n", entity_local_name(e));
1255  what_stat_debug(5, sc);
1256 
1257  lbuilt = CONS(ENTITY, e, lbuilt);
1258  modified = true;
1259  }
1260  },
1261  entities_list(built(sc)));
1262  },
1264 
1265  /* if the built set was modified, must propagate at next step... */
1266  if (modified)
1267  {
1268  entities_list(built_set) = lbuilt;
1269  MAP(CONTROL, c, ls = gen_once(control_statement(c), ls),
1271  }
1272 
1273  return ls;
1274 }
#define CONTROL(x)
CONTROL.
Definition: ri.h:910

References CONS, CONTROL, control_predecessors, control_statement, control_successors, current, entities_list, ENTITY, entity_local_name(), gen_in_list_p(), gen_once(), load_primary_entity(), MAP, pips_debug, and what_stat_debug.

Referenced by propagate_maybeuseful_mappings(), and propagate_used_arrays().

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

◆ ref_rwt()

static void ref_rwt ( reference  r)
static

Definition at line 931 of file dynamic.c.

932 {
933  entity var = reference_variable(r);
934  if (var==old_variable || var==new_variable)
935  {
937  array_used = true;
938  }
939 }

References array_used, new_variable, old_variable, and reference_variable.

Referenced by simple_switch_old_to_new().

+ Here is the caller graph for this function:

◆ regenerate_renamings()

static void regenerate_renamings ( statement  s)
static

regenerate the renaming structures after the optimizations performed on the remapping graph.

of entity(s)

ensures some remapping to enforce an update of the status, which may be necessary, for instance if KILL was used.

of renaming(s)

???

Definition at line 1338 of file dynamic.c.

1339 {
1340  list /* of entity(s) */
1341  lr = entities_list(load_reaching_mappings(s)),
1342  ll = entities_list(load_leaving_mappings(s)),
1343  ln = NIL;
1344 
1345  what_stat_debug(4, s);
1346 
1347  MAP(ENTITY, target,
1348  {
1349  entity primary = load_primary_entity(target);
1350  bool some_source_found = false;
1351 
1352  MAP(ENTITY, source,
1353  {
1354  if (load_primary_entity(source)==primary && source!=target)
1355  {
1356  pips_debug(4, "%s -> %s\n",
1357  entity_name(source), entity_name(target));
1358  ln = CONS(RENAMING, make_renaming(source, target), ln);
1359  some_source_found = true;
1360  }
1361  },
1362  lr);
1363 
1364  /* ensures some remapping to enforce an update of the status,
1365  * which may be necessary, for instance if KILL was used.
1366  */
1367  if (!some_source_found)
1368  {
1369  pips_debug(7, "no source found for %s\n", entity_name(target));
1370  ln = CONS(RENAMING, make_renaming(target, target), ln);
1371  }
1372  },
1373  ll);
1374 
1375  {
1376  list /* of renaming(s) */ l = load_renamings(s);
1377  gen_map((gen_iter_func_t)gen_free, l), gen_free_list(l); /* ??? */
1378  update_renamings(s, ln);
1379  }
1380 }
void gen_free(gen_chunk *obj)
version without shared_pointers.
Definition: genClib.c:992
void update_renamings(statement, list)

References CONS, entities_list, ENTITY, entity_name, gen_free(), gen_free_list(), gen_map(), load_primary_entity(), load_renamings(), make_renaming(), MAP, NIL, pips_debug, RENAMING, update_renamings(), and what_stat_debug.

Referenced by simplify_remapping_graph().

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

◆ reinitialize_reaching_mappings()

static void reinitialize_reaching_mappings ( statement  s)
static

of entity

new reachings

Definition at line 1199 of file dynamic.c.

1200 {
1201  entities er = load_reaching_mappings(s);
1202  list /* of entity */ newr = NIL, /* new reachings */
1203  lrem = entities_list(load_remapped(s));
1204 
1206 
1207  MAP(CONTROL, c,
1208  {
1209  MAP(ENTITY, e,
1210  {
1211  if (gen_in_list_p(load_primary_entity(e), lrem))
1212  newr = gen_once(e, newr);
1213  },
1214  entities_list(load_leaving_mappings(control_statement(c))));
1215  },
1216  control_predecessors(load_remapping_graph(s)));
1217 
1218  entities_list(er) = newr;
1219 }

References CONTROL, control_predecessors, control_statement, entities_list, ENTITY, gen_free_list(), gen_in_list_p(), gen_once(), load_primary_entity(), MAP, and NIL.

Referenced by simplify_remapping_graph().

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

◆ remove_from_entities()

static void remove_from_entities ( entity  primary,
entities  es 
)
static

of entity(s)

Definition at line 1294 of file dynamic.c.

1297 {
1298  list /* of entity(s) */ le = gen_copy_seq(entities_list(es));
1299 
1300  MAP(ENTITY, array,
1301  {
1302  if (load_primary_entity(array)==primary)
1304  },
1305  le);
1306 
1307  gen_free_list(le);
1308 }
void gen_remove(list *cpp, const void *o)
remove all occurences of item o from list *cpp, which is thus modified.
Definition: list.c:685

References array, entities_list, ENTITY, gen_copy_seq(), gen_free_list(), gen_remove(), load_primary_entity(), and MAP.

Referenced by remove_unused_remappings().

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

◆ remove_not_remapped_leavings()

static void remove_not_remapped_leavings ( statement  s)
static

of entities

REMAPPED and

NOT USED

=> NOT LEAVED

Definition at line 1166 of file dynamic.c.

1167 {
1168  entities leaving = load_leaving_mappings(s);
1169  list /* of entities */
1170  ll = entities_list(leaving),
1171  ln = gen_copy_seq(ll),
1172  lr = entities_list(load_remapped(s)),
1173  lu = entities_list(load_used_dynamics(s));
1174  entity primary;
1175 
1176  MAP(ENTITY, array,
1177  {
1178  primary = load_primary_entity(array);
1179 
1180  if (gen_in_list_p(primary, lr) && /* REMAPPED and */
1181  !gen_in_list_p(primary, lu)) /* NOT USED */
1182  {
1183  what_stat_debug(4, s);
1184  pips_debug(4, "removing %s\n", entity_name(array));
1185  gen_remove(&ln, array); /* => NOT LEAVED */
1186  }
1187  },
1188  ll);
1189 
1190  gen_free_list(ll), entities_list(leaving) = ln;
1191 }

References array, entities_list, ENTITY, entity_name, gen_copy_seq(), gen_free_list(), gen_in_list_p(), gen_remove(), load_primary_entity(), MAP, pips_debug, and what_stat_debug.

Referenced by simplify_remapping_graph().

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

◆ remove_unused_remappings()

static void remove_unused_remappings ( statement  s)
static

of entity(s)

Definition at line 1310 of file dynamic.c.

1311 {
1312  entities remapped = load_remapped(s),
1313  reaching = load_reaching_mappings(s),
1314  leaving = load_leaving_mappings(s);
1315  list /* of entity(s) */ le = gen_copy_seq(entities_list(remapped)),
1316  lu = entities_list(load_used_dynamics(s));
1317 
1318  MAP(ENTITY, primary,
1319  {
1320  pips_debug(5, "considering array %s\n", entity_name(primary));
1321 
1322  if (!storage_formal_p(entity_storage(primary)) &&
1323  !gen_in_list_p(primary, lu))
1324  {
1325  remove_from_entities(primary, remapped);
1326  remove_from_entities(primary, reaching);
1327  remove_from_entities(primary, leaving);
1328  }
1329  },
1330  le);
1331 
1332  gen_free_list(le);
1333 }
static void remove_from_entities(entity primary, entities es)
Definition: dynamic.c:1294

References entities_list, ENTITY, entity_name, entity_storage, gen_copy_seq(), gen_free_list(), gen_in_list_p(), MAP, pips_debug, remove_from_entities(), and storage_formal_p.

Referenced by simplify_remapping_graph().

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

◆ rename_directive_p()

static bool rename_directive_p ( entity  f)
static

Definition at line 978 of file dynamic.c.

979 {
981 }
#define same_string_p(s1, s2)

References entity_local_name(), f(), HPF_PREFIX, RENAME_SUFFIX, and same_string_p.

Referenced by continue_propagation_p().

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

◆ reset_dynamic_status()

void reset_dynamic_status ( void  )

reset_similar_mapping();

Definition at line 90 of file dynamic.c.

91 {
96  /* reset_similar_mapping(); */
97 }
void reset_maybeuseful_mappings(void)
void reset_dynamic_hpf(void)
void reset_renamings(void)
void reset_primary_entity(void)

References reset_dynamic_hpf(), reset_maybeuseful_mappings(), reset_primary_entity(), and reset_renamings().

Referenced by reset_hpfc_status().

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

◆ safe_load_primary_entity()

entity safe_load_primary_entity ( entity  e)

HPFC module by Fabien COELHO.

This file provides functions used by directives.c to deal with dynamic mappings (re*). It includes keeping track of variables tagged as dynamic, and managing the static synonyms introduced to deal with them in HPFC. DYNAMIC MANAGEMENT

the synonyms of a given array are stored in a entities. What I intend as a synonym is a version of the array or template which is distributed or aligned in a different way. the renamings are associated to the remapping statements here.

  • dynamic_hpf: keeps track of entities declared as dynamic.
  • primary_entity: primary entity of an entity, when synonyms are introduced to handle remappings.
  • renamings: remappings associated to a statement.
  • maybeuseful_mappings: to be kept for a statement.
  • similar_mapping: copies with similar mappings...

Definition at line 61 of file dynamic.c.

62 {
63  if (!bound_dynamic_hpf_p(e))
64  pips_user_error("%s is not dynamic\n", entity_local_name(e));
65 
66  return load_primary_entity(e);
67 }
bool bound_dynamic_hpf_p(entity)
#define pips_user_error
Definition: misc-local.h:147

References bound_dynamic_hpf_p(), entity_local_name(), load_primary_entity(), and pips_user_error.

Referenced by alive_arrays(), continue_propagation_p(), and propagate_synonym().

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

◆ same_align_p()

static bool same_align_p ( align  a1,
align  a2 
)
static

of alignments

Definition at line 418 of file dynamic.c.

421 {
422  list /* of alignments */ l1 = align_alignment(a1),
423  l2 = align_alignment(a2);
424 
426  (gen_length(l1)!=gen_length(l2)))
427  return false;
428 
429  MAP(ALIGNMENT, a,
430  if (!same_alignment_in_list_p(a, l2)) return false,
431  l1);
432 
433  return true;
434 }
static bool same_alignment_in_list_p(alignment a, list l)
comparison of ALIGN.
Definition: dynamic.c:385
bool conformant_templates_p(entity t1, entity t2)
Definition: dynamic.c:405
#define ALIGNMENT(x)
ALIGNMENT.
Definition: hpf.h:102

References align_alignment, align_template, ALIGNMENT, conformant_templates_p(), gen_length(), MAP, and same_alignment_in_list_p().

Referenced by array_synonym_aligned_as().

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

◆ same_alignment_in_list_p()

static bool same_alignment_in_list_p ( alignment  a,
list  l 
)
static

comparison of ALIGN.

Parameters
lof alignments

Definition at line 385 of file dynamic.c.

388 {
389  intptr_t adim = alignment_arraydim(a),
390  tdim = alignment_templatedim(a);
391 
392  MAP(ALIGNMENT, b,
393  {
394  if (adim==alignment_arraydim(b) && tdim==alignment_templatedim(b))
396  alignment_rate(b)) &&
398  alignment_constant(b));
399  },
400  l);
401 
402  return false;
403 }
#define alignment_templatedim(x)
Definition: hpf.h:136
#define alignment_constant(x)
Definition: hpf.h:140
#define alignment_rate(x)
Definition: hpf.h:138
#define alignment_arraydim(x)
Definition: hpf.h:134
bool expression_equal_p(expression e1, expression e2)
Syntactic equality e1==e2.
Definition: expression.c:1347
#define intptr_t
Definition: stdint.in.h:294

References ALIGNMENT, alignment_arraydim, alignment_constant, alignment_rate, alignment_templatedim, expression_equal_p(), intptr_t, and MAP.

Referenced by same_align_p().

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

◆ same_alignment_p()

static bool same_alignment_p ( entity  e1,
entity  t1,
alignment  a1,
entity  e2,
entity  t2,
alignment  a2 
)
static

compares the alignments if any

Definition at line 535 of file dynamic.c.

537 {
538  int b1, l1, b2, l2;
539  bool b;
540 
542  {
544  RETAL("some undefined", b);
545  }
546 
547  pips_debug(7, "considering %s[dim=%"PRIdPTR"] and %s[dim=%"PRIdPTR"]\n",
550 
551  /* compares the alignments if any
552  */
554  RETAL("diff. array dim", false);
555 
557  RETAL("different rate", false);
558 
561  RETAL("different template size", false);
562 
569 
570  b=(b1-l1)==(b2-l2);
571  RETAL("shift", b);
572 }
#define RETAL(msg, res)
Definition: dynamic.c:531
#define alignment_undefined_p(x)
Definition: hpf.h:109
int HpfcExpressionToInt(expression e)
HpfcExpressionToInt(e)
Definition: hpfc-util.c:569
dimension FindIthDimension(entity, int)
Definition: type.c:1180
Value b2
Definition: sc_gram.c:105
Value b1
booleen indiquant quel membre est en cours d'analyse
Definition: sc_gram.c:105

References alignment_arraydim, alignment_constant, alignment_rate, alignment_templatedim, alignment_undefined_p, b1, b2, dimension_lower, entity_name, expression_equal_p(), FindIthDimension(), HpfcExpressionToInt(), pips_debug, RETAL, and SizeOfIthDimension().

Referenced by array_distribution_similar_p().

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

◆ same_distribute_p()

static bool same_distribute_p ( distribute  d1,
distribute  d2 
)
static

comparison of DISTRIBUTE.

of distributions

Definition at line 353 of file dynamic.c.

356 {
357  list /* of distributions */ l1 = distribute_distribution(d1),
358  l2 = distribute_distribution(d2);
359 
361  distribute_processors(d2))) return false;
362 
363  pips_assert("valid distribution", gen_length(l1)==gen_length(l2));
364 
365  for(; !ENDP(l1); POP(l1), POP(l2))
366  {
367  distribution i1 = DISTRIBUTION(CAR(l1)),
368  i2 = DISTRIBUTION(CAR(l2));
370  s2 = distribution_style(i2);
371  tag t1 = style_tag(s1);
372 
373  if (t1!= (tag) style_tag(s2)) return false;
374  if (t1!=is_style_none &&
377  return false;
378  }
379 
380  return true;
381 }
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define DISTRIBUTION(x)
DISTRIBUTION.
Definition: hpf.h:180
#define distribution_style(x)
Definition: hpf.h:210
#define style_tag(x)
Definition: hpf.h:258
#define distribution_parameter(x)
Definition: hpf.h:212
@ is_style_none
Definition: hpf.h:237
int tag
TAG.
Definition: newgen_types.h:92
s1
Definition: set.c:247

References CAR, conformant_entities_p(), distribute_distribution, distribute_processors, DISTRIBUTION, distribution_parameter, distribution_style, ENDP, expression_equal_p(), gen_length(), is_style_none, pips_assert, POP, s1, and style_tag.

Referenced by conformant_templates_p(), and template_synonym_distributed_as().

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

◆ same_distribution_p()

static bool same_distribution_p ( distribution  d1,
distribution  d2 
)
static

array_distribution_similar_p

returns whether a1 and a2 are similar, i.e. even if distributed differently, the resulting mapping is similar.

e.g. align a1(i,j) with T(i,j), distribute T(*,block) and align a2(i,j) with T(j,i), distribute T(block,*)

impact: the same area can be used for holding both array versions but the version number must be accurate.

Definition at line 523 of file dynamic.c.

524 {
525  return
529 }

References distribution_parameter, distribution_style, expression_equal_p(), and style_tag.

Referenced by array_distribution_similar_p().

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

◆ same_primary_entity_p()

bool same_primary_entity_p ( entity  e1,
entity  e2 
)
Parameters
e11
e22

Definition at line 70 of file dynamic.c.

71 {
74  else
75  return false;
76 }
bool bound_primary_entity_p(entity)

References bound_primary_entity_p(), and load_primary_entity().

Referenced by simple_switch_old_to_new().

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

◆ set_dynamic_status()

void set_dynamic_status ( dynamic_status  d)

set_similar_mapping(...)

Definition at line 108 of file dynamic.c.

109 {
114  /* set_similar_mapping(...) */
115 }
#define dynamic_status_dynamics(x)
Definition: hpf_private.h:376
#define dynamic_status_renamings(x)
Definition: hpf_private.h:380
#define dynamic_status_tokeep(x)
Definition: hpf_private.h:382
#define dynamic_status_primary(x)
Definition: hpf_private.h:378
void set_dynamic_hpf(entity_entities)
void set_maybeuseful_mappings(statement_entities)
void set_primary_entity(entitymap)
void set_renamings(statement_renamings)

References dynamic_status_dynamics, dynamic_status_primary, dynamic_status_renamings, dynamic_status_tokeep, set_dynamic_hpf(), set_maybeuseful_mappings(), set_primary_entity(), and set_renamings().

Referenced by load_hpfc_status().

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

◆ set_entity_as_dynamic()

void set_entity_as_dynamic ( entity  e)

a new dynamic entity is stored.

HPF allows arrays and templates as dynamic. ??? could be asserted, but not here. should be checked afterward.

else the entity was already declared as dynamic...

Definition at line 130 of file dynamic.c.

131 {
132  if (!bound_dynamic_hpf_p(e))
133  {
135  store_primary_entity(e, e);
136 
137  store_similar_mapping(e, e);
138  }
139  /* else the entity was already declared as dynamic... */
140 }

References bound_dynamic_hpf_p(), CONS, ENTITY, make_entities(), NIL, store_dynamic_hpf(), store_primary_entity(), and store_similar_mapping().

Referenced by hpfc_translate_call_with_distributed_args(), and new_dynamic().

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

◆ set_similar_mappings_for_updates()

void set_similar_mappings_for_updates ( void  )

??? for final update after compilation! hummm....

??? should not deal with the same array twice...

may be in another module

Definition at line 162 of file dynamic.c.

163 {
164  /* ??? for final update after compilation! hummm....
165  */
166 
167  MAP(ENTITY, array,
168  {
169  pips_debug(7, "considering array %s\n", entity_name(array));
170 
171  /* ??? should not deal with the same array twice...
172  */
173  if (dynamic_entity_p(array) &&
175  bound_new_node_p(array)) /* may be in another module */
176  {
179  entity ns = load_new_node(s);
180 
181  pips_debug(7, "array %s\n", entity_name(array));
182 
183  if (!bound_new_node_p(n)) {
186  }
187  }
188  },
190 }
void store_new_node_variable(entity new, entity old)
entity load_new_node(entity)
bool bound_new_node_p(entity)

References array, bound_new_node_p(), bound_similar_mapping_p(), dynamic_entity_p, ENTITY, entity_name, list_of_distributed_arrays(), load_new_node(), load_similar_mapping(), MAP, pips_debug, and store_new_node_variable().

Referenced by compile_module().

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

◆ simple_switch_old_to_new()

static void simple_switch_old_to_new ( statement  s)
static

looks for direct references in s and switch them

STATEMENT

UNSTRUCTURED ?

REFERENCE

whether the array may be written... by scanning the proper effects of s. (caution, was just switched to the new_variable!)

Definition at line 941 of file dynamic.c.

942 {
943  DEBUG_STAT(9, "considering", s);
944 
945  /* looks for direct references in s and switch them
946  */
949  statement_domain, gen_false, gen_null, /* STATEMENT */
950  unstructured_domain, gen_false, gen_null, /* UNSTRUCTURED ? */
951  reference_domain, gen_true, ref_rwt, /* REFERENCE */
952  NULL);
953 
954  /* whether the array may be written... by scanning the proper effects of s.
955  * (caution, was just switched to the new_variable!)
956  */
957  pips_debug(8, "statement %p, array %s, rw proper %d\n",
959 
961  {
963  {
964  if(store_effect_p(e)) {
967  {
968  pips_debug(9, "%s W in %p\n", entity_name(new_variable), s);
969  array_modified = true;
970  return;
971  }
972  }
973  }
974  }
975 }
static void ref_rwt(reference r)
Definition: dynamic.c:931
bool same_primary_entity_p(entity e1, entity e2)
Definition: dynamic.c:70
list load_proper_rw_effects_list(statement)
bool bound_proper_rw_effects_p(statement)
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
#define effect_write_p(eff)
bool store_effect_p(effect)
Definition: effects.c:1062
#define EFFECT(x)
EFFECT.
Definition: effects.h:608
void gen_multi_recurse(void *o,...)
Multi recursion visitor function.
Definition: genClib.c:3428
bool gen_false(__attribute__((unused)) gen_chunk *unused)
Return false and ignore the argument.
Definition: genClib.c:2796
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
Definition: genClib.c:2780
#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 unstructured_domain
newgen_type_domain_defined
Definition: ri.h:442
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362
#define reference_domain
newgen_range_domain_defined
Definition: ri.h:338

References array_modified, bound_proper_rw_effects_p(), DEBUG_STAT, EFFECT, effect_any_reference, effect_write_p, entity_name, FOREACH, gen_false(), gen_multi_recurse(), gen_null(), gen_true(), load_proper_rw_effects_list(), new_variable, pips_debug, ref_rwt(), reference_domain, reference_variable, same_primary_entity_p(), statement_domain, statement_instruction, store_effect_p(), and unstructured_domain.

Referenced by propagate_synonym().

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

◆ simplify_remapping_graph()

void simplify_remapping_graph ( void  )

void simplify_remapping_graph()

what: simplifies the remapping graph. how: propagate unused reaching mappings to the next remappings, and remove unnecessary remappings. input: none. output: none. side effects: all is there!

  • the remapping graph remappings are modified.
  • some static structures are used.
  • current module statement needed. bugs or features:
  • special treatment of the current module statement to model the initial mapping at the entry of the module. The initial mapping may be modified by the algorithm if it is remapped before being used.
  • ??? the convergence and correctness are to be proved.
  • expected complexity: n vertices (small!), q nexts, m arrays, r remaps. assumes fast sets instead of lists, with O(1) tests/add/del... closure: O(n^2*vertex_operation) (if it is a simple propagation...) map: O(n*vertex_operation) C = n^2 q m r

of statements

Definition at line 1467 of file dynamic.c.

1468 {
1469  list /* of statements */ ls = list_of_remapping_statements();
1471  what_stat_debug(4, root);
1472 
1473  ifdebug(8) dump_remapping_graph("0", ls);
1474 
1479 
1480  ifdebug(4) dump_remapping_graph("1", ls);
1481 
1482  pips_debug(4, "used array propagation\n");
1484 
1485  pips_debug(4, "may be useful mapping propagation\n");
1487 
1488  ifdebug(4) dump_remapping_graph("2", ls);
1489 
1490  if (bound_remapped_p(root)) remove_unused_remappings(root);
1491 
1493 
1494  gen_free_list(ls);
1495 }
static void initialize_maybeuseful_mappings(statement s)
must be called after useless leaving mappings removal
Definition: dynamic.c:1194
static list propagate_used_arrays(statement s, list ls)
of statements
Definition: dynamic.c:1277
static list propagate_maybeuseful_mappings(statement s, list ls)
of statements
Definition: dynamic.c:1286
static void regenerate_renamings(statement s)
regenerate the renaming structures after the optimizations performed on the remapping graph.
Definition: dynamic.c:1338
static void initialize_reaching_propagation(statement s)
for statement s
Definition: dynamic.c:1142
static void remove_not_remapped_leavings(statement s)
Definition: dynamic.c:1166
static void remove_unused_remappings(statement s)
Definition: dynamic.c:1310
static void reinitialize_reaching_mappings(statement s)
Definition: dynamic.c:1199
if(!(yy_init))
Definition: genread_lex.c:1029
void gen_closure(list(*iterate)(), list(*initial)())
void gen_closure(iterate, initial) list [of X] (*iterate)([ X, list of X ]), initial;
Definition: list.c:839
list(* gen_closure_func_t)(gen_chunk *, list)
Definition: newgen_list.h:335

References dump_remapping_graph(), gen_closure(), gen_free_list(), gen_map(), get_current_module_statement(), ifdebug, initialize_maybeuseful_mappings(), initialize_reaching_propagation(), list_of_remapping_statements(), pips_debug, propagate_maybeuseful_mappings(), propagate_used_arrays(), regenerate_renamings(), reinitialize_reaching_mappings(), remove_not_remapped_leavings(), remove_unused_remappings(), and what_stat_debug.

Referenced by handle_hpf_directives().

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

◆ template_synonym_distributed_as()

entity template_synonym_distributed_as ( entity  temp,
distribute  d 
)

what: finds or creates a new entity distributed as needed.

input: an template (which must be dynamic) and a distribute output: returns a template distributed as specified by d side effects:

  • creates a new entity if necessary.
  • this entity is stored as a synonym of array, and tagged as dynamic.
  • the distribute is freed if not used.

the one found is returned

else no compatible template does exist, so one must be created

Parameters
tempemp

Definition at line 491 of file dynamic.c.

494 {
495  MAP(ENTITY, t,
496  {
498  {
499  free_distribute(d);
500  return t; /* the one found is returned */
501  }
502  },
504 
505  /* else no compatible template does exist, so one must be created
506  */
507  return new_synonym_template(temp, d);
508 }
void free_distribute(distribute p)
Definition: hpf.c:103
static entity new_synonym_template(entity t, distribute di)
builds a new synonym for template t, the distribution of which will be di.
Definition: dynamic.c:319

References entities_list, ENTITY, free_distribute(), load_dynamic_hpf(), load_hpf_distribution(), MAP, new_synonym_template(), and same_distribute_p().

Referenced by one_distribute_directive().

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

Variable Documentation

◆ array_modified

bool array_modified
static

true if the array was actually used

Definition at line 864 of file dynamic.c.

Referenced by propagate_synonym(), and simple_switch_old_to_new().

◆ array_propagation

bool array_propagation
static

replacement

Definition at line 862 of file dynamic.c.

Referenced by continue_propagation_p(), and propagate_synonym().

◆ array_used

bool array_used
static

true if an array is propagated, false if template

Definition at line 863 of file dynamic.c.

Referenced by propagate_synonym(), and ref_rwt().

◆ dynamic_entity_p

bool(* dynamic_entity_p) (entity) ( entity  ) = bound_dynamic_hpf_p

as expected, true if entity e is dynamic.

it is just a function name nicer than bound_...

Definition at line 145 of file dynamic.c.

Referenced by add_declaration_to_host_and_link(), add_dynamic_synonym(), create_init_common_param_for_arrays(), create_parameters_h(), one_align_directive(), one_distribute_directive(), and set_similar_mappings_for_updates().

◆ initial_statement

statement initial_statement = statement_undefined
static

true if the array may be modified...

Definition at line 866 of file dynamic.c.

Referenced by add_as_a_closing_statement(), add_as_a_modified_variable(), add_as_a_used_variable(), and propagate_synonym().

◆ new_variable

◆ old_variable

entity old_variable = entity_undefined
static

void propagate_synonym(s, old, new) statement s; entity old, new;

what: propagates a new array/template synonym (old->new) from statement s. how: travels thru the control graph till the next remapping. input: the starting statement, plus the two entities. output: none. side effects:

  • uses the crtl_graph travelling.
  • set some static variables for the continuation decisions and switch. bugs or features:
  • not very efficient. Could have done something to deal with several synonyms at the same time...
  • what is done on an "incorrect" code is not clear.

Definition at line 859 of file dynamic.c.

Referenced by clone_variable_with_unique_name(), continue_propagation_p(), generic_clone_variable_with_unique_name(), propagate_synonym(), and ref_rwt().