PIPS
phrase_distribution.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define EXTERNALIZED_CODE_PRAGMA_BEGIN   "BEGIN_FPGA_%s"
 
#define EXTERNALIZED_CODE_PRAGMA_END   "END_FPGA_%s"
 
#define EXTERNALIZED_CODE_PRAGMA_ANALYZED   "ANALYZED_FPGA_%s (%d statements)"
 
#define EXTERNALIZED_CODE_PRAGMA_CALL   "CALL_FPGA_%s"
 
#define EXTERNALIZED_FUNCTION_PARAM_NAME   "%s_PARAM_%d"
 Stuff for distribution controlization. More...
 
#define EXTERNALIZED_FUNCTION_PRIVATE_PARAM_NAME   "%s_PRIV"
 
#define CONTROL_DATA_COMMON_NAME   "CONTROL_DATA"
 
#define FUNCTION_COMMON_NAME   "%s_COMMON"
 
#define COMMON_PARAM_NAME   "%s_%s"
 
#define DYN_VAR_PARAM_NAME   "%s_DV_PARAM"
 
#define REF_VAR_PARAM_NAME   "%s_REF_PARAM"
 
#define UNITS_NB_NAME   "UNITS_NB"
 
#define UNIT_ID_NAME   "UNIT%d"
 
#define FUNCTIONS_NB_NAME   "FUNCTIONS_NB"
 
#define FUNCTION_ID_NAME   "%s_FUNCTION"
 
#define IN_PARAM_ID_NAME   "%s_%s_IN_PARAM"
 
#define OUT_PARAM_ID_NAME   "%s_%s_OUT_PARAM"
 
#define CONTROLIZED_STATEMENT_COMMENT   "! CONTROLIZED CALL TO %s\n"
 
#define START_RU_MODULE_NAME   "START_RU"
 Stuff for START_RU(...) subroutine generation. More...
 
#define START_RU_PARAM1_NAME   "FUNC_ID"
 
#define START_RU_PARAM2_NAME   "UNIT_ID"
 
#define WAIT_RU_MODULE_NAME   "WAIT_RU"
 Stuff for WAIT_RU(...) subroutine generation. More...
 
#define WAIT_RU_PARAM1_NAME   "FUNC_ID"
 
#define WAIT_RU_PARAM2_NAME   "UNIT_ID"
 
#define VARIABLE_NAME_FORMAT   "_%"PRIdPTR"_%"PRIdPTR
 Stuff for SEND_PARAM.... More...
 
#define SEND_PARAMETER_MODULE_NAME   "SEND_%s_PARAMETER"
 
#define RECEIVE_PARAMETER_MODULE_NAME   "RECEIVE_%s_PARAMETER"
 
#define SEND_ARRAY_PARAM_MODULE_NAME   "SEND_%s_%s_PARAMETER"
 
#define RECEIVE_ARRAY_PARAM_MODULE_NAME   "RECEIVE_%s_%s_PARAMETER"
 
#define COM_MODULE_PARAM1_NAME   "FUNC_ID"
 
#define COM_MODULE_PARAM2_NAME   "UNIT_ID"
 
#define COM_MODULE_PARAM3_NAME   "PARAM_ID"
 
#define COM_MODULE_PARAM4_NAME   "PARAM"
 
#define RU_SEND_FLOAT_PARAM_MODULE_NAME   "RU_SEND_FLOAT_PARAM"
 
#define RU_RECEIVE_FLOAT_PARAM_MODULE_NAME   "RU_RECEIVE_FLOAT_PARAM"
 

Functions

string get_function_name_by_searching_tag (statement stat, const char *tag)
 Return the identified function name of the externalized portion of code by searching comment matching tag. More...
 
string get_externalizable_function_name (statement stat)
 Return the identified function name of the externalized portion of code by searching comment matching tag EXTERNALIZED_CODE_PRAGMA_BEGIN. More...
 
string get_externalized_function_name (statement stat)
 Return the identified function name of the externalized portion of code by searching comment matching tag EXTERNALIZED_CODE_PRAGMA_CALL. More...
 
string get_externalized_and_analyzed_function_name (statement stat, int *stats_nb)
 Return the identified function name of the externalized portion of code by searching comment matching tags EXTERNALIZED_CODE_PRAGMA_ANALYZED Sets the number of statements of this externalizable statement. More...
 
bool compute_distribution_context (list l_stats, statement module_stat, entity module, hash_table *ht_stats, hash_table *ht_params, hash_table *ht_private, hash_table *ht_out_regions, hash_table *ht_in_regions)
 This function is called during PHRASE distribution. More...
 
bool compute_distribution_controlization_context (list l_calls, statement module_stat, entity module, hash_table *ht_calls, hash_table *ht_params, hash_table *ht_private, hash_table *ht_out_regions, hash_table *ht_in_regions)
 This function is called during PHRASE distribution controlization. More...
 
void register_scalar_communications (hash_table *ht_communications, entity function, list l_regions)
 Build an HASHTABLE where keys are VARIABLE and values are HASHTABLE where keys are modules or externalized function (ENTITY) and values are list of regions. More...
 
string variable_to_string (variable var)
 Return a unique (regarding variable_equal_p(var1,var2)) string representation of a variable var. More...
 
entity make_start_ru_module (hash_table ht_params, statement *module_statement, int number_of_deployment_units, entity global_common, list l_commons)
 Build and store new module START_RU. More...
 
entity make_wait_ru_module (statement *module_statement, int number_of_deployment_units, entity global_common, list l_commons)
 Build and store new module WAIT_RU. More...
 
string get_send_param_module_name (entity function, region reg)
 Return SEND_PARAM module name for function and region. More...
 
string get_receive_param_module_name (entity function, region reg)
 Return RECEIVE_PARAM module name for function and region. More...
 
list make_send_scalar_params_modules (hash_table ht_in_communications, int number_of_deployment_units, entity global_common, list l_commons)
 Build and return list of modules used for INPUT communications (SEND_PARAMETERS...) More...
 
list make_receive_scalar_params_modules (hash_table ht_out_communications, int number_of_deployment_units, entity global_common, list l_commons)
 Build and return list of modules used for OUTPUT communications (RECEIVE_PARAMETERS...) More...
 
list make_send_array_params_modules (entity function, list l_regions, entity global_common, entity externalized_fonction_common, int number_of_deployment_units)
 Make all SEND_PARAM communication modules for non-scalar regions for a given function. More...
 
list make_receive_array_params_modules (entity function, list l_regions, entity global_common, entity externalized_fonction_common, int number_of_deployment_units)
 Make all RECEIVE_PARAM communication modules for non-scalar regions for a given function. More...
 
entity create_private_variable_for_new_module (entity a_variable, const char *new_name, const char *new_module_name, entity module)
 Creates a private variable in specified module. More...
 
entity create_parameter_for_new_module (variable var, const char *parameter_name, const char *module_name, entity module, int param_nb)
 Create new variable parameter for a newly created module. More...
 
entity create_integer_parameter_for_new_module (const char *parameter_name, const char *module_name, entity module, int param_nb)
 Create new integer variable parameter for a newly created module. More...
 
void store_new_module (const char *module_name, entity module, statement module_statement)
 Store (PIPDBM) newly created module module with module_statement as USER_FILE by saving pretty printing. More...
 
string get_common_param_name (entity variable, entity function)
 
string get_function_id_name (entity function)
 
string get_send_parameter_module_name (variable var)
 
string get_receive_parameter_module_name (variable var)
 
string get_in_param_id_name (entity variable, entity function)
 
string get_out_param_id_name (entity variable, entity function)
 
void compute_region_variables (region reg, list *l_reg_params, list *l_reg_variables)
 Build and return parameters (PHI1,PHI2) and dynamic variables for region reg. More...
 
void declare_common_variables_in_module (entity common, entity module)
 Creates all the things that need to be created in order to declare common in module (all the variable are created) More...
 

Macro Definition Documentation

◆ COM_MODULE_PARAM1_NAME

