PIPS
distribution_context.c File Reference
#include <stdio.h>
#include <ctype.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "resources.h"
#include "misc.h"
#include "ri-util.h"
#include "prettyprint.h"
#include "effects-util.h"
#include "text-util.h"
#include "dg.h"
#include "graph.h"
#include "ray_dte.h"
#include "sommet.h"
#include "sg.h"
#include "polyedre.h"
#include "phrase_tools.h"
#include "effects-generic.h"
#include "effects-simple.h"
#include "effects-convex.h"
#include "phrase_distribution.h"
+ Include dependency graph for distribution_context.c:

Go to the source code of this file.

Typedefs

typedef dg_arc_label arc_label
 General computation for PHRASE distribution DISTRIBUTION CONTEXT. More...
 
typedef dg_vertex_label vertex_label
 

Functions

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. 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_in_regions, hash_table *ht_out_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_in_regions, hash_table *ht_out_regions)
 This function is called during PHRASE distribution controlization. More...
 
list compute_regions_union (list l_in, list l_out)
 Compute union of exact regions. 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...
 
string variable_to_string (variable var)
 Return a unique (regarding variable_equal_p(var1,var2)) string representation of a variable var. 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...
 

Typedef Documentation

◆ arc_label

General computation for PHRASE distribution DISTRIBUTION CONTEXT.

Definition at line 52 of file distribution_context.c.

◆ vertex_label

Definition at line 53 of file distribution_context.c.

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_regions_union()

list compute_regions_union ( list  l_in,
list  l_out 
)

Compute union of exact regions.

Parameters
l_in_in
l_out_out

Definition at line 291 of file distribution_context.c.

292 {
293  list l_union = gen_copy_seq (l_in);
294 
295  pips_debug(4, "BEGIN of computing regions UNION\n");
296  MAP (REGION, reg, {
297  entity e = region_entity (reg);
298  bool is_already_present = false;
299  region reg_already_present = NULL;
300  MAP (REGION, union_reg, {
301  entity e2 = region_entity (union_reg);
302  if (same_entity_p(e, e2)) {
303  is_already_present = true;
304  reg_already_present = union_reg;
305  }
306  }, l_union);
307  if (is_already_present) {
308  if (region_scalar_p(reg)) {
309  pips_debug(6, "Found SCALAR region already present [%s]. Ignored.\n",
310  entity_local_name(e));
311  }
312  else {
313  list new_regions;
314  pips_debug(6, "Found ARRAY region already present [%s].\n",
315  entity_local_name(e));
316  pips_debug(6, "Making UNION of:\n");
317  print_region(reg);
318  pips_debug(6, "and:\n");
319  print_region(reg_already_present);
320  new_regions = region_must_union(reg,reg_already_present);
321  pips_debug(6, "Getting:\n");
322  print_regions(new_regions);
323  if (gen_length(new_regions) > 1) {
324  pips_internal_error("Regions union must refer to only ONE region !");
325  }
326  else {
327  gen_remove (&l_union, reg_already_present);
328  l_union = CONS (REGION, REGION(gen_nth(0,new_regions)), l_union);
329  }
330  }
331  }
332  else {
333  pips_debug(6, "Adding region for [%s]\n", entity_local_name(e));
334  l_union = CONS(REGION, reg, l_union);
335  }
336  }, l_out);
337 
338  pips_debug(4, "END of computing regions UNION\n");
339  return l_union;
340 }
#define region_entity(reg)
#define REGION
#define region
simulation of the type region
#define region_scalar_p(reg)
list region_must_union(region r1, region r2)
computes the must union of two combinable array regions
void print_regions(list)
void gen_remove(list *cpp, const void *o)
remove all occurences of item o from list *cpp, which is thus modified.
Definition: list.c:685
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
size_t gen_length(const list l)
Definition: list.c:150
gen_chunk gen_nth(int n, const list l)
to be used as ENTITY(gen_nth(3, l))...
Definition: list.c:710
#define print_region(x)
Definition: print.c:343
bool same_entity_p(entity e1, entity e2)
predicates on entities
Definition: entity.c:1321

References CONS, entity_local_name(), gen_copy_seq(), gen_length(), gen_nth(), gen_remove(), MAP, pips_debug, pips_internal_error, print_region, print_regions(), region, REGION, region_entity, region_must_union(), region_scalar_p, and same_entity_p().

Referenced by internal_compute_distribution_context().

+ Here is the call graph for this function:
+ 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)
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
char * strdup()

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:

◆ internal_compute_distribution_context()

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.

Storing results in hash_tables

Parameters
externalized_codexternalized_code
ht_paramst_params
ht_privatet_private
ht_in_regionst_in_regions
ht_out_regionst_out_regions
key_valueey_value

Definition at line 346 of file distribution_context.c.

