PIPS
phrase_distributor_control_code.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 "effects-util.h"
#include "pipsdbm.h"
#include "text-util.h"
#include "properties.h"
#include "prettyprint.h"
#include "dg.h"
#include "graph.h"
#include "ray_dte.h"
#include "sommet.h"
#include "sg.h"
#include "polyedre.h"
#include "semantics.h"
#include "control.h"
#include "callgraph.h"
#include "phrase_tools.h"
#include "effects-generic.h"
#include "effects-simple.h"
#include "effects-convex.h"
#include "transformer.h"
#include "phrase_distribution.h"
+ Include dependency graph for phrase_distributor_control_code.c:

Go to the source code of this file.

Typedefs

typedef dg_arc_label arc_label
 
typedef dg_vertex_label vertex_label
 

Functions

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...
 
entity create_new_common_variable (string name, entity module, entity common, variable var)
 Creates and declares a new variable for a newly created common. More...
 
entity create_new_scalar_common_variable (string name, entity module, entity common, basic b)
 Creates and declares a new scalar variable for a newly created common. More...
 
entity create_new_integer_scalar_common_variable (string name, entity module, entity common)
 Creates and declares a new integer scalar variable for a newly created common. 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...
 
string get_controlized_statement_comment (entity function)
 
string get_in_param_id_name (entity variable, entity function)
 
string get_out_param_id_name (entity variable, entity function)
 
string get_function_id_name (entity function)
 
static string get_function_common_name (entity function)
 
string get_common_param_name (entity variable, entity function)
 
static string get_unit_id_name (int unit)
 
string get_send_parameter_module_name (variable var)
 
string get_receive_parameter_module_name (variable var)
 
entity entity_in_module (const char *name, entity module)
 Return entity named name in specified module. More...
 
static statement make_global_common_and_initialize (entity main_module, statement module_stat, entity *global_common, int number_of_deployment_units, hash_table ht_calls, hash_table ht_in_regions, hash_table ht_out_regions)
 Build and return CONTROL_DATA global common used to store global information on phrase distribution controlization and initialization of values contained in CONTROL_DATA common. More...
 
static entity create_externalized_function_common (entity main_module, entity externalized_function, list params_regions, int number_of_deployment_units)
 Creates and returns a common used to store variable for communications between control code and externalized code. More...
 
static statement controlize_distribution (statement module_stat, entity module)
 Main function for PHRASE_DISTRIBUTION_CONTROL_CODE. More...
 
bool phrase_distributor_control_code (const char *module_name)
 

Variables

static entity dynamic_area = entity_undefined
 

Typedef Documentation

◆ arc_label

Definition at line 48 of file phrase_distributor_control_code.c.

◆ vertex_label

Function Documentation

◆ controlize_distribution()

static statement controlize_distribution ( statement  module_stat,
entity  module 
)
static

Main function for PHRASE_DISTRIBUTION_CONTROL_CODE.

We identify all the statements containing an externalized-call tag

Compute the context of distribution, before to controlize

OK, be begin deployement...

Get the loop label form the user

Declare global common for controlization and make initializations

Let's begin to iterate on all externalized functions, in order to build commons and controlization modules

Get the function name

Creates a common used to store variable for communications between control code and externalized code

And register it to the list of commons

Build START_RU module

Build WAIT_RU module

Let's begin to iterate on all externalized functions and statements, in order to add controlization code

Get the function name

Retrieve variables func_id_variable and unit_id_variable

Iterate on all the statements where externalized function is called

Some debug

SEND PARAMS calls

Add dynamic variables

list of entities: phi1, phi2,...

list of dynamic variables....

START_RU_CALL

WAIT_RU_CALL

RECEIVE PARAMS calls

Add dynamic variables

list of entities: phi1, phi2,...

list of dynamic variables....

Now, just inverse list of statements

And replace CALL instruction by SEQUENCE instruction

Definition at line 615 of file phrase_distributor_control_code.c.