#define COM_MODULE_PARAM1_NAME   "FUNC_ID"

Definition at line 65 of file phrase_distribution.h.

◆ COM_MODULE_PARAM2_NAME

#define COM_MODULE_PARAM2_NAME   "UNIT_ID"

Definition at line 66 of file phrase_distribution.h.

◆ COM_MODULE_PARAM3_NAME

#define COM_MODULE_PARAM3_NAME   "PARAM_ID"

Definition at line 67 of file phrase_distribution.h.

◆ COM_MODULE_PARAM4_NAME

#define COM_MODULE_PARAM4_NAME   "PARAM"

Definition at line 68 of file phrase_distribution.h.

◆ COMMON_PARAM_NAME

#define COMMON_PARAM_NAME   "%s_%s"

Definition at line 37 of file phrase_distribution.h.

◆ CONTROL_DATA_COMMON_NAME

#define CONTROL_DATA_COMMON_NAME   "CONTROL_DATA"

Definition at line 35 of file phrase_distribution.h.

◆ CONTROLIZED_STATEMENT_COMMENT

#define CONTROLIZED_STATEMENT_COMMENT   "! CONTROLIZED CALL TO %s\n"

Definition at line 46 of file phrase_distribution.h.

◆ DYN_VAR_PARAM_NAME

#define DYN_VAR_PARAM_NAME   "%s_DV_PARAM"

Definition at line 38 of file phrase_distribution.h.

◆ EXTERNALIZED_CODE_PRAGMA_ANALYZED

#define EXTERNALIZED_CODE_PRAGMA_ANALYZED   "ANALYZED_FPGA_%s (%d statements)"

Definition at line 29 of file phrase_distribution.h.

◆ EXTERNALIZED_CODE_PRAGMA_BEGIN

#define EXTERNALIZED_CODE_PRAGMA_BEGIN   "BEGIN_FPGA_%s"

Definition at line 27 of file phrase_distribution.h.

◆ EXTERNALIZED_CODE_PRAGMA_CALL

#define EXTERNALIZED_CODE_PRAGMA_CALL   "CALL_FPGA_%s"

Definition at line 30 of file phrase_distribution.h.

◆ EXTERNALIZED_CODE_PRAGMA_END

#define EXTERNALIZED_CODE_PRAGMA_END   "END_FPGA_%s"

Definition at line 28 of file phrase_distribution.h.

◆ EXTERNALIZED_FUNCTION_PARAM_NAME

#define EXTERNALIZED_FUNCTION_PARAM_NAME   "%s_PARAM_%d"

Stuff for distribution controlization.

Definition at line 33 of file phrase_distribution.h.

◆ EXTERNALIZED_FUNCTION_PRIVATE_PARAM_NAME

#define EXTERNALIZED_FUNCTION_PRIVATE_PARAM_NAME   "%s_PRIV"

Definition at line 34 of file phrase_distribution.h.

◆ FUNCTION_COMMON_NAME

#define FUNCTION_COMMON_NAME   "%s_COMMON"

Definition at line 36 of file phrase_distribution.h.

◆ FUNCTION_ID_NAME

#define FUNCTION_ID_NAME   "%s_FUNCTION"

Definition at line 43 of file phrase_distribution.h.

◆ FUNCTIONS_NB_NAME

#define FUNCTIONS_NB_NAME   "FUNCTIONS_NB"

Definition at line 42 of file phrase_distribution.h.

◆ IN_PARAM_ID_NAME

#define IN_PARAM_ID_NAME   "%s_%s_IN_PARAM"

Definition at line 44 of file phrase_distribution.h.

◆ OUT_PARAM_ID_NAME

#define OUT_PARAM_ID_NAME   "%s_%s_OUT_PARAM"

Definition at line 45 of file phrase_distribution.h.

◆ RECEIVE_ARRAY_PARAM_MODULE_NAME

#define RECEIVE_ARRAY_PARAM_MODULE_NAME   "RECEIVE_%s_%s_PARAMETER"

Definition at line 64 of file phrase_distribution.h.

◆ RECEIVE_PARAMETER_MODULE_NAME

#define RECEIVE_PARAMETER_MODULE_NAME   "RECEIVE_%s_PARAMETER"

Definition at line 62 of file phrase_distribution.h.

◆ REF_VAR_PARAM_NAME

#define REF_VAR_PARAM_NAME   "%s_REF_PARAM"

Definition at line 39 of file phrase_distribution.h.

◆ RU_RECEIVE_FLOAT_PARAM_MODULE_NAME

#define RU_RECEIVE_FLOAT_PARAM_MODULE_NAME   "RU_RECEIVE_FLOAT_PARAM"

Definition at line 71 of file phrase_distribution.h.

◆ RU_SEND_FLOAT_PARAM_MODULE_NAME

#define RU_SEND_FLOAT_PARAM_MODULE_NAME   "RU_SEND_FLOAT_PARAM"

Definition at line 70 of file phrase_distribution.h.

◆ SEND_ARRAY_PARAM_MODULE_NAME

#define SEND_ARRAY_PARAM_MODULE_NAME   "SEND_%s_%s_PARAMETER"

Definition at line 63 of file phrase_distribution.h.

◆ SEND_PARAMETER_MODULE_NAME

#define SEND_PARAMETER_MODULE_NAME   "SEND_%s_PARAMETER"

Definition at line 61 of file phrase_distribution.h.

◆ START_RU_MODULE_NAME

#define START_RU_MODULE_NAME   "START_RU"

Stuff for START_RU(...) subroutine generation.

Definition at line 49 of file phrase_distribution.h.

◆ START_RU_PARAM1_NAME

#define START_RU_PARAM1_NAME   "FUNC_ID"

Definition at line 50 of file phrase_distribution.h.

◆ START_RU_PARAM2_NAME

#define START_RU_PARAM2_NAME   "UNIT_ID"

Definition at line 51 of file phrase_distribution.h.

◆ UNIT_ID_NAME

#define UNIT_ID_NAME   "UNIT%d"

Definition at line 41 of file phrase_distribution.h.

◆ UNITS_NB_NAME

#define UNITS_NB_NAME   "UNITS_NB"

Definition at line 40 of file phrase_distribution.h.

◆ VARIABLE_NAME_FORMAT

#define VARIABLE_NAME_FORMAT   "_%"PRIdPTR"_%"PRIdPTR

Stuff for SEND_PARAM....

(...) and RECEIVE_PARAM....(...) subroutines generation

Definition at line 60 of file phrase_distribution.h.

◆ WAIT_RU_MODULE_NAME

#define WAIT_RU_MODULE_NAME   "WAIT_RU"

Stuff for WAIT_RU(...) subroutine generation.

Definition at line 54 of file phrase_distribution.h.

◆ WAIT_RU_PARAM1_NAME

#define WAIT_RU_PARAM1_NAME   "FUNC_ID"

Definition at line 55 of file phrase_distribution.h.

◆ WAIT_RU_PARAM2_NAME

#define WAIT_RU_PARAM2_NAME   "UNIT_ID"

Definition at line 56 of file phrase_distribution.h.

Function Documentation

◆ compute_distribution_context()

bool compute_distribution_context ( list  l_stats,
statement  module_stat,
entity  module,
hash_table ht_stats,
hash_table ht_params,
hash_table ht_private,
hash_table ht_in_regions,
hash_table ht_out_regions 
)

This function is called during PHRASE distribution.

distribution_context.c

The goal here is to compute the context of the distribution from a given list of statements (after distribution initialization). Those results are stored in following hashtable:

HT_STATS: This hashtable stores the statement (values) associated to names (keys) of externalized function.

HT_PARAMS: This hashtable stores the list of regions (values) associated to names (keys) of externalized function. Those regions are computed as union of IN and OUT regions of specified statement. If two or more regions refer to the same variable (entity), those regions are transformed into ONE region (which could be converted to a MAY region). This hashtable is used to compute the parameters of specified externalized function.

