PIPS
quick_privatize.c
Go to the documentation of this file.
1 /*
2 
3  $Id: quick_privatize.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23  */
24 #ifdef HAVE_CONFIG_H
25 #include "pips_config.h"
26 #endif
27 /*********************************************************************************/
28 /* QUICK PRIVATIZATION */
29 /*********************************************************************************/
30 
31 #include "local.h"
32 
33 static bool quick_privatize_loop(statement /*stat*/, list /*successors*/);
34 static bool quick_privatize_statement_pair(statement /*s1*/,
35  statement /*s2*/,
36  list /*conflicts*/);
37 
39  /* we analyze arcs exiting from loop statements */
43  if(statement_loop_p(s1)) {
44  loop l = statement_loop(s1);
45  list locals = loop_locals(l);
46  entity ind = loop_index(l);
47 
48  if(gen_find_eq(ind, locals) == entity_undefined) {
49  if(// entity_privatizable_in_loop_p(ind, l) && /* to be restored when global variables are uniformly treated everywhere. BC.*/
51  pips_debug(1, "Index for loop %" PRIdPTR " privatized\n",
53  loop_locals(l) = CONS(ENTITY, ind, locals);
54  } else {
55  pips_debug(1, "could not privatize loop %" PRIdPTR "\n",
57  }
58  }
59  }
60  }
61 }
62 
64  pips_debug(3, "arcs from %" PRIdPTR "\n", statement_number(stat));
68 
69  pips_debug(3, "arcs to %" PRIdPTR "\n", statement_number(st));
70 
72  return (false);
73  }
74 
75  return (true);
76 }
77 
78 
79 
80 static bool quick_privatize_statement_pair(s1, s2, conflicts)
81  statement s1, s2;list conflicts; {
82  loop l1 = statement_loop(s1);
83  entity ind1 = loop_index(l1);
84  FOREACH(CONFLICT, c, conflicts) {
85  effect f1 = conflict_source(c);
87  entity e1 = reference_variable(r1);
88 
89  effect f2 = conflict_sink(c);
91  entity e2 = reference_variable(r2);
92 
93  pips_debug(2, "conflict between %s & %s\n",
94  entity_name(e1), entity_name(e2));
95 
96  /* equivalence or conflict not created by loop index. I give up ! */
97  if(e1 != ind1)
98  continue;
99 
101  /* we must know where this read effect come from. if it
102  comes from the loop body, the arc may be ignored. */
103 
105 
107  loop l2;
108  entity ind2;
109  list range_effects;
110 
111  pips_debug(3, "the arc goes outside the loop body.\n");
112 
114  pips_debug(3, "s2 is an implied loop\n");
115  return (true);
116  }
117  if(!statement_loop_p(s2)) {
118  pips_debug(3, "s2 not a loop\n");
119  return (false);
120  }
121 
122  /* s2 is a loop. if there are no read effet in the range
123  part, ignore this conflict. */
124  l2 = statement_loop(s2);
125  ind2 = loop_index(l2);
126  range_effects = proper_effects_of_range(loop_range(l2));
127  FOREACH(EFFECT, e, range_effects) {
129  && action_read_p(effect_action(e))) {
130 
131  pips_debug(3, "index read in range expressions\n");
132 
133  free_effects(make_effects(range_effects));
134  return (false);
135  }
136  }
137  free_effects(make_effects(range_effects));
138  }
139  }
140  }
141 
142  return (true);
143 }
144 
effects make_effects(list a)
Definition: effects.c:568
void free_effects(effects p)
Definition: effects.c:535
static list successors(list l)
static list loops
static graph dep_graph
Definition: deatomizer.c:65
struct _newgen_struct_dg_arc_label_ * dg_arc_label
Definition: dg.h:60
#define conflict_sink(x)
Definition: dg.h:167
#define CONFLICT(x)
CONFLICT.
Definition: dg.h:134
#define dg_arc_label_conflicts(x)
Definition: dg.h:201
#define conflict_source(x)
Definition: dg.h:165
list proper_effects_of_range(range)
bool is_implied_do_index(entity, instruction)
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
#define effect_action(x)
Definition: effects.h:642
#define action_write_p(x)
Definition: effects.h:314
#define action_read_p(x)
Definition: effects.h:311
#define EFFECT(x)
EFFECT.
Definition: effects.h:608
#define successor_vertex(x)
Definition: graph.h:118
#define successor_arc_label(x)
Definition: graph.h:116
#define vertex_successors(x)
Definition: graph.h:154
#define SUCCESSOR(x)
SUCCESSOR.
Definition: graph.h:86
#define graph_vertices(x)
Definition: graph.h:82
#define VERTEX(x)
VERTEX.
Definition: graph.h:122
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#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
void * gen_find_eq(const void *item, const list seq)
Definition: list.c:422
loop statement_loop(statement)
Get the loop of a statement.
Definition: statement.c:1374
bool statement_loop_p(statement)
Definition: statement.c:349
statement vertex_to_statement(vertex v)
Vertex_to_statement looks for the statement that is pointed to by vertex v.
Definition: util.c:45
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
int f2(int off1, int off2, int w, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:1
void quick_privatize_graph(graph dep_graph)
quick_privatize.c
static bool quick_privatize_statement_pair(statement, statement, list)
static bool quick_privatize_loop(statement, list)
QUICK PRIVATIZATION
list load_statement_enclosing_loops(statement)
#define reference_variable(x)
Definition: ri.h:2326
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define entity_undefined
Definition: ri.h:2761
#define entity_name(x)
Definition: ri.h:2790
#define loop_locals(x)
Definition: ri.h:1650
#define statement_instruction(x)
Definition: ri.h:2458
#define loop_range(x)
Definition: ri.h:1642
#define statement_number(x)
Definition: ri.h:2452
#define loop_index(x)
Definition: ri.h:1640
s1
Definition: set.c:247
The structure used to build lists in NewGen.
Definition: newgen_list.h:41