PIPS
variable_replication.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 "pipsdbm.h"
#include "control.h"
#include "misc.h"
#include "properties.h"
#include "task_parallelization.h"
#include "prettyprint.h"
+ Include dependency graph for variable_replication.c:

Go to the source code of this file.

Functions

static string variable_replication_declaration_commenter (__attribute__((unused)) entity e)
 Pass: VARIABLE_REPLICATION Debug mode: MPI_GENERATION_DEBUG_LEVEL Properties used: More...
 
static void replicate_declaration (entity decl, statement module_statement, statement st)
 
static bool make_global_variable_declaration_replication ()
 
static bool make_declaration_replication (statement module_statement)
 only replicate declaration declare at the first scope of the function. More...
 
bool variable_replication (const char *module_name)
 PIPS pass. More...
 

Function Documentation

◆ make_declaration_replication()

static bool make_declaration_replication ( statement  module_statement)
static

only replicate declaration declare at the first scope of the function.

The sub-scope has to be some pragma and don't have to be replicate. \pragma module_statement statement to work on

Definition at line 118 of file variable_replication.c.

118  {
120  pips_internal_error("module_statement have to be the statement of the module/function\n");
121  return false;
122  }
123 
124  // FOREACH statement of the module/function,
125  // check if it's a declaration
126  // then FOREACH declaration generate new variables (depend of the number of proc) and declare them
128  if (declaration_statement_p(st)) {
130  // declarations list of entity declared
131  list declarations = statement_declarations(st);
132  FOREACH(ENTITY, decl, declarations) {
133  // test if the entity decl is not in the private list of the task, if so no replication
134  if (gen_position(decl, task_private_data(t)) == 0) {
136  }
137  }
138  }
139  }
140 
141  return true;
142 }
static statement module_statement
Definition: alias_check.c:125
int gen_position(const void *item, const list l)
Element ranks are strictly positive as for first, second, and so on.
Definition: list.c:995
#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
sequence statement_sequence(statement)
Get the sequence of a statement sequence.
Definition: statement.c:1328
bool statement_sequence_p(statement)
Statement classes induced from instruction type.
Definition: statement.c:335
bool declaration_statement_p(statement)
Had to be optimized according to Beatrice Creusillet.
Definition: statement.c:224
#define pips_internal_error
Definition: misc-local.h:149
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define sequence_statements(x)
Definition: ri.h:2360
#define statement_declarations(x)
Definition: ri.h:2460
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
task load_parallel_task_mapping(statement)
#define task_private_data(x)
Definition: task_private.h:117
static void replicate_declaration(entity decl, statement module_statement, statement st)

References declaration_statement_p(), ENTITY, FOREACH, gen_position(), load_parallel_task_mapping(), module_statement, pips_internal_error, replicate_declaration(), sequence_statements, STATEMENT, statement_declarations, statement_sequence(), statement_sequence_p(), and task_private_data.

Referenced by variable_replication().

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

◆ make_global_variable_declaration_replication()

static bool make_global_variable_declaration_replication ( )
static

Definition at line 107 of file variable_replication.c.

107  {
108  pips_user_warning("global variable not implemented yet.\n");
109  return true;
110 }
#define pips_user_warning
Definition: misc-local.h:146

References pips_user_warning.

Referenced by variable_replication().

+ Here is the caller graph for this function:

◆ replicate_declaration()

static void replicate_declaration ( entity  decl,
statement  module_statement,
statement  st 
)
static

Definition at line 63 of file variable_replication.c.