HT_PRIVATE: This hashtable stores the list of privates regions (values) associated to names (keys) of externalized function. This hashtable is used to compute the private working area in specified externalized function.

HT_IN_REGIONS: This hashtable stores the list of IN regions (values) associated to names (keys) of externalized function. This hashtable is used to compute OUTPUT communication after externalized function execution.

HT_OUT_REGIONS: This hashtable stores the list of OUT regions (values) associated to names (keys) of externalized function. This hashtable is used to compute OUTPUT communication after externalized function execution.

Return true if everything is OK

NB: All lists are sorted using externalized fonction name

lazy init

lazy init

lazy init

lazy init

lazy init

Register new externalized function

Parameters
l_stats_stats
module_statodule_stat
moduleodule
ht_statst_stats
ht_paramst_params
ht_privatet_private
ht_in_regionst_in_regions
ht_out_regionst_out_regions

Definition at line 113 of file distribution_context.c.

121 {
122  bool returned_value = true;
123 
124  pips_debug(5, "[BEGIN] compute_distribution_context for %s: \n",
126 
127  *ht_stats = hash_table_make (hash_pointer, 0); /* lazy init */
128  *ht_params = hash_table_make (hash_pointer, 0); /* lazy init */
129  *ht_private = hash_table_make (hash_pointer, 0); /* lazy init */
130  *ht_in_regions = hash_table_make (hash_pointer, 0); /* lazy init */
131  *ht_out_regions = hash_table_make (hash_pointer, 0); /* lazy init */
132 
133  MAP (STATEMENT, s, {
134  statement externalized_code = NULL;
135  int stats_nb;
136  string function_name = get_externalized_and_analyzed_function_name(s, &stats_nb);
137  if (stats_nb > 1) {
138  externalized_code = sequence_statement_containing (module_stat, s);
139  }
140  else if (stats_nb == 1) {
141  externalized_code = s;
142  }
143  else {
144  pips_internal_error("Strange externalized code");
145  }
146 
147  /* Register new externalized function */
148  pips_debug(5, "Register externalized function %s: \n",
149  function_name);
150  if (!hash_defined_p(*ht_stats,function_name)) {
151  hash_put(*ht_stats,function_name,externalized_code);
152  }
153  else {
154  pips_user_warning("Multiply defined value in STATS hash_table!\n");
155  returned_value = false;
156  }
157 
158  pips_debug(3, "ANALYSING function named [%s]..................\n",
159  function_name);
160 
161  if (!internal_compute_distribution_context (externalized_code,
162  ht_params,
163  ht_private,
164  ht_in_regions,
165  ht_out_regions,
166  function_name)) {
167  returned_value = false;
168  }
169  }, l_stats);
170 
171  pips_debug(5, "[END] compute_distribution_context for %s: \n",
173 
174  return returned_value;
175 }
bool internal_compute_distribution_context(statement externalized_code, hash_table *ht_params, hash_table *ht_private, hash_table *ht_in_regions, hash_table *ht_out_regions, void *key_value)
Internally used to compute distribution context for statement externalized_code.
string get_externalized_and_analyzed_function_name(statement stat, int *stats_nb)
Return the identified function name of the externalized portion of code by searching comment matching...
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
Definition: newgen_list.h:226
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
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
bool hash_defined_p(const hash_table htp, const void *key)
true if key has e value in htp.
Definition: hash.c:484
#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_user_warning
Definition: misc-local.h:146
#define pips_internal_error
Definition: misc-local.h:149
@ hash_pointer
Definition: newgen_hash.h:32
statement sequence_statement_containing(statement, statement)
Definition: phrase_tools.c:536
static char * module
Definition: pips.c:74
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
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413

References entity_local_name(), get_externalized_and_analyzed_function_name(), hash_defined_p(), hash_pointer, hash_put(), hash_table_make(), internal_compute_distribution_context(), MAP, module, pips_debug, pips_internal_error, pips_user_warning, sequence_statement_containing(), and STATEMENT.

Referenced by comEngine_distribute(), and distribute().

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

◆ compute_distribution_controlization_context()

bool compute_distribution_controlization_context ( list  l_calls,
statement  module_stat,
entity  module,
hash_table ht_calls,
hash_table ht_params,
hash_table ht_private,
hash_table ht_in_regions,
hash_table ht_out_regions 
)

This function is called during PHRASE distribution controlization.

The goal here is to compute the context of the distribution from a given list of call statements (after distribution). Those results are stored in following hashtable:

HT_CALLS: This hashtable stores the list of call statements (values) associated to entity representing the external function (keys). This is a list because a same function can be called from multiple points of original program

HT_PARAMS: This hashtable stores the list of regions (values) associated to entity representing the external function (keys). Those regions are computed as union of IN and OUT regions of specified statement. If two or more regions refer to the same variable (entity), those regions are transformed into ONE region (which could be converted to a MAY region). This hashtable is used to compute the parameters of specified externalized function.

HT_PRIVATE: This hashtable stores the list of privates regions (values) associated to entity representing the external function (keys). This hashtable is used to compute the private working area in specified externalized function.

HT_IN_REGIONS: This hashtable stores the list of IN regions (values) associated to entity representing the external function (keys). This hashtable is used to compute OUTPUT communication after externalized function execution.

HT_OUT_REGIONS: This hashtable stores the list of OUT regions (values) associated to entity representing the external function (keys). This hashtable is used to compute OUTPUT communication after externalized function execution.

Return true if everything is OK

NB: All lists are sorted using externalized fonction name

lazy init

lazy init

lazy init

lazy init

lazy init

Register new externalized function

This function has NOT been already defined, Register it

This function has already been defined, add this statement to the list

Check that IN and OUT regions match !

NOT IMPLEMENTED Yet !

Parameters
l_calls_calls
module_statodule_stat
moduleodule
ht_callst_calls
ht_paramst_params
ht_privatet_private
ht_in_regionst_in_regions
ht_out_regionst_out_regions

Definition at line 216 of file distribution_context.c.

224 {
225  bool returned_value = true;
226  string function_name;
227  entity externalized_function;
228 
229  pips_debug(5, "[BEGIN] compute_distribution_controlization_context for %s: \n",
231  ifdebug(9) {
232  print_statement(module_stat);
233  }
234 
235  *ht_calls = hash_table_make (hash_pointer, 0); /* lazy init */
236  *ht_params = hash_table_make (hash_pointer, 0); /* lazy init */
237  *ht_private = hash_table_make (hash_pointer, 0); /* lazy init */
238  *ht_in_regions = hash_table_make (hash_pointer, 0); /* lazy init */
239  *ht_out_regions = hash_table_make (hash_pointer, 0); /* lazy init */
240 
241 
242  MAP (STATEMENT, s, {
243 
244  function_name = get_externalized_function_name(s);
245 
246  pips_debug(5, "Register statement calling externalized function %s: \n",
247  function_name);
248 
249  externalized_function = module_name_to_entity(function_name);
250 
251  /* Register new externalized function */
252 
253  if (!hash_defined_p(*ht_calls,externalized_function)) {
254  /* This function has NOT been already defined,
255  Register it */
256  pips_debug(2, "Register statement for NEW function %s\n", function_name);
257  hash_put(*ht_calls,externalized_function,CONS(STATEMENT, s, NIL));
259  ht_params,
260  ht_private,
261  ht_in_regions,
262  ht_out_regions,
263  externalized_function)) {
264  returned_value = false;
265  }
266  }
267  else {
268  /* This function has already been defined,
269  add this statement to the list */
270  list l_stats = (list)hash_get(*ht_calls,externalized_function);
271  hash_put(*ht_calls,externalized_function,CONS(STATEMENT, s, l_stats));
272  /* Check that IN and OUT regions match ! */
273  /* NOT IMPLEMENTED Yet ! */
274  pips_debug(2, "Adding statement to function %s\n", function_name);
275  }
276 
277  pips_debug(3, "ANALYSING function named [%s]..................\n",
278  function_name);
279 
280  }, l_calls);
281 
282  pips_debug(5, "[END] compute_distribution_controlization_context for %s: \n",
284 
285  return returned_value;
286 }
string get_externalized_function_name(statement stat)
Return the identified function name of the externalized portion of code by searching comment matching...
#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
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
struct cons * list
Definition: newgen_types.h:106
void print_statement(statement)
Print a statement on stderr.
Definition: statement.c:98
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479
#define ifdebug(n)
Definition: sg.c:47
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References CONS, entity_local_name(), get_externalized_function_name(), hash_defined_p(), hash_get(), hash_pointer, hash_put(), hash_table_make(), ifdebug, internal_compute_distribution_context(), MAP, module, module_name_to_entity(), NIL, pips_debug, print_statement(), and STATEMENT.

Referenced by controlize_distribution().

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

◆ compute_region_variables()

void compute_region_variables ( region  reg,
list l_reg_params,
list l_reg_variables 
)

Build and return parameters (PHI1,PHI2) and dynamic variables for region reg.


NOT IMPLEMENTED: suppress unused dynamic variables !!!!

NOT IMPLEMENTED: suppress unused dynamic variables !!!!

An entity in a system that has an undefined storage is necesseraly a PHI entity, not dynamic !!

Definition at line 626 of file phrase_distributor_communication.c.

629 {
630  Psysteme ps_reg;
631  Pbase ps_base;
632 
633  ps_reg = region_system(reg);
634  ps_base = ps_reg->base;
635 
636  *l_reg_params = NIL;
637  *l_reg_variables = NIL;
638 
639  pips_debug(3, "BEGIN compute_region_variables: \n");
640 
641  pips_assert("compute_region_variables", ! SC_UNDEFINED_P(ps_reg));
642 
643  for (; ! VECTEUR_NUL_P(ps_base); ps_base = ps_base->succ) {
644 
645  entity e = (entity) ps_base->var;
646  if (e != NULL) {
647  storage s = entity_storage(e);
648  pips_debug(7, "Variable: %s\n", entity_global_name(e));
649  /* An entity in a system that has an undefined storage is
650  necesseraly a PHI entity, not dynamic !! */
651  if (s != storage_undefined) {
652  if (storage_tag(s) == is_storage_ram) {
653  ram r = storage_ram(s);
654  if (dynamic_area_p(ram_section(r))) {
655  *l_reg_variables = CONS(ENTITY, e, *l_reg_variables);
656  }
657  }
658  else {
659  *l_reg_params = CONS(ENTITY, e, *l_reg_params);
660  }
661  }
662  }
663  }
664  pips_debug(3, "END compute_region_variables: \n");
665 }
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
#define region_system(reg)
if(!(yy_init))
Definition: genread_lex.c:1029
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
bool dynamic_area_p(entity aire)
Definition: area.c:68
string entity_global_name(entity e)
Used instead of the macro to pass as formal argument.
Definition: entity.c:464
#define storage_tag(x)
Definition: ri.h:2515
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define entity_storage(x)
Definition: ri.h:2794
#define ram_section(x)
Definition: ri.h:2249
@ is_storage_ram
Definition: ri.h:2492
#define storage_ram(x)
Definition: ri.h:2521
#define storage_undefined
Definition: ri.h:2476
Pbase base
Definition: sc-local.h:75
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
Variable var
Definition: vecteur-local.h:90
struct Svecteur * succ
Definition: vecteur-local.h:92
#define VECTEUR_NUL_P(v)

References Ssysteme::base, CONS, dynamic_area_p(), ENTITY, entity_global_name(), entity_storage, if(), is_storage_ram, NIL, pips_assert, pips_debug, ram_section, region_system, storage_ram, storage_tag, storage_undefined, Svecteur::succ, Svecteur::var, and VECTEUR_NUL_P.

Referenced by make_array_communication_module().

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

◆ create_integer_parameter_for_new_module()

entity create_integer_parameter_for_new_module ( const char *  parameter_name,
const char *  module_name,
entity  module,
int  param_nb 
)

Create new integer variable parameter for a newly created module.

Parameters
parameter_namearameter_name
module_nameodule_name
moduleodule
param_nbaram_nb

Definition at line 126 of file phrase_distributor_control_code.c.

130 {
133  parameter_name,
134  module_name,
135  module,
136  param_nb);
137 }
variable make_variable(basic a1, list a2, list a3)
Definition: ri.c:2895
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
entity create_parameter_for_new_module(variable var, const char *parameter_name, const char *module_name, entity module, int param_nb)
Create new variable parameter for a newly created module.
basic MakeBasic(int)
END_EOLE.
Definition: type.c:128
@ is_basic_int
Definition: ri.h:571

◆ create_parameter_for_new_module()

entity create_parameter_for_new_module ( variable  var,
const char *  parameter_name,
const char *  module_name,
entity  module,
int  param_nb 
)

Create new variable parameter for a newly created module.

phrase_distributor_control_code.c

This entity does not exist, we can safely create it

G used to be strdup("")

Parameters
varar
parameter_namearameter_name
module_nameodule_name
moduleodule
param_nbaram_nb

Definition at line 74 of file phrase_distributor_control_code.c.

79 {
81  parameter new_parameter;
83  list module_parameters;
84 
87  parameter_name,
88  NULL),
90  {
91  /* This entity does not exist, we can safely create it */
92 
95  parameter_name, NULL)),
99 
101 
104 
105  new_parameter = make_parameter (entity_type(new_variable),
107  make_dummy_identifier(new_variable)/*SG used to be strdup("")*/);
108 
110 
112  = CONS(PARAMETER, new_parameter, module_parameters);
113 
114  return new_variable;
115  }
116  else
117  {
118  pips_internal_error("Entity already exist: %s", parameter_name);
119  return NULL;
120  }
121 }
dummy make_dummy_identifier(entity _field_)
Definition: ri.c:620
value make_value_unknown(void)
Definition: ri.c:2847
parameter make_parameter(type a1, mode a2, dummy a3)
Definition: ri.c:1495
type make_type_variable(variable _field_)
Definition: ri.c:2715
mode make_mode_reference(void)
Definition: ri.c:1356
variable copy_variable(variable p)
VARIABLE.
Definition: ri.c:2859
storage make_storage_formal(formal _field_)
Definition: ri.c:2282
formal make_formal(entity a1, intptr_t a2)
Definition: ri.c:1067
static entity new_variable
entity to be replaced, the primary?
Definition: dynamic.c:860
#define MODULE_SEP_STRING
Definition: naming-local.h:30
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
#define make_entity(n, t, s, i)
#define type_functional(x)
Definition: ri.h:2952
#define code_declarations(x)
Definition: ri.h:784
#define entity_undefined
Definition: ri.h:2761
#define functional_parameters(x)
Definition: ri.h:1442
#define PARAMETER(x)
PARAMETER.
Definition: ri.h:1788
#define value_code(x)
Definition: ri.h:3067
#define entity_type(x)
Definition: ri.h:2792
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
#define entity_initial(x)
Definition: ri.h:2796
char * strdup()
list module_declarations(entity m)
High-level functions about modules, using pipsdbm and ri-util and some global variables assumed prope...
Definition: module.c:58

