PIPS
phrase_distribution.h
Go to the documentation of this file.
1 /*
2 
3  $Id: phrase_distribution.h 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 #ifndef PHRASE_DISTRIBUTOR_DEFS
25 #define PHRASE_DISTRIBUTOR_DEFS
26 
27 #define EXTERNALIZED_CODE_PRAGMA_BEGIN "BEGIN_FPGA_%s"
28 #define EXTERNALIZED_CODE_PRAGMA_END "END_FPGA_%s"
29 #define EXTERNALIZED_CODE_PRAGMA_ANALYZED "ANALYZED_FPGA_%s (%d statements)"
30 #define EXTERNALIZED_CODE_PRAGMA_CALL "CALL_FPGA_%s"
31 
32 /* Stuff for distribution controlization */
33 #define EXTERNALIZED_FUNCTION_PARAM_NAME "%s_PARAM_%d"
34 #define EXTERNALIZED_FUNCTION_PRIVATE_PARAM_NAME "%s_PRIV"
35 #define CONTROL_DATA_COMMON_NAME "CONTROL_DATA"
36 #define FUNCTION_COMMON_NAME "%s_COMMON"
37 #define COMMON_PARAM_NAME "%s_%s"
38 #define DYN_VAR_PARAM_NAME "%s_DV_PARAM"
39 #define REF_VAR_PARAM_NAME "%s_REF_PARAM"
40 #define UNITS_NB_NAME "UNITS_NB"
41 #define UNIT_ID_NAME "UNIT%d"
42 #define FUNCTIONS_NB_NAME "FUNCTIONS_NB"
43 #define FUNCTION_ID_NAME "%s_FUNCTION"
44 #define IN_PARAM_ID_NAME "%s_%s_IN_PARAM"
45 #define OUT_PARAM_ID_NAME "%s_%s_OUT_PARAM"
46 #define CONTROLIZED_STATEMENT_COMMENT "! CONTROLIZED CALL TO %s\n"
47 
48 /* Stuff for START_RU(...) subroutine generation */
49 #define START_RU_MODULE_NAME "START_RU"
50 #define START_RU_PARAM1_NAME "FUNC_ID"
51 #define START_RU_PARAM2_NAME "UNIT_ID"
52 
53 /* Stuff for WAIT_RU(...) subroutine generation */
54 #define WAIT_RU_MODULE_NAME "WAIT_RU"
55 #define WAIT_RU_PARAM1_NAME "FUNC_ID"
56 #define WAIT_RU_PARAM2_NAME "UNIT_ID"
57 
58 /* Stuff for SEND_PARAM....(...) and RECEIVE_PARAM....(...)
59  * subroutines generation */
60 #define VARIABLE_NAME_FORMAT "_%"PRIdPTR"_%"PRIdPTR
61 #define SEND_PARAMETER_MODULE_NAME "SEND_%s_PARAMETER"
62 #define RECEIVE_PARAMETER_MODULE_NAME "RECEIVE_%s_PARAMETER"
63 #define SEND_ARRAY_PARAM_MODULE_NAME "SEND_%s_%s_PARAMETER"
64 #define RECEIVE_ARRAY_PARAM_MODULE_NAME "RECEIVE_%s_%s_PARAMETER"
65 #define COM_MODULE_PARAM1_NAME "FUNC_ID"
66 #define COM_MODULE_PARAM2_NAME "UNIT_ID"
67 #define COM_MODULE_PARAM3_NAME "PARAM_ID"
68 #define COM_MODULE_PARAM4_NAME "PARAM"
69 
70 #define RU_SEND_FLOAT_PARAM_MODULE_NAME "RU_SEND_FLOAT_PARAM"
71 #define RU_RECEIVE_FLOAT_PARAM_MODULE_NAME "RU_RECEIVE_FLOAT_PARAM"
72 
73 /**
74  * Return the identified function name of the externalized portion of code
75  * by searching comment matching tag
76  */
77 string get_function_name_by_searching_tag (statement stat,const char* tag);
78 
79 /**
80  * Return the identified function name of the externalized portion of code
81  * by searching comment matching tag EXTERNALIZED_CODE_PRAGMA_BEGIN
82  */
84 
85 /**
86  * Return the identified function name of the externalized portion of code
87  * by searching comment matching tag EXTERNALIZED_CODE_PRAGMA_CALL
88  */
90 
91 /**
92  * Return the identified function name of the externalized portion of code
93  * by searching comment matching tags EXTERNALIZED_CODE_PRAGMA_ANALYZED
94  * Sets the number of statements of this externalizable statement
95  */
97  int* stats_nb);
98 
99 bool compute_distribution_context (list l_stats,
100  statement module_stat,
101  entity module,
102  hash_table* ht_stats,
103  hash_table* ht_params,
104  hash_table* ht_private,
105  hash_table* ht_out_regions,
106  hash_table* ht_in_regions);
107 
109  statement module_stat,
110  entity module,
111  hash_table* ht_calls,
112  hash_table* ht_params,
113  hash_table* ht_private,
114  hash_table* ht_out_regions,
115  hash_table* ht_in_regions);
116 void register_scalar_communications (hash_table* ht_communications,
117  entity function,
118  list l_regions);
119 
120 string variable_to_string (variable var);
121 
122 /**
123  * Build and store new module START_RU.
124  * Create statement module_statement
125  */
128  int number_of_deployment_units,
129  entity global_common,
130  list l_commons);
131 
132 /**
133  * Build and store new module WAIT_RU.
134  * Create statement module_statement
135  */
137  int number_of_deployment_units,
138  entity global_common,
139  list l_commons);
140 
141 
142 
143 /**
144  * Return SEND_PARAM module name for function and region
145  */
146 string get_send_param_module_name(entity function, region reg);
147 
148 
149 /**
150  * Return RECEIVE_PARAM module name for function and region
151  */
152 string get_receive_param_module_name(entity function, region reg);
153 
154 /**
155  * Build and return list of modules used for INPUT communications
156  * (SEND_PARAMETERS...)
157  */
158 list make_send_scalar_params_modules (hash_table ht_in_communications,
159  int number_of_deployment_units,
160  entity global_common,
161  list l_commons);
162 
163 /**
164  * Build and return list of modules used for OUTPUT communications
165  * (RECEIVE_PARAMETERS...)
166  */
167 list make_receive_scalar_params_modules (hash_table ht_out_communications,
168  int number_of_deployment_units,
169  entity global_common,
170  list l_commons);
171 
172 
173 /**
174  * Make all SEND_PARAM communication modules for non-scalar regions for a
175  * given function
176  */
178  list l_regions,
179  entity global_common,
180  entity externalized_fonction_common,
181  int number_of_deployment_units);
182 
183 /**
184  * Make all RECEIVE_PARAM communication modules for non-scalar regions for a
185  * given function
186  */
188  list l_regions,
189  entity global_common,
190  entity externalized_fonction_common,
191  int number_of_deployment_units);
192 
193 /**
194  * Creates a private variable in specified module
195  */
197  const char* new_name,
198  const char* new_module_name,
199  entity module);
200 
201 /**
202  * Create new variable parameter for a newly created module
203  */
205  const char* parameter_name,
206  const char* module_name,
207  entity module,
208  int param_nb);
209 
210 /**
211  * Create new integer variable parameter for a newly created module
212  */
213 entity create_integer_parameter_for_new_module (const char* parameter_name,
214  const char* module_name,
215  entity module,
216  int param_nb);
217 
218 /**
219  * Store (PIPDBM) newly created module module with module_statement
220  * as USER_FILE by saving pretty printing
221  */
222 void store_new_module (const char* module_name,
223  entity module,
225 
226 /*
227  * Return COMMON_PARAM_NAME
228  */
229 string get_common_param_name (entity variable, entity function);
230 
231 /*
232  * Return FUNCTION_ID_NAME
233  */
234 string get_function_id_name (entity function);
235 
236 /*
237  * Return SEND_PARAMETER_MODULE_NAME
238  */
240 
241 /*
242  * Return RECEIVE_PARAMETER_MODULE_NAME
243  */
245 
246 /*
247  * Return IN_PARAM_ID_NAME
248  */
249 string get_in_param_id_name (entity variable, entity function);
250 
251 /*
252  * Return OUT_PARAM_ID_NAME
253  */
254 string get_out_param_id_name (entity variable, entity function);
255 
256 /**
257  * Build and return parameters (PHI1,PHI2) and dynamic variables for
258  * region reg.
259  * NOT IMPLEMENTED: suppress unused dynamic variables !!!!
260  */
262  list* l_reg_params,
263  list* l_reg_variables);
264 
265 /**
266  * Creates all the things that need to be created in order to declare common
267  * in module (all the variable are created)
268  */
270 
271 #endif
static statement module_statement
Definition: alias_check.c:125
static list l_commons
#define region
simulation of the type region
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
static entity a_variable
int tag
TAG.
Definition: newgen_types.h:92
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.
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.
string get_externalizable_function_name(statement stat)
Return the identified function name of the externalized portion of code by searching comment matching...
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......
string variable_to_string(variable var)
Return a unique (regarding variable_equal_p(var1,var2)) string representation of a variable var.
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.
string get_common_param_name(entity variable, entity function)
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.
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.
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 externa...
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...
string get_receive_param_module_name(entity function, region reg)
Return RECEIVE_PARAM module name for function and region.
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...
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 printi...
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...
string get_out_param_id_name(entity variable, entity function)
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.
string get_send_parameter_module_name(variable var)
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....
string get_send_param_module_name(entity function, region reg)
Return SEND_PARAM module name for function and region.
string get_externalized_function_name(statement stat)
Return the identified function name of the externalized portion of code by searching comment matching...
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.
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.
string get_function_id_name(entity function)
string get_in_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.
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.
string get_receive_parameter_module_name(variable var)
static char * module
Definition: pips.c:74
The structure used to build lists in NewGen.
Definition: newgen_list.h:41