PIPS
eliminate_original_variables.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include "genC.h"
#include "linear.h"
#include "resources.h"
#include "database.h"
#include "ri.h"
#include "ri-util.h"
#include "effects.h"
#include "effects-util.h"
#include "pipsdbm.h"
#include "effects-generic.h"
#include "effects-simple.h"
#include "control.h"
#include "misc.h"
#include "properties.h"
#include "text-util.h"
#include "task_parallelization.h"
#include "prettyprint.h"
+ Include dependency graph for eliminate_original_variables.c:

Go to the source code of this file.

Data Structures

struct  ctx_eov
 ctx_eov: More...
 

Typedefs

typedef struct ctx_eov ctx_eov_t
 ctx_eov: More...
 

Functions

static void print_ctx (const ctx_eov_t ctx)
 
static ctx_eov_t eov_make_ctx (int nbr_cluster, string prefix_new_entity)
 
static void eov_free_ctx (ctx_eov_t *ctx)
 
static void eov_stack_task_push_task (ctx_eov_t *ctx, task t)
 
static task eov_stack_task_pop_task (ctx_eov_t *ctx)
 
static void eov_add_entity_to_eliminate (ctx_eov_t *ctx, entity e)
 
static bool eov_entity_to_eliminate_p (ctx_eov_t *ctx, entity e)
 
static entity eov_get_replaced_enity (ctx_eov_t *ctx, entity e, int on_cluster)
 call entity_to_eliminate_p before eov_get_replaced_enity check on_cluster <= ctx->nbr_cluster before eov_get_replaced_enity More...
 
static void eov_set_current_cluster (ctx_eov_t *ctx, int on_cluster)
 
static int eov_get_current_cluster (ctx_eov_t *ctx)
 
static void subtsitute_variable_in_reference (reference r, ctx_eov_t *ctx)
 if it's needed, variable present in list of variable to eliminate, substitute the variable entity present in reference r by the corresponding one on the corresponding cluster. More...
 
static bool prepare_context (statement st, ctx_eov_t *ctx)
 The function in this section modify the context to know. More...
 
static void release_context (__attribute__((unused)) statement st, ctx_eov_t *ctx)
 
static bool loop_replace_variable (loop l, ctx_eov_t *ctx)
 have to separate loop from reference because index and locals of loop can also be entity variables If it's needed, variable present in list of variable to eliminate, substitute the variable entity present in loop l by the corresponding one on the corresponding cluster. More...
 
static bool expression_substitute_variable (expression e, ctx_eov_t *ctx)
 expression_substitute_variable will substitute variable entity that have to be substitute In fact we can not recurse with this domain but directly recurse with reference_domain It was done like this because at the beginning, it was expected to use substitute_entity_in_expression But a custom substitution is more efficient. More...
 
static bool make_eliminate_original_variables (__attribute__((unused)) entity module, statement module_statement)
 
bool eliminate_original_variables (const char *module_name)
 PIPS pass. More...
 

Variables

static int compteur_stack_task = 0
 Pass: ELIMINATE_ORIGINAL_VARIABLES Debug mode: MPI_GENERATION_DEBUG_LEVEL Properties used: More...
 

Typedef Documentation

◆ ctx_eov_t

typedef struct ctx_eov ctx_eov_t

ctx_eov:

  • stack_task stack_task is a stack of task each time we enter a statement, we add task corresponding to the statement into stack_task each time we leave a statement, we remove task corresponding to this statement (the last task added) we could access to the current task with function eov_current_task
  • hash_entity_to_eliminate hash_entity_to_eliminate is a hash table with key an variable entity, that we will have to eliminate/replace with value an array of entity that correspond to the entity that will replace the key the array size correspond to the number of cluster asked by the user (see property with #define MPI_GENERATION_NBR_CLUSTER) structure of hash_entity_to_eliminate entity_var_key0 -> 0 -> entity_new_var0_0 1 -> entity_new_var0_1 2 -> entity_new_var0_2 3 -> entity_new_var0_3 ... entity_var_key1 -> 0 -> entity_new_var1_0 1 -> entity_new_var1_1 2 -> entity_new_var1_2 3 -> entity_new_var1_3 ... ...
  • nbr_cluster nbr_cluster is the number of cluster it must be different than 0 it's stocked in ctx to not always have to get it from properties
  • prefix_new_entity prefix_new_entity is a string corresponding to the prefix of the new entity it's stocked in ctx to not always have to get it from properties

Function Documentation

◆ eliminate_original_variables()

bool eliminate_original_variables ( const char *  module_name)

PIPS pass.

eliminate_original_variables.c

Reorder the module, because some statements have been added. Well, the order on the remaining statements should be the same, but by reordering the statements, the number are consecutive. Just for pretty print... :-)