617 {
618  statement returned_statement = module_stat;
619  list l_calls;
620  const char* function_name;
621 
622  entity start_ru_module;
623  entity wait_ru_module;
624  statement start_ru_module_statement;
625  statement wait_ru_module_statement;
626 
627  entity global_common;
628  entity externalized_fonction_common;
629  list l_commons = NIL;
630 
631  hash_table ht_calls;
632  hash_table ht_params;
633  hash_table ht_private;
634  hash_table ht_in_regions;
635  hash_table ht_out_regions;
636 
637  hash_table ht_in_communications = hash_table_make(hash_pointer, 0);
638  hash_table ht_out_communications = hash_table_make(hash_pointer, 0);
639 
640  int number_of_deployment_units;
641  int unit_id;
642 
643  /* We identify all the statements containing an externalized-call tag */
645  module_stat);
646 
647  /* Compute the context of distribution, before to controlize */
649  module_stat,
650  module,
651  &ht_calls,
652  &ht_params,
653  &ht_private,
654  &ht_in_regions,
655  &ht_out_regions);
656 
657 
658  if (hash_table_entry_count (ht_calls)) {
659 
660  /* OK, be begin deployement... */
661 
662  string resp;
663 
664  /* Get the loop label form the user */
665  resp = user_request("Deployment on how many externalized units ?\n"
666  "(give its number > 0): ");
667 
668  if (sscanf(resp,"%d",&number_of_deployment_units) > 0) {
669 
670  pips_debug(2, "Deployment on %d units\n", number_of_deployment_units);
671 
672  /* Declare global common for controlization and make initializations */
673  returned_statement
675  module_stat,
676  &global_common,
677  number_of_deployment_units,
678  ht_calls,
679  ht_in_regions,
680  ht_out_regions);
681 
682  /* Let's begin to iterate on all externalized functions,
683  * in order to build commons and controlization modules */
684 
685  pips_debug(2, "Found %d externalized functions\n", hash_table_entry_count(ht_calls));
686 
687  HASH_MAP (externalized_function, calls_for_f, {
688 
689  entity f = (entity)externalized_function;
690 
691  /* Get the function name */
692  function_name = entity_local_name(f);
693 
694  pips_debug(2, "Found %zd calls for externalized function %s\n",
695  gen_length((list)calls_for_f),
696  function_name);
697 
698  /* Creates a common used to store variable for communications
699  * between control code and externalized code */
700  externalized_fonction_common =
702  f,
703  (list)hash_get(ht_params,f),
704  number_of_deployment_units);
705 
706  /* And register it to the list of commons */
707  l_commons = CONS(ENTITY, externalized_fonction_common, l_commons);
708 
709  pips_debug(2, "Register input communications\n");
710  register_scalar_communications (&ht_in_communications,
711  f,
712  (list)hash_get(ht_in_regions,f));
713 
714  pips_debug(2, "Register output communications\n");
715  register_scalar_communications (&ht_out_communications,
716  f,
717  (list)hash_get(ht_out_regions,f));
718 
719  pips_debug(2, "Register and create ARRAY input communications\n");
721  (list)hash_get(ht_in_regions,f),
722  global_common,
723  externalized_fonction_common,
724  number_of_deployment_units);
725 
726  pips_debug(2, "Register and create ARRAY output communications\n");
728  (list)hash_get(ht_out_regions,f),
729  global_common,
730  externalized_fonction_common,
731  number_of_deployment_units);
732 
733  }, ht_calls);
734 
735  /* Build START_RU module */
736  start_ru_module = make_start_ru_module (ht_params,
737  &start_ru_module_statement,
738  number_of_deployment_units,
739  global_common,
740  l_commons);
741 
742  /* Build WAIT_RU module */
743  wait_ru_module = make_wait_ru_module (&wait_ru_module_statement,
744  number_of_deployment_units,
745  global_common,
746  l_commons);
747 
748 #if 0
749  /* Build SEND_PARAMS modules */
750  list send_params_modules = make_send_scalar_params_modules (ht_in_communications,
751  number_of_deployment_units,
752  global_common,
753  l_commons);
754 
755  /* Build RECEIVE_PARAMS modules */
756  list receive_params_modules = make_receive_scalar_params_modules (ht_out_communications,
757  number_of_deployment_units,
758  global_common,
759  l_commons);
760 #endif
761 
762  /* Let's begin to iterate on all externalized functions and statements,
763  * in order to add controlization code */
764 
765  HASH_MAP (externalized_function, calls_for_f, {
766 
767  entity f = (entity)externalized_function;
768  list l_stats = NIL;
769  entity func_id_variable;
770  entity unit_id_variable = NULL;
771 
772  /* Get the function name */
773  function_name = entity_local_name(f);
774 
775  /* Retrieve variables func_id_variable and unit_id_variable */
776  func_id_variable = entity_in_module(get_function_id_name(f), module);
777 
778  /* Iterate on all the statements where externalized function is called */
779 
780  MAP (STATEMENT, s, {
781 
782  l_stats = NIL;
783  unit_id = 0;
784 
785  if (number_of_deployment_units > 1) {
786  char *question;
787  unit_id = 0;
788  do {
789  asprintf (&question, "Deployment of function %s on which units ?\n(give its number 1-%d):", function_name, number_of_deployment_units);
790  resp = user_request(question);
791  sscanf(resp,"%d",&unit_id);
792  free(question);
793  }
794  while ((unit_id <1) || (unit_id > number_of_deployment_units));
795 
796  /* Some debug */
797  pips_debug(2, "Externalized function [%s] being executed on unit %d:\n", function_name, unit_id);
798  ifdebug(2) {
799  pips_debug(2, "Current statement is:\n");
800  print_statement(s);
801  }
802 
803  unit_id_variable = entity_in_module (get_unit_id_name(unit_id), module);
804 
805  }
806 
807 #if 0
808  /* Get the called module */
809  statement called_module_stat = (statement) db_get_memory_resource(DBR_CODE,
810  function_name,
811  true);
812  entity called_module = module_name_to_entity(function_name);
813 #endif
814 
815 
816  /* SEND PARAMS calls */
817  MAP (REGION, reg, {
818 
820  entity send_param_module;
821  entity param_id_variable;
822  statement new_stat;
823 
824  list call_params = NIL;
825 
826  send_param_module = module_name_to_entity(get_send_param_module_name(f, reg));
827  pips_debug(7, "Call to [%s]\n", entity_local_name(send_param_module));
828  pips_debug(7, "Concerned entity is [%s]\n", entity_local_name(param));
829 
830  call_params = CONS (EXPRESSION,
831  entity_to_expression(func_id_variable),
832  call_params);
833  if (number_of_deployment_units > 1) {
834  call_params = CONS (EXPRESSION,
835  entity_to_expression(unit_id_variable),
836  call_params);
837  }
838  param_id_variable = entity_in_module (get_in_param_id_name(param,f),
839  module);
840  call_params = CONS (EXPRESSION,
841  entity_to_expression(param_id_variable),
842  call_params);
843  call_params = CONS (EXPRESSION,
845  call_params);
846 
847 
848  if (!region_scalar_p(reg))
849  {
850  /* Add dynamic variables */
851 
852  list l_reg_params; /* list of entities: phi1, phi2,... */
853  list l_reg_variables; /* list of dynamic variables....*/
854  compute_region_variables(reg,&l_reg_params,&l_reg_variables);
855 
856  MAP (ENTITY, dyn_var, {
857  call_params = CONS (EXPRESSION,
858  entity_to_expression(dyn_var),
859  call_params);
860  }, l_reg_variables);
861  }
862 
863 
864  new_stat = make_statement(entity_empty_label(),
869  make_call(send_param_module,
870  gen_nreverse(call_params))),
871  NIL,NULL,
873 
874  l_stats = CONS (STATEMENT,
875  new_stat,
876  l_stats);
877 
878  }, (list)hash_get(ht_in_regions,f));
879 
880  /* START_RU_CALL */
881  {
882  list start_ru_call_params = CONS(EXPRESSION,
883  entity_to_expression(func_id_variable),
884  (number_of_deployment_units>1)?CONS(EXPRESSION,
885  entity_to_expression(unit_id_variable),
886  NIL):NIL);
887  l_stats = CONS (STATEMENT,
893  make_call(start_ru_module,
894  start_ru_call_params)),
895  NIL,NULL,
897  l_stats);
898  }
899 
900  /* WAIT_RU_CALL */
901  {
902  list wait_ru_call_params = CONS(EXPRESSION,
903  entity_to_expression(func_id_variable),
904  (number_of_deployment_units>1)?CONS(EXPRESSION,
905  entity_to_expression(unit_id_variable),
906  NIL):NIL);
907  l_stats = CONS (STATEMENT,
913  make_call(wait_ru_module,
914  wait_ru_call_params)),
915  NIL,NULL,
917  l_stats);
918  }
919 
920  /* RECEIVE PARAMS calls */
921 
922  MAP (REGION, reg, {
923 
925  entity receive_param_module;
926  entity param_id_variable;
927  statement new_stat;
928 
929  list call_params = NIL;
930 
931  receive_param_module = module_name_to_entity(get_receive_param_module_name(f, reg));
932  pips_debug(7, "Call to [%s]\n", entity_local_name(receive_param_module));
933  pips_debug(7, "Concerned entity is [%s]\n", entity_local_name(param));
934 
935  call_params = CONS (EXPRESSION,
936  entity_to_expression(func_id_variable),
937  call_params);
938  if (number_of_deployment_units > 1) {
939  call_params = CONS (EXPRESSION,
940  entity_to_expression(unit_id_variable),
941  call_params);
942  }
943  param_id_variable = entity_in_module (get_out_param_id_name(param,f),
944  module);
945  call_params = CONS (EXPRESSION,
946  entity_to_expression(param_id_variable),
947  call_params);
948  call_params = CONS (EXPRESSION,
950  call_params);
951 
952 
953  if (!region_scalar_p(reg))
954  {
955  /* Add dynamic variables */
956 
957  list l_reg_params; /* list of entities: phi1, phi2,... */
958  list l_reg_variables; /* list of dynamic variables....*/
959  compute_region_variables(reg,&l_reg_params,&l_reg_variables);
960 
961  MAP (ENTITY, dyn_var, {
962  call_params = CONS (EXPRESSION,
963  entity_to_expression(dyn_var),
964  call_params);
965  }, l_reg_variables);
966  }
967 
968  new_stat = make_statement(entity_empty_label(),
973  make_call(receive_param_module,
974  gen_nreverse(call_params))),
975  NIL,NULL,
977 
978  l_stats = CONS (STATEMENT,
979  new_stat,
980  l_stats);
981 
982  }, (list)hash_get(ht_out_regions,f));
983 
984  /* Now, just inverse list of statements */
985 
986  l_stats = gen_nreverse(l_stats);
987 
988  /* And replace CALL instruction by SEQUENCE instruction */
989 
992  make_sequence(l_stats));
993 
994  ifdebug(7) {
995  pips_debug(7, "After controlization, statement is\n");
996  print_statement(s);
997  }
998 
999  }, (list)calls_for_f);
1000 
1001  pips_debug(2, "Controlization is done on [%s]\n", entity_local_name(f));
1002 
1003  }, ht_calls);
1004 
1005 
1006  hash_table_free(ht_calls);
1007  hash_table_free(ht_params);
1008  hash_table_free(ht_private);
1009  hash_table_free(ht_in_regions);
1010  hash_table_free(ht_out_regions);
1011 
1012  HASH_MAP(k,v,{
1013  hash_table_free(v);
1014  },ht_in_communications);
1015  hash_table_free(ht_in_communications);
1016 
1017  HASH_MAP(k,v,{
1018  hash_table_free(v);
1019  },ht_out_communications);
1020  hash_table_free(ht_out_communications);
1021 
1022  }
1023 
1024  else {
1025  pips_debug(2, "Invalid number. Operation aborted\n");
1026  }
1027 
1028  }
1029  return returned_statement;
1030 }
call make_call(entity a1, list a2)
Definition: ri.c:269
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
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
static list l_commons
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
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...
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.
#define region_entity(reg)
#define REGION
#define region_scalar_p(reg)
void free(void *)
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
size_t gen_length(const list l)
Definition: list.c:150
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#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
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
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
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
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327
int hash_table_entry_count(hash_table htp)
now we define observers in order to hide the hash_table type...
Definition: hash.c:818
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define asprintf
Definition: misc-local.h:225
string user_request(const char *,...)
#define STATEMENT_ORDERING_UNDEFINED
mapping.h inclusion
Definition: newgen-local.h:35
#define HASH_MAP(k, v, code, ht)
Definition: newgen_hash.h:60
@ hash_pointer
Definition: newgen_hash.h:32
struct cons * list
Definition: newgen_types.h:106
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
entity make_start_ru_module(hash_table, statement *, int, entity, list)
phrase_distributor_communication.c
list get_statements_with_comments_containing(const char *, statement)
Definition: phrase_tools.c:481
list make_send_array_params_modules(entity, list, entity, entity, int)
Make all SEND_PARAM communication modules for non-scalar regions for a given function.
list make_receive_array_params_modules(entity, list, entity, entity, int)
Make all RECEIVE_PARAM communication modules for non-scalar regions for a given function.
list make_send_scalar_params_modules(hash_table, int, entity, list)
Build and return list of modules used for INPUT communications (SEND_PARAMETERS......
list make_receive_scalar_params_modules(hash_table, int, entity, list)
Build and return list of modules used for OUTPUT communications (RECEIVE_PARAMETERS....
string get_send_param_module_name(entity, effect)
void compute_region_variables(effect, list *, list *)
entity make_wait_ru_module(statement *, int, entity, list)
string get_receive_param_module_name(entity, effect)
#define EXTERNALIZED_CODE_PRAGMA_CALL
entity entity_in_module(const char *name, entity module)
Return entity named name in specified module.
string get_controlized_statement_comment(entity function)
static string get_unit_id_name(int unit)
string get_out_param_id_name(entity variable, entity function)
static entity create_externalized_function_common(entity main_module, entity externalized_function, list params_regions, int number_of_deployment_units)
Creates and returns a common used to store variable for communications between control code and exter...
string get_function_id_name(entity function)
string get_in_param_id_name(entity variable, entity function)
static statement make_global_common_and_initialize(entity main_module, statement module_stat, entity *global_common, int number_of_deployment_units, hash_table ht_calls, hash_table ht_in_regions, hash_table ht_out_regions)
Build and return CONTROL_DATA global common used to store global information on phrase distribution c...
static char * module
Definition: pips.c:74
void print_statement(statement)
Print a statement on stderr.
Definition: statement.c:98
#define STATEMENT_NUMBER_UNDEFINED
default values
#define empty_comments
Empty comments (i.e.
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
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479
entity entity_empty_label(void)
Definition: entity.c:1105
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
extensions empty_extensions(void)
extension.c
Definition: extension.c:43
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
@ is_instruction_call
Definition: ri.h:1474
@ is_instruction_sequence
Definition: ri.h:1469
#define statement_instruction(x)
Definition: ri.h:2458
#define statement_comments(x)
Definition: ri.h:2456
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
#define ifdebug(n)
Definition: sg.c:47
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
Definition: replace.c:135

References asprintf, compute_distribution_controlization_context(), compute_region_variables(), CONS, create_externalized_function_common(), db_get_memory_resource(), empty_comments, empty_extensions(), ENTITY, entity_empty_label(), entity_in_module(), entity_local_name(), entity_to_expression(), EXPRESSION, EXTERNALIZED_CODE_PRAGMA_CALL, f(), free(), gen_length(), gen_nreverse(), get_controlized_statement_comment(), get_function_id_name(), get_in_param_id_name(), get_out_param_id_name(), get_receive_param_module_name(), get_send_param_module_name(), get_statements_with_comments_containing(), get_unit_id_name(), hash_get(), HASH_MAP, hash_pointer, hash_table_entry_count(), hash_table_free(), hash_table_make(), ifdebug, is_instruction_call, is_instruction_sequence, l_commons, make_call(), make_global_common_and_initialize(), make_instruction(), make_receive_array_params_modules(), make_receive_scalar_params_modules(), make_send_array_params_modules(), make_send_scalar_params_modules(), make_sequence(), make_start_ru_module(), make_statement(), make_synchronization_none(), make_wait_ru_module(), MAP, module, module_name_to_entity(), NIL, pips_debug, print_statement(), REGION, region_entity, region_scalar_p, register_scalar_communications(), STATEMENT, statement_comments, statement_instruction, STATEMENT_NUMBER_UNDEFINED, STATEMENT_ORDERING_UNDEFINED, and user_request().

Referenced by phrase_distributor_control_code().

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

◆ create_externalized_function_common()

static entity create_externalized_function_common ( entity  main_module,
entity  externalized_function,
list  params_regions,
int  number_of_deployment_units 
)
static

Creates and returns a common used to store variable for communications between control code and externalized code.

Creates params variables

If many deployment units, add dimension to handle those different units

Definition at line 578 of file phrase_distributor_control_code.c.

582 {
583  entity returned_common;
584 
585  returned_common
586  = make_new_common(get_function_common_name (externalized_function),
587  main_module);
588 
589  /* Creates params variables */
590  MAP (REGION, reg, {
591  entity in_variable = region_entity(reg);
592  variable var = copy_variable(type_variable(entity_type(in_variable)));
593  /* If many deployment units, add dimension to handle those different units */
594  if (number_of_deployment_units > 1) {
595  list l_dimensions = variable_dimensions(var);
597  = gen_nconc(l_dimensions,
598  CONS(DIMENSION,
599  make_dimension (int_to_expression(1),int_to_expression (number_of_deployment_units), NIL),
600  NIL));
601  }
602  create_new_common_variable(get_common_param_name(in_variable,externalized_function),
603  main_module,
604  returned_common,
605  var);
606  }, params_regions);
607 
608  return returned_common;
609 }
variable copy_variable(variable p)
VARIABLE.
Definition: ri.c:2859
dimension make_dimension(expression a1, expression a2, list a3)
Definition: ri.c:565
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
string get_common_param_name(entity variable, entity function)
entity create_new_common_variable(string name, entity module, entity common, variable var)
Creates and declares a new variable for a newly created common.
static string get_function_common_name(entity function)
entity make_new_common(string name, entity mod)
This function creates a common for a given name in a given module.
Definition: entity.c:1806
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
Definition: expression.c:1188
#define type_variable(x)
Definition: ri.h:2949
#define variable_dimensions(x)
Definition: ri.h:3122
#define entity_type(x)
Definition: ri.h:2792

References CONS, copy_variable(), create_new_common_variable(), DIMENSION, entity_type, gen_nconc(), get_common_param_name(), get_function_common_name(), int_to_expression(), make_dimension(), make_new_common(), MAP, NIL, REGION, region_entity, type_variable, and variable_dimensions.

Referenced by controlize_distribution().

+ 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

References create_parameter_for_new_module(), is_basic_int, make_variable(), MakeBasic(), module, module_name(), and NIL.

Referenced by make_array_communication_module(), make_scalar_communication_module(), make_start_ru_module(), and make_wait_ru_module().

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

◆ create_new_common_variable()

entity create_new_common_variable ( string  name,
entity  module,
entity  common,
variable  var 
)

Creates and declares a new variable for a newly created common.

gen_nreverse(CONS(ENTITY,e,old_layout));

Parameters
nameame
moduleodule
commonommon
varar

Definition at line 194 of file phrase_distributor_control_code.c.

195 {
196  int old_size, variable_size;
197 
198  string var_global_name = strdup(concatenate(module_local_name(module),MODULE_SEP_STRING,
199  name,NULL));
200  type var_type = make_type(is_type_variable, var);
201  storage var_storage = storage_undefined;
202  value var_value = make_value_unknown();
203  entity e = make_entity(var_global_name,var_type,var_storage,var_value);
204  list old_layout = area_layout(type_area(entity_type(common)));
205  old_size = area_size(type_area(entity_type(common)));
206  variable_size = storage_space_of_variable(e);
207  pips_debug(2, "New variable %s created with size %d (old_size was:%d)\n", name, variable_size, old_size);
209  (make_ram(module,common,old_size,NIL)));
210  area_layout(type_area(entity_type(common))) = gen_nconc(old_layout,CONS(ENTITY,e,NIL));
211  /* gen_nreverse(CONS(ENTITY,e,old_layout)); */
212  area_size(type_area(entity_type(common))) = old_size+variable_size;
214  return e;
215 }
value make_value_unknown(void)
Definition: ri.c:2847
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
type make_type(enum type_utype tag, void *val)
Definition: ri.c:2706
#define MODULE_SEP_STRING
Definition: naming-local.h:30
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
#define make_entity(n, t, s, i)
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
int storage_space_of_variable(entity)
Definition: size.c:656
void AddEntityToDeclarations(entity, entity)
END_EOLE.
Definition: variable.c:108
#define area_size(x)
Definition: ri.h:544
#define entity_storage(x)
Definition: ri.h:2794
@ is_storage_ram
Definition: ri.h:2492
#define area_layout(x)
Definition: ri.h:546
#define type_area(x)
Definition: ri.h:2946
@ is_type_variable
Definition: ri.h:2900
#define storage_undefined
Definition: ri.h:2476
char * strdup()

References AddEntityToDeclarations(), area_layout, area_size, concatenate(), CONS, ENTITY, entity_storage, entity_type, gen_nconc(), is_storage_ram, is_type_variable, make_entity, make_ram(), make_storage(), make_type(), make_value_unknown(), module, module_local_name(), MODULE_SEP_STRING, NIL, pips_debug, storage_space_of_variable(), storage_undefined, strdup(), and type_area.

Referenced by create_externalized_function_common(), and create_new_scalar_common_variable().

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

◆ create_new_integer_scalar_common_variable()

entity create_new_integer_scalar_common_variable ( string  name,
entity  module,
entity  common 
)

Creates and declares a new integer scalar variable for a newly created common.

Parameters
nameame
moduleodule
commonommon

Definition at line 228 of file phrase_distributor_control_code.c.

229 {
231 }
entity create_new_scalar_common_variable(string name, entity module, entity common, basic b)
Creates and declares a new scalar variable for a newly created common.

References create_new_scalar_common_variable(), is_basic_int, MakeBasic(), and module.

Referenced by make_global_common_and_initialize().

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

◆ create_new_scalar_common_variable()

entity create_new_scalar_common_variable ( string  name,
entity  module,
entity  common,
basic  b 
)

Creates and declares a new scalar variable for a newly created common.

Parameters
nameame
moduleodule
commonommon

Definition at line 220 of file phrase_distributor_control_code.c.

221 {
222  return create_new_common_variable( name, module, common, make_variable(b, NIL,NIL));
223 }

References create_new_common_variable(), make_variable(), module, and NIL.

Referenced by create_new_integer_scalar_common_variable().

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

◆ 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
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
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 pips_internal_error
Definition: misc-local.h:149
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
#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_domain
newgen_syntax_domain_defined
Definition: ri.h:410
#define entity_initial(x)
Definition: ri.h:2796
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

References code_declarations, concatenate(), CONS, copy_variable(), ENTITY, entity_domain, entity_initial, entity_type, entity_undefined, functional_parameters, gen_find_tabulated(), make_dummy_identifier(), make_entity, make_formal(), make_mode_reference(), make_parameter(), make_storage_formal(), make_type_variable(), make_value_unknown(), module, module_declarations(), module_name(), MODULE_SEP_STRING, new_variable, PARAMETER, pips_internal_error, strdup(), type_functional, and value_code.

Referenced by create_integer_parameter_for_new_module(), make_array_communication_module(), and make_scalar_communication_module().

+ Here is the call graph for this function:
+ 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 }
type copy_type(type p)
TYPE.
Definition: ri.c:2655
value copy_value(value p)
VALUE.
Definition: ri.c:2784
static Value offset
Definition: translation.c:283
string entity_global_name(entity e)
Used instead of the macro to pass as formal argument.
Definition: entity.c:464
#define storage_ram(x)
Definition: ri.h:2521
#define ram_offset(x)
Definition: ri.h:2251

References AddEntityToDeclarations(), area_layout, concatenate(), CONS, copy_type(), copy_value(), ENTITY, entity_global_name(), entity_initial, entity_local_name(), entity_storage, entity_type, gen_nconc(), gen_nreverse(), ifdebug, is_storage_ram, make_entity, make_ram(), make_storage(), MAP, module, module_local_name(), MODULE_SEP_STRING, new_variable, NIL, offset, pips_debug, ram_offset, storage_ram, strdup(), and type_area.

Referenced by make_array_communication_module(), make_scalar_communication_module(), make_start_ru_module(), and make_wait_ru_module().

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

◆ entity_in_module()

entity entity_in_module ( const char *  name,
entity  module 
)

Return entity named name in specified module.

Is it the main module ?

Parameters
nameame
moduleodule

Definition at line 434 of file phrase_distributor_control_code.c.

435 {
436  /* Is it the main module ? */
437  if (strchr(entity_local_name(module),'%') != NULL) {
438  return FindEntity(entity_local_name(module)+1,name);
439  }
440  else {
441  return FindEntity(entity_local_name(module),name);
442  }
443 
444 }
entity FindEntity(const char *package, const char *name)
Retrieve an entity from its package/module name and its local name.
Definition: entity.c:1503

References entity_local_name(), FindEntity(), and module.

Referenced by controlize_distribution(), make_array_communication_statement(), make_communication_statement(), make_scalar_communication_module(), and make_start_ru_module().

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

◆ 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 COMMON_PARAM_NAME
static string buffer
Definition: string.c:113

References asprintf, buffer, COMMON_PARAM_NAME, entity_local_name(), and strdup().

Referenced by create_externalized_function_common(), make_array_communication_statement(), make_communication_statement(), and make_start_ru_module().

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

◆ get_controlized_statement_comment()

string get_controlized_statement_comment ( entity  function)
Parameters
functionunction

Definition at line 329 of file phrase_distributor_control_code.c.

330 {
331  char *buffer;
332  asprintf(&buffer,
334  entity_local_name(function));
335  return (buffer);
336 }
#define CONTROLIZED_STATEMENT_COMMENT

References asprintf, buffer, CONTROLIZED_STATEMENT_COMMENT, and entity_local_name().

Referenced by controlize_distribution().

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

◆ get_function_common_name()

static string get_function_common_name ( entity  function)
static

Definition at line 379 of file phrase_distributor_control_code.c.

380 {
381  char *buffer;
382  asprintf(&buffer,
384  entity_local_name(function));
385  return strdup(buffer);
386 }
#define FUNCTION_COMMON_NAME

References asprintf, buffer, entity_local_name(), FUNCTION_COMMON_NAME, and strdup().

Referenced by create_externalized_function_common().

+ 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

References asprintf, buffer, entity_local_name(), FUNCTION_ID_NAME, and strdup().

Referenced by controlize_distribution(), make_global_common_and_initialize(), make_scalar_communication_module(), and make_start_ru_module().

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

◆ 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

References asprintf, buffer, entity_local_name(), and IN_PARAM_ID_NAME.

Referenced by controlize_distribution(), make_global_common_and_initialize(), and make_scalar_communication_module().

+ Here is the call graph for this function:
+ 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

References asprintf, buffer, entity_local_name(), and OUT_PARAM_ID_NAME.

Referenced by controlize_distribution(), make_global_common_and_initialize(), and make_scalar_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

References asprintf, buffer, RECEIVE_PARAMETER_MODULE_NAME, strdup(), and variable_to_string().

Referenced by get_receive_param_module_name(), and make_scalar_communication_modules().

+ 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

References asprintf, buffer, SEND_PARAMETER_MODULE_NAME, strdup(), and variable_to_string().

Referenced by get_send_param_module_name(), and make_scalar_communication_modules().

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

◆ get_unit_id_name()

static string get_unit_id_name ( int  unit)
static

Definition at line 404 of file phrase_distributor_control_code.c.

405 {
406  char *buffer;
408  return strdup(buffer);
409 }
int unit
UNIT.
Definition: newgen_types.h:97
#define UNIT_ID_NAME

References asprintf, buffer, strdup(), and UNIT_ID_NAME.

Referenced by controlize_distribution(), and make_global_common_and_initialize().

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

◆ make_global_common_and_initialize()

static statement make_global_common_and_initialize ( entity  main_module,
statement  module_stat,
entity global_common,
int  number_of_deployment_units,
hash_table  ht_calls,
hash_table  ht_in_regions,
hash_table  ht_out_regions 
)
static

Build and return CONTROL_DATA global common used to store global information on phrase distribution controlization and initialization of values contained in CONTROL_DATA common.

_in = regions_dup(load_statement_in_regions(s)); l_out = regions_dup(load_statement_out_regions(s));

Definition at line 452 of file phrase_distributor_control_code.c.

459 {
460  list stats_list = CONS(STATEMENT,module_stat,NIL);
461  statement new_stat;
462  sequence new_sequence;
463  int i;
464  list l_in, l_out;
465  const char* function_name;
466  int id_function, id_param;
467  entity units_nb_variable;
468  entity functions_nb_variable;
469 
470  *global_common = make_new_common(CONTROL_DATA_COMMON_NAME,
471  main_module);
473  main_module,
474  *global_common);
475  new_stat = make_assignement_statement
476  (units_nb_variable,
477  int_to_expression (number_of_deployment_units), NULL);
478  stats_list = CONS (STATEMENT, new_stat,stats_list);
479 
480  if (number_of_deployment_units > 1) {
481  for (i=1; i<= number_of_deployment_units; i++) {
482  entity unit_id_variable =
484  main_module,
485  *global_common);
486  new_stat = make_assignement_statement
487  (unit_id_variable,
488  int_to_expression (i), NULL);
489  stats_list = CONS (STATEMENT, new_stat,stats_list);
490  }
491  }
492 
493 
494  functions_nb_variable =
496  main_module,
497  *global_common);
498 
499  new_stat = make_assignement_statement
500  (functions_nb_variable,
501  int_to_expression (hash_table_entry_count(ht_calls)), NULL);
502  stats_list = CONS (STATEMENT, new_stat,stats_list);
503 
504  id_function = 1;
505 
506  HASH_MAP (externalized_function, l_calls_for_function, {
507 
508  entity function = (entity)externalized_function;
509  entity function_id_variable;
510  function_name = entity_local_name(function);
511  pips_debug(2, "Function [%s]\n",function_name);
512 
513  function_id_variable =
515  (get_function_id_name(function),
516  main_module,
517  *global_common);
518  new_stat = make_assignement_statement
519  (function_id_variable,
520  int_to_expression (id_function++), NULL);
521  stats_list = CONS (STATEMENT, new_stat,stats_list);
522 
523  id_param = 1;
524 
525  l_in = (list)hash_get(ht_in_regions,function);
526  l_out = (list)hash_get(ht_out_regions,function);
527 
528  /*l_in = regions_dup(load_statement_in_regions(s));
529  l_out = regions_dup(load_statement_out_regions(s));*/
530 
531  MAP (REGION, reg, {
534  entity param_id_variable =
536  (get_in_param_id_name(variable,function),
537  main_module,
538  *global_common);
539  new_stat = make_assignement_statement
540  (param_id_variable,
541  int_to_expression (id_param++), NULL);
542  stats_list = CONS (STATEMENT, new_stat,stats_list);
543  }, l_in);
544 
545  MAP (REGION, reg, {
548  entity param_id_variable =
550  (get_out_param_id_name(variable,function),
551  main_module,
552  *global_common);
553  new_stat = make_assignement_statement
554  (param_id_variable,
555  int_to_expression (id_param++), NULL);
556  stats_list = CONS (STATEMENT, new_stat,stats_list);
557  }, l_out);
558 
559  }, ht_calls);
560 
561  new_sequence = make_sequence (stats_list);
562 
568  new_sequence),
569  NIL,NULL,
571 
572 }
static reference ref
Current stmt (an integer)
Definition: adg_read_paf.c:163
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
statement make_assignement_statement(entity, expression, statement)
Build and return new statement which is a assignement of variable a_variable with expression an_expre...
Definition: phrase_tools.c:392
#define FUNCTIONS_NB_NAME
#define CONTROL_DATA_COMMON_NAME
#define UNITS_NB_NAME
entity create_new_integer_scalar_common_variable(string name, entity module, entity common)
Creates and declares a new integer scalar variable for a newly created common.
#define reference_variable(x)
Definition: ri.h:2326