Referenced by create_integer_parameter_for_new_module().

+ Here is the caller graph for this function:

◆ create_private_variable_for_new_module()

entity create_private_variable_for_new_module ( entity  a_variable,
const char *  new_name,
const char *  new_module_name,
entity  module 
)

Creates a private variable in specified module.

This entity does not exist, we can safely create it

Parameters
a_variable_variable
new_nameew_name
new_module_nameew_module_name
moduleodule

Definition at line 586 of file phrase_distributor.c.

590 {
592  entity a;
593  basic base;
594 
595  if ((gen_find_tabulated(concatenate(new_module_name,
597  new_name,
598  NULL),
600  {
601  /* This entity does not exist, we can safely create it */
602 
603  new_variable = make_entity (strdup(concatenate(new_module_name,
605  new_name, NULL)),
609  a = FindEntity(new_module_name, DYNAMIC_AREA_LOCAL_NAME);
613  make_ram(module, a,
616  NIL));
617  pips_debug(2, "Created new private variable: %s\n", entity_global_name(new_variable));
618  return new_variable;
619  }
620  else
621  {
622  pips_internal_error("Entity already exist: %s", new_name);
623  return NULL;
624  }
625 }
type copy_type(type p)
TYPE.
Definition: ri.c:2655
storage make_storage(enum storage_utype tag, void *val)
Definition: ri.c:2273
ram make_ram(entity a1, entity a2, intptr_t a3, list a4)
Definition: ri.c:1999
value copy_value(value p)
VALUE.
Definition: ri.c:2784
bdt base
Current expression.
Definition: bdt_read_paf.c:100
static entity a_variable
#define DYNAMIC_AREA_LOCAL_NAME
Definition: naming-local.h:69
entity FindEntity(const char *package, const char *name)
Retrieve an entity from its package/module name and its local name.
Definition: entity.c:1503
int add_variable_to_area(entity, entity)
Definition: variable.c:1376
@ is_basic_overloaded
Definition: ri.h:574
#define basic_tag(x)
Definition: ri.h:613
#define type_variable(x)
Definition: ri.h:2949
#define variable_basic(x)
Definition: ri.h:3120

Referenced by add_private_variable_to_module().

+ Here is the caller graph for this function:

◆ declare_common_variables_in_module()

void declare_common_variables_in_module ( entity  common,
entity  module 
)

Creates all the things that need to be created in order to declare common in module (all the variable are created)

Compute the primary variables

We iterate on the primary variables declared in the common and create a new variable mapping the one declared in common

Creates the name for the new variable

Copy type of variable

Create storage for new variable

Copy initial value of variable

Build the new variable

Mark for addition

Add to declarations....

Add those new variable to common layout

Parameters
commonommon
moduleodule

Definition at line 237 of file phrase_distributor_control_code.c.

238 {
239  list new_variables = NIL;
240  list primary_variables = NIL;
241  bool is_primary_area = true;
242  int totalized_offset = -1;
243 
244  /* Compute the primary variables */
245  MAP (ENTITY, v, {
246  if (is_primary_area) {
248  if (offset > totalized_offset) {
249  totalized_offset = offset;
250  primary_variables = CONS (ENTITY,v,primary_variables);
251  }
252  else {
253  is_primary_area = false;
254  }
255  }
256  }, area_layout(type_area(entity_type(common))));
257 
258  primary_variables = gen_nreverse(primary_variables);
259 
260  ifdebug(4) {
261  pips_debug(4, "Current layout for %s\n", entity_global_name(common));
262  MAP(ENTITY, v, {
263  pips_debug(4, "[%s] offset %"PRIdPTR"\n", entity_global_name(v),ram_offset(storage_ram(entity_storage(v))));
264  }, area_layout(type_area(entity_type(common))));
265  pips_debug(4, "Primary variables for %s\n", entity_global_name(common));
266  MAP(ENTITY, v, {
267  pips_debug(4, "[%s] offset %"PRIdPTR" PRIMARY\n", entity_global_name(v),ram_offset(storage_ram(entity_storage(v))));
268  }, primary_variables);
269  }
270 
271  MAP (ENTITY, v, {
272 
273  /* We iterate on the primary variables declared in the common and
274  create a new variable mapping the one declared in common */
275 
277  const char* name = entity_local_name(v);
278  int v_offset = ram_offset(storage_ram(entity_storage(v)));
279 
280  /* Creates the name for the new variable */
281  string var_global_name = strdup(concatenate(module_local_name(module),
283  name,NULL));
284 
285  /* Copy type of variable */
286  type var_type = copy_type(entity_type(v));
287 
288  /* Create storage for new variable */
289  storage var_storage = make_storage(is_storage_ram,
290  (make_ram(module,
291  common,
292  v_offset,
293  NIL)));
294  /* Copy initial value of variable */
295  value var_value = copy_value(entity_initial(v));
296 
297  pips_debug(7, "Build variable %s\n", var_global_name);
298 
299  /* Build the new variable */
300  new_variable = make_entity(var_global_name,var_type,var_storage,var_value);
301 
302  /* Mark for addition */
303  new_variables = gen_nconc(new_variables,CONS(ENTITY,new_variable,NIL));
304 
305  pips_debug(7, "Add to declarations %s\n", var_global_name);
306 
307  /* Add to declarations.... */
309 
310  pips_debug(7, "New common variable %s declared\n", var_global_name);
311 
312  }, primary_variables);
313 
314  /* Add those new variable to common layout */
315  {
316  list old_layout = area_layout(type_area(entity_type(common)));
317  area_layout(type_area(entity_type(common))) = gen_nconc(old_layout,new_variables);
318  }
319 
321  pips_debug(3, "Common %s declared in module %s\n",
322  entity_local_name(common),
324 }
static Value offset
Definition: translation.c:283
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
void AddEntityToDeclarations(entity, entity)
END_EOLE.
Definition: variable.c:108
#define area_layout(x)
Definition: ri.h:546
#define type_area(x)
Definition: ri.h:2946
#define ram_offset(x)
Definition: ri.h:2251

◆ get_common_param_name()

string get_common_param_name ( entity  variable,
entity  function 
)
Parameters
functionunction

Definition at line 391 of file phrase_distributor_control_code.c.

392 {
393  char *buffer;
394  asprintf(&buffer,
397  entity_local_name(function));
398  return strdup(buffer);
399 }
#define asprintf
Definition: misc-local.h:225
#define COMMON_PARAM_NAME
static string buffer
Definition: string.c:113

Referenced by create_externalized_function_common().

+ Here is the caller graph for this function:

◆ get_externalizable_function_name()

string get_externalizable_function_name ( statement  stat)

Return the identified function name of the externalized portion of code by searching comment matching tag EXTERNALIZED_CODE_PRAGMA_BEGIN.

Parameters
stattat

Definition at line 449 of file distribution_context.c.

450 {
453 }
string get_function_name_by_searching_tag(statement, const char *)
phrase_distributor.c
#define EXTERNALIZED_CODE_PRAGMA_BEGIN

References EXTERNALIZED_CODE_PRAGMA_BEGIN, and get_function_name_by_searching_tag().

Referenced by identify_statements_to_distribute(), and isolate_code_portion().

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

◆ get_externalized_and_analyzed_function_name()

string get_externalized_and_analyzed_function_name ( statement  stat,
int stats_nb 
)

Return the identified function name of the externalized portion of code by searching comment matching tags EXTERNALIZED_CODE_PRAGMA_ANALYZED Sets the number of statements of this externalizable statement.

Parameters
stattat
stats_nbtats_nb

Definition at line 470 of file distribution_context.c.

472 {
473  string comments;
474  string searched_string;
475  string comment_portion = strdup(EXTERNALIZED_CODE_PRAGMA_ANALYZED);
476  char* function_name = NULL;
477  char* next_line;
479 
482  }
483 
484  if (!statement_with_empty_comment_p(stat)) {
485  searched_string = strdup(comment_portion);
486  searched_string[strcspn(comment_portion, "%s")] = '\0';
487  comments = strdup(statement_comments(stat));
488  next_line = strtok (comments, "\n");
489  if (next_line != NULL) {
490  do {
491  string first_occurence = strstr(next_line,searched_string);
492  if (first_occurence != NULL) {
493  function_name = malloc(256);
494  pips_debug(5, "Scanning: [%s] with [%s]", first_occurence, comment_portion);
495  sscanf (first_occurence, comment_portion, function_name, stats_nb);
496  pips_debug(5, "Found function: [%s] and %d stats \n", function_name, *stats_nb);
497  }
498  next_line = strtok(NULL, "\n");
499  }
500  while (next_line != NULL);
501  }
502  }
503 
504  return function_name;
505 }
void * malloc(YYSIZE_T)
gen_chunk gen_nth(int n, const list l)
to be used as ENTITY(gen_nth(3, l))...
Definition: list.c:710
bool statement_with_empty_comment_p(statement)
Return true if the statement has an empty statement:
Definition: statement.c:126
#define EXTERNALIZED_CODE_PRAGMA_ANALYZED
@ is_instruction_sequence
Definition: ri.h:1469
#define instruction_tag(x)
Definition: ri.h:1511
#define sequence_statements(x)
Definition: ri.h:2360
#define instruction_sequence(x)
Definition: ri.h:1514
#define statement_instruction(x)
Definition: ri.h:2458
#define statement_comments(x)
Definition: ri.h:2456

References EXTERNALIZED_CODE_PRAGMA_ANALYZED, gen_nth(), instruction_sequence, instruction_tag, is_instruction_sequence, malloc(), pips_debug, sequence_statements, STATEMENT, statement_comments, statement_instruction, statement_with_empty_comment_p(), and strdup().

Referenced by compute_distribution_context().

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

◆ get_externalized_function_name()

string get_externalized_function_name ( statement  stat)

Return the identified function name of the externalized portion of code by searching comment matching tag EXTERNALIZED_CODE_PRAGMA_CALL.

Parameters
stattat

Definition at line 459 of file distribution_context.c.

460 {
463 }
#define EXTERNALIZED_CODE_PRAGMA_CALL

References EXTERNALIZED_CODE_PRAGMA_CALL, and get_function_name_by_searching_tag().

Referenced by compute_distribution_controlization_context().

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

◆ get_function_id_name()

string get_function_id_name ( entity  function)
Parameters
functionunction

Definition at line 367 of file phrase_distributor_control_code.c.

368 {
369  char *buffer;
370  asprintf(&buffer,
372  entity_local_name(function));
373  return strdup(buffer);
374 }
#define FUNCTION_ID_NAME

Referenced by controlize_distribution(), and make_global_common_and_initialize().

+ Here is the caller graph for this function:

◆ get_function_name_by_searching_tag()

string get_function_name_by_searching_tag ( statement  stat,
const char *  tag 
)

Return the identified function name of the externalized portion of code by searching comment matching tag.

phrase_distributor.c

Parameters
stattat
tagag

Definition at line 82 of file phrase_distributor.c.

84 {
85  string comments;
86  string searched_string;
87  string comment_portion = strdup(tag);
88  char* function_name = NULL;
89  char* next_line;
91 
92  ifdebug(5) {
93  pips_debug(5, "BEGIN get_function_name_by_searching_tag [%s] on \n", tag);
94  print_statement(stat);
95  }
96 
99  }
100 
101  if (!statement_with_empty_comment_p(stat)) {
102  searched_string = strdup(comment_portion);
103  searched_string[strcspn(comment_portion, "%s")] = '\0';
104  comments = strdup(statement_comments(stat));
105  next_line = strtok (comments, "\n");
106  if (next_line != NULL) {
107  do {
108  string first_occurence = strstr(next_line,searched_string);
109  if (first_occurence != NULL) {
110  function_name = malloc(256);
111  sscanf (first_occurence, comment_portion, function_name);
112  pips_debug(5, "Found function: [%s]\n", function_name);
113  }
114  next_line = strtok(NULL, "\n");
115  }
116  while (next_line != NULL);
117  }
118  }
119 
120  pips_debug(5, "END get_function_name_by_searching_tag [%s] on \n", tag);
121  return function_name;
122 }
int tag
TAG.
Definition: newgen_types.h:92

◆ get_in_param_id_name()

string get_in_param_id_name ( entity  variable,
entity  function 
)
Parameters
functionunction

Definition at line 341 of file phrase_distributor_control_code.c.

342 {
343  char *buffer;
344  asprintf(&buffer,
347  entity_local_name(function));
348  return (buffer);
349 }
#define IN_PARAM_ID_NAME

Referenced by controlize_distribution(), and make_global_common_and_initialize().

+ Here is the caller graph for this function:

◆ get_out_param_id_name()

string get_out_param_id_name ( entity  variable,
entity  function 
)
Parameters
functionunction

Definition at line 354 of file phrase_distributor_control_code.c.

355 {
356  char *buffer;
357  asprintf(&buffer,
360  entity_local_name(function));
361  return (buffer);
362 }
#define OUT_PARAM_ID_NAME

Referenced by controlize_distribution(), and make_global_common_and_initialize().

+ Here is the caller graph for this function:

◆ get_receive_param_module_name()

string get_receive_param_module_name ( entity  function,
region  reg 
)

Return RECEIVE_PARAM module name for function and region.

Definition at line 543 of file phrase_distributor_communication.c.

544 {
545  if (region_scalar_p(reg)) {
547  }
548  else {
549  char *buffer;
550  asprintf(&buffer,
552  entity_local_name(function),
554  return (buffer);
555  }
556 }
#define region_entity(reg)
#define region_scalar_p(reg)
string get_receive_parameter_module_name(variable)
#define RECEIVE_ARRAY_PARAM_MODULE_NAME

References asprintf, buffer, entity_local_name(), entity_type, get_receive_parameter_module_name(), RECEIVE_ARRAY_PARAM_MODULE_NAME, region_entity, region_scalar_p, and type_variable.

Referenced by make_array_communication_module().

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

◆ get_receive_parameter_module_name()

string get_receive_parameter_module_name ( variable  var)
Parameters
varar

Definition at line 424 of file phrase_distributor_control_code.c.

425 {
426  char *buffer;
428  return strdup(buffer);
429 }
string variable_to_string(variable var)
Return a unique (regarding variable_equal_p(var1,var2)) string representation of a variable var.
#define RECEIVE_PARAMETER_MODULE_NAME

◆ get_send_param_module_name()

string get_send_param_module_name ( entity  function,
region  reg 
)

Return SEND_PARAM module name for function and region.

Definition at line 525 of file phrase_distributor_communication.c.

526 {
527  if (region_scalar_p(reg)) {
529  }
530  else {
531  char *buffer;
532  asprintf(&buffer,
534  entity_local_name(function),
536  return (buffer);
537  }
538 }
string get_send_parameter_module_name(variable)
#define SEND_ARRAY_PARAM_MODULE_NAME

References asprintf, buffer, entity_local_name(), entity_type, get_send_parameter_module_name(), region_entity, region_scalar_p, SEND_ARRAY_PARAM_MODULE_NAME, and type_variable.

Referenced by make_array_communication_module().

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

◆ get_send_parameter_module_name()

string get_send_parameter_module_name ( variable  var)
Parameters
varar

Definition at line 414 of file phrase_distributor_control_code.c.

415 {
416  char *buffer;
418  return strdup(buffer);
419 }
#define SEND_PARAMETER_MODULE_NAME

◆ make_receive_array_params_modules()

list make_receive_array_params_modules ( entity  function,
list  l_regions,
entity  global_common,
entity  externalized_fonction_common,
int  number_of_deployment_units 
)

Make all RECEIVE_PARAM communication modules for non-scalar regions for a given function.

Parameters
functionunction
l_regions_regions
global_commonlobal_common
externalized_fonction_commonxternalized_fonction_common
number_of_deployment_unitsumber_of_deployment_units

Definition at line 961 of file phrase_distributor_communication.c.

966 {
967  return make_array_communication_modules (function,
968  l_regions,
969  global_common,
970  externalized_fonction_common,
971  number_of_deployment_units,
972  true);
973 }
static list make_array_communication_modules(entity function, list l_regions, entity global_common, entity externalized_fonction_common, int number_of_deployment_units, bool is_receiving)
Internally used for making all communication modules for non-scalar IN or OUT regions for a given fun...

◆ make_receive_scalar_params_modules()

list make_receive_scalar_params_modules ( hash_table  ht_out_communications,
int  number_of_deployment_units,
entity  global_common,
list  l_commons 
)

Build and return list of modules used for OUTPUT communications (RECEIVE_PARAMETERS...)

Parameters
ht_out_communicationst_out_communications
number_of_deployment_unitsumber_of_deployment_units
global_commonlobal_common
l_commons_commons

Definition at line 609 of file phrase_distributor_communication.c.

613 {
614  return make_scalar_communication_modules (ht_out_communications,
615  number_of_deployment_units,
616  global_common,
617  l_commons,
618  true);
619 }
static list l_commons
static list make_scalar_communication_modules(hash_table ht_communications, int number_of_deployment_units, entity global_common, list l_commons, bool is_receiving)
Internally used for building communication modules.

◆ make_send_array_params_modules()

list make_send_array_params_modules ( entity  function,
list  l_regions,
entity  global_common,
entity  externalized_fonction_common,
int  number_of_deployment_units 
)

Make all SEND_PARAM communication modules for non-scalar regions for a given function.

Parameters
functionunction
l_regions_regions
global_commonlobal_common
externalized_fonction_commonxternalized_fonction_common
number_of_deployment_unitsumber_of_deployment_units

Definition at line 943 of file phrase_distributor_communication.c.

948 {
949  return make_array_communication_modules (function,
950  l_regions,
951  global_common,
952  externalized_fonction_common,
953  number_of_deployment_units,
954  false);
955 }

◆ make_send_scalar_params_modules()

list make_send_scalar_params_modules ( hash_table  ht_in_communications,
int  number_of_deployment_units,
entity  global_common,
list  l_commons 
)

Build and return list of modules used for INPUT communications (SEND_PARAMETERS...)

Parameters
ht_in_communicationst_in_communications
number_of_deployment_unitsumber_of_deployment_units
global_commonlobal_common
l_commons_commons

Definition at line 593 of file phrase_distributor_communication.c.

597 {
598  return make_scalar_communication_modules (ht_in_communications,
599  number_of_deployment_units,
600  global_common,
601  l_commons,
602  false);
603 }

◆ make_start_ru_module()

entity make_start_ru_module ( hash_table  ht_params,
statement module_statement,
int  number_of_deployment_units,
entity  global_common,
list  l_commons 
)

Build and store new module START_RU.

Create statement module_statement

Build and store new module START_RU.

phrase_distributor_communication.c

Build and store new module START_RU. Create statement module_statement

Declare CONTROL_DATA common to be visible here

Declare commons for all externalized functions to be visible here

Compute the parameters of call function

Processing PARAMS regions

Make the CALL statement

Parameters
ht_paramst_params
module_statementodule_statement
number_of_deployment_unitsumber_of_deployment_units
global_commonlobal_common
l_commons_commons

Definition at line 71 of file phrase_distributor_communication.c.

76 {
77  entity start_ru_module;
78  entity func_id;
79  entity unit_id = NULL;
80  const char* function_name;
81  list stat_seq = NIL;
82  sequence new_sequence;
83  instruction sequence_instruction;
84  entity set_entity = get_current_module_entity();
85 
87  pips_debug(2, "Creating module %s\n", entity_global_name(start_ru_module));
89  set_current_module_entity(start_ru_module);
92  start_ru_module,
93  1);
94  if (number_of_deployment_units > 1) {
97  start_ru_module,
98  2);
99  }
100 
101  /* Declare CONTROL_DATA common to be visible here */
102  declare_common_variables_in_module (global_common, start_ru_module);
103 
104  /* Declare commons for all externalized functions to be visible here */
105  MAP (ENTITY, com, {
106  declare_common_variables_in_module (com, start_ru_module);
107  },l_commons);
108 
109  ifdebug(7) {
110  pips_debug(7, "Declarations for START_RU module: \n");
111  fprint_environment(stderr, start_ru_module);
112  }
113 
114  HASH_MAP (externalized_function, l_params, {
115 
116  entity function = (entity)externalized_function;
118  test new_test;
119  instruction test_instruction;
120  statement test_statement;
121  statement call_statement;
122  list call_params ;
123 
124  function_name = entity_local_name(function);
125 #if 0
126  statement called_module_stat = (statement) db_get_memory_resource(DBR_CODE,
127  function_name,
128  true);
129 
130 #endif
131  entity called_module = local_name_to_top_level_entity(function_name);
132 
133  /* Compute the parameters of call function */
134  call_params = NIL;
135 
136  /* Processing PARAMS regions */
137  MAP (REGION, reg, {
140  entity local_variable
141  = entity_in_module (get_common_param_name(reference_variable(ref), function), start_ru_module);
142  list indices = NIL;
143  if (number_of_deployment_units > 1) {
144  list primary_indices = variable_dimensions(type_variable(entity_type(local_variable)));
145  expression to_be_replaced = NULL;
146  MAP (DIMENSION, dim, {
148  dimension_lower(dim),
149  indices);
150  to_be_replaced=dimension_lower(dim);
151  }, primary_indices);
152  gen_list_patch (indices,to_be_replaced,entity_to_expression(unit_id));
154  }
155  new_param = make_entity_expression (local_variable, indices);
156  call_params = CONS(EXPRESSION, new_param, call_params);
157  }, (list)l_params);
158 
159  call_params = gen_nreverse(call_params);
160 
161  /* Make the CALL statement */
162  call_statement = make_statement(entity_empty_label(),
167  make_call(called_module,call_params)),
168  NIL,NULL,
170 
173  entity_to_expression (func_id),
174  entity_to_expression (entity_in_module (get_function_id_name(function), start_ru_module)));
175 
176  new_test = make_test (test_condition, call_statement,
178 
179  test_instruction = make_instruction (is_instruction_test,new_test);
180 
181  test_statement = make_statement (entity_empty_label(),
185  test_instruction,NIL,NULL,
187 
188  stat_seq = CONS (STATEMENT, test_statement, stat_seq);
189 
190  }, ht_params);
191 
192  stat_seq = gen_nreverse(CONS(STATEMENT, make_return_statement(start_ru_module), stat_seq));
193 
194  new_sequence
195  = make_sequence (stat_seq);
196 
197  sequence_instruction
199  new_sequence);
200 
205  sequence_instruction,NIL,NULL,
207 
209 
211  set_current_module_entity(set_entity);
212  return start_ru_module;
213 }
call make_call(entity a1, list a2)
Definition: ri.c:269
language make_language_unknown(void)
Definition: ri.c:1259
test make_test(expression a1, statement a2, statement a3)
Definition: ri.c:2607
statement make_statement(entity a1, intptr_t a2, intptr_t a3, string a4, instruction a5, list a6, string a7, extensions a8, synchronization a9)
Definition: ri.c:2222
instruction make_instruction(enum instruction_utype tag, void *val)
Definition: ri.c:1166
synchronization make_synchronization_none(void)
Definition: ri.c:2424
sequence make_sequence(list a)
Definition: ri.c:2125
void new_param(string s)
===========================================================================
Definition: adg_read_paf.c:262
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
static statement module_statement
Definition: alias_check.c:125
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
#define REGION
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
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_list_patch(list l, const void *x, const void *y)
Replace all the reference to x in list l by a reference to y:
Definition: list.c:985
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
statement make_return_statement(entity)
Definition: statement.c:779
statement make_continue_statement(entity)
Definition: statement.c:953
static list indices
Definition: icm.c:204
#define STATEMENT_ORDERING_UNDEFINED
mapping.h inclusion
Definition: newgen-local.h:35
#define HASH_MAP(k, v, code, ht)
Definition: newgen_hash.h:60
entity entity_in_module(const char *, entity)
Return entity named name in specified module.
string get_common_param_name(entity variable, entity)
entity create_integer_parameter_for_new_module(const char *, const char *, entity, int)
Create new integer variable parameter for a newly created module.
void store_new_module(const char *, entity, statement)
Store (PIPDBM) newly created module module with module_statement as USER_FILE by saving pretty printi...
void declare_common_variables_in_module(entity, entity)
Creates all the things that need to be created in order to declare common in module (all the variable...
string get_function_id_name(entity)
#define START_RU_PARAM1_NAME
#define START_RU_PARAM2_NAME
#define START_RU_MODULE_NAME
Stuff for START_RU(...) subroutine generation.
#define EQUAL_OPERATOR_NAME
#define STATEMENT_NUMBER_UNDEFINED
default values
#define empty_comments
Empty comments (i.e.
void fprint_environment(FILE *fd, entity m)
Definition: declarations.c:287
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
entity make_empty_subroutine(const char *name, language l)
Definition: entity.c:268
entity entity_empty_label(void)
Definition: entity.c:1105
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
expression make_entity_expression(entity e, cons *inds)
Definition: expression.c:176
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
Definition: expression.c:354
extensions empty_extensions(void)
extension.c
Definition: extension.c:43
#define reference_variable(x)
Definition: ri.h:2326
#define dimension_lower(x)
Definition: ri.h:980
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
@ is_instruction_test
Definition: ri.h:1470
@ is_instruction_call
Definition: ri.h:1474
#define test_condition(x)
Definition: ri.h:2833
#define variable_dimensions(x)
Definition: ri.h:3122

◆ make_wait_ru_module()

entity make_wait_ru_module ( statement module_statement,
int  number_of_deployment_units,
entity  global_common,
list  l_commons 
)

Build and store new module WAIT_RU.

Create statement module_statement

◆ register_scalar_communications()

void register_scalar_communications ( hash_table ht_communications,
entity  function,
list  l_regions 
)

Build an HASHTABLE where keys are VARIABLE and values are HASHTABLE where keys are modules or externalized function (ENTITY) and values are list of regions.

Iterate on all regions of the given list

Get the variable type

Look if this variable is already registered

Parameters
ht_communicationst_communications
functionunction
l_regions_regions

Definition at line 538 of file distribution_context.c.

541 {
542 
543  /* Iterate on all regions of the given list */
544  MAP (REGION, reg, {
545 
546  if (region_scalar_p(reg)) {
547 
548  bool already_present = false;
549  variable already_registered_variable = NULL;
550 
551  /* Get the variable type */
553 
554  pips_debug(2, "Variable %s %zd \n", basic_to_string(variable_basic(var)), gen_length(variable_dimensions(var)));
555  print_region(reg);
556 
557  /* Look if this variable is already registered */
558  HASH_MAP (var2, l2, {
559  if (variable_equal_p(var,var2)) {
560  already_present = true;
561  already_registered_variable = var2;
562  }
563  },*ht_communications);
564 
565  if (already_present) {
566  hash_table ht_for_variable
567  = (hash_table)hash_get(*ht_communications,
568  already_registered_variable);
569  if (hash_defined_p(ht_for_variable,function)) {
570  list old_regs = hash_get(ht_for_variable,
571  function);
572  hash_update(ht_for_variable, function,
573  CONS(REGION,reg,old_regs));
574  pips_debug(2, "Add region for existing function\n");
575  }
576  else {
577  hash_put(ht_for_variable, function,
578  CONS(REGION,reg,NIL));
579  pips_debug(2, "New region for existing function\n");
580  }
581  }
582  else {
583  hash_table new_ht_for_variable
585  hash_put(new_ht_for_variable, function,
586  CONS(REGION,reg,NIL));
587  hash_put(*ht_communications,var,new_ht_for_variable);
588  pips_debug(2, "New function\n");
589  }
590  }
591  }, l_regions);
592 }
size_t gen_length(const list l)
Definition: list.c:150
void hash_update(hash_table htp, const void *key, const void *val)
update key->val in htp, that MUST be pre-existent.
Definition: hash.c:491
struct __hash_table * hash_table
Define hash_table structure which is hidden.
Definition: newgen_hash.h:43
#define print_region(x)
Definition: print.c:343
string basic_to_string(basic)
Definition: type.c:87
bool variable_equal_p(variable, variable)
Definition: type.c:819

References basic_to_string(), CONS, entity_type, gen_length(), hash_defined_p(), hash_get(), HASH_MAP, hash_pointer, hash_put(), hash_table_make(), hash_update(), MAP, NIL, pips_debug, print_region, REGION, region_entity, region_scalar_p, type_variable, variable_basic, variable_dimensions, and variable_equal_p().

Referenced by controlize_distribution().

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

◆ store_new_module()

void store_new_module ( const char *  module_name,
entity  module,
statement  module_statement 
)

Store (PIPDBM) newly created module module with module_statement as USER_FILE by saving pretty printing.

Parameters
module_nameodule_name
moduleodule
module_statementodule_statement

Definition at line 143 of file phrase_distributor_control_code.c.

146 {
147  string source_file;
148  text code;
149 
150  pips_debug(2, "[BEGIN] store_new_module [%s]\n", module_name);
151  ifdebug(2) {
152  entity set_entity = get_current_module_entity();
155  pips_debug(2, "Statement for module: ");
157  pips_debug(7, "Declarations for module: \n");
158  MAP (ENTITY, e, {
159  pips_debug(2, "Declared entity %s\n", entity_global_name(e));
161  fprint_environment(stderr, module);
163  set_current_module_entity(set_entity);
164  }
165 
169  DBR_SOURCE_FILE,
170  ".f",
171  code);
173 
174  source_file = db_build_file_resource_name(DBR_SOURCE_FILE, module_name, ".f");
175 
176  pips_debug(5, "Source file : [%s]\n", source_file);
177 
178  DB_PUT_NEW_FILE_RESOURCE (DBR_USER_FILE, module_name, source_file);
179  DB_PUT_NEW_FILE_RESOURCE (DBR_INITIAL_FILE, module_name, source_file);
180 
183  DBR_INITIAL_FILE,
184  ".f_initial",
185  code);
187 
188  pips_debug(2, "[END] store_new_module [%s]\n", module_name);
189 }
#define DB_PUT_NEW_FILE_RESOURCE(res_name, own_name, res_val)
Put a new file resource into the current workspace database.
string db_build_file_resource_name(const char *rname, const char *oname, const char *suffix)
returns an allocated file name for a file resource.
Definition: lowlevel.c:169
text empty_text(entity __attribute__((unused)) e, int __attribute__((unused)) m, statement __attribute__((unused)) s)
Definition: misc.c:219
void close_prettyprint()
because some prettyprint functions may be used for debug, so the last hook set by somebody may have s...
Definition: misc.c:242
void init_prettyprint(text(*hook)(entity, int, statement))
checks that the prettyprint hook was actually reset...
Definition: misc.c:231
text text_module(entity, statement)
bool make_text_resource(const char *, const char *, const char *, text)
print.c
Definition: print.c:55
struct _newgen_struct_code_ * code
Definition: ri.h:79

◆ variable_to_string()

string variable_to_string ( variable  var)

Return a unique (regarding variable_equal_p(var1,var2)) string representation of a variable var.

Parameters
varar

Definition at line 511 of file distribution_context.c.

512 {
513  string returned_value;
514  intptr_t low, up;
515 
516  returned_value = basic_to_string(variable_basic(var));
517  (strchr(returned_value,'*'))[0] = '\0';
519  if ((expression_integer_value(dimension_lower(dim), &low))
520  && (expression_integer_value(dimension_upper(dim), &up))) {
521  char buffer[256];
522  sprintf (buffer, VARIABLE_NAME_FORMAT, low, up);
523  returned_value = strdup(concatenate(returned_value,strdup(buffer),NULL));
524  }
525  else {
526  returned_value = strdup(concatenate(returned_value,":UNDEFINED",NULL));
527  }
528  }
529 
530  return returned_value;
531 }
#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 VARIABLE_NAME_FORMAT
Stuff for SEND_PARAM....
bool expression_integer_value(expression e, intptr_t *pval)
Definition: eval.c:792
#define dimension_upper(x)
Definition: ri.h:982
#define intptr_t
Definition: stdint.in.h:294

References basic_to_string(), buffer, concatenate(), DIMENSION, dimension_lower, dimension_upper, expression_integer_value(), FOREACH, intptr_t, strdup(), variable_basic, variable_dimensions, and VARIABLE_NAME_FORMAT.

Referenced by get_receive_parameter_module_name(), and get_send_parameter_module_name().

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