Parameters
module_nameodule_name

Definition at line 474 of file eliminate_original_variables.c.

474  {
475  entity module;
477  bool good_result_p = true;
478 
479  debug_on("MPI_GENERATION_DEBUG_LEVEL");
480  pips_debug(1, "begin\n");
481 
482  //-- configure environment --//
485 
487  db_get_memory_resource(DBR_CODE, module_name, true) );
489 
490  pips_assert("Statement should be OK before...",
492 
494 
495  //-- get dependencies --//
497  db_get_memory_resource(DBR_TASK, module_name, true));
498 
499 
500  //-- Make the job -- //
502 // gen_recurse(module_statement, statement_domain, gen_true, eliminate_in_statement);
503 
504 
505  /* Reorder the module, because some statements have been added.
506  Well, the order on the remaining statements should be the same,
507  but by reordering the statements, the number are consecutive. Just
508  for pretty print... :-) */
510 
511  pips_assert("Statement should be OK after...",
513 
514  //-- Save modified code to database --//
516 
521 
522  pips_debug(1, "end\n");
523  debug_off();
524 
525  return (good_result_p);
526 }
bool statement_consistent_p(statement p)
Definition: ri.c:2195
static statement module_statement
Definition: alias_check.c:125
static bool make_eliminate_original_variables(__attribute__((unused)) entity module, statement module_statement)
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
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
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
#define debug_on(env)
Definition: misc-local.h:157
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define debug_off()
Definition: misc-local.h:160
hash_table set_ordering_to_statement(statement s)
To be used instead of initialize_ordering_to_statement() to make sure that the hash table ots is in s...
Definition: ordering.c:172
void reset_ordering_to_statement(void)
Reset the mapping from ordering to statement.
Definition: ordering.c:185
static char * module
Definition: pips.c:74
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
Definition: reorder.c:244
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479
char * strdup()
void set_parallel_task_mapping(statement_task)
void reset_parallel_task_mapping(void)

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, get_current_module_entity(), get_current_module_statement(), make_eliminate_original_variables(), module, module_name(), module_name_to_entity(), module_reorder(), module_statement, pips_assert, pips_debug, reset_current_module_entity(), reset_current_module_statement(), reset_ordering_to_statement(), reset_parallel_task_mapping(), set_current_module_entity(), set_current_module_statement(), set_ordering_to_statement(), set_parallel_task_mapping(), statement_consistent_p(), and strdup().

+ Here is the call graph for this function:

◆ eov_add_entity_to_eliminate()

static void eov_add_entity_to_eliminate ( ctx_eov_t ctx,
entity  e 
)
static

Definition at line 172 of file eliminate_original_variables.c.

172  {
173  int nbr_cluster = ctx->nbr_cluster;
174  string prefix = ctx->prefix_new_entity;
175 
176  gen_array_t array = gen_array_make(nbr_cluster);
177 
178  string name = "";
179  entity new_entity = entity_undefined;
180 
181  for (int i=0; i<nbr_cluster; i++) {
182  name = concatenate(
185  prefix, entity_user_name(e), "_", i2a(i),
186  NULL);
187 
188  if ((new_entity = gen_find_tabulated(name, entity_domain)) != entity_undefined) {
189  gen_array_addto(array, i, new_entity);
190  }
191  else {
192  pips_internal_error("The variable with name %s doesn't exist.\n"
193  " PIPS can't generate the copy for this variable.\n"
194  " Try to launch pass VARIABLE_REPLICATION.\n", name);
195  }
196  name = "";
197  new_entity = entity_undefined;
198  }
199 
201 }
gen_array_t gen_array_make(size_t size)
declarations...
Definition: array.c:40
void gen_array_addto(gen_array_t a, size_t i, void *what)
Definition: array.c:87
void hash_put(hash_table htp, const void *key, const void *val)
This functions stores a couple (key,val) in the hash table pointed to by htp.
Definition: hash.c:364
#define pips_internal_error
Definition: misc-local.h:149
#define MODULE_SEP_STRING
Definition: naming-local.h:30
char * i2a(int)
I2A (Integer TO Ascii) yields a string for a given Integer.
Definition: string.c:121
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
static const char * prefix
const char * entity_user_name(entity e)
Since entity_local_name may contain PIPS special characters such as prefixes (label,...
Definition: entity.c:487
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
string local_name_to_scope(const char *ln)
allocates a new string
Definition: entity.c:563
const char * entity_module_name(entity e)
See comments about module_name().
Definition: entity.c:1092
#define entity_undefined
Definition: ri.h:2761
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
static entity array
hash_table hash_entity_to_eliminate

References array, concatenate(), entity_domain, entity_local_name(), entity_module_name(), entity_undefined, entity_user_name(), gen_array_addto(), gen_array_make(), gen_find_tabulated(), ctx_eov::hash_entity_to_eliminate, hash_put(), i2a(), local_name_to_scope(), MODULE_SEP_STRING, ctx_eov::nbr_cluster, pips_internal_error, prefix, and ctx_eov::prefix_new_entity.

Referenced by prepare_context().

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

◆ eov_entity_to_eliminate_p()

static bool eov_entity_to_eliminate_p ( ctx_eov_t ctx,
entity  e 
)
static

Definition at line 202 of file eliminate_original_variables.c.

202  {
204 }
bool hash_defined_p(const hash_table htp, const void *key)
true if key has e value in htp.
Definition: hash.c:484

References hash_defined_p(), and ctx_eov::hash_entity_to_eliminate.

Referenced by loop_replace_variable(), and subtsitute_variable_in_reference().

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

◆ eov_free_ctx()

static void eov_free_ctx ( ctx_eov_t ctx)
static

Definition at line 139 of file eliminate_original_variables.c.

139  {
140  pips_assert("stack of task not empty", stack_size(ctx->stack_task) == 0);
141 // pips_assert("current_task have to be undefined", ctx->current_task == task_undefined);
143  gen_array_free(a);
144  }
146 }
void gen_array_free(gen_array_t a)
Definition: array.c:70
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327
#define HASH_FOREACH(key_type, k, value_type, v, ht)
Definition: newgen_hash.h:71
int stack_size(const stack)
observers

References gen_array_free(), ctx_eov::hash_entity_to_eliminate, HASH_FOREACH, hash_table_free(), pips_assert, stack_size(), and ctx_eov::stack_task.

Referenced by make_eliminate_original_variables().

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

◆ eov_get_current_cluster()

static int eov_get_current_cluster ( ctx_eov_t ctx)
static

Definition at line 223 of file eliminate_original_variables.c.

223  {
224  return ctx->current_cluster;
225 }

References ctx_eov::current_cluster.

Referenced by loop_replace_variable(), and subtsitute_variable_in_reference().

+ Here is the caller graph for this function:

◆ eov_get_replaced_enity()

static entity eov_get_replaced_enity ( ctx_eov_t ctx,
entity  e,
int  on_cluster 
)
static

call entity_to_eliminate_p before eov_get_replaced_enity check on_cluster <= ctx->nbr_cluster before eov_get_replaced_enity

Definition at line 209 of file eliminate_original_variables.c.

209  {
210  //since it was only local call and I know what I do this assert was not needed
211  // pips_assert("entity don't have to be eliminate", entity_to_eliminate_p(ctx, e));
212  //since it was only local call and I know what I do this assert was not needed
213  // pips_assert("entity asked out of bounded", on_cluster <= ctx->nbr_cluster);
214 
216  entity new_entity = gen_array_item(array, on_cluster);
217 
218  return new_entity;
219 }
void * gen_array_item(const gen_array_t a, size_t i)
Definition: array.c:143
void * hash_get(const hash_table htp, const void *key)
this function retrieves in the hash table pointed to by htp the couple whose key is equal to key.
Definition: hash.c:449

