PIPS
localize_memory.c File Reference
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "ri-util.h"
#include "effects-util.h"
#include "misc.h"
#include "effects-generic.h"
#include "effects-simple.h"
#include "control.h"
#include "callgraph.h"
#include "pipsdbm.h"
#include "resources.h"
+ Include dependency graph for localize_memory.c:

Go to the source code of this file.

Functions

static bool mark_loop_to_outline (const statement s)
 
static void gpu_ify_statement (statement s, int depth)
 
bool old__gpu_ify (const string module_name)
 

Variables

list loop_nests_to_outline
 Store the loop nests found that meet the spec to be executed on a GPU. More...
 

Function Documentation

◆ gpu_ify_statement()

static void gpu_ify_statement ( statement  s,
int  depth 
)
static

First outline the innermost code (the kernel itself) to avoid spoiling its memory effects if we start with the outermost code first:

Definition at line 60 of file localize_memory.c.

60  {
61  ifdebug(1) {
62  pips_debug(1, "Parallel loop-nest of depth %d\n", depth);
63  print_statement(s);
64  }
65  /* First outline the innermost code (the kernel itself) to avoid
66  spoiling its memory effects if we start with the outermost code
67  first: */
68  list sk = CONS(STATEMENT,
70  NIL);
71  outliner(build_new_top_level_module_name("kernel_wrapper",false), sk);
72 
73  // Outline the kernel launcher:
74  list sl = CONS(STATEMENT, s, NIL);
75  outliner(build_new_top_level_module_name("kernel_launcher",false), sl);
76 }
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
statement perfectly_nested_loop_to_body_at_depth(statement s, int depth)
Extract the loop-body of a perfect loop-nest at a given depth.
Definition: loop.c:646
#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
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
void print_statement(statement)
Print a statement on stderr.
Definition: statement.c:98
string build_new_top_level_module_name(const char *prefix, bool prevent_suffix)
Get a new name for a module built from a prefix.
Definition: module.c:55
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
#define ifdebug(n)
Definition: sg.c:47
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
static int depth
la sequence de nids

References build_new_top_level_module_name(), CONS, depth, ifdebug, NIL, outliner(), perfectly_nested_loop_to_body_at_depth(), pips_debug, print_statement(), and STATEMENT.

Referenced by old__gpu_ify().

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

◆ mark_loop_to_outline()

static bool mark_loop_to_outline ( const statement  s)
static

An interesting loop must be parallel first...

We recurse on statements instead of loops in order to pick informations on the statement itself, such as pragmas

Since we only outline outermost loop-nest, stop digging further in this statement:

Definition at line 34 of file localize_memory.c.

34  {
35  /* An interesting loop must be parallel first...
36 
37  We recurse on statements instead of loops in order to pick
38  informations on the statement itself, such as pragmas
39  */
40  int parallel_loop_nest_depth = depth_of_parallel_perfect_loop_nest(s);
41  ifdebug(3) {
42  pips_debug(1, "Statement %td with // depth %d\n", statement_number(s),
43  parallel_loop_nest_depth);
44  print_statement(s);
45  }
46  if (parallel_loop_nest_depth > 0) {
47  // Register the loop-nest (note the list is in the reverse order):
49  /* Since we only outline outermost loop-nest, stop digging further in
50  this statement: */
51  pips_debug(1, "Statement %td marked to be outlined\n", statement_number(s));
52  return false;
53  }
54  // This statement is not a parallel loop, go on digging:
55  return true;
56 }
int depth_of_parallel_perfect_loop_nest(statement s)
Compute the depth of a parallel perfect loop-nest.
Definition: loop.c:436
list loop_nests_to_outline
Store the loop nests found that meet the spec to be executed on a GPU.
#define statement_number(x)
Definition: ri.h:2452

References CONS, depth_of_parallel_perfect_loop_nest(), ifdebug, loop_nests_to_outline, pips_debug, print_statement(), STATEMENT, and statement_number.

Referenced by old__gpu_ify().

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

◆ old__gpu_ify()

bool old__gpu_ify ( const string  module_name)

Outline the previous marked loop nests. First put the statements to outline in the good order:

Definition at line 79 of file localize_memory.c.

79  {
80  // Use this module name and this environment variable to set
82  "GPU_IFY_DEBUG_LEVEL");
83 
84  // Get the effects and use them:
86 
87  // Initialize the loop nest set to outline to the empty set yet:
89 
90  // Mark interesting loops:
93 
94  /* Outline the previous marked loop nests.
95  First put the statements to outline in the good order: */
98  // We could have stored the depth, but it complexify the code...
100  }
101 
103 
104  // No longer use effects:
106 
107  // We may have outline some code, so recompute the callees:
108  DB_PUT_MEMORY_RESOURCE(DBR_CALLEES, module_name,
110 
111  // Put back the new statement module
113 }
static statement module_statement
Definition: alias_check.c:125
callees compute_callees(const statement stat)
Recompute the callees of a module statement.
Definition: callgraph.c:355
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
#define gen_recurse(start, domain_number, flt, rwt)
Definition: genC.h:283
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
void * gen_identity(const void *x)
Just return the argument.
Definition: genClib.c:2807
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
#define PIPS_PHASE_POSTLUDE(new_module_statement)
End a transformation phase by putting back into PIPS the (possibly) modified statement.
#define PIPS_PHASE_PRELUDE(module_name, debug_env_var)
Start a phase that use a module CODE.
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
static void gpu_ify_statement(statement s, int depth)
static bool mark_loop_to_outline(const statement s)
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362

References compute_callees(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, depth_of_parallel_perfect_loop_nest(), FOREACH, gen_free_list(), gen_identity(), gen_nreverse(), gen_recurse, get_current_module_statement(), gpu_ify_statement(), loop_nests_to_outline, mark_loop_to_outline(), module_name(), module_statement, NIL, PIPS_PHASE_POSTLUDE, PIPS_PHASE_PRELUDE, reset_cumulated_rw_effects(), set_cumulated_rw_effects(), STATEMENT, and statement_domain.

+ Here is the call graph for this function:

Variable Documentation

◆ loop_nests_to_outline

list loop_nests_to_outline

Store the loop nests found that meet the spec to be executed on a GPU.

Use a list and not a set or hash_map to have always the same order

Definition at line 30 of file localize_memory.c.

Referenced by mark_loop_to_outline(), and old__gpu_ify().