References CONS, CONTROL_DATA_COMMON_NAME, create_new_integer_scalar_common_variable(), effect_any_reference, empty_comments, empty_extensions(), entity_empty_label(), entity_local_name(), FUNCTIONS_NB_NAME, get_function_id_name(), get_in_param_id_name(), get_out_param_id_name(), get_unit_id_name(), hash_get(), HASH_MAP, hash_table_entry_count(), int_to_expression(), is_instruction_sequence, make_assignement_statement(), make_instruction(), make_new_common(), make_sequence(), make_statement(), make_synchronization_none(), MAP, NIL, pips_debug, ref, reference_variable, REGION, STATEMENT, STATEMENT_NUMBER_UNDEFINED, STATEMENT_ORDERING_UNDEFINED, and UNITS_NB_NAME.

Referenced by controlize_distribution().

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

◆ phrase_distributor_control_code()

bool phrase_distributor_control_code ( const char *  module_name)

set and get the current properties concerning regions

get the resources

sets dynamic_area

Get the READ, WRITE, IN and OUT regions of the module

Now do the job

Display the statement before to check consistency

Check the coherency of data

Reorder the module, because new statements have been added

update/release resources

Parameters
module_nameodule_name

Definition at line 1039 of file phrase_distributor_control_code.c.

1040 {
1041  statement module_stat;
1042  entity module;
1043 
1044  /* set and get the current properties concerning regions */
1045  set_bool_property("MUST_REGIONS", true);
1046  set_bool_property("EXACT_REGIONS", true);
1048 
1049  /* get the resources */
1050  module_stat = (statement) db_get_memory_resource(DBR_CODE,
1051  module_name,
1052  true);
1053 
1055 
1056  set_current_module_statement(module_stat);
1058 
1060  db_get_memory_resource(DBR_CUMULATED_EFFECTS, module_name, true));
1062  db_get_memory_resource(DBR_PROPER_EFFECTS, module_name, true));
1064 
1065  /* sets dynamic_area */
1069  }
1070 
1071  debug_on("PHRASE_DISTRIBUTOR_DEBUG_LEVEL");
1072 
1073  /* Get the READ, WRITE, IN and OUT regions of the module
1074  */
1076  db_get_memory_resource(DBR_REGIONS, module_name, true));
1078  db_get_memory_resource(DBR_IN_REGIONS, module_name, true));
1080  db_get_memory_resource(DBR_OUT_REGIONS, module_name, true));
1081 
1082  /* Now do the job */
1083 
1084  pips_debug(2, "BEGIN of PHRASE_DISTRIBUTOR_CONTROL_CODE\n");
1085  module_stat = controlize_distribution (module_stat, module);
1086  pips_debug(2, "END of PHRASE_DISTRIBUTOR_CONTROL_CODE\n");
1087 
1088  /* Display the statement before to check consistency */
1089  ifdebug(4) {
1090  print_statement(module_stat);
1091  }
1092 
1093  /* Check the coherency of data */
1094 
1095  pips_assert("Statement structure is consistent after PHRASE_DISTRIBUTOR_CONTROL_CODE",
1096  gen_consistent_p((gen_chunk*)module_stat));
1097 
1098  pips_assert("Statement is consistent after PHRASE_DISTRIBUTOR_CONTROL_CODE",
1099  statement_consistent_p(module_stat));
1100 
1101 
1102  /* Reorder the module, because new statements have been added */
1103  module_reorder(module_stat);
1104  DB_PUT_MEMORY_RESOURCE(DBR_CODE, module_name, module_stat);
1105  DB_PUT_MEMORY_RESOURCE(DBR_CALLEES, module_name,
1106  compute_callees(module_stat));
1107 
1108  /* update/release resources */
1114  reset_rw_effects();
1115  reset_in_effects();
1118 
1119  debug_off();
1120 
1121  return true;
1122 }
bool statement_consistent_p(statement p)
Definition: ri.c:2195
callees compute_callees(const statement stat)
Recompute the callees of a module statement.
Definition: callgraph.c:355
void get_regions_properties(void)
void set_rw_effects(statement_effects)
void reset_out_effects(void)
void reset_proper_rw_effects(void)
void set_proper_rw_effects(statement_effects)
void set_cumulated_rw_effects(statement_effects)
void set_out_effects(statement_effects)
void set_in_effects(statement_effects)
void reset_in_effects(void)
void reset_cumulated_rw_effects(void)
void reset_rw_effects(void)
int gen_consistent_p(gen_chunk *obj)
GEN_CONSISTENT_P dynamically checks the type correctness of OBJ.
Definition: genClib.c:2398
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
void reset_current_module_statement(void)
Reset the current module statement.
Definition: static.c:221
statement set_current_module_statement(statement)
Set the current module statement.
Definition: static.c:165
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
#define debug_on(env)
Definition: misc-local.h:157
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define debug_off()
Definition: misc-local.h:160
#define DYNAMIC_AREA_LOCAL_NAME
Definition: naming-local.h:69
static entity dynamic_area
static statement controlize_distribution(statement module_stat, entity module)
Main function for PHRASE_DISTRIBUTION_CONTROL_CODE.
void set_bool_property(const char *, bool)
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
Definition: reorder.c:244
entity FindOrCreateEntity(const char *package, const char *local_name)
Problem: A functional global entity may be referenced without parenthesis or CALL keyword in a functi...
Definition: entity.c:1586
#define entity_undefined_p(x)
Definition: ri.h:2762
void module_to_value_mappings(entity m)
void module_to_value_mappings(entity m): build hash tables between variables and values (old,...
Definition: mappings.c:624
void free_value_mappings(void)
Normal call to free the mappings.
Definition: value.c:1212
A gen_chunk is used to store every object.
Definition: genC.h:58

References compute_callees(), controlize_distribution(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, debug_off, debug_on, dynamic_area, DYNAMIC_AREA_LOCAL_NAME, entity_undefined, entity_undefined_p, FindOrCreateEntity(), free_value_mappings(), gen_consistent_p(), get_regions_properties(), ifdebug, module, module_local_name(), module_name(), module_name_to_entity(), module_reorder(), module_to_value_mappings(), pips_assert, pips_debug, print_statement(), reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), reset_in_effects(), reset_out_effects(), reset_proper_rw_effects(), reset_rw_effects(), set_bool_property(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_in_effects(), set_out_effects(), set_proper_rw_effects(), set_rw_effects(), and statement_consistent_p().

+ Here is the call 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 }
static statement module_statement
Definition: alias_check.c:125
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
#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
void fprint_environment(FILE *fd, entity m)
Definition: declarations.c:287
struct _newgen_struct_code_ * code
Definition: ri.h:79

References close_prettyprint(), code_declarations, db_build_file_resource_name(), DB_PUT_NEW_FILE_RESOURCE, empty_text(), ENTITY, entity_global_name(), entity_initial, fprint_environment(), get_current_module_entity(), ifdebug, init_prettyprint(), make_text_resource(), MAP, module, module_name(), module_statement, pips_debug, print_statement(), reset_current_module_entity(), set_current_module_entity(), text_module(), and value_code.

Referenced by make_array_communication_module(), make_scalar_communication_module(), make_start_ru_module(), and make_wait_ru_module().

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

Variable Documentation

◆ dynamic_area

entity dynamic_area = entity_undefined
static

Definition at line 1037 of file phrase_distributor_control_code.c.

Referenced by phrase_distributor_control_code().