References array, gen_array_item(), ctx_eov::hash_entity_to_eliminate, and hash_get().

Referenced by loop_replace_variable(), and subtsitute_variable_in_reference().

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

◆ eov_make_ctx()

static ctx_eov_t eov_make_ctx ( int  nbr_cluster,
string  prefix_new_entity 
)
static

Definition at line 128 of file eliminate_original_variables.c.

128  {
129  pips_assert("number of cluster can't be equal to 0", nbr_cluster != 0);
130  ctx_eov_t ctx;
131  ctx.stack_task = stack_make(task_domain, 0, 0);
134  ctx.nbr_cluster = nbr_cluster;
135  ctx.current_cluster = -2;
136  ctx.prefix_new_entity = prefix_new_entity;
137  return ctx;
138 }
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
@ hash_pointer
Definition: newgen_hash.h:32
stack stack_make(int, int, int)
allocation
Definition: stack.c:246
#define task_undefined
Definition: task_private.h:89
#define task_domain
newgen_statement_task_domain_defined
Definition: task_private.h:32

References ctx_eov::current_cluster, ctx_eov::current_task, ctx_eov::hash_entity_to_eliminate, hash_pointer, hash_table_make(), ctx_eov::nbr_cluster, pips_assert, ctx_eov::prefix_new_entity, stack_make(), ctx_eov::stack_task, task_domain, and task_undefined.

Referenced by make_eliminate_original_variables().

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

◆ eov_set_current_cluster()

static void eov_set_current_cluster ( ctx_eov_t ctx,
int  on_cluster 
)
static

Definition at line 220 of file eliminate_original_variables.c.

220  {
221  ctx->current_cluster = on_cluster;
222 }

References ctx_eov::current_cluster.

Referenced by prepare_context().

+ Here is the caller graph for this function:

◆ eov_stack_task_pop_task()

static task eov_stack_task_pop_task ( ctx_eov_t ctx)
static

Definition at line 154 of file eliminate_original_variables.c.

154  {
156  stack s = ctx->stack_task;
157  task pop = (task) stack_pop(s);
158  if (stack_empty_p(s)) {
160  ctx->current_cluster = -2;
161  }
162  else {
163  ctx->current_task = (task) stack_head(ctx->stack_task);
165  }
166  return pop;
167 }
static int compteur_stack_task
Pass: ELIMINATE_ORIGINAL_VARIABLES Debug mode: MPI_GENERATION_DEBUG_LEVEL Properties used:
bool stack_empty_p(const stack)
void * stack_head(const stack)
returns the item on top of stack s
Definition: stack.c:420
void * stack_pop(stack)
POPs one item from stack s.
Definition: stack.c:399
the stack head
Definition: stack.c:62
struct _newgen_struct_task_ * task
Definition: task_private.h:37
#define task_on_cluster(x)
Definition: task_private.h:119

References compteur_stack_task, ctx_eov::current_cluster, ctx_eov::current_task, stack_empty_p(), stack_head(), stack_pop(), ctx_eov::stack_task, task_on_cluster, and task_undefined.

Referenced by release_context().

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

◆ eov_stack_task_push_task()

static void eov_stack_task_push_task ( ctx_eov_t ctx,
task  t 
)
static

Definition at line 148 of file eliminate_original_variables.c.

148  {
150  ctx->current_task = t;
152  stack_push((void *)t, ctx->stack_task);
153 }
void stack_push(void *, stack)
stack use
Definition: stack.c:373

References compteur_stack_task, ctx_eov::current_cluster, ctx_eov::current_task, stack_push(), ctx_eov::stack_task, and task_on_cluster.

Referenced by prepare_context().

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

◆ expression_substitute_variable()

static bool expression_substitute_variable ( expression  e,
ctx_eov_t ctx 
)
static

expression_substitute_variable will substitute variable entity that have to be substitute In fact we can not recurse with this domain but directly recurse with reference_domain It was done like this because at the beginning, it was expected to use substitute_entity_in_expression But a custom substitution is more efficient.

Returns
false since we make another gen_context_recurse inside expression_substitute_variable the filter always return false

Definition at line 423 of file eliminate_original_variables.c.

423  {
424  ifdebug(3) {
425  pips_debug(3, "work on expression\n");
426  print_expression(e);
427  ifdebug(8) {
428  print_ctx(*ctx);
429  }
430  }
431 
432  //We don't use substitute_entity_in_expression for performance
433  // to use substitute_entity_in_expression we will have to parse 2 times the expression
434  // 1 time to find the entity to substitute and make some filter to not have duplicated
435  // 1 time with substitute_entity_in_expression to make the substitution
437 
438  return false;
439 }
static void subtsitute_variable_in_reference(reference r, ctx_eov_t *ctx)
if it's needed, variable present in list of variable to eliminate, substitute the variable entity pre...
static void print_ctx(const ctx_eov_t ctx)
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
Definition: genC.h:285
bool gen_true2(__attribute__((unused)) gen_chunk *u1, __attribute__((unused)) void *u2)
Definition: genClib.c:2785
void print_expression(expression e)
no file descriptor is passed to make is easier to use in a debugging stage.
Definition: expression.c:58
#define reference_domain
newgen_range_domain_defined
Definition: ri.h:338
#define ifdebug(n)
Definition: sg.c:47

References gen_context_recurse, gen_true2(), ifdebug, pips_debug, print_ctx(), print_expression(), reference_domain, and subtsitute_variable_in_reference().

Referenced by make_eliminate_original_variables().

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

◆ loop_replace_variable()

static bool loop_replace_variable ( loop  l,
ctx_eov_t ctx 
)
static

have to separate loop from reference because index and locals of loop can also be entity variables If it's needed, variable present in list of variable to eliminate, substitute the variable entity present in loop l by the corresponding one on the corresponding cluster.

Parameters
lloop on which the variable will be substituted
ctxcontext that content the cluster in which the reference will be executed list on var to eliminate correspondence between variable and new_variable

Definition at line 340 of file eliminate_original_variables.c.

340  {
341  ifdebug(3) {
342  pips_debug(3, "work on loop\n");
343  printf_loop(l);
344  ifdebug(8) {
345  print_ctx(*ctx);
346  }
347  }
348  //task t = eov_current_task(ctx);
349  //int on_cluster = task_on_cluster(t);
350  int on_cluster = eov_get_current_cluster(ctx);
351  if (on_cluster>=ctx->nbr_cluster) {
352  pips_user_error("the cluster asked is out of bounded, on_cluster=%%d", on_cluster);
353  return true;
354  }
355 
356  entity idx = loop_index(l);
357  if (eov_entity_to_eliminate_p(ctx, idx)) {
358  entity new_idx = eov_get_replaced_enity(ctx, idx, on_cluster);
359  loop_index(l) = new_idx;
360  }
361 
362  list new_locs = NIL;
363  FOREACH(ENTITY, ent, loop_locals(l)) {
364  if (eov_entity_to_eliminate_p(ctx, ent)) {
365  entity new_ent = eov_get_replaced_enity(ctx, ent, on_cluster);
366  new_locs = gen_nconc(new_locs, CONS(ENTITY,new_ent,NIL));
367  }
368  else {
369  new_locs = gen_nconc(new_locs, CONS(ENTITY,ent,NIL));
370  }
371  }
372 
373  return true;
374 }
static int eov_get_current_cluster(ctx_eov_t *ctx)
static entity eov_get_replaced_enity(ctx_eov_t *ctx, entity e, int on_cluster)
call entity_to_eliminate_p before eov_get_replaced_enity check on_cluster <= ctx->nbr_cluster before ...
static bool eov_entity_to_eliminate_p(ctx_eov_t *ctx, entity e)
#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
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#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_user_error
Definition: misc-local.h:147
void printf_loop(loop lp)
=======================================================================
Definition: loop.c:48
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define loop_locals(x)
Definition: ri.h:1650
#define loop_index(x)
Definition: ri.h:1640
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References CONS, ENTITY, eov_entity_to_eliminate_p(), eov_get_current_cluster(), eov_get_replaced_enity(), FOREACH, gen_nconc(), ifdebug, loop_index, loop_locals, ctx_eov::nbr_cluster, NIL, pips_debug, pips_user_error, print_ctx(), and printf_loop().