352 {
353  bool returned_value = true;
354 
355  list l_read, l_write, l_in, l_out;
356  list l_params = NIL;
357  list l_priv = NIL;
358 
359  pips_debug(6, "Compute regions\n");
360 
361  l_write = regions_dup
363  l_read = regions_dup
364  (regions_read_regions(load_statement_local_regions(externalized_code)));
365  l_in = regions_dup(load_statement_in_regions(externalized_code));
366  l_out = regions_dup(load_statement_out_regions(externalized_code));
367 
368  ifdebug(6) {
369  pips_debug(6, "READ regions: \n");
370  print_regions(l_read);
371  pips_debug(6, "WRITE regions: \n");
372  print_regions(l_write);
373  }
374 
375  l_params = compute_regions_union (l_in, l_out);
376 
377  l_in = regions_dup(load_statement_in_regions(externalized_code));
378  l_out = regions_dup(load_statement_out_regions(externalized_code));
379  l_priv = RegionsEntitiesInfDifference(l_write, l_in, w_r_combinable_p);
380  l_priv = RegionsEntitiesInfDifference(l_priv, l_out, w_w_combinable_p);
381 
382  l_in = regions_dup(load_statement_in_regions(externalized_code));
383  l_out = regions_dup(load_statement_out_regions(externalized_code));
384 
389 
390  ifdebug(2)
391  {
392  pips_debug(2, "IN regions: \n");
393  print_regions(l_in);
394  pips_debug(2, "OUT regions: \n");
395  print_regions(l_out);
396  pips_debug(2, "Params regions: \n");
397  print_regions(l_params);
398  pips_debug(2, "Private regions: \n");
399  print_regions(l_priv);
400  }
401 
402  /* Storing results in hash_tables */
403 
404  pips_debug(2, "Storing in hash_tables with key %s: \n", (string)key_value);
405 
406  pips_debug(5, "Storing in ht_param: \n");
407  if (!hash_defined_p(*ht_params,key_value)) {
408  hash_put(*ht_params,key_value,l_params);
409  }
410  else {
411  pips_user_warning("Multiply defined value in PARAMS hash_table!\n");
412  returned_value = false;
413  }
414 
415  pips_debug(5, "Storing in ht_private: \n");
416  if (!hash_defined_p(*ht_private,key_value)) {
417  hash_put(*ht_private,key_value,l_priv);
418  }
419  else {
420  pips_user_warning("Multiply defined value in PRIVATE hash_table!\n");
421  returned_value = false;
422  }
423 
424  pips_debug(5, "Storing in ht_in_regions: \n");
425  if (!hash_defined_p(*ht_in_regions,key_value)) {
426  hash_put(*ht_in_regions,key_value,l_in);
427  }
428  else {
429  pips_user_warning("Multiply defined value in IN_REGIONS hash_table!\n");
430  returned_value = false;
431  }
432 
433  pips_debug(5, "Storing in ht_out_regions: \n");
434  if (!hash_defined_p(*ht_out_regions,key_value)) {
435  hash_put(*ht_out_regions,key_value,l_out);
436  }
437  else {
438  pips_user_warning("Multiply defined value in OUT_REGIONS hash_table!\n");
439  returned_value = false;
440  }
441 
442  return returned_value;
443 }
int compare_effect_reference(effect *e1, effect *e2)
int compare_effect_reference(e1, e2):
Definition: compare.c:210
list compute_regions_union(list l_in, list l_out)
Compute union of exact regions.
list RegionsEntitiesInfDifference(list l1, list l2, bool(*difference_combinable_p)(effect, effect))
list RegionsEntitiesInfDifference(list l1, l2) input : two lists of regions output : a list of region...
list regions_write_regions(list)
list regions_read_regions(list)
list regions_dup(list)
bool w_r_combinable_p(effect, effect)
bool w_w_combinable_p(effect, effect)
list load_statement_out_regions(statement)
list load_statement_in_regions(statement)
list load_statement_local_regions(statement)
void gen_sort_list(list l, gen_cmp_func_t compare)
Sorts a list of gen_chunks in place, to avoid allocations...
Definition: list.c:796
int(* gen_cmp_func_t)(const void *, const void *)
Definition: newgen_types.h:114

References compare_effect_reference(), compute_regions_union(), gen_sort_list(), hash_defined_p(), hash_put(), ifdebug, load_statement_in_regions(), load_statement_local_regions(), load_statement_out_regions(), NIL, pips_debug, pips_user_warning, print_regions(), regions_dup(), regions_read_regions(), regions_write_regions(), RegionsEntitiesInfDifference(), w_r_combinable_p(), and w_w_combinable_p().

Referenced by compute_distribution_context(), and compute_distribution_controlization_context().

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

◆ 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 }
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
#define HASH_MAP(k, v, code, ht)
Definition: newgen_hash.h:60
struct __hash_table * hash_table
Define hash_table structure which is hidden.
Definition: newgen_hash.h:43
string basic_to_string(basic)
Definition: type.c:87
bool variable_equal_p(variable, variable)
Definition: type.c:819
#define type_variable(x)
Definition: ri.h:2949
#define variable_dimensions(x)
Definition: ri.h:3122
#define entity_type(x)
Definition: ri.h:2792
#define variable_basic(x)
Definition: ri.h:3120

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:

◆ 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
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
#define VARIABLE_NAME_FORMAT
Stuff for SEND_PARAM....
bool expression_integer_value(expression e, intptr_t *pval)
Definition: eval.c:792
#define dimension_lower(x)
Definition: ri.h:980
#define dimension_upper(x)
Definition: ri.h:982
#define intptr_t
Definition: stdint.in.h:294
static string buffer
Definition: string.c:113

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: