PIPS
taskify.c
Go to the documentation of this file.
1 /*
2  Copyright 2012 MINES ParisTech
3  Copyright 2012 Silkan
4 
5  This file is part of PIPS.
6 
7  PIPS is free software: you can redistribute it and/or modify it
8  under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  any later version.
11 
12  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
13  WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  FITNESS FOR A PARTICULAR PURPOSE.
15 
16  See the GNU General Public License for more details.
17 
18  You should have received a copy of the GNU General Public License
19  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
20 
21  */
22 
23 /**
24  * @file taskify.c
25  * Task generation
26  * @author Mehdi Amini <mehdi.amini@silkan.com>
27  */
28 
29 #ifdef HAVE_CONFIG_H
30  #include "pips_config.h"
31 #endif
32 #include "genC.h"
33 #include "linear.h"
34 #include "ri.h"
35 #include "effects.h"
36 #include "ri-util.h"
37 #include "prettyprint.h"
38 #include "effects-util.h"
39 #include "gpu.h"
40 #include "accel-util.h"
41 #include "text.h"
42 #include "pipsdbm.h"
43 #include "pipsmake.h"
44 #include "resources.h"
45 #include "properties.h"
46 #include "misc.h"
47 #include "control.h"
48 #include "callgraph.h"
49 #include "effects-generic.h"
50 #include "effects-convex.h"
51 #include "preprocessor.h"
52 #include "expressions.h"
53 #include "text-util.h"
54 #include "parser_private.h"
55 
56 static string get_next_task_name() {
57  string prefix = (string)get_string_property("TASKIFY_TASK_PREFIX");
59  return task_name;
60 }
61 
62 static bool loop_found_p(_UNUSED_ loop l, bool *found) {
63  *found = true;
64  return false;
65 }
66 
68  bool contains_a_loop = false;
69  if(!statement_loop_p(s)) {
70  gen_context_recurse(s, &contains_a_loop, loop_domain, loop_found_p, gen_null2);
71  }
72 
73  if( !contains_a_loop
75  && !return_statement_p(s)
78  ifdebug(2) {
79  pips_debug(2,"Ouline statement into a new task : ");
80  print_statement(s);
81  }
83  return false;
84  }
85  return true;
86 }
87 
88 bool taskify(char * module_name) {
89 
90  statement module_stat = (statement)db_get_memory_resource(DBR_CODE,
92  true);
93  set_current_module_statement(module_stat);
94 
96 
97  debug_on("TASKIFY_DEBUG_LEVEL");
98 
99 
100  /* regions */
101  string region = db_get_memory_resource(DBR_REGIONS, module_name, true);
104  module_name,
105  true));
106 
107 
108  // Save the value of a property we are going to change locally:
109  bool old_outline_independent_compilation_unit =
110  get_bool_property("OUTLINE_INDEPENDENT_COMPILATION_UNIT");
111  set_bool_property("OUTLINE_INDEPENDENT_COMPILATION_UNIT",false);
112 
113  /* Initialize set for each statement */
115 
116  // Restore the original property value:
117  set_bool_property("OUTLINE_INDEPENDENT_COMPILATION_UNIT",
118  old_outline_independent_compilation_unit);
119 
120 
122  DB_PUT_MEMORY_RESOURCE(DBR_CODE,
123  module_name,
124  module_stat);
125 
126  // We may have outline some code, so recompute the callees:
127  DB_PUT_MEMORY_RESOURCE(DBR_CALLEES, module_name,
129 
130 
131  debug_off();
132 
137 
138  return true;
139 }
140 
statement outliner(const char *, list)
outline the statements in statements_to_outline into a module named outline_module_name the outlined ...
Definition: outlining.c:1327
callees compute_callees(const statement stat)
Recompute the callees of a module statement.
Definition: callgraph.c:355
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
#define region
simulation of the type region
void reset_proper_rw_effects(void)
void set_proper_rw_effects(statement_effects)
void set_cumulated_rw_effects(statement_effects)
void reset_cumulated_rw_effects(void)
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
char * get_string_property(const char *)
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
Definition: genC.h:285
#define gen_recurse(start, domain_number, flt, rwt)
Definition: genC.h:283
string build_outline_name(const char *base_prefix, const char *mod_name)
Build the outline function name.
Definition: gpu-ify.c:78
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
void reset_current_module_statement(void)
Reset the current module statement.
Definition: static.c:221
statement set_current_module_statement(statement)
Set the current module statement.
Definition: static.c:165
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
void gen_null2(__attribute__((unused)) void *u1, __attribute__((unused)) void *u2)
idem with 2 args, to please overpeaky compiler checks
Definition: genClib.c:2758
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
bool empty_statement_or_continue_p(statement)
Return true if the statement is an empty instruction block or a continue or a recursive combination o...
Definition: statement.c:474
bool statement_loop_p(statement)
Definition: statement.c:349
bool statement_contains_user_call_p(statement)
Definition: statement.c:3939
bool return_statement_p(statement)
Test if a statement is a C or Fortran "return".
Definition: statement.c:172
bool declaration_statement_p(statement)
Had to be optimized according to Beatrice Creusillet.
Definition: statement.c:224
#define debug_on(env)
Definition: misc-local.h:157
#define _UNUSED_
Definition: misc-local.h:232
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define debug_off()
Definition: misc-local.h:160
char * string
STRING.
Definition: newgen_types.h:39
void print_statement(statement)
Print a statement on stderr.
Definition: statement.c:98
void set_bool_property(const char *, bool)
static const char * prefix
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
Definition: reorder.c:244
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
Definition: entity.c:487
entity local_name_to_top_level_entity(const char *n)
This function try to find a top-level entity from a local name.
Definition: entity.c:1450
#define loop_domain
newgen_language_domain_defined
Definition: ri.h:218
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362
#define ifdebug(n)
Definition: sg.c:47
static bool loop_found_p(_UNUSED_ loop l, bool *found)
Definition: taskify.c:62
bool taskify(char *module_name)
Definition: taskify.c:88
bool taskify_statement(statement s)
Definition: taskify.c:67
static string get_next_task_name()
Definition: taskify.c:56