Referenced by make_eliminate_original_variables().

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

◆ make_eliminate_original_variables()

static bool make_eliminate_original_variables ( __attribute__((unused)) entity  module,
statement  module_statement 
)
static

Definition at line 442 of file eliminate_original_variables.c.

442  {
443  int nbr_cluster = get_int_property(MPI_GENERATION_NBR_CLUSTER);
445  ctx_eov_t ctx = eov_make_ctx(nbr_cluster, prefix);
446 
447  ifdebug(1) {
448  pips_debug(1, "begin\n");
449  print_ctx(ctx);
450  }
451 
452  // The domain was parse
454  module_statement, &ctx,
455  // to know in which task we are
457  // do the work
458  // have to distinguish loop since it can have variable entity not encapsulated inside an expression...
461  NULL);
462 
463  ifdebug(1) {
464  pips_debug(1, "end\n");
465  print_ctx(ctx);
466  }
467  eov_free_ctx(&ctx);
468  return true;
469 }
int get_int_property(const string)
static ctx_eov_t eov_make_ctx(int nbr_cluster, string prefix_new_entity)
static bool expression_substitute_variable(expression e, ctx_eov_t *ctx)
expression_substitute_variable will substitute variable entity that have to be substitute In fact we ...
static bool prepare_context(statement st, ctx_eov_t *ctx)
The function in this section modify the context to know.
static void release_context(__attribute__((unused)) statement st, ctx_eov_t *ctx)
static void eov_free_ctx(ctx_eov_t *ctx)
static bool loop_replace_variable(loop l, ctx_eov_t *ctx)
have to separate loop from reference because index and locals of loop can also be entity variables If...
char * get_string_property(const char *)
void gen_context_multi_recurse(void *o, void *context,...)
Multi-recursion with context function visitor.
Definition: genClib.c:3373
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
char * string
STRING.
Definition: newgen_types.h:39
#define expression_domain
newgen_execution_domain_defined
Definition: ri.h:154
#define loop_domain
newgen_language_domain_defined
Definition: ri.h:218
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362
#define MPI_GENERATION_NBR_CLUSTER
#define MPI_GENERATION_PREFIX

References eov_free_ctx(), eov_make_ctx(), expression_domain, expression_substitute_variable(), gen_context_multi_recurse(), gen_null(), get_int_property(), get_string_property(), ifdebug, loop_domain, loop_replace_variable(), module_statement, MPI_GENERATION_NBR_CLUSTER, MPI_GENERATION_PREFIX, pips_debug, prefix, prepare_context(), print_ctx(), release_context(), and statement_domain.

Referenced by eliminate_original_variables().

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

◆ prepare_context()

static bool prepare_context ( statement  st,
ctx_eov_t ctx 
)
static

The function in this section modify the context to know.

  • where we are
  • on which cluster the statement is executed
  • which variables will be replaced
  • in which expression/loop the variable are replaced update current_task update list of entity_variable to eliminate
    Parameters
    stcurrent statement
    ctxcontext to uppdate

Definition at line 250 of file eliminate_original_variables.c.

250  {
251  ifdebug(2) {
252  pips_debug(2, "prepare_context\n");
253  print_statement(st);
254  }
255  //TODO have to do something for return statement... (on a previous pass?)
257  return false;
258  }
260 
261  // update the current task to work on
262  eov_stack_task_push_task(ctx, t);
263  pips_debug(4, "current_task modified:%s\n", task_to_string(t, false));
264 
265  // update the eliminated variable
266  // Check if it's a declaration statement
267  // if so maybe have to add entity to the list of entity to eliminate
268  if (declaration_statement_p(st)) {
269  // we don't have to eliminate variable on_cluster generated
272  if (strncasecmp(entity_user_name(var), ctx->prefix_new_entity, strlen(ctx->prefix_new_entity)) != 0
273  && !entity_in_list_p(var, task_private_data(t))) {
274  //add entity to the list of entity to eliminate
275  eov_add_entity_to_eliminate(ctx, var);
276  }
277  }
278  ifdebug(4) {
280  if (strncasecmp(entity_user_name(var), ctx->prefix_new_entity, strlen(ctx->prefix_new_entity))) {
281  pips_debug(5, "add entity to entity_to_eliminate:\n");
283  }
284  }
285  }
286  }
287  // for variable on_cluster generated, check if it's an dynamic declaration of an array
288  // and so modify the size of the array with the right new size (the old variable by the new one)
289  else {
291  if (strncasecmp(entity_user_name(var), ctx->prefix_new_entity, strlen(ctx->prefix_new_entity)) == 0
292  && !entity_in_list_p(var, task_private_data(t))) {
293  //Modify type dependency declaration
294  //a1[size] -> a1[size1]
295  //TODO : modify type dependency
296  variable vvar = type_variable(entity_type(var));
297  if (variable_entity_dimension(var)>0) {
298  //if (variable_dimension_number(vvar)) {
299  string scurrent_cluster = strrchr(entity_user_name(var),'_');
300  if (scurrent_cluster != NULL) {
301  int current_cluster = atoi(scurrent_cluster+1);
302  eov_set_current_cluster(ctx, current_cluster);
304  }
305  }
306  }
307  }
308  }
309  }
310 
311  ifdebug(8) {
312  print_ctx(*ctx);
313  }
314  return true;
315 }
static void eov_add_entity_to_eliminate(ctx_eov_t *ctx, entity e)
static void eov_set_current_cluster(ctx_eov_t *ctx, int on_cluster)
static void eov_stack_task_push_task(ctx_eov_t *ctx, task t)
call statement_call(statement)
Get the call of a statement.
Definition: statement.c:1406
bool statement_call_p(statement)
Definition: statement.c:364
bool comments_equal_p(string, string)
Definition: statement.c:116
bool declaration_statement_p(statement)
Had to be optimized according to Beatrice Creusillet.
Definition: statement.c:224
void print_entity_variable(entity e)
print_entity_variable(e)
Definition: entity.c:56
void print_statement(statement)
Print a statement on stderr.
Definition: statement.c:98
#define ENTITY_C_RETURN_P(e)
bool entity_in_list_p(entity ent, list ent_l)
look for ent in ent_l
Definition: entity.c:2221
int variable_entity_dimension(entity)
variable_entity_dimension(entity v): returns the dimension of variable v; scalar have dimension 0.
Definition: variable.c:1293
#define call_function(x)
Definition: ri.h:709
#define type_variable(x)
Definition: ri.h:2949
#define statement_declarations(x)
Definition: ri.h:2460
#define statement_comments(x)
Definition: ri.h:2456
#define entity_type(x)
Definition: ri.h:2792
string task_to_string(task t, bool pretty_print)
Definition: task_mapping.c:84
#define COMMENT_VARIABLE_REPLICATION
task load_parallel_task_mapping(statement)
#define task_private_data(x)
Definition: task_private.h:117

References call_function, COMMENT_VARIABLE_REPLICATION, comments_equal_p(), declaration_statement_p(), ENTITY, ENTITY_C_RETURN_P, entity_in_list_p(), entity_type, entity_user_name(), eov_add_entity_to_eliminate(), eov_set_current_cluster(), eov_stack_task_push_task(), FOREACH, gen_context_recurse, gen_true2(), ifdebug, load_parallel_task_mapping(), pips_debug, ctx_eov::prefix_new_entity, print_ctx(), print_entity_variable(), print_statement(), reference_domain, statement_call(), statement_call_p(), statement_comments, statement_declarations, subtsitute_variable_in_reference(), task_private_data, task_to_string(), type_variable, and variable_entity_dimension().

Referenced by make_eliminate_original_variables().

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

◆ print_ctx()

static void print_ctx ( const ctx_eov_t  ctx)
static

Definition at line 116 of file eliminate_original_variables.c.