63  {
64  ifdebug(4) {
65  pips_debug(4, "begin\n");
66  pips_debug(4, "declaration statement to replicated\n");
67  print_statement(st);
68  }
69  const char * prefix = get_string_property((const char *) MPI_GENERATION_PREFIX);
71  statement declaration=statement_undefined;
72 
74  for (int i=0; i<nbr_copy; i++) {
75  string new_name = "";
76  entity new_entity = entity_undefined;
77  new_name = concatenate(
80  prefix, entity_user_name(decl), "_", i2a(i),
81  NULL);
82 
84  pips_user_error("The entity %s already exist\n", new_name);
85  return;
86  }
87  new_entity = make_entity_copy_with_new_name(decl, new_name, true);
88 
89  declaration = add_declaration_statement_here(module_statement, st, new_entity, true);
90 
91  //statement_declarations(module_statement) = CONS(ENTITY, new_entity, statement_declarations(module_statement));
92  }
94 
95  pips_assert("module_statement is consistent\n", statement_consistent_p(module_statement));
96  ifdebug(4) {
97  pips_debug(4, "declaration statement that be added\n");
98  print_statement(declaration);
99  print_statement(st);
100  pips_debug(4, "end\n");
101  }
102 }
int get_int_property(const string)
bool statement_consistent_p(statement p)
Definition: ri.c:2195
char * get_string_property(const char *)
void pop_generated_variable_commenter(void)
Definition: statement.c:2623
statement add_declaration_statement_here(statement, statement, entity, bool)
Add a new declaration statement (inspired by generic_add_declaration_statement)
Definition: statement.c:2839
void push_generated_variable_commenter(string(*)(entity))
Definition: statement.c:2616
#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 pips_user_error
Definition: misc-local.h:147
#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
void print_statement(statement)
Print a statement on stderr.
Definition: statement.c:98
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
entity make_entity_copy_with_new_name(entity e, string global_new_name, bool move_initialization_p)
Create a copy of an entity, with (almost) identical type, storage and initial value if move_initializ...
Definition: entity.c:2463
#define entity_undefined
Definition: ri.h:2761
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
#define statement_undefined
Definition: ri.h:2419
#define ifdebug(n)
Definition: sg.c:47
#define MPI_GENERATION_NBR_CLUSTER
#define MPI_GENERATION_PREFIX
static string variable_replication_declaration_commenter(__attribute__((unused)) entity e)
Pass: VARIABLE_REPLICATION Debug mode: MPI_GENERATION_DEBUG_LEVEL Properties used:

References add_declaration_statement_here(), concatenate(), entity_domain, entity_local_name(), entity_module_name(), entity_undefined, entity_user_name(), gen_find_tabulated(), get_int_property(), get_string_property(), i2a(), ifdebug, local_name_to_scope(), make_entity_copy_with_new_name(), MODULE_SEP_STRING, module_statement, MPI_GENERATION_NBR_CLUSTER, MPI_GENERATION_PREFIX, pips_assert, pips_debug, pips_user_error, pop_generated_variable_commenter(), prefix, print_statement(), push_generated_variable_commenter(), statement_consistent_p(), statement_undefined, and variable_replication_declaration_commenter().

Referenced by make_declaration_replication().

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

◆ variable_replication()

bool variable_replication ( const char *  module_name)

PIPS pass.

variable_replication.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 148 of file variable_replication.c.

148  {
149  //entity module;
151  bool good_result_p = true;
152 
153  debug_on("MPI_GENERATION_DEBUG_LEVEL");
154  pips_debug(1, "begin\n");
155 
156  //-- configure environment --//
158  //module = get_current_module_entity();
159 
161  db_get_memory_resource(DBR_CODE, module_name, true) );
163 
164  pips_assert("Statement should be OK before...",
166 
168 
169  //-- get dependencies --//
171  db_get_memory_resource(DBR_TASK, module_name, true));
172 
173  //-- Make the job -- //
176 
177  /* Reorder the module, because some statements have been added.
178  Well, the order on the remaining statements should be the same,
179  but by reordering the statements, the number are consecutive. Just
180  for pretty print... :-) */
182 
183  pips_assert("Statement should be OK after...",
185 
186  //-- Save modified code to database --//
188 
193 
194  pips_debug(1, "end\n");
195  debug_off();
196 
197  return (good_result_p);
198 }
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
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 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
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)
static bool make_global_variable_declaration_replication()
static bool make_declaration_replication(statement module_statement)
only replicate declaration declare at the first scope of the function.

References db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, get_current_module_statement(), make_declaration_replication(), make_global_variable_declaration_replication(), 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:

◆ variable_replication_declaration_commenter()

static string variable_replication_declaration_commenter ( __attribute__((unused)) entity  e)
static

Pass: VARIABLE_REPLICATION Debug mode: MPI_GENERATION_DEBUG_LEVEL Properties used:

  • MPI_NBR_CLUSTER
  • MPI_DUPLICATE_VARIABLE_PREFIX Resource needed:
  • DBR_TASK

Definition at line 59 of file variable_replication.c.

59  {
61 }
#define COMMENT_VARIABLE_REPLICATION

References COMMENT_VARIABLE_REPLICATION, and strdup().

Referenced by replicate_declaration().

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