116  {
117  fprintf(stderr, "current_task:\n");
119  fprintf(stderr, "entities to eliminate:\n");
122  fprintf(stderr, "\n");
123  }
124  fprintf(stderr, "nbr_cluster=%d", ctx.nbr_cluster);
125  fprintf(stderr, "current_cluster=%d", ctx.current_cluster);
126 }
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
void print_task(task t)
Pass: TASK_MAPPING Debug mode: MPI_GENERATION_DEBUG_LEVEL Resource generated:
Definition: task_mapping.c:73

References ctx_eov::current_cluster, ctx_eov::current_task, fprintf(), ctx_eov::hash_entity_to_eliminate, HASH_FOREACH, ctx_eov::nbr_cluster, print_entity_variable(), and print_task().

Referenced by expression_substitute_variable(), loop_replace_variable(), make_eliminate_original_variables(), prepare_context(), release_context(), and subtsitute_variable_in_reference().

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

◆ release_context()

static void release_context ( __attribute__((unused)) statement  st,
ctx_eov_t ctx 
)
static

Definition at line 317 of file eliminate_original_variables.c.

317  {
318  pips_debug(2, "release_context\n");
320  ifdebug(8) {
321  print_ctx(*ctx);
322  }
323 }
static task eov_stack_task_pop_task(ctx_eov_t *ctx)

References eov_stack_task_pop_task(), ifdebug, pips_debug, and print_ctx().

Referenced by make_eliminate_original_variables().

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

◆ subtsitute_variable_in_reference()

static void subtsitute_variable_in_reference ( reference  r,
ctx_eov_t ctx 
)
static

if it's needed, variable present in list of variable to eliminate, substitute the variable entity present in reference r by the corresponding one on the corresponding cluster.

Parameters
rreference on which the variable will be substituted
ctxcontext that content the cluster in which the reference will be executed list on var to eliminate correspondence between variable and new_variable

Definition at line 385 of file eliminate_original_variables.c.

385  {
386  ifdebug(3) {
387  pips_debug(3, "work on reference\n");
388  print_reference(r);
389  ifdebug(8) {
390  print_ctx(*ctx);
391  }
392  }
393  //task t = eov_current_task(ctx);
394  //int on_cluster = task_on_cluster(t);
395  int on_cluster = eov_get_current_cluster(ctx);
396  entity var = reference_variable(r);
397 
398  //Test if we want to substitute the variable
399  if (eov_entity_to_eliminate_p(ctx, var)) {
400  if (on_cluster==-1) {
402  pips_user_error("statement %p in all cluster. This case may never happens.\n%s\n", st, text_to_string(statement_to_text(st)));
403  }
404  else if (on_cluster < ctx->nbr_cluster) {
405  entity new_idx = eov_get_replaced_enity(ctx, var, on_cluster);
406  reference_variable(r) = new_idx;
407  }
408  else {
409  pips_user_error("the cluster asked is out of bounded, on_cluster=%%d", on_cluster);
410  }
411  }
412 }
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
gen_chunk * gen_get_ancestor(int, const void *)
return the first ancestor object found of the given type.
Definition: genClib.c:3560
void print_reference(reference r)
Definition: expression.c:142
text statement_to_text(statement)
Definition: statement.c:124
#define reference_variable(x)
Definition: ri.h:2326
string text_to_string(text t)
SG: moved here from ricedg.
Definition: print.c:239

References eov_entity_to_eliminate_p(), eov_get_current_cluster(), eov_get_replaced_enity(), gen_get_ancestor(), ifdebug, pips_debug, pips_user_error, print_ctx(), print_reference(), reference_variable, statement_domain, statement_to_text(), and text_to_string().

Referenced by expression_substitute_variable(), and prepare_context().

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

Variable Documentation

◆ compteur_stack_task

int compteur_stack_task = 0
static

Pass: ELIMINATE_ORIGINAL_VARIABLES Debug mode: MPI_GENERATION_DEBUG_LEVEL Properties used:

  • MPI_NBR_CLUSTER
  • MPI_DUPLICATE_VARIABLE_PREFIX Resource needed:
  • DBR_TASK

Definition at line 66 of file eliminate_original_variables.c.

Referenced by eov_stack_task_pop_task(), and eov_stack_task_push_task().