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

Go to the source code of this file.

Macros

#define WP65_INCLUDED
 Warning! Do not modify this file that is automatically generated! More...
 
#define EMULATED_SHARED_MEMORY_PREFIX   "ES_"
 
#define LOCAL_MEMORY_PREFIX   "L_"
 
#define LOCAL_MEMORY_SEPARATOR   "_"
 
#define COMPUTE_ENGINE_NAME   "WP65"
 
#define BANK_NAME   "BANK"
 #define WP65_SUFFIX "_WP65" More...
 
#define PROCESSOR_IDENTIFIER   "PROC_ID"
 #define MEMORY_EMULATOR_SUFFIX "_BANK" More...
 
#define BANK_IDENTIFIER   "BANK_ID"
 
#define BANK_LINE_IDENTIFIER   "L"
 
#define BANK_OFFSET_IDENTIFIER   "O"
 
#define SUFFIX_FOR_INDEX_TILE_IN_INITIAL_BASIS   "_1"
 
#define SUFFIX_FOR_INDEX_TILE_IN_TILE_BASIS   "_0"
 
#define PREFIX_FOR_LOCAL_TILE_BASIS   "L_"
 
#define PIPELINE_DEPTH   1
 These values should be read in model.rc (FI, 20/11/91) #define PROCESSOR_NUMBER 4 #define BANK_NUMBER 4 #define LINE_SIZE 25
More...
 
#define MAXIMUM_LOCAL_VARIABLE_NAME_SIZE   256
 

Functions

void eval_variable_in_statement (entity, statement, Variable, int)
 
void tile_change_of_basis (Psysteme, Pbase, Pbase, Pbase, tiling)
 
statement make_scanning_over_tiles (entity, list, entity, int, tiling, Pbase, Pbase, Pbase, Psysteme, int, int)
 make_scanning_over_tiles() More...
 
statement make_scanning_over_one_tile (entity, statement, tiling, Pbase, Pbase, Pbase, Pbase, Psysteme, int, int)
 make_scanning_over_one_tile(): More...
 
list make_compute_block (entity, statement, Pvecteur, hash_table, tiling, Pbase, Pbase, Pbase, Pbase, Psysteme, int, int)
 
list reference_conversion_statement (entity, statement, list *, hash_table, Pvecteur, Pbase, Pbase, Pbase, tiling)
 void reference_conversion_statement(body, r_to_llv, offsets, initial_basis, local_basis): More...
 
list reference_conversion_computation (entity, list *, expression, Pbase, Pbase, Pbase, tiling)
 
entity reference_translation (reference, Pbase, Pbase)
 
void reference_conversion_expression (expression, hash_table, Pvecteur, Pbase, Pbase)
 
bool uniform_dependence_p (reference, reference)
 This function checks if two references have a uniform dependence. More...
 
list classify_reference (list, reference)
 This function classifies the references in lists. More...
 
Psysteme build_sc_with_several_uniform_ref (entity, cons *, Psysteme, Pbase *)
 build_sc_with_several_uniform_ref(): More...
 
void make_store_blocks (entity, entity, entity, entity, entity, entity, list, hash_table, Psysteme, Pbase, Pbase, Pbase, Pbase, entity, int, int, int, statement *, statement *, int, int)
 
void make_load_blocks (entity, entity, entity, entity, entity, entity, list, hash_table, Psysteme, Pbase, Pbase, Pbase, Pbase, entity, int, int, int, statement *, statement *, int, int)
 
Psysteme tile_membership (matrice, Pbase, Pbase)
 Psysteme tile_membership(P, origin, member): More...
 
tiling loop_nest_to_tile (Psysteme, int, Pbase, int, int, int)
 tiling.c More...
 
void loop_nest_to_local_variables (entity, entity, entity, hash_table, hash_table, hash_table, hash_table, hash_table, hash_table, list, statement, Pbase, graph, int, int, int, tiling)
 variable.c More...
 
entity make_emulated_shared_variable (entity, entity, int, int)
 
entity find_or_create_emulated_shared_variable (entity, entity, hash_table, int, int)
 
list make_new_local_variables (entity, entity, int, int, hash_table)
 
bool reference_conflicting_test_and_update (reference, graph, hash_table, hash_table, hash_table, hash_table)
 reference_conflicting_test_and_update(): More...
 
bool reference_conflicting_p (reference, reference, graph)
 
Psysteme make_tile_constraints (matrice, Pbase)
 Psysteme make_tile_constraints(P, b): More...
 
void set_dimensions_of_local_variables (hash_table, Pbase, tiling, hash_table)
 
void set_dimensions_of_local_variable_family (list, Psysteme, list, tiling, int)
 void set_dimensions_of_local_variable_family(llv, tc, lr): More...
 
bool list_of_calls_p (list)
 instruction_to_wp65_code.c More...
 
entity ith_index_of_ref (reference, int)
 
loop ith_loop_in_loop_nest (statement, int)
 
void instruction_to_wp65_code (entity, list, graph, int, int, int, int, entity, entity, Pbase, hash_table, hash_table, entity, statement, entity, statement, statement_mapping, statement_mapping)
 
void call_to_wp65_code (statement, entity, entity, entity, entity, statement, statement, statement_mapping, statement_mapping, hash_table)
 
expression ref_in_implied_do (expression)
 This function extracts from an implied_do expression the reference having to be computed or printed. More...
 
reference translate_IO_ref (call, hash_table, bool)
 This function translates a reference in I/O statement into its corresponding emulated shared memory reference. More...
 
statement generate_io_wp65_code (statement, statement, hash_table, bool)
 
bool io_loop_nest_p (statement)
 Test if the statement resulting from the perfectly_loop_nest_to_body function contains at first call an io. More...
 
void loop_nest_movement_generation (entity, statement, int, int, int, int, entity, entity, Pbase, hash_table, hash_table, entity, statement, entity, statement, statement_mapping, statement_mapping, statement, bool, Psysteme, Pbase, Pbase, Pbase, Pbase, Pbase, Pbase, list, list *, list *, list *, list *, int, int, hash_table, hash_table, hash_table, hash_table)
 
void loop_nest_to_wp65_code (entity, statement, graph, int, int, int, int, entity, entity, Pbase, hash_table, hash_table, entity, statement, entity, statement, statement_mapping, statement_mapping, statement)
 
void make_all_movement_blocks (entity, entity, entity, entity, list, hash_table, hash_table, hash_table, hash_table, int, int, int, Psysteme, Pbase, Pbase, entity, Pbase, Pbase, list *, list *, tag, int, int)
 generates all data movements related to entity v, loads or stores depending on use_def More...
 
void search_parallel_loops (statement, statement, graph, bool[11])
 
bool full_parallel_loop_nest_p (statement, statement, int, graph, bool *)
 
bool fetch_map_undefined_p (void)
 wp65.c More...
 
void set_fetch_map (statement_mapping)
 
statement_mapping get_fetch_map (void)
 
void reset_fetch_map (void)
 
void free_fetch_map (void)
 
void make_fetch_map (void)
 
list load_statement_fetch (statement)
 
void delete_statement_fetch (statement)
 
bool statement_fetch_undefined_p (statement)
 
void store_statement_fetch (statement, list)
 
void update_statement_fetch (statement, list)
 
bool store_map_undefined_p (void)
 
void set_store_map (statement_mapping)
 
statement_mapping get_store_map (void)
 
void reset_store_map (void)
 
void free_store_map (void)
 
void make_store_map (void)
 
list load_statement_store (statement)
 
void delete_statement_store (statement)
 
bool statement_store_undefined_p (statement)
 
void store_statement_store (statement, list)
 
void update_statement_store (statement, list)
 
entity MakeEntityFunction (string)
 
bool wp65 (const string)
 
void module_to_wp65_modules (entity, statement, graph, int, int, int, int, entity *, statement *, entity *, statement *)
 
void fprint_wp65_hash_tables (FILE *, hash_table, hash_table, hash_table, hash_table, hash_table)
 Ignore this function: debugging purposes only. More...
 
bool wp65_conform_p (statement)
 
entity create_local_index (entity, Pvecteur, string)
 basis.c More...
 
entity create_local_index2 (entity, Pvecteur, string)
 
void create_tile_basis (entity, entity, entity, Pbase, Pbase *, Pbase *, Pbase *, Pbase *, Pbase *)
 
void find_iteration_domain (statement, Psysteme *, Pbase *, int *, list *, instruction *)
 find_iteration_domain.c More...
 
void compute_iteration_domain (list, Psysteme *, Pbase *)
 
void iteration_domain_from_statement (list *, statement, int *, list *, instruction *)
 
void model_fprint (FILE *, int, int, int)
 model.c More...
 
void model_fscan (FILE *, int *, int *, int *)
 
void get_model (int *, int *, int *)
 
bool ref_in_list_p (list, reference)
 references.c More...
 
void update_map (statement_mapping, statement, reference)
 
list expression_to_operand_list (expression, list)
 This function gives the list of operands belonging to Expression e. More...
 
bool reference_in_list_p (reference, list)
 This function tests whether at least one array indice of Reference r belongs to List lwr or not. More...
 
bool array_indice_in_list_p (reference, list)
 
void reference_list_update (list *, reference)
 This function add Reference r to List l, if r doesn't belong to l. More...
 
void reference_list_add (list *, list *)
 This function adds all the references of l2 to l1 if they don't appear in l1. More...
 
void reference_list_print (list)
 This function prints the references belonging to l. More...
 
void reference_scalar_defined_p (reference)
 
void variable_list_update (list *, reference)
 This function adds the reference r to List l, if the reference_variable(r) doesn't belong to l. More...
 
void variable_list_add (list *, list *)
 This function adds all the references of l2 to l1 if they don't appear in l1. More...
 
void concat_data_list (list *, list *, statement, statement_mapping, bool)
 
void call_instruction_to_communications (statement, statement, statement, list *, list *, statement_mapping *, statement_mapping *, hash_table, list *)
 communications.c More...
 
void loop_instruction_to_communications (statement, statement, statement, list *, list *, statement_mapping *, statement_mapping *, hash_table, list *)
 This function associates to each variable in the loop the statement where it should be communicated (this statement may be external to the loop). More...
 
void statement_to_communications (statement, statement, statement, list *, list *, statement_mapping *, statement_mapping *, hash_table, list *)
 This function associates to each variable in stmt the statement where it should be communicated. More...
 
void compute_communications (list, statement_mapping *, statement_mapping *)
 This function associates to each variable the statement in l where it should be communicated Fecth_map contains for each statement the list of variables having to be communicated before its execution. More...
 
void include_constant_symbolic_communication (entity, list, bool, statement, entity)
 
list array_scalar_access_to_bank_communication (entity, Pbase, int, int, list, bool, entity, entity, bool)
 
void insert_run_time_communications (entity, entity, Pbase, int, int, entity, list, statement_mapping, statement_mapping, list *, list *, hash_table, bool, Pbase, tiling, Pvecteur, Pvecteur, Pvecteur)
 
bool test_run_time_communications (list, statement_mapping, statement_mapping)
 

Variables

Value offset_dim1
 WP65_INCLUDED. More...
 
Value offset_dim2
 

Macro Definition Documentation

◆ BANK_IDENTIFIER

#define BANK_IDENTIFIER   "BANK_ID"

Definition at line 50 of file wp65.h.

◆ BANK_LINE_IDENTIFIER

#define BANK_LINE_IDENTIFIER   "L"

Definition at line 51 of file wp65.h.

◆ BANK_NAME

#define BANK_NAME   "BANK"

#define WP65_SUFFIX "_WP65"

Definition at line 47 of file wp65.h.

◆ BANK_OFFSET_IDENTIFIER

#define BANK_OFFSET_IDENTIFIER   "O"

Definition at line 52 of file wp65.h.

◆ COMPUTE_ENGINE_NAME

#define COMPUTE_ENGINE_NAME   "WP65"

Definition at line 45 of file wp65.h.

◆ EMULATED_SHARED_MEMORY_PREFIX

#define EMULATED_SHARED_MEMORY_PREFIX   "ES_"

Definition at line 42 of file wp65.h.

◆ LOCAL_MEMORY_PREFIX

#define LOCAL_MEMORY_PREFIX   "L_"

Definition at line 43 of file wp65.h.

◆ LOCAL_MEMORY_SEPARATOR

#define LOCAL_MEMORY_SEPARATOR   "_"

Definition at line 44 of file wp65.h.

◆ MAXIMUM_LOCAL_VARIABLE_NAME_SIZE

#define MAXIMUM_LOCAL_VARIABLE_NAME_SIZE   256

Definition at line 68 of file wp65.h.

◆ PIPELINE_DEPTH

#define PIPELINE_DEPTH   1

These values should be read in model.rc (FI, 20/11/91) #define PROCESSOR_NUMBER 4 #define BANK_NUMBER 4 #define LINE_SIZE 25

FI: PIPELINE_DEPTH should be set to 3

Definition at line 66 of file wp65.h.

◆ PREFIX_FOR_LOCAL_TILE_BASIS

#define PREFIX_FOR_LOCAL_TILE_BASIS   "L_"

Definition at line 56 of file wp65.h.

◆ PROCESSOR_IDENTIFIER

#define PROCESSOR_IDENTIFIER   "PROC_ID"

#define MEMORY_EMULATOR_SUFFIX "_BANK"

Definition at line 49 of file wp65.h.

◆ SUFFIX_FOR_INDEX_TILE_IN_INITIAL_BASIS

#define SUFFIX_FOR_INDEX_TILE_IN_INITIAL_BASIS   "_1"

Definition at line 54 of file wp65.h.

◆ SUFFIX_FOR_INDEX_TILE_IN_TILE_BASIS

#define SUFFIX_FOR_INDEX_TILE_IN_TILE_BASIS   "_0"

Definition at line 55 of file wp65.h.

◆ WP65_INCLUDED

#define WP65_INCLUDED

Warning! Do not modify this file that is automatically generated!

Modify src/Libs/wp65/wp65-local.h instead, to add your own modifications. header file built by cproto wp65-local.h Header File for WP65

Francois Irigoin, Corinne Ancourt, Lei Zhou

September 1991

Definition at line 40 of file wp65.h.

Function Documentation

◆ array_indice_in_list_p()

bool array_indice_in_list_p ( reference  r,
list  lwr 
)
Parameters
lwrwr

Definition at line 140 of file references.c.

141 {
142 
143  list lr = NIL;
144  bool result = false;
145  list lref1;
146  MAPL(ce,{ expression e = EXPRESSION(CAR(ce));
147  lr = expression_to_reference_list(e, lr);
148  },
149  reference_indices(r));
150  for (lref1 = lr;
151  lref1 != NIL && !result;
152  result = result || reference_in_list_p(REFERENCE(CAR(lref1)),
153  lwr),
154  lref1 = CDR(lref1));
155 
156  return result;
157 }
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
Definition: newgen_list.h:203
bool reference_in_list_p(reference r, list lwr)
This function tests whether at least one array indice of Reference r belongs to List lwr or not.
Definition: references.c:130
list expression_to_reference_list(expression e, list lr)
conversion of an expression into a list of references; references are appended to list lr as they are...
Definition: expression.c:1263
#define REFERENCE(x)
REFERENCE.
Definition: ri.h:2296
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define reference_indices(x)
Definition: ri.h:2328
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References CAR, CDR, EXPRESSION, expression_to_reference_list(), MAPL, NIL, REFERENCE, reference_in_list_p(), and reference_indices.

Referenced by call_instruction_to_communications().

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

◆ array_scalar_access_to_bank_communication()

list array_scalar_access_to_bank_communication ( entity  memory_module,
Pbase  bank_indices,
int  bn,
int  ls,
list  lt,
bool  load_code,
entity  proc_id,
entity  var_id,
bool  fully_sequential 
)

Generation of the emulated shared memory code corresponding to the transfer of a scalar array element :

CALL BANK_RECEIVE_4(PROC_ID, X1, 1) CALL BANK_RECEIVE_4(PROC_ID, L, 1) CALL BANK_RECEIVE_4(PROC_ID, O, 1) IF (BANK_ID = X1) THEN CALL BANK_SEND_4(PROC_ID, ES_B(O,L), 1) ENDIF

Parameters
memory_moduleemory_module
bank_indicesank_indices
bnn
lss
ltt
load_codeoad_code
proc_idroc_id
var_idar_id
fully_sequentialully_sequential

Definition at line 527 of file communications.c.

530 {
531  pips_assert("true", ls==ls);
532 
533  reference ref1 = make_reference((entity) bank_indices->succ->var,NIL);
534  reference ref2 = make_reference((entity) bank_indices->succ->succ->var,NIL);
535  list lst = CONS(REFERENCE,make_reference(var_id,NIL),
536  CONS(REFERENCE,ref1, CONS(REFERENCE,ref2,NIL)));
537  if (!fully_sequential) {
538  /*
539  Generation of the emulated shared memory code corresponding to
540  the transfer of a scalar array element :
541 
542  CALL BANK_RECEIVE_4(PROC_ID, X1, 1)
543  CALL BANK_RECEIVE_4(PROC_ID, L, 1)
544  CALL BANK_RECEIVE_4(PROC_ID, O, 1)
545  IF (BANK_ID = X1) THEN
546  CALL BANK_SEND_4(PROC_ID, ES_B(O,L), 1)
547  ENDIF
548  */
549  list ccode= constant_symbolic_communication(memory_module,
550  lst,!load_code,proc_id);
551  list tcode = constant_symbolic_communication(memory_module,
552  lt,load_code,proc_id);
553  expression exp1 =make_vecteur_expression(vect_new(bank_indices->var,
554  VALUE_ONE));
556  VALUE_ONE));
558  statement testbody = make_block_statement(tcode);
559  statement stat = make_test_statement(test_bound,testbody,
561  return (gen_nconc(ccode,CONS(STATEMENT,stat,NIL)));
562  }
563  else {
564  entity ent1 = make_new_module_variable(memory_module,100);
565  list ccode= constant_symbolic_communication(memory_module,lst,
566  !load_code,(entity) bank_indices->var);
567  list icode= constant_symbolic_communication(memory_module,lt,
568  load_code,ent1);
569  range looprange = make_range(int_to_expression(0),
570  int_to_expression(bn-1),
571  int_to_expression(1));
572  statement loopbody = make_block_statement(icode);
573  entity looplabel = make_loop_label(9000, memory_module);
574 
575  loop newloop = make_loop(ent1,looprange, loopbody, looplabel,
577 
578  statement stat = loop_to_statement(newloop);
579  AddEntityToDeclarations(ent1,memory_module);
580  icode = gen_nconc(ccode,CONS(STATEMENT,stat,NIL));
581  return icode;
582  }
583 }
execution make_execution(enum execution_utype tag, void *val)
Definition: ri.c:838
loop make_loop(entity a1, range a2, statement a3, entity a4, execution a5, list a6)
Definition: ri.c:1301
reference make_reference(entity a1, list a2)
Definition: ri.c:2083
range make_range(expression a1, expression a2, expression a3)
Definition: ri.c:2041
#define VALUE_ONE
static list constant_symbolic_communication(entity compute_or_memory_module, list lrefs, bool load_code, entity var_id)
statement make_block_statement(list)
Make a block statement from a list of statement.
Definition: statement.c:616
statement make_empty_block_statement(void)
Build an empty statement (block/sequence)
Definition: statement.c:625
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
statement make_test_statement(expression, statement, statement)
Definition: statement.c:1248
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define UU
Definition: newgen_types.h:98
#define loop_to_statement(l)
#define EQUAL_OPERATOR_NAME
entity make_loop_label(int __attribute__((unused)) desired_number, entity module)
Definition: entity.c:370
entity entity_intrinsic(const char *name)
FI: I do not understand this function name (see next one!).
Definition: entity.c:1292
expression make_vecteur_expression(Pvecteur pv)
make expression for vector (Pvecteur)
Definition: expression.c:1650
expression MakeBinaryCall(entity f, expression eg, expression ed)
Creates a call expression to a function with 2 arguments.
Definition: expression.c:354
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
entity make_new_module_variable(entity, int)
Make a new module integer variable of name X<d>.
Definition: variable.c:830
void AddEntityToDeclarations(entity, entity)
END_EOLE.
Definition: variable.c:108
@ is_execution_parallel
Definition: ri.h:1190
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
Variable var
Definition: vecteur-local.h:90
struct Svecteur * succ
Definition: vecteur-local.h:92
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Definition: vecteur-local.h:60
Pvecteur vect_new(Variable var, Value coeff)
Pvecteur vect_new(Variable var,Value coeff): allocation d'un vecteur colineaire au vecteur de base va...
Definition: alloc.c:110

References AddEntityToDeclarations(), CONS, constant_symbolic_communication(), entity_intrinsic(), EQUAL_OPERATOR_NAME, gen_nconc(), int_to_expression(), is_execution_parallel, loop_to_statement, make_block_statement(), make_empty_block_statement(), make_execution(), make_loop(), make_loop_label(), make_new_module_variable(), make_range(), make_reference(), make_test_statement(), make_vecteur_expression(), MakeBinaryCall(), NIL, pips_assert, REFERENCE, STATEMENT, Svecteur::succ, UU, VALUE_ONE, Svecteur::var, and vect_new().

Referenced by insert_array_scalar_access_movement().

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

◆ build_sc_with_several_uniform_ref()

Psysteme build_sc_with_several_uniform_ref ( entity  module,
cons lr,
Psysteme  sc_domain,
Pbase new_index_base 
)

build_sc_with_several_uniform_ref():

Build the set of constraints describing the array function for the set of uniform references to the array and update the system describing the domain with constraints on new variables

build the system of constraints describing the array function. One constraint for each dimension of the array is built. This constraint is put in the system of inequalities of sc_array_function

update the system describing the image function with the others array functions having a uniform dependence with the first one for example, assume we have A(i,j) and A(i+2,j+3)
then the final system will be : i + 2 X1 <= 0 j - 3 X1 <= 0 X1 is new variable

add to the system of constraints describing the domain the set of constraints on the new variables. If X1,X2,...Xn are these new variables the set of constraints added is: 0 <= X1 <= 1 0 <= X2 <= 1 - X1 0 <= X3 <= 1 - X1 -X2 0<= Xn <= 1 - X1 - X2 ... -Xn-1

Parameters
moduleodule
lrr
sc_domainc_domain
new_index_baseew_index_base

Definition at line 1011 of file code.c.

1016 {
1017  cons * expr;
1018 
1019  Psysteme sc_array_function = sc_new();
1020  Psysteme sc2;
1021  Pcontrainte pc,pc3=NULL;
1022  Pvecteur pv,pv1,pv2,pv3;
1023  Pvecteur pv_sup = VECTEUR_NUL;
1024  normalized norm;
1025  reference r;
1026  cons * ind;
1028  Value cst = VALUE_ZERO;
1029  Pcontrainte pc1,pc2;
1030  expression expr1;
1031 
1032  debug(8,"build_sc_with_several_uniform_ref", "begin\n");
1033  ifdebug(8) {
1034  list crefs;
1035  (void) fprintf(stderr, "Associated reference list:");
1036  for(crefs=lr; !ENDP(crefs); POP(crefs)) {
1037  reference r1 = REFERENCE(CAR(crefs));
1038  print_reference(r1);
1039  if(ENDP(CDR(crefs)))
1040  (void) putc('\n', stderr);
1041  else
1042  (void) putc(',', stderr);
1043  }
1044  }
1045 
1046 
1047  r= REFERENCE(CAR(lr));
1048  ind = reference_indices(r);
1049 
1050  /* build the system of constraints describing the array function.
1051  One constraint for each dimension of the array is built.
1052  This constraint is put in the system of inequalities of
1053  sc_array_function */
1054 
1055  for (expr = ind;expr!= NULL; expr = CDR(expr)) {
1056  expr1 = EXPRESSION(CAR(expr));
1058  if (normalized_linear_p(norm)) {
1059  pv1 = (Pvecteur) normalized_linear(norm);
1060  pc = contrainte_make(vect_dup(pv1));
1061  if (sc_array_function->inegalites == NULL) {
1062  sc_array_function->inegalites = pc;
1063  }
1064  else pc3->succ = pc;
1065  pc3=pc;
1066  sc_array_function->nb_ineq ++;
1067  }
1068  else {
1069  pips_internal_error("Non-linear subscript expression");
1070  }
1071  }
1072  sc_creer_base(sc_array_function);
1073 
1074  /* update the system describing the image function with the others array
1075  functions having a uniform dependence with the first one
1076  for example, assume we have A(i,j) and A(i+2,j+3)
1077  then the final system will be :
1078  i + 2 X1 <= 0
1079  j - 3 X1 <= 0
1080  X1 is new variable
1081  */
1082  sc2 =sc_dup(sc_dup(sc_array_function));
1083  for (lr = CDR(lr); lr != NIL;lr = CDR(lr)) {
1084  bool new_variable = false;
1085  r= REFERENCE(CAR(lr));
1086  ind = reference_indices(r);
1087  for (expr = ind,pc = sc_array_function->inegalites,
1088  pc2 = sc2->inegalites;
1089  expr!= NULL; expr = CDR(expr), pc=pc->succ,pc2 = pc2->succ) {
1090 
1092  pv1 = (Pvecteur) normalized_linear(norm);
1093  pv3 = vect_substract(pv1,pc2->vecteur);
1094  if (vect_size(pv3) == 1) {
1095  if (value_notzero_p(cst=vecteur_val(pv3))) {
1096  if (!new_variable) {
1097  new_variable = true;
1099  sc_array_function);
1100 
1101  vect_chg_coeff(&pv_sup,var,VALUE_ONE);
1102  }
1103  vect_chg_coeff(&pc->vecteur,var,cst);
1104  }
1105  }
1106  else if (vect_size(pv3) >1)
1107  pips_internal_error("Non uniform dependent references");
1108  }
1109  }
1110 
1111  /* add to the system of constraints describing the domain the
1112  set of constraints on the new variables. If X1,X2,...Xn are these
1113  new variables the set of constraints added is:
1114  0 <= X1 <= 1
1115  0 <= X2 <= 1 - X1
1116  0 <= X3 <= 1 - X1 -X2
1117  0<= Xn <= 1 - X1 - X2 ... -Xn-1
1118  */
1119  for (pv = pv_sup; !VECTEUR_NUL_P(pv); pv = pv->succ) {
1120  sc_domain->base = vect_add_variable(sc_domain->base,pv->var);
1121  sc_domain->dimension++;
1122  *new_index_base = vect_add_variable(*new_index_base,pv->var);
1123  pv1 = vect_dup(pv);
1125  pc1= contrainte_make(pv1);
1126  sc_add_ineg(sc_domain,pc1);
1127  pv2 = vect_dup(pv);
1128  vect_chg_sgn(pv2);
1129  pc2 = contrainte_make(pv2);
1130  sc_add_ineg(sc_domain,pc2);
1131  }
1132 
1133  ifdebug(8) {
1134  (void) fprintf(stderr," The array function :\n");
1135  (void) sc_fprint(stderr,sc_array_function,(string(*)(Variable))entity_local_name);
1136  }
1137 
1138  debug(8,"build_sc_with_several_uniform_ref", "end\n");
1139 
1140 
1141  return(sc_array_function);
1142 }
#define VALUE_ZERO
#define value_notzero_p(val)
#define VALUE_MONE
int Value
Pbase vect_add_variable(Pbase b, Variable v)
package vecteur - routines sur les bases
Definition: base.c:61
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
Definition: alloc.c:73
static entity new_variable
entity to be replaced, the primary?
Definition: dynamic.c:860
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
int vect_size(Pvecteur v)
package vecteur - reductions
Definition: reductions.c:47
#define pips_internal_error
Definition: misc-local.h:149
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
Variable sc_add_new_variable_name(entity, Psysteme)
sc_add_variable.c
static char * module
Definition: pips.c:74
void print_reference(reference r)
Definition: expression.c:142
static void norm(struct rproblem *RR)
cette procedure normalise la fonction cout, calcule les valeurs des seconds membres resultant d'une n...
Definition: r1.c:271
#define NORMALIZE_EXPRESSION(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
#define normalized_linear_p(x)
Definition: ri.h:1779
struct _newgen_struct_normalized_ * normalized
Definition: ri.h:247
#define normalized_linear(x)
Definition: ri.h:1781
void sc_creer_base(Psysteme ps)
void sc_creer_base(Psysteme ps): initialisation des parametres dimension et base d'un systeme lineair...
Definition: sc_alloc.c:129
Psysteme sc_new(void)
Psysteme sc_new(): alloue un systeme vide, initialise tous les champs avec des valeurs nulles,...
Definition: sc_alloc.c:55
Psysteme sc_dup(Psysteme ps)
Psysteme sc_dup(Psysteme ps): should becomes a link.
Definition: sc_alloc.c:176
void sc_fprint(FILE *fp, Psysteme ps, get_variable_name_t nom_var)
void sc_fprint(FILE * f, Psysteme ps, char * (*nom_var)()): cette fonction imprime dans le fichier po...
Definition: sc_io.c:220
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
void vect_chg_sgn(Pvecteur v)
void vect_chg_sgn(Pvecteur v): multiplie v par -1
Definition: scalaires.c:151
#define ifdebug(n)
Definition: sg.c:47
Pvecteur vecteur
struct Scontrainte * succ
Pcontrainte inegalites
Definition: sc-local.h:71
Pbase base
Definition: sc-local.h:75
int dimension
Definition: sc-local.h:74
int nb_ineq
Definition: sc-local.h:73
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
#define vecteur_val(v)
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.
struct Svecteur * Pvecteur
#define VECTEUR_NUL_P(v)
#define VARIABLE_UNDEFINED
Definition: vecteur-local.h:64
Pvecteur vect_dup(Pvecteur v_in)
Pvecteur vect_dup(Pvecteur v_in): duplication du vecteur v_in; allocation de et copie dans v_out;.
Definition: alloc.c:51
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2)
Pvecteur vect_substract(Pvecteur v1, Pvecteur v2): allocation d'un vecteur v dont la valeur est la di...
Definition: binaires.c:75
void vect_chg_coeff(Pvecteur *ppv, Variable var, Value val)
void vect_chg_coeff(Pvecteur *ppv, Variable var, Value val): mise de la coordonnee var du vecteur *pp...
Definition: unaires.c:143

References Ssysteme::base, CAR, CDR, contrainte_make(), debug(), Ssysteme::dimension, ENDP, entity_local_name(), EXPRESSION, fprintf(), ifdebug, Ssysteme::inegalites, module, Ssysteme::nb_ineq, new_variable, NIL, norm(), NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, pips_internal_error, POP, print_reference(), REFERENCE, reference_indices, sc_add_new_variable_name(), sc_creer_base(), sc_dup(), sc_fprint(), sc_new(), Scontrainte::succ, Svecteur::succ, TCST, VALUE_MONE, value_notzero_p, VALUE_ONE, VALUE_ZERO, Svecteur::var, VARIABLE_UNDEFINED, vect_add_variable(), vect_chg_coeff(), vect_chg_sgn(), vect_dup(), vect_size(), vect_substract(), Scontrainte::vecteur, VECTEUR_NUL, VECTEUR_NUL_P, and vecteur_val.

Referenced by make_load_blocks(), and make_store_blocks().

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

◆ call_instruction_to_communications()

void call_instruction_to_communications ( statement  s,
statement  st_level1,
statement  st_level2,
list lwr,
list lwr_local,
statement_mapping fetch_map,
statement_mapping store_map,
hash_table  r_to_ud,
list lpv 
)

communications.c

communications.c

first reference in statement s

Parameters
st_level1t_level1
st_level2t_level2
lwrwr
lwr_localwr_local
fetch_mapetch_map
store_maptore_map
r_to_ud_to_ud
lpvpv

Definition at line 67 of file communications.c.

77 {
78  pips_assert("true", r_to_ud==r_to_ud);
79 
80  if(assignment_statement_p(s)) {
81  reference r;
82  entity rv;
83  list lexpr =
85  /* first reference in statement s */
86  bool first_reference = true;
87 
88  for(; !ENDP(lexpr); POP(lexpr)) {
89  expression e = EXPRESSION(CAR(lexpr));
91  if (lr != NIL) {
92  list consr = lr;
93  ifdebug(2) {
94  (void) fprintf(stderr, "reference list:");
96  (void) fprintf(stderr, "first_reference=%s\n",
97  bool_to_string(first_reference));
98  }
99  for(consr = lr; !ENDP(consr) ; POP(consr)) {
100  r = REFERENCE(CAR(consr));
101  rv = reference_variable(r);
102  if (first_reference) {
103  ifdebug(2) {
104  (void) fprintf(stderr,"list lwr_local:");
105  reference_list_print(*lwr_local);}
106  reference_list_update(lwr_local,r);
107  update_map(*store_map,st_level2,r);
108  first_reference = false;
109  }
110  else {
111  if(!entity_is_argument_p(rv, *lpv)) {
112  debug(8,"loop_nest_to_local_variables",
113  "Variable %s is not private\n",
114  entity_local_name(rv));
115  ifdebug(2) {
116  (void) fprintf(stderr,"list lwr_local:");
117  reference_list_print(*lwr_local);
118  (void) fprintf(stderr,"list lwr : ");
119  reference_list_print(*lwr);}
120 
121  if (reference_scalar_p(r)) {
122  if (!reference_in_list_p(r,*lwr_local))
123  update_map(*fetch_map,st_level1,r);
124  }
125  else {
126  if (array_indice_in_list_p(r,*lwr_local))
127  update_map(*fetch_map,s,r);
128  else if (array_indice_in_list_p(r,*lwr))
129  update_map(*fetch_map,st_level2,r);
130  else update_map(*fetch_map,st_level1,r);
131  }
132  }
133  }
134  }
135  }
136  }
137  }
138  else {
139  ifdebug(9)
140  (void) fprintf(stderr,
141  "call-communications - not assignment\n");
142  }
143 }
bool entity_is_argument_p(entity e, cons *args)
Definition: arguments.c:150
bool assignment_statement_p(statement)
Test if a statement is an assignment.
Definition: statement.c:135
string bool_to_string(bool)
Definition: string.c:243
void print_reference_list(list lr)
Definition: expression.c:147
list expression_to_operand_list(expression e, list lr)
This function gives the list of operands belonging to Expression e.
Definition: references.c:96
void reference_list_print(list l)
This function prints the references belonging to l.
Definition: references.c:186
void reference_list_update(list *l, reference r)
This function add Reference r to List l, if r doesn't belong to l.
Definition: references.c:161
bool array_indice_in_list_p(reference r, list lwr)
Definition: references.c:140
void update_map(statement_mapping m, statement st, reference r)
Definition: references.c:68
bool reference_scalar_p(reference r)
This function returns true if Reference r is scalar.
Definition: expression.c:3530
#define reference_variable(x)
Definition: ri.h:2326
#define statement_instruction(x)
Definition: ri.h:2458
#define instruction_call(x)
Definition: ri.h:1529
#define call_arguments(x)
Definition: ri.h:711

References array_indice_in_list_p(), assignment_statement_p(), bool_to_string(), call_arguments, CAR, debug(), ENDP, entity_is_argument_p(), entity_local_name(), EXPRESSION, expression_to_operand_list(), fprintf(), ifdebug, instruction_call, NIL, pips_assert, POP, print_reference_list(), REFERENCE, reference_in_list_p(), reference_list_print(), reference_list_update(), reference_scalar_p(), reference_variable, statement_instruction, and update_map().

Referenced by statement_to_communications().

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

◆ call_to_wp65_code()

void call_to_wp65_code ( statement  s,
entity  compute_module,
entity  memory_module,
entity  bank_id,
entity  proc_id,
statement  computational,
statement  emulator,
statement_mapping  fetch_map,
statement_mapping  store_map,
hash_table  v_to_esv 
)

To deal with implied_do and I/Os

communications for variables having to be loaded in local memories for assignments

communications for variables having to be stored in global memory for assignments

Parameters
compute_moduleompute_module
memory_moduleemory_module
bank_idank_id
proc_idroc_id
computationalomputational
emulatormulator
fetch_mapetch_map
store_maptore_map
v_to_esv_to_esv

Definition at line 267 of file instruction_to_wp65_code.c.

272 {
273  list lrefs;
274  bool load_code = true;
275  instruction i;
277  /* To deal with implied_do and I/Os */
278 
279 
280  if (strcmp(entity_local_name(call_function(c)), "WRITE") == 0) {
281  generate_io_wp65_code(s,s,v_to_esv,false);
282  i = statement_instruction(emulator);
284  CONS(STATEMENT,
285  copy_statement(s), NIL));
286  }
287  else { /* communications for variables having to be
288  loaded in local memories for assignments */
289  if ((lrefs = (list) GET_STATEMENT_MAPPING(fetch_map,s))
290  != (list) HASH_UNDEFINED_VALUE) {
291  ifdebug(9) {
292  (void) fprintf(stderr,
293  "Vars having to be loaded for stat %"PRIdPTR":\n",
294  statement_number(s));
295  reference_list_print(lrefs); }
296  include_constant_symbolic_communication(compute_module,lrefs,
297  load_code,computational,
298  proc_id);
299  include_constant_symbolic_communication(memory_module,lrefs,
300  !load_code,emulator,
301  bank_id);
302  }
303  i = statement_instruction(computational);
306  /* communications for variables having to be
307  stored in global memory for assignments */
308  if ((lrefs = (list) GET_STATEMENT_MAPPING(store_map,s))
309  != (list) HASH_UNDEFINED_VALUE) {
310  load_code = false;
311  ifdebug(9) {
312  (void) fprintf(stderr,
313  "Vars having to be stored for stat %"PRIdPTR":\n",
314  statement_number(s));
315  reference_list_print(lrefs); }
316  include_constant_symbolic_communication(compute_module,lrefs,
317  load_code,computational,proc_id);
318  include_constant_symbolic_communication(memory_module,lrefs,
319  !load_code,emulator,bank_id);
320  }
321  }
322 }
statement copy_statement(statement p)
STATEMENT.
Definition: ri.c:2186
void include_constant_symbolic_communication(entity compute_or_memory_module, list lrefs, bool load_code, statement computational_or_emulator, entity var_id)
statement generate_io_wp65_code(statement s1, statement body, hash_table v_to_esv, bool loop_or_call_print)
#define GET_STATEMENT_MAPPING(map, stat)
Definition: newgen-local.h:49
#define HASH_UNDEFINED_VALUE
value returned by hash_get() when the key is not found; could also be called HASH_KEY_NOT_FOUND,...
Definition: newgen_hash.h:56
#define instruction_block(i)
#define call_function(x)
Definition: ri.h:709
#define statement_number(x)
Definition: ri.h:2452

References call_function, CONS, copy_statement(), entity_local_name(), fprintf(), gen_nconc(), generate_io_wp65_code(), GET_STATEMENT_MAPPING, HASH_UNDEFINED_VALUE, ifdebug, include_constant_symbolic_communication(), instruction_block, instruction_call, NIL, reference_list_print(), STATEMENT, statement_instruction, and statement_number.

Referenced by instruction_to_wp65_code().

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

◆ classify_reference()

list classify_reference ( list  llr,
reference  r 
)

This function classifies the references in lists.

All the references belonging to the same list are uniform dependent references

Parameters
llrlr

Definition at line 975 of file code.c.

978 {
979  list plr,lr,bllr,lr2;
980  list blr = NIL;
981  bool trouve = false;
982  reference r2;
983 
984  debug(8,"classify_reference", "begin\n");
985  for (plr = llr,bllr = NIL; plr != NIL && !trouve; plr = CDR(plr)) {
986  for (lr = LIST(CAR(plr)), blr=NIL; lr!= NIL && !trouve;
987  lr = CDR(lr)) {
988  r2 = REFERENCE(CAR(lr));
989  if (uniform_dependence_p(r2,r))
990  trouve = true;
991  }
992  blr = (trouve) ? CONS(REFERENCE,r,LIST(CAR(plr))) :
993  LIST(CAR(plr));
994  bllr = CONS(LIST,blr,bllr);
995  }
996  if (!trouve) {
997  lr2 = CONS(REFERENCE,r,NIL);
998  bllr = CONS(LIST,lr2,bllr);
999  }
1000  debug(8,"classify_reference", "end\n");
1001  return(bllr);
1002 
1003 }
bool uniform_dependence_p(reference r1, reference r2)
This function checks if two references have a uniform dependence.
Definition: code.c:939
#define LIST(x)
Definition: genC.h:93

References CAR, CDR, CONS, debug(), LIST, NIL, REFERENCE, and uniform_dependence_p().

Referenced by make_load_blocks(), and make_store_blocks().

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

◆ compute_communications()

void compute_communications ( list  l,
statement_mapping fetch_map,
statement_mapping store_map 
)

This function associates to each variable the statement in l where it should be communicated Fecth_map contains for each statement the list of variables having to be communicated before its execution.

Store_map contains for each statement the list of variables having to be communicated after its execution.

list of written variables

list of variables written in a local instruction block

list of privates variables

Parameters
fetch_mapetch_map
store_maptore_map

Definition at line 267 of file communications.c.

268 {
269  list lwr=NIL; /* list of written variables */
270  list lwr_local= NIL; /* list of variables written in a local
271  instruction block */
272  list lpv = NIL; /* list of privates variables */
274  statement first_stmt = STATEMENT(CAR(l));
275  MAPL(pm,{
276  statement s1 = STATEMENT(CAR(pm));
277  statement_to_communications(s1,first_stmt,s1,&lwr, &lwr_local,
278  fetch_map,store_map, r_to_ud1,&lpv);
279  },l);
280 
281 }
void statement_to_communications(statement stmt, statement st_level1, statement st_level2, list *lwr, list *lwr_local, statement_mapping *fetch_map, statement_mapping *store_map, hash_table r_to_ud, list *lpv)
This function associates to each variable in stmt the statement where it should be communicated.
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
@ hash_pointer
Definition: newgen_hash.h:32
s1
Definition: set.c:247

References CAR, hash_pointer, hash_table_make(), MAPL, NIL, s1, STATEMENT, and statement_to_communications().

Referenced by module_to_wp65_modules().

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

◆ compute_iteration_domain()

void compute_iteration_domain ( list  list_loop_statement,
Psysteme sc,
Pbase basis 
)

computation of the list of loop indices base_index and of the iteration domain sci

Parameters
list_loop_statementist_loop_statement
scc
basisasis

Definition at line 92 of file find_iteration_domain.c.

96 {
97 
98  Psysteme sci;
99  Pbase base_index = BASE_NULLE;
100 
101  /* computation of the list of loop indices base_index
102  and of the iteration domain sci*/
103 
104  debug(8,"compute_iteration_domain","begin\n");
105 
106  sci = loop_iteration_domaine_to_sc(list_loop_statement, &base_index);
107  sci->base = base_reversal(sci->base);
108  ifdebug(8) { (void) fprintf(stderr,"compute_iteration_domain\n");
109  vect_fprint(stderr,base_index,(string(*)(void*))entity_local_name);
110  }
111  *sc = sci;
112  *basis = base_index;
113  debug(8,"compute_iteration_domain","end\n");
114 }
Pbase base_reversal(Pbase b_in)
Pbase base_reversal(Pbase b_in): produces a basis b_out, having the same basis vectors as b_in,...
Definition: base.c:221
Psysteme loop_iteration_domaine_to_sc(list, Pbase *)
loop_iteration_domaine_to_sc.c
void vect_fprint(FILE *f, Pvecteur v, get_variable_name_t variable_name)
void vect_fprint(FILE * f, Pvecteur v, char * (*variable_name)()): impression d'un vecteur creux v su...
Definition: io.c:124
#define BASE_NULLE
MACROS SUR LES BASES.

References Ssysteme::base, BASE_NULLE, base_reversal(), debug(), entity_local_name(), fprintf(), ifdebug, loop_iteration_domaine_to_sc(), and vect_fprint().

Referenced by find_iteration_domain().

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

◆ concat_data_list()

void concat_data_list ( list l,
list lr,
statement  st,
statement_mapping  map,
bool  perfect_nested_loop 
)
Parameters
lrr
stt
mapap
perfect_nested_looperfect_nested_loop

Definition at line 236 of file references.c.

237 {
238  instruction inst;
239  list lt = (list) GET_STATEMENT_MAPPING(map,st);
240 
241  if (lt != (list) HASH_UNDEFINED_VALUE) {
242  variable_list_add(l, &lt);
243  reference_list_add(lr,&lt);
244  }
245  inst = statement_instruction(st);
246  switch(instruction_tag(inst)) {
247  case is_instruction_block:{
248  cons * b;
249  b = instruction_block(inst);
250  if (list_of_calls_p(b))
251  concat_data_list(l,lr,STATEMENT(CAR(b)),map,perfect_nested_loop);
252  else
253  MAPL(st, {
254  concat_data_list(l,lr,STATEMENT(CAR(st)), map,
255  perfect_nested_loop);
256  } , b);
257  break;
258  }
259 
260  case is_instruction_loop: {
262  perfect_nested_loop);
263  break;}
264  default: return;
265  }
266 }
bool list_of_calls_p(list lsb)
instruction_to_wp65_code.c
struct cons * list
Definition: newgen_types.h:106
void concat_data_list(list *l, list *lr, statement st, statement_mapping map, bool perfect_nested_loop)
Definition: references.c:236
void reference_list_add(list *l1, list *l2)
This function adds all the references of l2 to l1 if they don't appear in l1.
Definition: references.c:175
void variable_list_add(list *l1, list *l2)
This function adds all the references of l2 to l1 if they don't appear in l1.
Definition: references.c:225
#define is_instruction_block
soft block->sequence transition
#define loop_body(x)
Definition: ri.h:1644
#define instruction_loop(x)
Definition: ri.h:1520
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511

References CAR, GET_STATEMENT_MAPPING, HASH_UNDEFINED_VALUE, instruction_block, instruction_loop, instruction_tag, is_instruction_block, is_instruction_loop, list_of_calls_p(), loop_body, MAPL, reference_list_add(), STATEMENT, statement_instruction, and variable_list_add().

Referenced by loop_nest_movement_generation().

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

◆ create_local_index()

entity create_local_index ( entity  module,
Pvecteur  pv,
string  st 
)

basis.c

Parameters
moduleodule
pvv
stt

Definition at line 61 of file basis.c.

62 {
63  entity new_ind;
65  vecteur_var(pv)),
66  st,NULL));
67  if ((new_ind =
69  MODULE_SEP_STRING,name,NULL),
71  {
72  new_ind=make_scalar_integer_entity(name,
75  }
76  free(name);
77  return(new_ind);
78 }
void free(void *)
#define MODULE_SEP_STRING
Definition: naming-local.h:30
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
const char * module_local_name(entity e)
Returns the module local user name.
Definition: entity.c:582
entity make_scalar_integer_entity(const char *, const char *)
Create an integer variable of name "name" in module of name "module_name".
Definition: variable.c:1068
#define entity_undefined
Definition: ri.h:2761
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
char * strdup()
#define vecteur_var(v)

References AddEntityToDeclarations(), concatenate(), entity_domain, entity_local_name(), entity_undefined, free(), gen_find_tabulated(), make_scalar_integer_entity(), module, module_local_name(), MODULE_SEP_STRING, strdup(), and vecteur_var.

Referenced by create_tile_basis().

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

◆ create_local_index2()

entity create_local_index2 ( entity  module,
Pvecteur  pv,
string  st 
)
Parameters
moduleodule
pvv
stt

Definition at line 80 of file basis.c.

81 {
82  entity new_ind;
83  string name = strdup(concatenate(st,
85  NULL));
86  if ((new_ind=gen_find_tabulated(concatenate
88  MODULE_SEP_STRING,name,NULL),
90  new_ind=make_scalar_integer_entity(name,
92  module));
94  }
95  free(name);
96  return(new_ind);
97 }

References AddEntityToDeclarations(), concatenate(), entity_domain, entity_local_name(), entity_undefined, free(), gen_find_tabulated(), make_scalar_integer_entity(), module, module_local_name(), MODULE_SEP_STRING, strdup(), and vecteur_var.

Referenced by create_tile_basis().

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

◆ create_tile_basis()

void create_tile_basis ( entity  initial_module,
entity  compute_module,
entity  memory_module,
Pbase  initial_basis,
Pbase tile_basis_in_initial_basis,
Pbase tile_basis_in_tile_basis,
Pbase local_tile_basis,
Pbase tile_basis_in_tile_basis2,
Pbase local_tile_basis2 
)
Parameters
initial_modulenitial_module
compute_moduleompute_module
memory_moduleemory_module
initial_basisnitial_basis
tile_basis_in_initial_basisile_basis_in_initial_basis
tile_basis_in_tile_basisile_basis_in_tile_basis
local_tile_basisocal_tile_basis
tile_basis_in_tile_basis2ile_basis_in_tile_basis2
local_tile_basis2ocal_tile_basis2

Definition at line 100 of file basis.c.

111 {
112  string name;
113  entity new_ind;
114  Pvecteur pv;
115  Pbase tbib = BASE_NULLE;
116  Pbase tbtb = BASE_NULLE;
117  Pbase tbtbc = BASE_NULLE;
118  Pbase ltb = BASE_NULLE;
119  Pbase ltbc = BASE_NULLE;
120 
121  debug(8, "create_tile_basis", "begin initial_module_name=%s\n",
122  module_local_name(initial_module));
123  ifdebug(8) {
124  (void) fprintf(stderr, "initial_basis:\n");
125  vect_fprint(stderr, initial_basis, (string(*)(void*))entity_local_name);
126  }
127 
128  for (pv = initial_basis; !VECTEUR_NUL_P(pv); pv=pv->succ) {
129 
131  vecteur_var(pv)),
133  NULL));
134  if ((new_ind =
136  MODULE_SEP_STRING,name,NULL),
138  new_ind=make_scalar_integer_entity(name,
139  module_local_name(initial_module));
140 
141  free(name);
142  tbib = vect_add_variable (tbib,(char *)new_ind);
143 
144  new_ind = create_local_index(compute_module,
145  pv,
147  tbtbc = vect_add_variable (tbtbc,(char *) new_ind);
148 
149  new_ind= create_local_index(memory_module,
150  pv,
152  tbtb = vect_add_variable (tbtb,(char *) new_ind);
153 
154  new_ind = create_local_index2(compute_module, pv,
156  ltbc = vect_add_variable (ltbc,(char *) new_ind);
157 
158  new_ind = create_local_index2(memory_module, pv,
160  ltb = vect_add_variable (ltb,(char *) new_ind);
161  }
162 
163 
164  *tile_basis_in_initial_basis = base_reversal(tbib);
165  *tile_basis_in_tile_basis = base_reversal(tbtb);
166  *local_tile_basis = base_reversal(ltb);
167  *tile_basis_in_tile_basis2 = base_reversal(tbtbc);
168  *local_tile_basis2 = base_reversal(ltbc);
169 
170  ifdebug(8) {
171  (void) fprintf(stderr,"\nInitial basis:");
172  base_fprint(stderr, initial_basis, (string(*)(void*))entity_local_name);
173  (void) fprintf(stderr,"\nTile basis in initial basis:");
174  base_fprint(stderr, *tile_basis_in_initial_basis, (string(*)(void*))entity_local_name);
175  (void) fprintf(stderr,"\nTile basis in tile basis:");
176  base_fprint(stderr, *tile_basis_in_tile_basis, (string(*)(void*))entity_local_name);
177  (void) fprintf(stderr,"\nLocal basis:");
178  base_fprint(stderr, *local_tile_basis, (string(*)(void*))entity_local_name);
179  (void) fprintf(stderr,
180  "\nTile basis in tile basis for compute module:");
181  base_fprint(stderr, *tile_basis_in_tile_basis2, (string(*)(void*))entity_local_name);
182  (void) fprintf(stderr,"\nLocal basis for compute module:");
183  base_fprint(stderr, *local_tile_basis2, (string(*)(void*))entity_local_name);
184  }
185 
186  debug(8, "create_tile_basis", "end\n");
187 }
entity create_local_index(entity module, Pvecteur pv, string st)
basis.c
Definition: basis.c:61
entity create_local_index2(entity module, Pvecteur pv, string st)
Definition: basis.c:80
void base_fprint(FILE *f, Pbase b, get_variable_name_t variable_name)
void base_fprint(FILE * f, Pbase b, char * (*variable_name)()): impression d'une base sur le fichier ...
Definition: io.c:342
#define SUFFIX_FOR_INDEX_TILE_IN_TILE_BASIS
Definition: wp65-local.h:47
#define PREFIX_FOR_LOCAL_TILE_BASIS
Definition: wp65-local.h:48
#define SUFFIX_FOR_INDEX_TILE_IN_INITIAL_BASIS
Definition: wp65-local.h:46

References base_fprint(), BASE_NULLE, base_reversal(), concatenate(), create_local_index(), create_local_index2(), debug(), entity_domain, entity_local_name(), entity_undefined, fprintf(), free(), gen_find_tabulated(), ifdebug, make_scalar_integer_entity(), module_local_name(), MODULE_SEP_STRING, PREFIX_FOR_LOCAL_TILE_BASIS, strdup(), Svecteur::succ, SUFFIX_FOR_INDEX_TILE_IN_INITIAL_BASIS, SUFFIX_FOR_INDEX_TILE_IN_TILE_BASIS, vect_add_variable(), vect_fprint(), VECTEUR_NUL_P, and vecteur_var.

Referenced by loop_nest_to_wp65_code().

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

◆ delete_statement_fetch()

void delete_statement_fetch ( statement  )

◆ delete_statement_store()

void delete_statement_store ( statement  )

◆ eval_variable_in_statement()

void eval_variable_in_statement ( entity  module,
statement  s,
Variable  v,
int  min 
)
Parameters
moduleodule
minin

Definition at line 141 of file code.c.

142 {
143  var_to_evaluate = v;
144  var_minmax = min;
145  ifdebug(8) {
146  (void) fprintf(stderr, "Loop body :\n");
148  }
149  gen_recurse(s,
151  gen_true,
152  eval_var);
153  ifdebug(8) {
154  (void) fprintf(stderr, "New loop body :\n");
156  }
157 
158 }
static Variable var_to_evaluate
Definition: code.c:73
static void eval_var(reference ref)
Definition: code.c:95
static Value var_minmax
Definition: code.c:72
#define min(a, b)
#define gen_recurse(start, domain_number, flt, rwt)
Definition: genC.h:283
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
Definition: genClib.c:2780
void wp65_debug_print_text(entity m, statement s)
include "values.h"
#define reference_domain
newgen_range_domain_defined
Definition: ri.h:338

References eval_var(), fprintf(), gen_recurse, gen_true(), ifdebug, min, module, reference_domain, var_minmax, var_to_evaluate, and wp65_debug_print_text().

+ Here is the call graph for this function:

◆ expression_to_operand_list()

list expression_to_operand_list ( expression  e,
list  lr 
)

This function gives the list of operands belonging to Expression e.

Parameters
lrr

Definition at line 96 of file references.c.

99 {
100  syntax s = expression_syntax(e);
101  switch(syntax_tag(s)) {
102  case is_syntax_reference:
103  lr = gen_nconc(lr, CONS(REFERENCE, syntax_reference(s), NIL));
104  break;
105  case is_syntax_range:
109  lr);
110  break;
111  case is_syntax_call:
112  MAPL(ce, {
113  expression e = EXPRESSION(CAR(ce));
114  lr = expression_to_operand_list(e, lr);
115  },
117  break;
118  default:
119  (void) fprintf(stderr,
120  "expression_to_operand_list - unexpected syntax\n");
121  }
122 
123  return lr;
124 }
#define syntax_reference(x)
Definition: ri.h:2730
#define syntax_tag(x)
Definition: ri.h:2727
#define range_upper(x)
Definition: ri.h:2290
#define syntax_range(x)
Definition: ri.h:2733
@ is_syntax_range
Definition: ri.h:2692
@ is_syntax_call
Definition: ri.h:2693
@ is_syntax_reference
Definition: ri.h:2691
#define range_increment(x)
Definition: ri.h:2292
#define syntax_call(x)
Definition: ri.h:2736
#define range_lower(x)
Definition: ri.h:2288
#define expression_syntax(x)
Definition: ri.h:1247

References call_arguments, CAR, CONS, EXPRESSION, expression_syntax, fprintf(), gen_nconc(), is_syntax_call, is_syntax_range, is_syntax_reference, MAPL, NIL, range_increment, range_lower, range_upper, REFERENCE, syntax_call, syntax_range, syntax_reference, and syntax_tag.

Referenced by call_instruction_to_communications().

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

◆ fetch_map_undefined_p()

bool fetch_map_undefined_p ( void  )

◆ find_iteration_domain()

void find_iteration_domain ( statement  ,
Psysteme ,
Pbase ,
int ,
list ,
instruction  
)

◆ find_or_create_emulated_shared_variable()

entity find_or_create_emulated_shared_variable ( entity  v,
entity  memory_module,
hash_table  v_to_esv,
int  bn,
int  ls 
)

nothing to do

Parameters
memory_moduleemory_module
v_to_esv_to_esv
bnn
lss

Definition at line 284 of file variable.c.

290 {
291  entity esv = entity_undefined;
292 
293  if ( (esv = gen_find_tabulated(concatenate(entity_local_name(memory_module),
297  NULL),
299  /* nothing to do */
300  ;
301  else {
302  esv = make_emulated_shared_variable(v, memory_module, bn, ls);
303  hash_put(v_to_esv, (char *) v, (char *) esv);
304  }
305  return (esv);
306 }
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
entity make_emulated_shared_variable(entity v, entity memory_module, int bn, int ls)
Definition: variable.c:195
#define EMULATED_SHARED_MEMORY_PREFIX
Header File for WP65.
Definition: wp65-local.h:34

References concatenate(), EMULATED_SHARED_MEMORY_PREFIX, entity_domain, entity_local_name(), entity_undefined, gen_find_tabulated(), hash_put(), make_emulated_shared_variable(), and MODULE_SEP_STRING.

Referenced by loop_nest_to_local_variables().

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

◆ fprint_wp65_hash_tables()

void fprint_wp65_hash_tables ( FILE *  fd,
hash_table  llv_to_lcr,
hash_table  r_to_llv,
hash_table  v_to_lllv,
hash_table  r_to_ud,
hash_table  v_to_esv 
)

Ignore this function: debugging purposes only.

Parameters
fdd
llv_to_lcrlv_to_lcr
r_to_llv_to_llv
v_to_lllv_to_lllv
r_to_ud_to_ud
v_to_esv_to_esv

Definition at line 406 of file wp65.c.

414 {
415  fputs("\nKey mappings for WP65:\n\n", fd);
416 
417  fputs("Mapping llv_to_lcr from list of local variables to conflicting references:\n",
418  fd);
419  HASH_MAP(llv, lcr,
420  {
421  list llvl=(list) llv;
422  list lcrl= (list) lcr;
423  for(; !ENDP(llvl); POP(llvl)) {
424  entity lv = ENTITY(CAR(llvl));
425  fputs(entity_local_name(lv), fd);
426  if(ENDP(CDR(llvl)))
427  (void) putc(' ', fd);
428  else
429  (void) putc(',', fd);
430  }
431  fputs("\t->\t",fd);
432  for(; !ENDP(lcrl); POP(lcrl)) {
433  reference r = REFERENCE(CAR(lcrl));
434  fprint_reference(fd, r);
435  if(ENDP(CDR(lcrl)))
436  (void) putc('\n', fd);
437  else
438  (void) putc(',', fd);
439  }
440  },
441  llv_to_lcr);
442 
443  fputs("\nMapping r_to_llv from a reference to a list of local variables:\n",
444  fd);
445  HASH_MAP(r, llv,
446  { list llvl=(list) llv;
447  fprint_reference(fd, (reference) r);
448  fputs("\t->\t",fd);
449  for(; !ENDP(llvl); POP(llvl)) {
450  entity lv = ENTITY(CAR(llvl));
451  fputs(entity_local_name(lv), fd);
452  if(ENDP(CDR(llvl)))
453  (void) putc(' ', fd);
454  else
455  (void) putc(',', fd);
456  }
457  (void) putc('\n', fd);
458  },
459  r_to_llv);
460 
461  fputs("\nMapping v_to_lllv from variables to lists of lists of local variables:\n",
462  fd);
463  HASH_MAP(v, lllv,
464  { list lllvl=(list)lllv;
465  (void) fprintf(fd,"%s\t->\t", entity_name((entity) v));
466  for(; !ENDP(lllvl); POP(lllvl)) {
467  list llv = LIST(CAR(lllvl));
468  (void) putc('(',fd);
469  for(; !ENDP(llv); POP(llv)) {
470  fputs(entity_local_name(ENTITY(CAR(llv))), fd);
471  if(ENDP(CDR(llv)))
472  (void) putc(')', fd);
473  else
474  (void) putc(',', fd);
475  }
476  if(ENDP(CDR(lllvl)))
477  (void) putc('\n', fd);
478  else
479  (void) putc(',',fd);
480  }
481  },
482  v_to_lllv);
483 
484 
485  fputs("\nMapping r_to_ud from references to use-def:\n", fd);
486  HASH_MAP(r, use_def,
487  {
488  fprint_reference(fd, (reference) r);
489  fputs("\t->\t",fd);
490  fputs(((intptr_t) use_def == (intptr_t)is_action_read) ? "use\n" : "def\n", fd);
491  },
492  r_to_ud);
493 
494 
495  fputs("\nMapping v_to_esv from variables to emulated shared variables:\n",
496  fd);
497  HASH_MAP(v, esv,
498  {
499  (void) fprintf(fd,"%s\t->\t", entity_name((entity) v));
500  (void) fprintf(fd,"%s\n", entity_name((entity) esv));
501  },
502  v_to_esv);
503 
504  (void) putc('\n', fd);
505 }
@ is_action_read
Definition: effects.h:292
#define HASH_MAP(k, v, code, ht)
Definition: newgen_hash.h:60
void fprint_reference(FILE *fd, reference r)
Definition: expression.c:128
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define entity_name(x)
Definition: ri.h:2790
#define intptr_t
Definition: stdint.in.h:294

References CAR, CDR, ENDP, ENTITY, entity_local_name(), entity_name, fprint_reference(), fprintf(), HASH_MAP, intptr_t, is_action_read, LIST, POP, and REFERENCE.

Referenced by loop_nest_to_wp65_code().

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

◆ free_fetch_map()

void free_fetch_map ( void  )

◆ free_store_map()

void free_store_map ( void  )

◆ full_parallel_loop_nest_p()

bool full_parallel_loop_nest_p ( statement  mod_stat,
statement  loop_stmt,
int  nest_dim,
graph  dg,
bool loop_carried_dep 
)
Parameters
mod_statod_stat
loop_stmtoop_stmt
nest_dimest_dim
dgg
loop_carried_depoop_carried_dep

Definition at line 1119 of file instruction_to_wp65_code.c.

1121 {
1122  int i;
1123  search_parallel_loops(mod_stat,loop_stmt, dg,loop_carried_dep);
1124  for (i=1; i<= nest_dim && loop_carried_dep[i]== false; i++);
1125  return( (i>nest_dim) ? true : false);
1126 }
static graph dg
dg is the dependency graph ; FIXME : should not be static global ?
Definition: chains.c:124
static statement mod_stat
We want to keep track of the current statement inside the recurse.
Definition: impact_check.c:41
void search_parallel_loops(statement mod_stat, statement loop_statement, graph dg, loop_carried_dep)

References dg, mod_stat, and search_parallel_loops().

Referenced by loop_nest_to_wp65_code().

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

◆ generate_io_wp65_code()

statement generate_io_wp65_code ( statement  s1,
statement  body,
hash_table  v_to_esv,
bool  loop_or_call_print 
)

we know that it is a loop nest containing a PRINT function The loop body contains block statement in case of CONTINUE loop nest style

loop nest belonging IO statement

implied_do case

Parameters
s11
bodyody
v_to_esv_to_esv
loop_or_call_printoop_or_call_print

Definition at line 406 of file instruction_to_wp65_code.c.

407 {
408 
409  list rvld,pl;
410  statement result = s1;
411  instruction inst = statement_instruction(body);
412  call c;
413  reference r;
414 
415  entity rv,esv_ref;
416  type rvt;
417  int nb_dim,i;
418 
419  /* we know that it is a loop nest containing a PRINT function
420  The loop body contains block statement in case of CONTINUE
421  loop nest style*/
423  if (instruction_block_p(inst)) {
424  list b = instruction_block(inst);
426  }
427  else
428  c= instruction_call(inst);
429  r = translate_IO_ref(c,v_to_esv,loop_or_call_print);
430  rv = reference_variable(r);
431  esv_ref = (entity) hash_get(v_to_esv,(char *) rv);
432  rvt = entity_type(esv_ref);
433  rvld = variable_dimensions(type_variable(rvt));
434  nb_dim = gen_length((list) rvld);
435 
436  if (loop_or_call_print) /* loop nest belonging IO statement */
437  for (i=1; i<=nb_dim; i++) {
438  list ldim = gen_nthcdr(i-1,rvld);
439  expression low = dimension_lower(DIMENSION(CAR(ldim)));
441  range looprange = make_range(low, up,
442  int_to_expression(1));
443  loop loopi = ith_loop_in_loop_nest(result,i);
444  loop_range(loopi) = looprange;
445  }
446  else { /* implied_do case */
448  implied_do_ranges(result);
450  for (i=1,pl = implied_do_range_list; !ENDP(pl); POP(pl),i++) {
451  range r1 = RANGE(CAR(pl));
452  list ldim = gen_nthcdr(i-1,rvld);
454  dimension_lower(DIMENSION(CAR(ldim))));
456  dimension_upper(DIMENSION(CAR(ldim))));
457  range_lower(r1)=low;
458  range_upper(r1)=up;
459  }
460  }
461  return(result);
462 }
expression copy_expression(expression p)
EXPRESSION.
Definition: ri.c:850
struct _newgen_struct_entity_ * entity
Definition: abc_private.h:14
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
size_t gen_length(const list l)
Definition: list.c:150
list gen_nthcdr(int n, const list lx)
caution: the first item is 0! was: return( (n<=0) ? l : gen_nthcdr( n-1, CDR( l ))) ; if n>gen_length...
Definition: list.c:700
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
static list implied_do_range_list
loop ith_loop_in_loop_nest(statement s1, int level)
reference translate_IO_ref(call c, hash_table v_to_esv, bool loop_or_call_print)
This function translates a reference in I/O statement into its corresponding emulated shared memory r...
static void implied_do_ranges(statement s)
#define STATEMENT_ORDERING_UNDEFINED
mapping.h inclusion
Definition: newgen-local.h:35
static hash_table pl
properties are stored in this hash table (string -> property) for fast accesses.
Definition: properties.c:783
#define instruction_block_p(i)
#define statement_ordering(x)
Definition: ri.h:2454
#define dimension_lower(x)
Definition: ri.h:980
#define type_variable(x)
Definition: ri.h:2949
#define RANGE(x)
RANGE.
Definition: ri.h:2257
#define dimension_upper(x)
Definition: ri.h:982
#define variable_dimensions(x)
Definition: ri.h:3122
#define loop_range(x)
Definition: ri.h:1642
#define entity_type(x)
Definition: ri.h:2792

References CAR, copy_expression(), DIMENSION, dimension_lower, dimension_upper, ENDP, entity_type, gen_length(), gen_nreverse(), gen_nthcdr(), hash_get(), implied_do_range_list, implied_do_ranges(), instruction_block, instruction_block_p, instruction_call, int_to_expression(), ith_loop_in_loop_nest(), loop_range, make_range(), NIL, pl, POP, RANGE, range_lower, range_upper, reference_variable, s1, STATEMENT, statement_instruction, statement_ordering, STATEMENT_ORDERING_UNDEFINED, translate_IO_ref(), type_variable, and variable_dimensions.

Referenced by call_to_wp65_code(), and loop_nest_to_wp65_code().

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

◆ get_fetch_map()

statement_mapping get_fetch_map ( void  )

◆ get_model()

void get_model ( int ppn,
int pbn,
int pls 
)
Parameters
ppnpn
pbnbn
plsls

Definition at line 71 of file model.c.

72 {
73  FILE * fd;
74  const char* model_rc = get_string_property("WP65_MODEL_FILE");
75  if ((fd = fopen(model_rc, "r")) == NULL) {
76  fd = fopen_config(model_rc, NULL,NULL);
77  }
78 
79  model_fscan(fd, ppn, pbn, pls);
80 }
char * get_string_property(const char *)
FILE * fopen_config(const char *canonical_name, const char *cproperty, const char *cenv)
Definition: file.c:952
void model_fscan(FILE *fd, int *ppn, int *pbn, int *pls)
Definition: model.c:59

References fopen_config(), get_string_property(), and model_fscan().

Referenced by wp65().

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

◆ get_store_map()

statement_mapping get_store_map ( void  )

◆ include_constant_symbolic_communication()

void include_constant_symbolic_communication ( entity  compute_or_memory_module,
list  lrefs,
bool  load_code,
statement  computational_or_emulator,
entity  var_id 
)

Add data movements to the appropriated module

Parameters
compute_or_memory_moduleompute_or_memory_module
lrefsrefs
load_codeoad_code
computational_or_emulatoromputational_or_emulator
var_idar_id

Definition at line 305 of file communications.c.

309 {
310  instruction i;
311  list ccode = constant_symbolic_communication(compute_or_memory_module,lrefs,
312  load_code,var_id);
313  /* Add data movements to the appropriated module */
314  i = statement_instruction(computational_or_emulator);
316 }

References constant_symbolic_communication(), gen_nconc(), instruction_block, and statement_instruction.

Referenced by call_to_wp65_code(), and loop_nest_to_wp65_code().

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

◆ insert_run_time_communications()

void insert_run_time_communications ( entity  compute_module,
entity  memory_module,
Pbase  bank_indices,
int  bn,
int  ls,
entity  proc_id,
list  list_statement_block,
statement_mapping  fetch_map,
statement_mapping  store_map,
list new_slst,
list new_blist,
hash_table  v_to_esv,
bool  fully_sequential,
Pbase  loop_indices,
tiling  tile,
Pvecteur  tile_delay,
Pvecteur  tile_indices,
Pvecteur  tile_local_indices 
)
Parameters
compute_moduleompute_module
memory_moduleemory_module
bank_indicesank_indices
bnn
lss
proc_idroc_id
list_statement_blockist_statement_block
fetch_mapetch_map
store_maptore_map
new_slstew_slst
new_blistew_blist
v_to_esv_to_esv
fully_sequentialully_sequential
loop_indicesoop_indices
tileile
tile_delayile_delay
tile_indicesile_indices
tile_local_indicesile_local_indices

Definition at line 639 of file communications.c.

647 {
648  int nbcall=0;
649  entity ent1=entity_undefined;
650 
651  MAPL(st1,
653  switch(instruction_tag(inst)) {
654  case is_instruction_block: {
655 
656  list new_slst1 = NIL;
657  nbcall = 0;
658  MAPL(st2, {
659  insert_run_time_communications(compute_module,memory_module,
660  bank_indices,bn,ls,proc_id,
661  CONS(STATEMENT,
662  STATEMENT(CAR(st2)),NIL),
663  fetch_map,store_map,
664  &new_slst1,new_blist,
665  v_to_esv,fully_sequential,
666  loop_indices,tile, tile_delay,
667  tile_indices,tile_local_indices);
668 
669 
670 },
671  instruction_block(inst));
672  instruction_block(inst)= new_slst1;
673  break; }
674  case is_instruction_loop: {
675  statement lbody = loop_body(instruction_loop(inst));
677  lbody,NIL));
678  cons *nbody=(instruction_call_p(statement_instruction(lbody))) ?
679  CONS(STATEMENT,sbody,NIL) :
680  CONS(STATEMENT,lbody,NIL);
681  insert_run_time_communications(compute_module,memory_module,
682  bank_indices,bn,ls,proc_id,
683  nbody,fetch_map,store_map,new_slst,
684  new_blist,
685  v_to_esv,fully_sequential,
686  loop_indices,tile, tile_delay,
687  tile_indices,tile_local_indices);
688  *new_slst = gen_nconc(*new_slst,
689  CONS(STATEMENT,STATEMENT(CAR(st1)),NIL));
690  break;
691  }
692  case is_instruction_call: {
693  list lt;
694 
695  if ((lt= (list)
696  GET_STATEMENT_MAPPING(fetch_map,STATEMENT(CAR(st1))))
697  != (list) HASH_UNDEFINED_VALUE && nbcall ) {
698 
699  ent1 = make_new_module_variable(compute_module,100);
700  AddEntityToDeclarations(ent1,compute_module);
701 
702  insert_array_scalar_access_movement(compute_module,memory_module,bank_indices,
703  bn,ls,proc_id,ent1,lt,STATEMENT(CAR(st1)),true,
704  v_to_esv,new_slst,new_blist,fully_sequential,
705  loop_indices,tile, tile_delay,tile_indices,
706  tile_local_indices
707  );
708  }
709  if ((lt=(list) GET_STATEMENT_MAPPING(store_map,
710  STATEMENT(CAR(st1))))
711  != (list) HASH_UNDEFINED_VALUE && nbcall )
712  {
713  ent1 = make_new_module_variable(compute_module,100);
714  AddEntityToDeclarations(ent1,compute_module);
715 
716  insert_array_scalar_access_movement(compute_module,memory_module,bank_indices,
717  bn,ls,proc_id,ent1,lt,STATEMENT(CAR(st1)),false,
718  v_to_esv,new_slst,new_blist,fully_sequential,
719  loop_indices,tile, tile_delay,tile_indices,
720  tile_local_indices);
721  }
722  *new_slst = gen_nconc(*new_slst,CONS(STATEMENT,STATEMENT(CAR(st1)),NIL));
723  nbcall ++;
724  break;
725  }
726  default:
727  break;
728  }
729  }, list_statement_block);
730 }
void insert_run_time_communications(entity compute_module, entity memory_module, Pbase bank_indices, int bn, int ls, entity proc_id, list list_statement_block, statement_mapping fetch_map, statement_mapping store_map, list *new_slst, list *new_blist, hash_table v_to_esv, bool fully_sequential, Pbase loop_indices, tiling tile, Pvecteur tile_delay, Pvecteur tile_indices, Pvecteur tile_local_indices)
static void insert_array_scalar_access_movement(entity compute_module, entity memory_module, Pbase bank_indices, int bn, int ls, entity proc_id, entity ent1, list lt, statement stat, bool load, hash_table v_to_esv, list *new_slst, list *new_blist, bool fully_sequential, Pbase loop_indices, tiling tile, Pvecteur tile_delay, Pvecteur tile_indices, Pvecteur tile_local_indices)
@ is_instruction_call
Definition: ri.h:1474
#define instruction_call_p(x)
Definition: ri.h:1527

References AddEntityToDeclarations(), CAR, CONS, entity_undefined, gen_nconc(), GET_STATEMENT_MAPPING, HASH_UNDEFINED_VALUE, insert_array_scalar_access_movement(), instruction_block, instruction_call_p, instruction_loop, instruction_tag, is_instruction_block, is_instruction_call, is_instruction_loop, loop_body, make_block_statement(), make_new_module_variable(), MAPL, NIL, STATEMENT, and statement_instruction.

Referenced by loop_nest_to_wp65_code().

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

◆ instruction_to_wp65_code()

void instruction_to_wp65_code ( entity  module,
list  l,
graph  dg,
int  pn,
int  bn,
int  ls,
int  pd,
entity  proc_id,
entity  proc_id_mm,
Pbase  bank_indices,
hash_table  v_to_esv,
hash_table  v_to_nlv,
entity  compute_module,
statement  computational,
entity  memory_module,
statement  emulator,
statement_mapping  fetch_map,
statement_mapping  store_map 
)

cms

FI: the semantics has been changed: the next two get_xxx() cannot/should not return something undefined.

if ((cme = get_current_module_entity()) == entity_undefined)

FI: already done somewhere else

set_current_module_entity(local_name_to_top_level_entity(module_local_name(module)));

if ((cms = get_current_module_statement()) == statement_undefined)

FI: shouldn't the current statement be retrieved at the same time as the current module?

reset_current_module_entity();

Parameters
moduleodule
dgg
pnn
bnn
lss
pdd
proc_idroc_id
proc_id_mmroc_id_mm
bank_indicesank_indices
v_to_esv_to_esv
v_to_nlv_to_nlv
compute_moduleompute_module
computationalomputational
memory_moduleemory_module
emulatormulator
fetch_mapetch_map
store_maptore_map

Definition at line 175 of file instruction_to_wp65_code.c.

182 {
183 
184  statement mod_stat/*,cms*/;
185  //entity cme;
186  debug_on("WP65_DEBUG_LEVEL");
187 
188  /* FI: the semantics has been changed: the next two get_xxx() cannot/should not return
189  * something undefined.
190  */
191  /* if ((cme = get_current_module_entity()) == entity_undefined) */
192  /* FI: already done somewhere else */
193  /* set_current_module_entity(local_name_to_top_level_entity(module_local_name(module))); */
194  /* if ((cms = get_current_module_statement()) == statement_undefined) */
195  /* FI: shouldn't the current statement be retrieved at the same time as the current module? */
197  db_get_memory_resource(DBR_CODE,
199  true) );
201  MAPL(pm,{
202  statement s1 = STATEMENT(CAR(pm));
204  ifdebug(9)
205  (void) fprintf(stderr,
206  "instruction_to_wp65_code-instruction- begin\n");
207  switch(instruction_tag(inst)) {
208 
209  case is_instruction_block:{
211  dg, pn, bn, ls, pd,
212  proc_id, proc_id_mm, bank_indices,
213  v_to_esv, v_to_nlv,
214  compute_module, computational,
215  memory_module, emulator,
216  fetch_map,store_map);
217 
218  break;}
219  case is_instruction_test: {
220  (void) fprintf(stderr,
221  "instruction_to_wp65_code-Sorry:test not implemented\n");
222  break;}
223  case is_instruction_goto: {
224  (void) fprintf(stderr,
225  "instruction_to_wp65_cod -Sorry:goto implemented\n");
226  break;}
227  case is_instruction_loop: {
228  loop_nest_to_wp65_code(module, s1, dg, pn, bn, ls, pd,
229  proc_id, proc_id_mm, bank_indices,
230  v_to_esv, v_to_nlv,
231  compute_module, computational,
232  memory_module, emulator,
233  fetch_map,store_map,mod_stat);
234  break;}
235  case is_instruction_call: {
236  if (!return_statement_p(s1)) {
237 
238  call_to_wp65_code(s1,compute_module,
239  memory_module,
240  (entity) bank_indices->var,proc_id,
241  computational,emulator, fetch_map,
242  store_map,v_to_esv);
243  }
244  break;
245  }
247  pips_internal_error("Sorry: unstructured not implemented");
248  break;}
249  default:
250  (void) fprintf(stderr,
251  " instruction_to_wp65_code- bad instruction tag \n");
252  break;
253  }
254  ifdebug(9)
255  (void) fprintf(stderr,
256  "instruction_to_wp65_code-instruction_end \n");
257  },l);
258  /* reset_current_module_entity(); */
260  debug_off();
261 }
void reset_current_module_statement(void)
Reset the current module statement.
Definition: static.c:221
statement set_current_module_statement(statement)
Set the current module statement.
Definition: static.c:165
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
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
bool return_statement_p(statement)
Test if a statement is a C or Fortran "return".
Definition: statement.c:172
void loop_nest_to_wp65_code(entity module, statement loop_nest, graph dg, int pn, int bn, int ls, int pd, entity proc_id, entity proc_id_mm, Pbase bank_indices, hash_table v_to_esv, hash_table v_to_nlv, entity compute_module, statement computational, entity memory_module, statement emulator, statement_mapping fetch_map, statement_mapping store_map, statement mod_stat)
void instruction_to_wp65_code(entity module, list l, graph dg, int pn, int bn, int ls, int pd, entity proc_id, entity proc_id_mm, Pbase bank_indices, hash_table v_to_esv, hash_table v_to_nlv, entity compute_module, statement computational, entity memory_module, statement emulator, statement_mapping fetch_map, statement_mapping store_map)
void call_to_wp65_code(statement s, entity compute_module, entity memory_module, entity bank_id, entity proc_id, statement computational, statement emulator, statement_mapping fetch_map, statement_mapping store_map, hash_table v_to_esv)
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160
@ is_instruction_goto
Definition: ri.h:1473
@ is_instruction_unstructured
Definition: ri.h:1475
@ is_instruction_test
Definition: ri.h:1470

References call_to_wp65_code(), CAR, db_get_memory_resource(), debug_off, debug_on, dg, fprintf(), get_current_module_statement(), ifdebug, instruction_block, instruction_tag, is_instruction_block, is_instruction_call, is_instruction_goto, is_instruction_loop, is_instruction_test, is_instruction_unstructured, loop_nest_to_wp65_code(), MAPL, mod_stat, module, module_local_name(), pips_internal_error, reset_current_module_statement(), return_statement_p(), s1, set_current_module_statement(), STATEMENT, statement_instruction, and Svecteur::var.

Referenced by module_to_wp65_modules().

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

◆ io_loop_nest_p()

bool io_loop_nest_p ( statement  st)

Test if the statement resulting from the perfectly_loop_nest_to_body function contains at first call an io.

Parameters
stt

Definition at line 467 of file instruction_to_wp65_code.c.

468 {
470  call c;
471  if (instruction_block_p(inst)) {
472  list b = instruction_block(inst);
474  }
475  else
476  c= instruction_call(inst);
477  return (strcmp(entity_local_name(call_function(c)), "WRITE") == 0) ;
478 }

References call_function, CAR, entity_local_name(), instruction_block, instruction_block_p, instruction_call, STATEMENT, and statement_instruction.

Referenced by loop_nest_to_wp65_code().

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

◆ iteration_domain_from_statement()

void iteration_domain_from_statement ( list list_loop_statement,
statement  s,
int nested_level,
list blocks,
instruction inst 
)

case where there is a unique assignment in do-enddo loop nest

Parameters
list_loop_statementist_loop_statement
nested_levelested_level
blockslocks
instnst

Definition at line 116 of file find_iteration_domain.c.

122 {
123  instruction i;
124  cons *b;
125  loop l;
126  debug(8, "iteration_domain_from_statement", "begin\n");
127 
128  i = statement_instruction(s);
129  switch (instruction_tag(i)) {
130 
131  case is_instruction_loop:
132  l = instruction_loop(i);
133  *list_loop_statement = CONS (STATEMENT,s,*list_loop_statement);
134  iteration_domain_from_statement(list_loop_statement,loop_body(l),
135  nested_level,
136  blocks,inst);
137  break;
138 
139  case is_instruction_block: {
140  int nbl = 0;
141  bool simple_block = false;
142  b= instruction_block(i);
143  nbl = gen_length((list) b);
144  simple_block = (nbl==1
145  || (nbl ==2 && continue_statement_p(STATEMENT(CAR(CDR(b))))))
146  ? true : false;
147 
148  if (simple_block && instruction_loop_p(statement_instruction(STATEMENT(CAR(b)))))
149  iteration_domain_from_statement(list_loop_statement,
150  STATEMENT(CAR(b))
151  ,nested_level, blocks,inst);
152  else {
153  *nested_level = gen_length(*list_loop_statement);
154  *inst = i;
155  *blocks = b;
156  }
157 
158  break;
159  }
160  case is_instruction_call: {
161  /* case where there is a unique assignment in do-enddo loop nest*/
162  *nested_level = gen_length(*list_loop_statement);
164  *blocks =CONS(STATEMENT,s,NIL);
165  return;
166  }
167 
168  case is_instruction_test:
169  return;
170 
172  return;
173 
174  case is_instruction_goto:
175  pips_internal_error("unexpected goto in code");
176  default:
177  pips_internal_error("unexpected tag");
178  }
179 
180  debug(8, "search_array_from_statement", "end\n");
181 }
static list blocks
lisp of loops
void iteration_domain_from_statement(list *list_loop_statement, statement s, int *nested_level, list *blocks, instruction *inst)
instruction make_instruction_block(list statements)
Build an instruction block from a list of statements.
Definition: instruction.c:106
bool continue_statement_p(statement)
Test if a statement is a CONTINUE, that is the FORTRAN nop, the ";" in C or the "pass" in Python....
Definition: statement.c:203
#define true
Definition: newgen_types.h:81
#define instruction_loop_p(x)
Definition: ri.h:1518

References blocks, CAR, CDR, CONS, continue_statement_p(), debug(), gen_length(), instruction_block, instruction_loop, instruction_loop_p, instruction_tag, is_instruction_block, is_instruction_call, is_instruction_goto, is_instruction_loop, is_instruction_test, is_instruction_unstructured, loop_body, make_instruction_block(), NIL, pips_internal_error, STATEMENT, statement_instruction, and true.

Referenced by find_iteration_domain().

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

◆ ith_index_of_ref()

entity ith_index_of_ref ( reference  r,
int  level 
)
Parameters
levelevel

Definition at line 146 of file instruction_to_wp65_code.c.

147 {
148  entity result = entity_undefined;
149  list ith_index=reference_indices(r);
150  expression exp_ind = EXPRESSION(gen_nth(level,ith_index));
151  syntax sy = expression_syntax(exp_ind);
152  if (syntax_reference_p(sy))
153  result = reference_variable(syntax_reference(sy));
154  return (result);
155 }
gen_chunk gen_nth(int n, const list l)
to be used as ENTITY(gen_nth(3, l))...
Definition: list.c:710
#define syntax_reference_p(x)
Definition: ri.h:2728
#define level

References entity_undefined, EXPRESSION, expression_syntax, gen_nth(), level, reference_indices, reference_variable, syntax_reference, and syntax_reference_p.

+ Here is the call graph for this function:

◆ ith_loop_in_loop_nest()

loop ith_loop_in_loop_nest ( statement  s1,
int  level 
)
Parameters
s11
levelevel

Definition at line 158 of file instruction_to_wp65_code.c.

159 {
161  loop loop1;
162  if (instruction_block_p(inst)) {
164  inst = statement_instruction(st1);
165  }
166  loop1 = instruction_loop(inst);
167  return((level ==1) ? loop1 :
169 
170 }
loop loop1
tiling_sequence.c

References CAR, instruction_block, instruction_block_p, instruction_loop, level, loop1, loop_body, s1, STATEMENT, and statement_instruction.

Referenced by generate_io_wp65_code().

+ Here is the caller graph for this function:

◆ list_of_calls_p()

bool list_of_calls_p ( list  lsb)

instruction_to_wp65_code.c

Parameters
lsbsb

Definition at line 136 of file instruction_to_wp65_code.c.

137 {
138  list pl;
139  for(pl=lsb;
141  pl = CDR(pl));
142  return(pl==NIL);
143 }
bool statement_call_p(statement)
Definition: statement.c:364

References CAR, CDR, NIL, pl, STATEMENT, and statement_call_p().

Referenced by concat_data_list(), and loop_nest_to_wp65_code().

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

◆ load_statement_fetch()

list load_statement_fetch ( statement  )

◆ load_statement_store()

list load_statement_store ( statement  )

◆ loop_instruction_to_communications()

void loop_instruction_to_communications ( statement  stmt,
statement  st_level1,
statement  st_level2,
list lwr,
list lwr_local,
statement_mapping fetch_map,
statement_mapping store_map,
hash_table  r_to_ud,
list lpv 
)

This function associates to each variable in the loop the statement where it should be communicated (this statement may be external to the loop).

Parameters
stmttmt
st_level1t_level1
st_level2t_level2
lwrwr
lwr_localwr_local
fetch_mapetch_map
store_maptore_map
r_to_ud_to_ud
lpvpv

Definition at line 150 of file communications.c.

154 {
158  reference_list_add(lwr, lwr_local);
161  NIL));
162  *lwr_local = NIL;
163  *lpv=loop_locals(instruction_loop(inst));
164 
165  switch(instruction_tag(inst2)) {
166  case is_instruction_block:
167  st_level2 = STATEMENT(CAR(instruction_block(inst)));
168  break;
169  case is_instruction_call:
170  st_level2 =b;
171  break;
172  default:
173  (void) fprintf(stderr,
174  "loop_instruction_to_communications: non implemented case \n");
175  break;
176  }
177  statement_to_communications(b,st_level1, st_level2,
178  lwr,lwr_local,
179  fetch_map,store_map,r_to_ud,lpv);
180 
181 }
struct _newgen_struct_instruction_ * instruction
Definition: ri.h:207
#define loop_locals(x)
Definition: ri.h:1650
#define loop_index(x)
Definition: ri.h:1640
Definition: statement.c:54

References CAR, fprintf(), instruction_block, instruction_loop, instruction_tag, is_instruction_block, is_instruction_call, loop_body, loop_index, loop_locals, make_reference(), NIL, reference_list_add(), reference_list_update(), STATEMENT, statement_instruction, and statement_to_communications().

Referenced by statement_to_communications().

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

◆ loop_nest_movement_generation()

void loop_nest_movement_generation ( entity  module,
statement  loop_nest,
int  pn,
int  bn,
int  ls,
int  pd,
entity  proc_id,
entity  proc_id_mm,
Pbase  bank_indices,
hash_table  v_to_esv,
hash_table  v_to_nlv,
entity  compute_module,
statement  computational,
entity  memory_module,
statement  emulator,
statement_mapping  fetch_map,
statement_mapping  store_map,
statement  mod_stat,
bool  fully_parallel,
Psysteme  sc_tile,
Pbase  initial_basis,
Pbase  local_basis,
Pbase  local_basis2,
Pbase  tile_basis_in_tile_basis,
Pbase  tile_basis_in_tile_basis2,
Pbase  loop_body_indices,
list  lpv,
list lb,
list blb,
list sb,
list bsb,
int  first_parallel_level,
int  last_parallel_level,
hash_table  llv_to_lcr,
hash_table  r_to_llv,
hash_table  v_to_lllv,
hash_table  r_to_ud 
)

the list of data having to be store into the global memory is the concatenation of store_map sets of the internal loops

update of variable names according to the module of appartenance

Parameters
moduleodule
loop_nestoop_nest
pnn
bnn
lss
pdd
proc_idroc_id
proc_id_mmroc_id_mm
bank_indicesank_indices
v_to_esv_to_esv
v_to_nlv_to_nlv
compute_moduleompute_module
computationalomputational
memory_moduleemory_module
emulatormulator
fetch_mapetch_map
store_maptore_map
mod_statod_stat
fully_parallelully_parallel
sc_tilec_tile
initial_basisnitial_basis
local_basisocal_basis
local_basis2ocal_basis2
tile_basis_in_tile_basisile_basis_in_tile_basis
tile_basis_in_tile_basis2ile_basis_in_tile_basis2
loop_body_indicesoop_body_indices
lpvpv
lbb
blblb
sbb
bsbsb
first_parallel_levelirst_parallel_level
last_parallel_levelast_parallel_level
llv_to_lcrlv_to_lcr
r_to_llv_to_llv
v_to_lllv_to_lllv
r_to_ud_to_ud

Definition at line 483 of file instruction_to_wp65_code.c.

521 {
522  pips_assert("true", pd==pd
523  && proc_id_mm==proc_id_mm
524  &&v_to_nlv==v_to_nlv
525  && emulator==emulator
526  && mod_stat==mod_stat
527  && r_to_llv==r_to_llv
528  && computational==computational);
529 
530  list fetch_data_list =NIL;
531  list store_data_list = NIL;
532  list fetch_reference_list = NIL;
533  list store_reference_list = NIL;
534  debug_on("WP65_DEBUG_LEVEL");
535  /* the list of data having to be store into the global memory
536  is the concatenation of store_map sets of the internal loops */
537 
538  concat_data_list(&fetch_data_list,&fetch_reference_list,
539  loop_nest,fetch_map,fully_parallel);
540  concat_data_list(&store_data_list , &store_reference_list ,
541  loop_nest,store_map,fully_parallel);
542  MAPL(r1,{ entity rv = (entity) reference_variable(REFERENCE(CAR(r1)));
543  if(!entity_is_argument_p(rv, lpv))
545  module,compute_module,memory_module,
546  rv,fetch_reference_list,
547  llv_to_lcr, v_to_lllv,r_to_ud, v_to_esv,
548  pn,bn, ls,
549  sc_tile, initial_basis, local_basis,
550  proc_id, bank_indices,loop_body_indices,
551  lb, blb,is_action_read,first_parallel_level,
552  last_parallel_level);
553  },
554  fetch_data_list);
555  /* update of variable names according to the module of appartenance */
556  sc_variables_rename(sc_tile,local_basis2,local_basis, (string(*)(void*))entity_local_name);
557  sc_variables_rename(sc_tile, tile_basis_in_tile_basis2,
558  tile_basis_in_tile_basis,(string(*)(void*))entity_local_name);
559  MAPL(r1,{
560  reference rf = REFERENCE(CAR(r1));
561  entity rv = (entity) reference_variable(rf);
562  if (!reference_scalar_p(rf) && !entity_is_argument_p(rv, lpv))
563  make_all_movement_blocks(module,compute_module,memory_module,
564  rv,store_reference_list ,
565  llv_to_lcr, v_to_lllv, r_to_ud, v_to_esv,
566  pn,bn, ls,
567  sc_tile, initial_basis, local_basis,
568  proc_id, bank_indices, loop_body_indices,
569  sb, bsb, is_action_write,
570  first_parallel_level,
571  last_parallel_level);
572  },
573  store_data_list);
574  debug_off();
575 }
@ is_action_write
Definition: effects.h:293
void make_all_movement_blocks(entity initial_module, entity compute_module, entity memory_module, entity v, list map, hash_table llv_to_lcr, hash_table v_to_lllv, hash_table r_to_ud, hash_table v_to_esv, int pn, int bn, int ls, Psysteme iteration_domain, Pbase initial_basis, Pbase local_basis, entity proc_id, Pbase bank_indices, Pbase loop_body_indices, list *pmb, list *pbmb, tag use_def, int first_parallel_level, int last_parallel_level)
generates all data movements related to entity v, loads or stores depending on use_def
Psysteme sc_variables_rename(Psysteme s, Pvecteur pv_old, Pvecteur pv_new, get_variable_name_t variable_name)
Psysteme sc_variables_rename(Psysteme s, Pvecteur pv_old, Pvecteur pv_new): reecriture du systeme s r...
Definition: sc.c:224
Definition: statement.c:4047

References CAR, concat_data_list(), debug_off, debug_on, entity_is_argument_p(), entity_local_name(), is_action_read, is_action_write, make_all_movement_blocks(), MAPL, mod_stat, module, NIL, pips_assert, REFERENCE, reference_scalar_p(), reference_variable, and sc_variables_rename().

Referenced by loop_nest_to_wp65_code().

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

◆ loop_nest_to_local_variables()

void loop_nest_to_local_variables ( entity  initial_module,
entity  compute_module,
entity  memory_module,
hash_table  llv_to_lcr,
hash_table  r_to_llv,
hash_table  v_to_lllv,
hash_table  r_to_ud,
hash_table  v_to_esv,
hash_table  v_to_nlv,
list  lpv,
statement  body,
Pbase  indices,
graph  dg,
int  bn,
int  ls,
int  pd,
tiling  tile 
)

variable.c

variable.c

loop_nest_to_local_variables():

Key function allocating local copies according to interferences between references. It also gather information about references (which is also indirectly available in the effect information), allocate emulated shared variables, and create different mappings between local variables and references.

pips_assert("loop_nest_to_local_variables", instruction_block_p(instr));

first reference in statement s

there are only two expressions to loop over: the lhs and the rhs

FI: local variable dimensions should be set later by the caller so as to use the clustering performed here to compute space complexity, to use space complexity to define the tiling and to use the tiling to define the dimensions

Parameters
initial_modulenitial_module
compute_moduleloop_nest_to_local_variables():

Key function allocating local copies according to interferences between references. It also gather information about references (which is also indirectly available in the effect information), allocate emulated shared variables, and create different mappings between local variables and references. initial module: achtung, this arg. is not used!?!

Parameters
memory_moduleloop_nest_to_local_variables():

Key function allocating local copies according to interferences between references. It also gather information about references (which is also indirectly available in the effect information), allocate emulated shared variables, and create different mappings between local variables and references. compute module

Parameters
llv_to_lcrloop_nest_to_local_variables():

Key function allocating local copies according to interferences between references. It also gather information about references (which is also indirectly available in the effect information), allocate emulated shared variables, and create different mappings between local variables and references. memory module

Parameters
r_to_llvloop_nest_to_local_variables():

Key function allocating local copies according to interferences between references. It also gather information about references (which is also indirectly available in the effect information), allocate emulated shared variables, and create different mappings between local variables and references. local variable to list of conflicting references

Parameters
v_to_lllvloop_nest_to_local_variables():

Key function allocating local copies according to interferences between references. It also gather information about references (which is also indirectly available in the effect information), allocate emulated shared variables, and create different mappings between local variables and references. reference to list of local variables

Parameters
r_to_udloop_nest_to_local_variables():

Key function allocating local copies according to interferences between references. It also gather information about references (which is also indirectly available in the effect information), allocate emulated shared variables, and create different mappings between local variables and references. variable to list of lists of local variables

Parameters
v_to_esvloop_nest_to_local_variables():

Key function allocating local copies according to interferences between references. It also gather information about references (which is also indirectly available in the effect information), allocate emulated shared variables, and create different mappings between local variables and references. reference to use def

Parameters
v_to_nlvloop_nest_to_local_variables():

Key function allocating local copies according to interferences between references. It also gather information about references (which is also indirectly available in the effect information), allocate emulated shared variables, and create different mappings between local variables and references. variable to emulated shared variable

Parameters
lpvloop_nest_to_local_variables():

Key function allocating local copies according to interferences between references. It also gather information about references (which is also indirectly available in the effect information), allocate emulated shared variables, and create different mappings between local variables and references. variable to number of associated local variables (local to this procedure)

Parameters
bodyloop_nest_to_local_variables():

Key function allocating local copies according to interferences between references. It also gather information about references (which is also indirectly available in the effect information), allocate emulated shared variables, and create different mappings between local variables and references. private variables

Parameters
indicesndices
dgg
bnn
lss
pdd
tileile

Definition at line 80 of file variable.c.

103 {
104  pips_assert("true", initial_module==initial_module);
105  list block;
106  instruction instr = statement_instruction(body);
107 
108  debug(6,"loop_nest_to_local_variables","begin\n");
109 
110  ifdebug(5) {
111  (void) fprintf(stderr,"Private variables:");
112  print_entities(lpv);
113  }
114 
115 /* pips_assert("loop_nest_to_local_variables",
116  instruction_block_p(instr));*/
117 
118  if (instruction_call_p(instr))
119  block = CONS(STATEMENT,body,NIL);
120  else block = instruction_block(instr);
121 
122  for( ;!ENDP(block); POP(block)) {
124 
125  if(assignment_statement_p(s)) {
127  /* first reference in statement s */
128  bool first_reference = true;
129  /* there are only two expressions to loop over: the lhs and the
130  rhs */
131  for(; !ENDP(lexpr); POP(lexpr)) {
132  expression e = EXPRESSION(CAR(lexpr));
134  list consr;
135 
136  ifdebug(7) {
137  (void) fprintf(stderr, "reference list:");
139  (void) fprintf(stderr, "first_reference=%s\n",
140  bool_to_string(first_reference));
141  }
142 
143  for(consr = lr; !ENDP(consr) ; POP(consr)) {
144  reference r = REFERENCE(CAR(consr));
145  entity rv = reference_variable(r);
146 
147  if(entity_is_argument_p(rv, lpv) || reference_indices(r) ==NIL) {
148  debug(7,"loop_nest_to_local_variables",
149  "Variable %s is private\n",
150  entity_local_name(rv));
151 
152  first_reference = false;
153  }
154  else {
155  hash_put(r_to_ud, r,
156  (void*)(intptr_t)(first_reference?
158  first_reference = false;
160  v_to_lllv,
161  llv_to_lcr,
162  r_to_llv,
163  r_to_ud)) {
164  entity v = reference_variable(r);
165  intptr_t n;
166  list llv;
167  (void) find_or_create_emulated_shared_variable(v, memory_module,
168  v_to_esv,
169  bn, ls);
170  if((n = (intptr_t) hash_get(v_to_nlv, (char *) v))
172  n = 0;
173  llv = make_new_local_variables(v, compute_module, n, pd,
174  v_to_lllv);
175  hash_put(llv_to_lcr, llv,
176  CONS(REFERENCE, r, NIL));
177  hash_put(r_to_llv, r, llv);
178  hash_put(v_to_nlv, v, (void*)(n+1));
179  }
180  }
181  }
182  gen_free_list(lr);
183  }
184  }
185  }
186  /* FI: local variable dimensions should be set later by the caller
187  so as to use the clustering performed here to compute space
188  complexity, to use space complexity to define the tiling and
189  to use the tiling to define the dimensions */
190  set_dimensions_of_local_variables(v_to_lllv, indices, tile, llv_to_lcr);
191 
192  debug(6,"loop_nest_to_local_variables","end\n");
193 }
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
static list indices
Definition: icm.c:204
void set_dimensions_of_local_variables(hash_table v_to_lllv, Pbase basis, tiling tile, hash_table llv_to_lcr)
Definition: variable.c:652
list make_new_local_variables(entity v, entity compute_module, int number, int pd, hash_table v_to_lllv)
Definition: variable.c:310
bool reference_conflicting_test_and_update(reference r, graph dg, hash_table v_to_lllv, hash_table llv_to_lcr, hash_table r_to_llv, hash_table r_to_ud)
reference_conflicting_test_and_update():
Definition: variable.c:401
entity find_or_create_emulated_shared_variable(entity v, entity memory_module, hash_table v_to_esv, int bn, int ls)
Definition: variable.c:284
void print_entities(list l)
Definition: entity.c:167
struct block block

References assignment_statement_p(), bool_to_string(), call_arguments, CAR, CONS, debug(), dg, ENDP, entity_is_argument_p(), entity_local_name(), EXPRESSION, expression_to_reference_list(), find_or_create_emulated_shared_variable(), fprintf(), gen_free_list(), hash_get(), hash_put(), HASH_UNDEFINED_VALUE, ifdebug, indices, instruction_block, instruction_call, instruction_call_p, intptr_t, is_action_read, is_action_write, make_new_local_variables(), NIL, pips_assert, POP, print_entities(), print_reference_list(), REFERENCE, reference_conflicting_test_and_update(), reference_indices, reference_variable, set_dimensions_of_local_variables(), STATEMENT, and statement_instruction.

Referenced by loop_nest_to_wp65_code().

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

◆ loop_nest_to_tile()

tiling loop_nest_to_tile ( Psysteme  sc,
int  ls,
Pbase  base_index,
int  first_parallel_level,
int  last_parallel_level,
int  perfect_nested_level 
)

tiling.c

tiling.c

Functions to decide a specific tiling for a loop nest

File: tiling.c

PUMA, ESPRIT contract 2701

Francois Irigoin, Corinne Ancourt, Lei Zhou 1991 loop_nest_to_tile():

Because the number of elements per bank ligne is usefull to optimize the tiling, parameter ls is used temporarily to build it. Because ls is the number of bytes of each bank ligne, it is divided by the assumed number of bytes needed for the
location of one element (4 for int and real)

build the diagonal matrix: ls x I

build origin tile vector as the first iteration to minimize the number of partial tiles (heuristics)

vect_chg_coeff(&porigin,var,min);

Parameters
scc
lss
base_indexase_index
first_parallel_levelirst_parallel_level
last_parallel_levelast_parallel_level
perfect_nested_levelerfect_nested_level

Definition at line 58 of file tiling.c.

65 {
66 
67  tiling tile;
68  matrice M;
69  Pvecteur porigin = VECTEUR_NUL;
70  Pvecteur pv;
71  int vs = vect_size((Pvecteur)(base_index));
72  Psysteme sc_proj;
73  Value min,max;
74  bool faisable;
75  int i;
76 
77  /* Because the number of elements per bank ligne is usefull to
78  optimize the tiling, parameter ls is used temporarily to build it.
79  Because ls is the number of bytes of each bank ligne, it is
80  divided by the assumed number of bytes needed for the
81  location of one element (4 for int and real) */
82 
83  int lsd = ls/4;
84 
85  /* build the diagonal matrix: ls x I */
86 
87  M = matrice_new(vs,vs);
88  matrice_nulle(M,vs,vs);
89  for (i =1; i<= vs && i < first_parallel_level; i++)
90  ACCESS(M,vs,i,i) = VALUE_ONE;
91  for (; i<= vs && i <= last_parallel_level; i++)
92  ACCESS(M,vs,i,i) = int_to_value(lsd);
93  for (i = MIN(perfect_nested_level+1,last_parallel_level+1); i<= vs; i++)
94  ACCESS(M,vs,i,i) = VALUE_CONST(999);
95 
96 
97  /* build origin tile vector as the first iteration to minimize
98  the number of partial tiles (heuristics) */
99 
100  for (pv = base_index; !VECTEUR_NUL_P(pv); pv = pv->succ) {
101  Variable var = vecteur_var(pv);
102  sc_proj = sc_dup(sc);
103  faisable = sc_minmax_of_variable(sc_proj,var, &min, &max);
104  if (faisable)
105  /* vect_chg_coeff(&porigin,var,min);*/
106  vect_chg_coeff(&porigin,var,VALUE_ONE);
107  else
108  pips_internal_error("illegal empty iteration domain");
109 
110  }
111 
112  tile = make_tiling(M, porigin);
113  return tile;
114 }
tiling make_tiling(matrice a1, Pvecteur a2)
Definition: tiling.c:56
#define int_to_value(i)
end LINEAR_VALUE_IS_INT
#define VALUE_CONST(val)
#define MIN(x, y)
minimum and maximum if they are defined somewhere else, they are very likely to be defined the same w...
#define max(a, b)
#define ACCESS(matrix, column, i, j)
Macros d'acces aux elements d'une matrice.
Definition: matrice-local.h:86
#define matrice_new(n, m)
Allocation et desallocation d'une matrice.
Definition: matrice-local.h:77
Value * matrice
package matrice
Definition: matrice-local.h:71
void matrice_nulle(matrice Z, int n, int m)
void matrice_nulle(matrice Z, int n, int m): Initialisation de la matrice Z a la valeur matrice nulle
Definition: matrice.c:311
bool sc_minmax_of_variable(Psysteme ps, Variable var, Value *pmin, Value *pmax)
void sc_minmax_of_variable(Psysteme ps, Variable var, Value *pmin, *pmax): examine un systeme pour tr...
Definition: sc_eval.c:143

References ACCESS, int_to_value, make_tiling(), matrice_new, matrice_nulle(), max, min, MIN, pips_internal_error, sc_dup(), sc_minmax_of_variable(), Svecteur::succ, VALUE_CONST, VALUE_ONE, vect_chg_coeff(), vect_size(), VECTEUR_NUL, VECTEUR_NUL_P, and vecteur_var.

Referenced by loop_nest_to_wp65_code().

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

◆ loop_nest_to_wp65_code()

void loop_nest_to_wp65_code ( entity  module,
statement  loop_nest,
graph  dg,
int  pn,
int  bn,
int  ls,
int  pd,
entity  proc_id,
entity  proc_id_mm,
Pbase  bank_indices,
hash_table  v_to_esv,
hash_table  v_to_nlv,
entity  compute_module,
statement  computational,
entity  memory_module,
statement  emulator,
statement_mapping  fetch_map,
statement_mapping  store_map,
statement  mod_stat 
)

load block

bank load block

store block

bank store block

compute block

list of local variables to list of conflicting references

inverse table: list of local variables to use for a given reference

variable to list of list of local variables: the main list is an image of connected components of the dependence graph filtered for a given variable, v; the low-level list is a function of the number of pipeline stages

reference to use-def usage ; use and def are encoded as action_is_read and action_is_write

pipelining offset; no pipelining is implemented yet

private variables for the loop nest

local variables

pour eviter tous les problemes de tiling sur les nids de boucles internes a des nids de boucles mal imbriques on execute les boucles internes en sequentiel. Il faudrait autrement s'assurer que l'on a les meme indices de boucles en interne pour le tiling et que les bornes sont identiques (meme restrictions que pour du loop fusion)

creation of new indices

a modifie pour tenir compte des dimensions reelles des domaines

normalement full_initila_basis == initial_basis2

a modifie pour tenir compte des dimensions reelles des domaines

put together the different pieces of code as two lists of statements

add the scanning over the tiles around them to build a proper stmt

update computational and emulator with cs and ems

Parameters
moduleodule
loop_nestoop_nest
dgg
pnn
bnn
lss
pdd
proc_idroc_id
proc_id_mmroc_id_mm
bank_indicesank_indices
v_to_esv_to_esv
v_to_nlv_to_nlv
compute_moduleompute_module
computationalomputational
memory_moduleemory_module
emulatormulator
fetch_mapetch_map
store_maptore_map
mod_statod_stat

Definition at line 579 of file instruction_to_wp65_code.c.

599 {
600 
601  Psysteme iteration_domain = sc_new();
602  Psysteme iteration_domain2 = sc_new();
603  Psysteme sc_tile = SC_UNDEFINED;
604  tiling tile;
605  Pvecteur tile_delay = VECTEUR_NUL;
606  Pvecteur pv;
607  int it;
608  list lb = NIL; /* load block */
609  list blb = NIL; /* bank load block */
610  list sb = NIL; /* store block */
611  list bsb = NIL; /* bank store block */
612  list cb = NIL; /* compute block */
613  /* list of local variables to list of conflicting references */
614  hash_table llv_to_lcr = hash_table_make(hash_pointer, 0);
615  /* inverse table: list of local variables to use for a given reference */
616  hash_table r_to_llv = hash_table_make(hash_pointer, 0);
617  /* variable to list of list of local variables: the main list
618  is an image of connected components of the dependence graph filtered
619  for a given variable, v; the low-level list is a function of
620  the number of pipeline stages */
621  hash_table v_to_lllv = hash_table_make(hash_pointer,0);
622  /* reference to use-def usage ; use and def are encoded as action_is_read
623  and action_is_write */
625 
626  /* pipelining offset; no pipelining is implemented yet */
627  Pbase offsets = VECTEUR_NUL;
628  statement body;
629 
630  /* private variables for the loop nest */
632 
633  /* local variables */
634  list cbl, embl = NIL;
635  statement cs, ems,bs;
637  instruction i;
638  list store_data_list = NIL;
639  list store_reference_list = NIL;
640  Pbase initial_basis = BASE_NULLE;
641  Pbase full_initial_basis = BASE_NULLE;
642  Pbase local_basis = BASE_NULLE;
643  Pbase tile_basis_in_initial_basis = BASE_NULLE;
644  Pbase tile_basis_in_tile_basis = BASE_NULLE;
645  Pbase local_basis2 = BASE_NULLE;
646  Pbase initial_basis2= BASE_NULLE;
647  Pbase tile_basis_in_tile_basis2 = BASE_NULLE;
648  Pbase loop_body_indices = BASE_NULLE;
649  int i1,lpl, loop_nest_dimt;
650  int first_parallel_level=1;
651  int last_parallel_level, perfect_nested_loop_size;
652  bool loop_carried_dep[11];
653  bool fully_parallel;
654  bool fully_sequential=true;
655  int nested_level2,nested_level=0;
656  list list_statement_block=NIL;
657  list list_statement_block2=NIL;
658  list new_compute_lst = NIL;
659  list new_bank_lst = NIL;
660  instruction binst,binst2;
661  bool io_statementp=false;
662 
663  debug_on("WP65_DEBUG_LEVEL");
664  debug(5,"loop_nest_to_wp65_code", "begin\n");
665 
666  for (i1=1;i1<=10;i1++) loop_carried_dep[i1] = false;
667  compute_loop_nest_dim(loop_nest);
668  loop_nest_dimt = loop_nest_dim;
669 
670 
671  fully_parallel = full_parallel_loop_nest_p(mod_stat,loop_nest,
672  loop_nest_dimt,dg,
673  loop_carried_dep);
674  find_iteration_domain(loop_nest,&iteration_domain, &initial_basis,
675  &nested_level,&list_statement_block, &binst);
676  full_initial_basis = base_dup(initial_basis);
677  perfect_nested_loop_size= vect_size(initial_basis);
678 
679  /* pour eviter tous les problemes de tiling sur les nids de boucles
680  internes a des nids de boucles mal imbriques on execute les boucles
681  internes en sequentiel. Il faudrait autrement s'assurer que l'on a
682  les meme indices de boucles en interne pour le tiling et que les
683  bornes sont identiques (meme restrictions que pour du loop fusion) */
684 
685  for (i1=perfect_nested_loop_size+1;i1<=10;i1++)
686  loop_carried_dep[i1] = true;
687  assert(perfect_nested_loop_size <=10);
688 
689  last_parallel_level =perfect_nested_loop_size+1;
690  if (!fully_parallel) {
691  for (i1=1; i1<=loop_nest_dimt && (loop_carried_dep[i1] == true);
692  i1++);
693  first_parallel_level = i1;
694  for (i1=first_parallel_level;
695  i1<=loop_nest_dimt && (loop_carried_dep[i1] == false);i1++);
696  last_parallel_level = i1-1;
697  for (it=1, pv=initial_basis;
698  it <perfect_nested_loop_size && it<last_parallel_level;
699  it++, pv=pv->succ);
700  loop_body_indices = base_dup(pv->succ);
701  ifdebug(4) {
702  (void) fprintf(stderr,"first_parallel_level :%d, last_parallel_level %d\n",
703  first_parallel_level,last_parallel_level);
704  (void) fprintf(stderr,"\nLoop body basis - loop_nest:");
705  base_fprint(stderr, loop_body_indices, (string(*)(void*))entity_local_name);
706  (void) fprintf(stderr,"\nInitial basis - loop_nest:");
707  base_fprint(stderr, initial_basis, (string(*)(void*))entity_local_name);
708  }
709  }
710 
711  /* creation of new indices */
712  create_tile_basis(module,compute_module,memory_module, initial_basis,
713  &tile_basis_in_initial_basis,
714  &tile_basis_in_tile_basis,
715  &local_basis,
716  &tile_basis_in_tile_basis2,
717  &local_basis2);
718  lpl = (fully_parallel) ? last_parallel_level-1:last_parallel_level;
719  tile = loop_nest_to_tile(iteration_domain, ls,
720  initial_basis, first_parallel_level,lpl,
721  perfect_nested_loop_size);
722 
723  sc_tile = loop_bounds_to_tile_bounds(iteration_domain,initial_basis,
724  tile, tile_delay,
725  tile_basis_in_tile_basis,
726  local_basis);
727 
728  ifdebug(8) {
729  fprintf(stderr,"loop body \n");
731  list_statement_block);
732  }
733  if (list_of_calls_p(list_statement_block)) {
734  body = perfectly_nested_loop_to_body(loop_nest);
735 
736  if (io_loop_nest_p(body)) {
737  io_st = generate_io_wp65_code(loop_nest,body,v_to_esv,true);
738  io_statementp = true;}
739  else {
740 
741  /* a modifie pour tenir compte des dimensions reelles des domaines */
742 
743  loop_nest_to_local_variables(module, compute_module, memory_module,
744  llv_to_lcr, r_to_llv, v_to_lllv,
745  r_to_ud, v_to_esv, v_to_nlv,
746  lpv, body, initial_basis, dg,
747  bn, ls, pd,
748  tile);
749  ifdebug(4) fprint_wp65_hash_tables(stderr, llv_to_lcr, r_to_llv, v_to_lllv,
750  r_to_ud, v_to_esv);
751 
752  loop_nest_movement_generation(module,loop_nest,pn,bn, ls, pd,proc_id,proc_id_mm,
753  bank_indices,v_to_esv,v_to_nlv,compute_module,
754  computational, memory_module,emulator,fetch_map,
755  store_map,mod_stat,fully_parallel,sc_tile,
756  full_initial_basis,local_basis, local_basis2,
757  tile_basis_in_tile_basis, tile_basis_in_tile_basis2,
758  loop_body_indices,lpv,&lb,&blb,&sb,
759  &bsb,first_parallel_level, last_parallel_level,
760  llv_to_lcr, r_to_llv, v_to_lllv,r_to_ud );
761 }
762  }
763  else {
764  Pbase tbib2 = BASE_NULLE;
765  Pbase tbtl3 = BASE_NULLE;
766  Pbase tbtl4 = BASE_NULLE;
767  Pbase lba3 = BASE_NULLE;
768  Pbase lba4 = BASE_NULLE;
769  Pbase lba5 = BASE_NULLE;
770  Pbase lba6 = BASE_NULLE;
771  Pbase tbtl5 = BASE_NULLE;
772  Pbase tbtl6 = BASE_NULLE;
773  Psysteme sc_tile2 = SC_UNDEFINED;
774  tiling tile2;
775 
776  MAPL(lsb,
777  {
778  statement stmp = STATEMENT(CAR(lsb));
779  if (!continue_statement_p(stmp)) {
780  instruction_block(binst) = CONS(STATEMENT,stmp,NIL);
781  ifdebug(8)
782  {
783  fprintf(stderr,"generation des transferts pour \n");
784  wp65_debug_print_text(module, loop_nest);
785  }
786  body = perfectly_nested_loop_to_body(loop_nest);
787  find_iteration_domain(loop_nest,&iteration_domain2,
788  &initial_basis2,&nested_level2,
789  &list_statement_block2,&binst2);
790  if (loop_nest_dimt > perfect_nested_loop_size) {
791  loop_body_indices = vect_dup(initial_basis2);
792  for ( pv=initial_basis; pv!= NULL;
793  vect_chg_coeff(&loop_body_indices,pv->var,VALUE_ZERO),
794  pv =pv->succ);
795  full_initial_basis=base_reversal(vect_add(initial_basis,
796  loop_body_indices));
797  /* normalement full_initila_basis == initial_basis2*/
798  }
799  ifdebug(2) {
800  (void) fprintf(stderr,"full basis\n");
801  base_fprint(stderr, initial_basis2,
802  (string(*)(void*))entity_local_name);
803  (void) fprintf(stderr,"full iteration domain\n");
804  sc_fprint(stderr,iteration_domain2,
805  (string(*)(void*))entity_local_name);
806  }
807  create_tile_basis(module,compute_module,memory_module, loop_body_indices,
808  &tbib2, &tbtl3, &lba3, &tbtl4, &lba4);
809  tbtl5= base_reversal(vect_add(tile_basis_in_tile_basis, tbtl3));
810  tbtl6= base_reversal(vect_add(tile_basis_in_tile_basis2, tbtl4));
811  //Pbase tbib3=base_reversal(vect_add(tile_basis_in_initial_basis, tbib2));
812  lba5= base_reversal(vect_add( local_basis, lba3));
813  lba6= base_reversal(vect_add( local_basis2, lba4));
814  /* a modifie pour tenir compte des dimensions reelles des domaines */
815  tile2 = loop_nest_to_tile(iteration_domain2, ls, initial_basis2,
816  first_parallel_level,lpl,
817  perfect_nested_loop_size);
818  sc_tile2=loop_bounds_to_tile_bounds(iteration_domain2,initial_basis2,
819  tile2, tile_delay,tbtl5,lba5);
820 
821  loop_nest_to_local_variables(module, compute_module, memory_module,
822  llv_to_lcr, r_to_llv, v_to_lllv,
823  r_to_ud, v_to_esv, v_to_nlv,
824  lpv, body, initial_basis2, dg,
825  bn, ls, pd,tile2);
826  ifdebug(4) fprint_wp65_hash_tables(stderr, llv_to_lcr,
827  r_to_llv, v_to_lllv,
828  r_to_ud, v_to_esv);
830  module,stmp,pn,bn, ls, pd,proc_id,
831  proc_id_mm, bank_indices,v_to_esv,
832  v_to_nlv,compute_module, computational,
833  memory_module,emulator,fetch_map,
834  store_map, mod_stat,fully_parallel,
835  sc_tile2,initial_basis2,lba5,lba6,tbtl5,
836  tbtl6,loop_body_indices,lpv,&lb,&blb,&sb,
837  &bsb,first_parallel_level,
838  last_parallel_level, llv_to_lcr,
839  r_to_llv, v_to_lllv,r_to_ud );
841  }
842 
843  },
844  list_statement_block);
845  }
846  fully_sequential = (first_parallel_level >last_parallel_level);
847 
848  if (io_statementp) {
849  cs = statement_undefined;
850  ems =io_st;
851  }
852  else {
853  insert_run_time_communications(compute_module, memory_module,
854  bank_indices,bn,ls,proc_id,
855  list_statement_block,fetch_map,
856  store_map,&new_compute_lst,
857  &new_bank_lst,v_to_esv,
858  fully_sequential,
859  initial_basis,tile, tile_delay,
860  tile_basis_in_tile_basis,
861  local_basis);
862 
863  instruction_block(binst)= new_compute_lst;
864  body = instruction_to_statement(binst);
865  ifdebug(8) {
866  fprintf(stderr,"loop body \n");
868  fprintf(stderr,"base_initiale 1\n");
869  vect_fprint(stderr,initial_basis,(string(*)(void*))entity_local_name);
870  }
871 
872  sc_variables_rename(sc_tile,local_basis,local_basis2, (string(*)(void*))entity_local_name);
873  sc_variables_rename(sc_tile, tile_basis_in_tile_basis,
874  tile_basis_in_tile_basis2,(string(*)(void*))entity_local_name);
875 
876  cb = make_compute_block(compute_module, body, offsets, r_to_llv,tile,
877  initial_basis, local_basis2,
878  tile_basis_in_tile_basis2,
879  tile_basis_in_initial_basis,
880  iteration_domain,first_parallel_level,
881  last_parallel_level);
882 
883 
884  if (new_bank_lst != NIL) {
886  make_block_statement(new_bank_lst),
887  tile, initial_basis, local_basis,
888  tile_basis_in_tile_basis,
889  tile_basis_in_initial_basis,
890  iteration_domain,
891  first_parallel_level,
892  last_parallel_level);
893  new_bank_lst = CONS(STATEMENT,bs,NIL);
894  }
895  /* put together the different pieces of code as two lists of
896  statements */
897  cbl = gen_nconc(lb, gen_nconc(cb ,sb));
898  bsb = gen_nconc(new_bank_lst, bsb);
899  embl =gen_nconc(blb, bsb);
900 
901  /* add the scanning over the tiles around them to build a proper stmt */
902  cs = make_scanning_over_tiles(compute_module, cbl, proc_id, pn,tile,
903  initial_basis,
904  tile_basis_in_tile_basis2,
905  tile_basis_in_initial_basis,
906  iteration_domain,first_parallel_level,
907  last_parallel_level);
908  ems = make_scanning_over_tiles(memory_module, embl, proc_id_mm,
909  pn, tile, initial_basis,
910  tile_basis_in_tile_basis,
911  tile_basis_in_initial_basis,
912  iteration_domain,first_parallel_level,
913  last_parallel_level);
914 
915  if (fully_sequential) {
916  range looprange = make_range(int_to_expression(0),
917  int_to_expression(pn-1),
918  int_to_expression(1));
919  entity looplabel = make_loop_label(9000,
920  compute_module);
921  loop newloop = make_loop(proc_id,
922  looprange,
923  ems,
924  looplabel,
926  UU),
927  NIL);
928 
929  ems = loop_to_statement(newloop);
930  }
931  /* update computational and emulator with cs and ems */
932  }
933  i = statement_instruction(computational);
934  if (cs != statement_undefined)
936  i = statement_instruction(emulator);
938 
939  ifdebug(5) {
940  (void) fprintf(stderr,
941  "Vars having to be stored into global memory:\n");
942  reference_list_print(store_data_list);
943  reference_list_print(store_reference_list);
944  }
946 
947  MAPL(r1,{
948  reference rf = REFERENCE(CAR(r1));
949  if (reference_scalar_p(rf)) {
951  false,computational,proc_id);
953  true,emulator,(entity)bank_indices->var);
954  }
955  },
956  store_data_list);
957  hash_table_free(llv_to_lcr);
958  hash_table_free(r_to_llv);
959  hash_table_free(v_to_lllv);
960  hash_table_free(r_to_ud);
961 
962  debug(5,"loop_nest_to_wp65_code", "end\n");
963  debug_off();
964 }
tiling loop_nest_to_tile(Psysteme sc, int ls, Pbase base_index, int first_parallel_level, int last_parallel_level, int perfect_nested_level)
Code Generation for Distributed Memory Machines.
Definition: tiling.c:58
void create_tile_basis(entity initial_module, entity compute_module, entity memory_module, Pbase initial_basis, Pbase *tile_basis_in_initial_basis, Pbase *tile_basis_in_tile_basis, Pbase *local_tile_basis, Pbase *tile_basis_in_tile_basis2, Pbase *local_tile_basis2)
Definition: basis.c:100
Psysteme loop_bounds_to_tile_bounds(Psysteme loop_bounds, Pbase loop_indices, tiling t, Pvecteur tile_delay, Pvecteur tile_indices, Pvecteur tile_local_indices)
this function returns the system of constraints
Definition: build_sc_tile.c:97
statement make_scanning_over_tiles(entity module, list body, entity proc_id, int pn, tiling tile, Pbase initial_basis, Pbase tile_basis_in_tile_basis, Pbase tile_basis_in_initial_basis, Psysteme iteration_domain, int first_parallel_level, int last_parallel_level)
make_scanning_over_tiles()
Definition: code.c:227
list make_compute_block(entity module, statement body, Pvecteur offsets, hash_table r_to_llv, tiling tile, Pbase initial_basis, Pbase local_basis, Pbase tile_basis_in_tile_basis, Pbase tile_basis_in_initial_basis, Psysteme iteration_domain, int first_parallel_level, int last_parallel_level)
Definition: code.c:679
statement make_scanning_over_one_tile(entity module, statement body, tiling tile, Pbase initial_basis, Pbase local_basis, Pbase tile_basis_in_tile_basis, Pbase tile_basis_in_initial_basis, Psysteme iteration_domain, int first_parallel_level, int last_parallel_level)
make_scanning_over_one_tile():
Definition: code.c:475
void find_iteration_domain(statement s, Psysteme *sc, Pbase *basis, nested_level, list *list_statement_block, instruction *inst)
if(!(yy_init))
Definition: genread_lex.c:1029
statement instruction_to_statement(instruction)
Build a statement from a give instruction.
Definition: statement.c:597
statement perfectly_nested_loop_to_body(statement loop_nest)
Extract the body of a perfectly nested loop body.
Definition: loop.c:590
void gen_map(gen_iter_func_t fp, const list l)
Definition: list.c:172
#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
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327
static int loop_nest_dim
bool io_loop_nest_p(statement st)
Test if the statement resulting from the perfectly_loop_nest_to_body function contains at first call ...
bool full_parallel_loop_nest_p(statement mod_stat, statement loop_stmt, int nest_dim, graph dg, bool *loop_carried_dep)
void loop_nest_movement_generation(entity module, statement loop_nest, int pn, int bn, int ls, int pd, entity proc_id, entity proc_id_mm, Pbase bank_indices, hash_table v_to_esv, hash_table v_to_nlv, entity compute_module, statement computational, entity memory_module, statement emulator, statement_mapping fetch_map, statement_mapping store_map, statement mod_stat, bool fully_parallel, Psysteme sc_tile, Pbase initial_basis, Pbase local_basis, Pbase local_basis2, Pbase tile_basis_in_tile_basis, Pbase tile_basis_in_tile_basis2, Pbase loop_body_indices, list lpv, list *lb, list *blb, list *sb, list *bsb, int first_parallel_level, int last_parallel_level, hash_table llv_to_lcr, hash_table r_to_llv, hash_table v_to_lllv, hash_table r_to_ud)
static void reduce_loop_bound_for_st(statement stmp)
static void compute_loop_nest_dim(statement l)
#define assert(ex)
Definition: newgen_assert.h:41
void(* gen_iter_func_t)(void *)
Definition: newgen_types.h:116
void loop_nest_to_local_variables(entity initial_module, entity compute_module, entity memory_module, hash_table llv_to_lcr, hash_table r_to_llv, hash_table v_to_lllv, hash_table r_to_ud, hash_table v_to_esv, hash_table v_to_nlv, list lpv, statement body, Pbase indices, graph dg, int bn, int ls, int pd, tiling tile)
for the phi variable
Definition: variable.c:80
void reference_scalar_defined_p(reference r)
Definition: references.c:199
#define statement_undefined
Definition: ri.h:2419
else
Definition: set.c:239
Pbase base_dup(Pbase b)
Pbase base_dup(Pbase b) Note: this function changes the value of the pointer.
Definition: alloc.c:268
Pvecteur vect_add(Pvecteur v1, Pvecteur v2)
package vecteur - operations binaires
Definition: binaires.c:53
void fprint_wp65_hash_tables(FILE *fd, hash_table llv_to_lcr, hash_table r_to_llv, hash_table v_to_lllv, hash_table r_to_ud, hash_table v_to_esv)
Ignore this function: debugging purposes only.
Definition: wp65.c:406

References assert, base_dup(), base_fprint(), BASE_NULLE, base_reversal(), CAR, compute_loop_nest_dim(), CONS, continue_statement_p(), create_tile_basis(), debug(), debug_off, debug_on, dg, entity_local_name(), find_iteration_domain(), fprint_wp65_hash_tables(), fprintf(), full_parallel_loop_nest_p(), gen_map(), gen_nconc(), generate_io_wp65_code(), hash_pointer, hash_table_free(), hash_table_make(), ifdebug, include_constant_symbolic_communication(), insert_run_time_communications(), instruction_block, instruction_loop, instruction_to_statement(), int_to_expression(), io_loop_nest_p(), is_execution_parallel, list_of_calls_p(), loop_bounds_to_tile_bounds(), loop_locals, loop_nest_dim, loop_nest_movement_generation(), loop_nest_to_local_variables(), loop_nest_to_tile(), loop_to_statement, make_block_statement(), make_compute_block(), make_execution(), make_loop(), make_loop_label(), make_range(), make_scanning_over_one_tile(), make_scanning_over_tiles(), MAP, MAPL, mod_stat, module, NIL, perfectly_nested_loop_to_body(), reduce_loop_bound_for_st(), REFERENCE, reference_list_print(), reference_scalar_defined_p(), reference_scalar_p(), sc_fprint(), sc_new(), sc_variables_rename(), STATEMENT, statement_instruction, statement_undefined, Svecteur::succ, UU, VALUE_ZERO, Svecteur::var, vect_add(), vect_chg_coeff(), vect_dup(), vect_fprint(), vect_size(), VECTEUR_NUL, and wp65_debug_print_text().

Referenced by instruction_to_wp65_code().

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

◆ make_all_movement_blocks()

void make_all_movement_blocks ( entity  initial_module,
entity  compute_module,
entity  memory_module,
entity  v,
list  map,
hash_table  llv_to_lcr,
hash_table  v_to_lllv,
hash_table  r_to_ud,
hash_table  v_to_esv,
int  pn,
int  bn,
int  ls,
Psysteme  iteration_domain,
Pbase  initial_basis,
Pbase  local_basis,
entity  proc_id,
Pbase  bank_indices,
Pbase  loop_body_indices,
list pmb,
list pbmb,
tag  use_def,
int  first_parallel_level,
int  last_parallel_level 
)

generates all data movements related to entity v, loads or stores depending on use_def

FI: depending on the pipeline stage, a specific lv should be chosen; by default, let's take the first one

statement for one movement block

statement for one bank movement block

Parameters
initial_modulenitial_module
compute_moduleompute_module
memory_moduleemory_module
mapap
llv_to_lcrlv_to_lcr
v_to_lllv_to_lllv
r_to_ud_to_ud
v_to_esv_to_esv
pnn
bnn
lss
iteration_domainteration_domain
initial_basisnitial_basis
local_basisocal_basis
proc_idroc_id
bank_indicesank_indices
loop_body_indicesoop_body_indices
pmbmb
pbmbbmb
use_defse_def
first_parallel_levelirst_parallel_level
last_parallel_levelast_parallel_level

Definition at line 972 of file instruction_to_wp65_code.c.

1001 {
1002  list lllv = (list) hash_get(v_to_lllv, (char *) v);
1003  entity esv = (entity) hash_get(v_to_esv, (char *) v);
1004 
1005  debug(8,"make_all_movement_blocks", "begin\n");
1006  for(; !ENDP(lllv); POP(lllv)) {
1007  /* FI: depending on the pipeline stage, a specific lv should be
1008  chosen; by default, let's take the first one */
1009  list llv = LIST(CAR(lllv));
1010  entity lv = ENTITY(CAR(llv));
1011  list lr = (list) hash_get(llv_to_lcr, (char *) llv);
1012  bool proper_tag = false;
1013 
1014  for(; !ENDP(lr) && !proper_tag ; POP(lr)) {
1015  reference r = REFERENCE(CAR(lr));
1016  if( reference_in_list_p(r,map) &&
1017  (intptr_t) hash_get(r_to_ud, r) == (intptr_t)use_def) {
1018  statement mbs = NULL; /* statement for one movement block */
1019  statement bmbs = NULL; /* statement for one bank movement block */
1020 
1021  proper_tag = true;
1022  switch(use_def) {
1023  case is_action_read:
1024  make_load_blocks(initial_module,compute_module,
1025  memory_module, v, esv, lv,
1026  lr, r_to_ud, iteration_domain,
1027  initial_basis, bank_indices,
1028  local_basis, loop_body_indices,
1029  proc_id, pn,bn, ls,
1030  &mbs, &bmbs,first_parallel_level,
1031  last_parallel_level);
1032 
1033  break;
1034  case is_action_write:
1035  make_store_blocks(initial_module,compute_module,
1036  memory_module, v, esv, lv,
1037  lr, r_to_ud, iteration_domain,
1038  initial_basis,
1039  bank_indices,local_basis,
1040  loop_body_indices,
1041  proc_id, pn,bn, ls,
1042  &mbs, &bmbs,first_parallel_level,
1043  last_parallel_level);
1044  break;
1045  default:
1046  pips_internal_error("unexpected use-def = %d", use_def);
1047  }
1048 
1049  ifdebug(9) {
1050  pips_debug(9, "mbs=\n");
1051  wp65_debug_print_text(compute_module, mbs);
1052  pips_debug(9, "bmbs=\n");
1053  wp65_debug_print_text(compute_module, mbs);
1054  }
1055 
1056  *pmb = gen_nconc(*pmb, CONS(STATEMENT, mbs, NIL));
1057  *pbmb = gen_nconc(*pbmb, CONS(STATEMENT, bmbs, NIL));
1058  }
1059  }
1060  }
1061 
1062  debug(8,"make_all_movement_blocks", "end\n");
1063 }
void make_store_blocks(entity initial_module, entity compute_module, entity memory_module, entity var, entity shared_variable, entity local_variable, list lrefs, hash_table r_to_ud, Psysteme sc_domain, Pbase index_base, Pbase bank_indices, Pbase tile_indices, Pbase loop_body_indices, entity Proc_id, int pn, int bn, int ls, statement *store_block, statement *bank_store_block, int first_parallel_level, int last_parallel_level)
Definition: code.c:1166
void make_load_blocks(entity initial_module, entity compute_module, entity memory_module, entity var, entity shared_variable, entity local_variable, list lrefs, hash_table r_to_ud, Psysteme sc_domain, Pbase index_base, Pbase bank_indices, Pbase tile_indices, Pbase loop_body_indices, entity Proc_id, int pn, int bn, int ls, statement *load_block, statement *bank_load_block, int first_parallel_level, int last_parallel_level)
Definition: code.c:1312
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145

References CAR, CONS, debug(), ENDP, ENTITY, gen_nconc(), hash_get(), ifdebug, intptr_t, is_action_read, is_action_write, LIST, make_load_blocks(), make_store_blocks(), NIL, pips_debug, pips_internal_error, POP, REFERENCE, reference_in_list_p(), STATEMENT, and wp65_debug_print_text().

Referenced by loop_nest_movement_generation().

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

◆ make_compute_block()

list make_compute_block ( entity  module,
statement  body,
Pvecteur  offsets,
hash_table  r_to_llv,
tiling  tile,
Pbase  initial_basis,
Pbase  local_basis,
Pbase  tile_basis_in_tile_basis,
Pbase  tile_basis_in_initial_basis,
Psysteme  iteration_domain,
int  first_parallel_level,
int  last_parallel_level 
)
Parameters
moduleodule
bodyody
offsetsffsets
r_to_llv_to_llv
tileile
initial_basisnitial_basis
local_basisocal_basis
tile_basis_in_tile_basisile_basis_in_tile_basis
tile_basis_in_initial_basisile_basis_in_initial_basis
iteration_domainteration_domain
first_parallel_levelirst_parallel_level
last_parallel_levelast_parallel_level

Definition at line 679 of file code.c.

696 {
697  statement s;
698 
699  list lt = NIL;
700  lt = reference_conversion_statement(module,body, &lt, r_to_llv, offsets, initial_basis,
701  tile_basis_in_tile_basis,local_basis,tile);
704  tile, initial_basis, local_basis,
705  tile_basis_in_tile_basis,
706  tile_basis_in_initial_basis,
707  iteration_domain,first_parallel_level,last_parallel_level);
708 
709  return CONS(STATEMENT, s, NIL);
710 }
list reference_conversion_statement(entity module, statement body, list *lt, hash_table r_to_llv, Pvecteur offsets, Pbase initial_basis, Pbase tile_indices, Pbase local_basis, tiling tile)
void reference_conversion_statement(body, r_to_llv, offsets, initial_basis, local_basis):
Definition: code.c:723

References CONS, gen_nconc(), instruction_block, make_block_statement(), make_scanning_over_one_tile(), module, NIL, reference_conversion_statement(), STATEMENT, and statement_instruction.

Referenced by loop_nest_to_wp65_code().

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

◆ make_emulated_shared_variable()

entity make_emulated_shared_variable ( entity  v,
entity  memory_module,
int  bn,
int  ls 
)

filled in the following

filled in the following

generate the proper type; basic is preserved but the array is made two dimensional

In two sprintf , -1 is added once seperately by LZ make_expression_1 takes the place of the make_expression_1 12/11/91

FI->CA, LZ: what should we do with scalar variables? Put a copy on each memory bank? Take into account memory bank conflicts shown in thresholding (PUMA WP 6.1 and 6.7)

Parameters
memory_moduleemory_module
bnn
lss

Definition at line 195 of file variable.c.

200 {
201  string esv_name = strdup(concatenate(entity_local_name(memory_module),
205  NULL));
206  entity esv = gen_find_tabulated(esv_name, entity_domain);
207  type tv = entity_type(v);
210  entity a;
211  int number_of_elements = 1;
212 
215  debug(8,"make_emulated_shared_variable", "begin\n");
216 
217  pips_assert("make_emulated_shared_variable", esv == entity_undefined );
218  pips_assert("make_emulated_shared_variable", type_variable_p(tv));
219 
220 
221 
222  esv = make_entity(esv_name,
223  type_undefined, /* filled in the following */
225  value_undefined ); /* filled in the following */
226 
227  /* generate the proper type; basic is preserved but the array is made
228  two dimensional */
229 
230  for( ; !ENDP(ldv); POP(ldv)) {
231  dimension d = DIMENSION(CAR(ldv));
232  int size = dimension_size(d);
233  number_of_elements *= size;
234  }
235 
236  ifdebug(8) {
237  (void) fprintf(stderr,"number of elements for %s: %d\n",
239  }
240 
241  /* In two sprintf , -1 is added once seperately by LZ
242  * make_expression_1 takes the place of the make_expression_1
243  * 12/11/91
244  */
245  if(number_of_elements > 1) {
247  int_to_expression(ls-1),
248  NIL);
250  int_to_expression((number_of_elements+ls*bn-1)/(ls*bn)),
251  NIL);
252 
254  CONS(DIMENSION, esvd1,
255  CONS(DIMENSION, esvd2, NIL)));
256  }
257  else {
258  /* FI->CA, LZ: what should we do with scalar variables? Put a copy
259  on each memory bank? Take into account memory bank conflicts
260  shown in thresholding (PUMA WP 6.1 and 6.7) */
262  }
263 
265 
266  a = FindEntity(module_local_name(memory_module),
269  (make_ram(memory_module,
270  a,
272  esv),
273  NIL)));
274 
275  AddEntityToDeclarations(esv,memory_module);
276 
277  debug(8,"make_emulated_shared_variable", "esv_name=%s\n", entity_name(esv));
278  ifdebug(8) print_sentence(stderr,Sentence_Variable(esv));
280 
281  return(esv);
282 }
value make_value_unknown(void)
Definition: ri.c:2847
basic copy_basic(basic p)
BASIC.
Definition: ri.c:104
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
dimension make_dimension(expression a1, expression a2, list a3)
Definition: ri.c:565
bool number_of_elements(list, intptr_t *)
flint_utils.c
Definition: flint_utils.c:50
char end
Definition: gtk_status.c:82
#define DYNAMIC_AREA_LOCAL_NAME
Definition: naming-local.h:69
void AddEntityToDeclarations(entity e, entity module)
END_EOLE.
Definition: variable.c:108
int add_variable_to_area(entity a, entity v)
Definition: variable.c:1376
sentence Sentence_Variable(entity e)
Definition: declarations.c:583
#define make_entity(n, t, s, i)
entity FindEntity(const char *package, const char *name)
Retrieve an entity from its package/module name and its local name.
Definition: entity.c:1503
int dimension_size(dimension)
this function computes the size of a dimension.
Definition: size.c:491
type MakeTypeVariable(basic, cons *)
BEGIN_EOLE.
Definition: type.c:116
#define value_undefined
Definition: ri.h:3016
#define entity_storage(x)
Definition: ri.h:2794
@ is_storage_ram
Definition: ri.h:2492
#define dimension_undefined
Definition: ri.h:955
#define type_undefined
Definition: ri.h:2883
#define type_variable_p(x)
Definition: ri.h:2947
#define variable_basic(x)
Definition: ri.h:3120
#define storage_undefined
Definition: ri.h:2476
#define entity_initial(x)
Definition: ri.h:2796
return(s1)
void print_sentence(FILE *fd, sentence s)
FI: just to make sure that text.h is built; pips-makemake -l does not tale into account a library who...
Definition: print.c:53

References add_variable_to_area(), AddEntityToDeclarations(), CAR, concatenate(), CONS, copy_basic(), debug(), DIMENSION, dimension_size(), dimension_undefined, DYNAMIC_AREA_LOCAL_NAME, EMULATED_SHARED_MEMORY_PREFIX, ENDP, entity_domain, entity_initial, entity_local_name(), entity_name, entity_storage, entity_type, entity_undefined, FindEntity(), fprintf(), gen_find_tabulated(), ifdebug, int_to_expression(), is_storage_ram, make_dimension(), make_entity, make_ram(), make_storage(), make_value_unknown(), MakeTypeVariable(), module_local_name(), MODULE_SEP_STRING, NIL, number_of_elements(), pips_assert, POP, print_sentence(), Sentence_Variable(), storage_undefined, strdup(), type_undefined, type_variable, type_variable_p, value_undefined, variable_basic, and variable_dimensions.

Referenced by find_or_create_emulated_shared_variable().

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

◆ make_fetch_map()

void make_fetch_map ( void  )

◆ make_load_blocks()

void make_load_blocks ( entity  initial_module,
entity  compute_module,
entity  memory_module,
entity  var,
entity  shared_variable,
entity  local_variable,
list  lrefs,
hash_table  r_to_ud,
Psysteme  sc_domain,
Pbase  index_base,
Pbase  bank_indices,
Pbase  tile_indices,
Pbase  loop_body_indices,
entity  Proc_id,
int  pn,
int  bn,
int  ls,
statement load_block,
statement bank_load_block,
int  first_parallel_level,
int  last_parallel_level 
)

is true if it is the generation of code for bank false if it is for engine

is true if the generated code must be a RECEIVE, false if it must be a SEND

Cases where the references are scalar variables

In the other cases the references must be classified in lists of uniform dependent references

For each list of uniform dependent references, "load_block" and "bank_load_block" are computed

Parameters
initial_modulenitial_module
compute_moduleompute_module
memory_moduleemory_module
varar
shared_variablehared_variable
local_variableocal_variable
lrefsrefs
r_to_ud_to_ud
sc_domainc_domain
index_basendex_base
bank_indicesank_indices
tile_indicesile_indices
loop_body_indicesoop_body_indices
Proc_idroc_id
pnn
bnn
lss
load_blockoad_block
bank_load_blockank_load_block
first_parallel_levelirst_parallel_level
last_parallel_levelast_parallel_level

Definition at line 1312 of file code.c.

1340 {
1341  pips_assert("true", last_parallel_level==last_parallel_level &&
1342  first_parallel_level==first_parallel_level);
1343  list lur;
1344  list llur = NIL;
1345  list lrs = lrefs;
1346  Psysteme sc_image,sc_array_function;
1347  int n,dim_h;
1348  Pbase const_base;
1349  Pbase new_index_base = BASE_NULLE;
1350  Pbase new_tile_indices = BASE_NULLE;
1351  bool bank_code; /* is true if it is the generation
1352  of code for bank false if it is
1353  for engine */
1354  bool receive_code; /* is true if the generated code
1355  must be a RECEIVE, false if it
1356  must be a SEND*/
1357  reference r;
1358  statement stat1,stat2,lb,blb;
1359  cons * bst_lb= NIL;
1360  cons * bst_blb= NIL;
1361  Pbase var_id;
1362  Pvecteur ppid = vect_new((char *) Proc_id, VALUE_ONE);
1363  Psysteme sc_image2= SC_UNDEFINED;
1364  debug(8,"make_load_blocks",
1365  "begin variable=%s, shared_variable=%s, local_variable=%s\n",
1366  entity_local_name(var), entity_local_name(shared_variable),
1367  entity_local_name(local_variable));
1368 
1369  ifdebug(8) {
1370  list crefs;
1371  (void) fprintf(stderr, "Associated reference list:");
1372  for(crefs=lrefs; !ENDP(crefs); POP(crefs)) {
1373  reference r1 = REFERENCE(CAR(crefs));
1374  print_reference(r1);
1375  if(ENDP(CDR(crefs)))
1376  (void) putc('\n', stderr);
1377  else
1378  (void) putc(',', stderr);
1379  }
1380  }
1381 
1382 
1383  /* Cases where the references are scalar variables */
1384 
1385  for (lrs =lrefs ; !ENDP(lrs) ; POP(lrs)) {
1386  r = REFERENCE(CAR(lrs));
1387  if (reference_indices(r) ==NIL) {
1388 
1389  receive_code = true;
1390  *load_block =make_movement_scalar_wp65(compute_module,receive_code,
1391  r,Proc_id);
1392  receive_code = false;
1393  *bank_load_block=
1394  make_movement_scalar_wp65(memory_module,receive_code,
1395  r,(entity) bank_indices->var);
1396  return;
1397  }
1398  }
1399  /* In the other cases the references must be classified in lists of
1400  uniform dependent references */
1401 
1402  for (lrs =lrefs ; !ENDP(lrs) ; POP(lrs)) {
1403  r = REFERENCE(CAR(lrs));
1404  if ( (intptr_t) hash_get(r_to_ud, r) == (intptr_t)is_action_read)
1405  llur = classify_reference(llur,r);
1406  }
1407 
1408  /* For each list of uniform dependent references, "load_block" and
1409  "bank_load_block" are computed */
1410 
1411  for (lur=llur; lur != NIL; lur = CDR(lur)) {
1412  sc_array_function=
1413  build_sc_with_several_uniform_ref(initial_module,
1414  LIST(CAR(lur)),
1415  sc_domain,&new_index_base);
1416  new_index_base = vect_add(new_index_base,
1417  vect_dup(index_base));
1418 
1419  sc_image = sc_image_computation(initial_module,var,sc_domain,
1420  sc_array_function,new_index_base,
1421  &const_base,Proc_id,bank_indices,
1422  tile_indices,&new_tile_indices,
1423  pn,bn,ls,
1424  &n,&dim_h);
1425  nullify_offsets();
1426  sc_image2= sc_dup(sc_image);
1427  bank_code = true ;
1428  receive_code = false;
1429  var_id = (Pbase) vect_new(vecteur_var(ppid),
1430  vecteur_val(ppid));
1431  stat1 = movement_computation(memory_module,
1432  true,
1433  bank_code,
1434  receive_code,
1435  shared_variable,sc_image,
1436  const_base,bank_indices,new_tile_indices,
1437  var_id, loop_body_indices,n,dim_h);
1438  initialize_offsets(lur);
1439  bank_code = false ;
1440  receive_code = true;
1441  var_id = (Pbase) vect_new(vecteur_var(bank_indices),
1442  vecteur_val(bank_indices));
1443  stat2 = movement_computation(compute_module,
1444  true,
1445  bank_code,
1446  receive_code,
1447  local_variable,sc_image2,
1448  const_base,bank_indices,new_tile_indices,
1449  var_id, loop_body_indices,n,dim_h);
1450 
1451  bst_lb = CONS(STATEMENT,stat2,bst_lb);
1452  bst_blb = CONS(STATEMENT,stat1,bst_blb);
1453  }
1454 
1455  lb = make_block_statement(bst_lb);
1456  blb = make_block_statement(bst_blb);
1457  *load_block =lb;
1458  *bank_load_block=blb;
1459 
1460  debug(8,"make_load_blocks", "end\n");
1461 }
static void initialize_offsets(list lt)
Definition: code.c:1144
list classify_reference(list llr, reference r)
This function classifies the references in lists.
Definition: code.c:975
static void nullify_offsets()
Definition: code.c:1163
Psysteme build_sc_with_several_uniform_ref(entity module, cons *lr, Psysteme sc_domain, Pbase *new_index_base)
build_sc_with_several_uniform_ref():
Definition: code.c:1011
statement make_movement_scalar_wp65(entity module, bool receive_code, reference r, entity var_id)
statement make_movement_scalar_wp65(receive_code,r)
Psysteme sc_image_computation(entity module, entity entity_var, Psysteme sc_domain, Psysteme sc_array_function, Pbase index_base, Pbase *const_base, entity proc_id, Pbase bank_indices, Pbase tile_indices, Pbase *new_tile_indices, int pn, int bn, int ls, int *n, int *dim_h)
This function computes the system of constraints characterizing the image by the array function of th...
statement movement_computation(entity module, bool used_def, bool bank_code, bool receive_code, entity private_entity, Psysteme sc_image, Pbase const_base, Pbase bank_indices, Pbase tile_indices, Pbase ppid, Pbase loop_body_indices, int n, int dim_h)
Calcul des nouvelles bornes des boucles et de la nouvelle fonction d'acces a une reference d'un table...
#define false
Definition: newgen_types.h:80
struct Svecteur * Pbase

References BASE_NULLE, build_sc_with_several_uniform_ref(), CAR, CDR, classify_reference(), CONS, debug(), ENDP, entity_local_name(), false, fprintf(), hash_get(), ifdebug, initialize_offsets(), intptr_t, is_action_read, LIST, make_block_statement(), make_movement_scalar_wp65(), movement_computation(), NIL, nullify_offsets(), pips_assert, POP, print_reference(), REFERENCE, reference_indices, sc_dup(), sc_image_computation(), STATEMENT, true, VALUE_ONE, Svecteur::var, vect_add(), vect_dup(), vect_new(), vecteur_val, and vecteur_var.

Referenced by make_all_movement_blocks().

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

◆ make_new_local_variables()

list make_new_local_variables ( entity  v,
entity  compute_module,
int  number,
int  pd,
hash_table  v_to_lllv 
)

Local variables cannot be immediately dimensionned because this will depend on all associated references.

To avoid a possible "fusion" between references connected in the dg, local variable declarations should be delayed to that point.

concatenate cannot be used (directly) because of n and s conversions

a new btv is necessary for each variable because CONS cannot be shared under NewGen rules

FI->LZ: the type should be v's type, except for the dimensions, the storage should be RAM and allocated in the dynamic area of module_name, and the value is undefined; the actual dimensions will be updated later

update v_to_lllv by side effect

Parameters
compute_moduleompute_module
numberumber
pdd
v_to_lllv_to_lllv

Definition at line 310 of file variable.c.

316 {
317  /* Local variables cannot be immediately dimensionned because this
318  will depend on *all* associated references.
319 
320  To avoid a possible "fusion" between references connected in the dg,
321  local variable declarations should be delayed to that point. */
322 
323  /* concatenate cannot be used (directly) because of n and s conversions */
324  char *local_variable_name;
325  int s;
326  list llv = NIL;
327  list lllv = NIL;
328  const char* computational_name = entity_local_name(compute_module);
329 
330  type tv = entity_type(v);
331  entity a;
332 
333  debug(7,"make_new_local_variables","begin v=%s, number=%d, pd=%d\n",
334  entity_name(v), number, pd);
335 
336  for(s=0; s<pd; s++) {
337  entity lv;
338  /* a new btv is necessary for each variable because CONS cannot
339  be shared under NewGen rules */
341 
342  (void) asprintf(&local_variable_name,"%s%s%s%s%s%d%s%d",
343  computational_name,
348  number,
350  s);
351 
352  /* FI->LZ: the type should be v's type, except for the dimensions,
353  the storage should be RAM and allocated in the dynamic
354  area of module_name, and the value is undefined;
355  the actual dimensions will be updated later */
356  lv = make_entity(local_variable_name,
357  MakeTypeVariable(btv, NIL),
360 
361  a = FindEntity(module_local_name(compute_module),
363  pips_assert("make_new_local_variables",!entity_undefined_p(a));
364 
366  (make_ram(compute_module, a,
367  add_variable_to_area(a, lv),
368  NIL)));
369 
370 
371  AddEntityToDeclarations( lv,compute_module);
372  llv = gen_nconc(llv, CONS(ENTITY, lv, NIL));
373  }
374 
375  if((lllv = (list) hash_get(v_to_lllv, (char *) v))
376  == (list) HASH_UNDEFINED_VALUE) {
377  lllv = CONS(LIST, llv, NIL);
378  hash_put(v_to_lllv, (char *) v, (char *) lllv);
379  }
380  else {
381  /* update v_to_lllv by side effect */
382  lllv = gen_nconc(lllv, CONS(LIST, llv, NIL));
383  }
384 
385 
386  debug(7,"make_new_local_variables","end\n");
387 
388  return llv;
389 }
#define asprintf
Definition: misc-local.h:225
#define entity_undefined_p(x)
Definition: ri.h:2762
#define LOCAL_MEMORY_SEPARATOR
Definition: wp65-local.h:36
#define LOCAL_MEMORY_PREFIX
Definition: wp65-local.h:35

References add_variable_to_area(), AddEntityToDeclarations(), asprintf, CONS, copy_basic(), debug(), DYNAMIC_AREA_LOCAL_NAME, ENTITY, entity_local_name(), entity_name, entity_storage, entity_type, entity_undefined_p, FindEntity(), gen_nconc(), hash_get(), hash_put(), HASH_UNDEFINED_VALUE, is_storage_ram, LIST, LOCAL_MEMORY_PREFIX, LOCAL_MEMORY_SEPARATOR, make_entity, make_ram(), make_storage(), MakeTypeVariable(), module_local_name(), MODULE_SEP_STRING, NIL, pips_assert, storage_undefined, type_variable, value_undefined, and variable_basic.

Referenced by loop_nest_to_local_variables().

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

◆ make_scanning_over_one_tile()

statement make_scanning_over_one_tile ( entity  module,
statement  body,
tiling  tile,
Pbase  initial_basis,
Pbase  local_basis,
Pbase  tile_basis_in_tile_basis,
Pbase  tile_basis_in_initial_basis,
Psysteme  iteration_domain,
int  first_parallel_level,
int  last_parallel_level 
)

make_scanning_over_one_tile():

generates a nest of loops to enumerate all iterations contained in one tile; the loop bounds are such that empty tiles execute no iteration at all;

The following system is built:

-> -> B i <= b

-> --> -> t1 = P t0 + o

-> --> -> i = t1 + l

-> -1 -> --> -—> 0 <= k P ( i - t1 ) <= (k-1)

where (B,b) defines the iteration domain, t1 is the tile origin in the initial basis, t0 is the tile origin in the tile basis, P is the partitioning matrix, o is the partitioning origin, i is an iteration, and k is the denominator of the inverse of P. l is an iteration in the local (to the current tile) basis.

Because the loops over the tiles are built with t1 and because we need to access the copy with local coordinates, i and t0 are eliminated.

A few changes would make this function generate loops for a shared memory machine. The local_basis would be useless and the initial basis should be chosen as indices for the loops so as not to have to update the loop body. So l would not be introduced and i would not be projected.

Algorithm described in PPoPP'91.

only fully-dimensional partitioning for the time being

add change of basis equations to iteration domain: tile_basis_in_tile_basis to tile_basis_in_initial_basis

add translation equations from initial basis to local basis using tile_basis_in_initial_basis: i == t1 + l

add the tile membership inequalities

update the basis for system tile_domain

get rid of tile_basis_in_initial_basis; we might as well (?) keep them and get rid of tile_basis_in_tile_basis

get rid of initial indices

TEMPTATIVE

compute general information on loop bound origins this is done to take into account information carried by the outer loops, scanning the tile set

get rid of local indices

inject this redundant information

END OF TEMPTATIVE SECTION

apply a row echelon transformation

transform these constraints into a loop nest with the right body, starting with the innermost loop

test pour optimiser le nid de boucles genere

I need new labels and new continues for my loops! make_loop_label() needs (at least) a module name

Parameters
moduleodule
bodyody
tileile
initial_basisnitial_basis
local_basisocal_basis
tile_basis_in_tile_basisile_basis_in_tile_basis
tile_basis_in_initial_basisile_basis_in_initial_basis
iteration_domainteration_domain
first_parallel_levelirst_parallel_level
last_parallel_levelast_parallel_level

Definition at line 475 of file code.c.

491 {
492  pips_assert("true", first_parallel_level==first_parallel_level);
493  Psysteme tile_domain = sc_dup(iteration_domain);
494  Psysteme ordered_tile_domain = SC_UNDEFINED;
495  Psysteme origin_domain = SC_UNDEFINED;
496  int id = base_dimension(initial_basis);
497  int td = base_dimension(tile_basis_in_tile_basis);
498  int l,t,i;
500  Pvecteur pv;
501 
502  debug(8,"make_scanning_over_one_tile", "begin for module %s\n",
504 
505  /* only fully-dimensional partitioning for the time being */
506  pips_assert("make_scanning_over_one_tile",id==td);
507 
508  /* add change of basis equations to iteration domain:
509  tile_basis_in_tile_basis to tile_basis_in_initial_basis */
510 
511 
512  tile_change_of_basis(tile_domain,initial_basis,
513  tile_basis_in_tile_basis,
514  tile_basis_in_initial_basis,tile);
515 
516  /* add translation equations from initial basis to local basis
517  using tile_basis_in_initial_basis: i == t1 + l */
518 
519  for(l=1; l <= id; l++) {
520  Pcontrainte eq;
521  Pvecteur v = VECTEUR_NUL;
522  vect_add_elem(&v, variable_of_rank(initial_basis, l), VALUE_ONE);
523  vect_add_elem(&v, variable_of_rank(tile_basis_in_initial_basis, l),
524  VALUE_MONE);
525  vect_add_elem(&v, variable_of_rank(local_basis, l), VALUE_MONE);
526  eq = contrainte_make(v);
527  sc_add_egalite(tile_domain, eq);
528  }
529 
530 
531  /* add the tile membership inequalities */
532  tile_domain = sc_append(tile_domain,
534  tile_basis_in_initial_basis,
535  initial_basis));
536 
537  /* update the basis for system tile_domain */
538  base_rm(sc_base(tile_domain));
539  sc_base(tile_domain) = BASE_NULLE;
540  sc_creer_base(tile_domain);
541 
542  ifdebug(8) {
543  (void) fprintf(stderr, "Full system before projections:\n");
544  sc_fprint(stderr, tile_domain,(string(*)(Variable)) entity_local_name);
545  }
546 
547  /* get rid of tile_basis_in_initial_basis; we might as well (?) keep
548  them and get rid of tile_basis_in_tile_basis */
549  for(l=1; l <= td; l++) {
550  entity ind = (entity) variable_of_rank(tile_basis_in_initial_basis, l);
551  tile_domain = sc_projection_pure(tile_domain, (Variable) ind);
552  }
553 
554  ifdebug(8) {
555  (void) fprintf(stderr,
556  "Constraints on local tile indices parametrized by tile origin and initial indices:\n");
557  sc_fprint(stderr, tile_domain,(string(*)(Variable)) entity_local_name);
558  }
559 
560  /* get rid of initial indices */
561  for(l=1; l <= id; l++) {
562  entity ind = (entity) variable_of_rank(initial_basis, l);
563  tile_domain = sc_projection_pure(tile_domain, (Variable) ind);
564  }
565 
566  ifdebug(8) {
567  (void) fprintf(stderr,
568  "Constraints on local tile indices parametrized by tile origin:\n");
569  sc_fprint(stderr, tile_domain, (string(*)(Variable))entity_local_name);
570  }
571 
572  /* TEMPTATIVE */
573 
574  /* compute general information on loop bound origins
575  this is done to take into account information carried by the
576  outer loops, scanning the tile set */
577  origin_domain = sc_dup(tile_domain);
578 
579  /* get rid of local indices */
580  for(l=1; l <= id; l++) {
581  entity ind = (entity) variable_of_rank(local_basis, l);
582  origin_domain = sc_projection_pure(origin_domain, (Variable) ind);
583  }
584 
585  ifdebug(8) {
586  (void) fprintf(stderr,
587  "Absolute constraints on tile origins:\n");
588  sc_fprint(stderr, origin_domain,(string(*)(Variable)) entity_local_name);
589  }
590 
591  /* inject this redundant information */
592  tile_domain = sc_append(origin_domain, tile_domain);
593 
594  ifdebug(8) {
595  (void) fprintf(stderr,
596  "Constraints on local tile indices parametrized by tile origin, with redundant information:\n");
597  sc_fprint(stderr, tile_domain,(string(*)(Variable)) entity_local_name);
598  }
599 
600  pv =tile_basis_in_tile_basis;
601  for (i=1; i<= last_parallel_level && !VECTEUR_NUL_P(pv); i++, pv = pv->succ);
602 
603  for ( ; !VECTEUR_NUL_P(pv); pv = pv->succ) {
604  sc_force_variable_to_zero(tile_domain,vecteur_var(pv));
605  }
606 
607 
608  /* END OF TEMPTATIVE SECTION */
609 
610  /* apply a row echelon transformation */
611  ordered_tile_domain = new_loop_bound(tile_domain, local_basis);
612  sc_transform_eg_in_ineg(ordered_tile_domain);
613 
614  ifdebug(8) {
615  (void) fprintf(stderr, "Ordered constraints on local indices:\n");
616  sc_fprint(stderr, ordered_tile_domain,(string(*)(Variable)) entity_local_name);
617  }
618 
619  /* transform these constraints into a loop nest with the right body,
620  starting with the innermost loop */
621 
622  s = body;
623 
624  /* test pour optimiser le nid de boucles genere */
625  for (t =id; t >= 1; t--) {
626  Value min,max;
627  Variable var = variable_of_rank(local_basis, t);
628 
629  Psysteme sctmp = sc_dup(ordered_tile_domain);
630  sc_minmax_of_variable(sctmp,var,&min,&max);
631  }
632 
633 
634  for(t = id; t >= 1; t--) {
635  expression lower;
636  expression upper;
637  range r;
638  loop new_l;
639  entity ind;
640  entity new_label;
641  statement cs;
642 
643  ind = (entity) variable_of_rank(local_basis, t);
645  local_basis,
646  ordered_tile_domain,
647  &lower, &upper);
648  r = make_range(lower, upper, int_to_expression(1));
649  /* I need new labels and new continues for my loops!
650  make_loop_label() needs (at least) a module name */
651  new_label = make_loop_label(9000, module);
652  cs = make_continue_statement(new_label);
655  CONS(STATEMENT, cs, NIL));
656  else
658  CONS(STATEMENT, cs, NIL)));
659 
660  new_l = make_loop(ind, r, s,
661  new_label,
663  s = loop_to_statement( new_l);
664  }
665  statement_comments(s) =
666  strdup("C To scan each iteration of the current tile\n");
667  ifdebug(8) {
668  (void) fprintf(stderr, "Loop nest over tiles:\n");
670  }
671 
672  debug(8,"make_scanning_over_one_tile", "end\n");
673 
674  return s;
675 }
Psysteme tile_membership(matrice P, Pbase origin, Pbase member)
Psysteme tile_membership(P, origin, member):
Definition: code.c:1469
void tile_change_of_basis(Psysteme tile_domain, Pbase initial_basis, Pbase tile_basis, Pbase tile_init_basis, tiling tile)
Definition: code.c:161
statement make_continue_statement(entity)
Definition: statement.c:953
void make_bound_expression(Variable index, Pbase base, Psysteme sc, expression *lower, expression *upper)
void make_bound_expression(variable index, Pbase base, Psysteme sc, expression *lower,...
#define statement_comments(x)
Definition: ri.h:2456
@ is_execution_sequential
Definition: ri.h:1189
void sc_add_egalite(Psysteme p, Pcontrainte e)
void sc_add_egalite(Psysteme p, Pcontrainte e): macro ajoutant une egalite e a un systeme p; la base ...
Definition: sc_alloc.c:389
void sc_force_variable_to_zero(Psysteme ps, Variable var)
void sc_force_variable_to_zero(Psysteme ps, Variable var): force la variable var a prendre la valeur ...
Definition: sc_eval.c:251
Pcontrainte eq
element du vecteur colonne du systeme donne par l'analyse
Definition: sc_gram.c:108
Variable variable_of_rank()
Psysteme sc_append(Psysteme s1, Psysteme s2)
Psysteme sc_append(Psysteme s1, Psysteme s2): calcul de l'intersection des polyedres definis par s1 e...
Psysteme new_loop_bound(Psysteme scn, Pbase base_index)
Psysteme new_loop_bound(Psysteme scn, Pbase base_index) computation of the new iteration space (given...
void sc_transform_eg_in_ineg(Psysteme sc)
Package sc.
#define tiling_tile(x)
Definition: tiling.h:68
#define base_rm(b)
#define base_dimension(b)
void vect_add_elem(Pvecteur *pvect, Variable var, Value val)
void vect_add_elem(Pvecteur * pvect, Variable var, Value val): addition d'un vecteur colineaire au ve...
Definition: unaires.c:72

References base_dimension, BASE_NULLE, base_rm, CONS, contrainte_make(), debug(), entity_local_name(), eq, fprintf(), gen_nconc(), ifdebug, instruction_block, instruction_block_p, int_to_expression(), is_execution_sequential, loop_to_statement, make_block_statement(), make_bound_expression(), make_continue_statement(), make_execution(), make_loop(), make_loop_label(), make_range(), max, min, module, module_local_name(), new_loop_bound(), NIL, pips_assert, sc_add_egalite(), sc_append(), sc_creer_base(), sc_dup(), sc_force_variable_to_zero(), sc_fprint(), sc_minmax_of_variable(), sc_transform_eg_in_ineg(), STATEMENT, statement_comments, statement_instruction, statement_undefined, strdup(), Svecteur::succ, tile_change_of_basis(), tile_membership(), tiling_tile, UU, VALUE_MONE, VALUE_ONE, variable_of_rank(), vect_add_elem(), VECTEUR_NUL, VECTEUR_NUL_P, vecteur_var, and wp65_debug_print_text().

Referenced by loop_nest_to_wp65_code(), and make_compute_block().

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

◆ make_scanning_over_tiles()

statement make_scanning_over_tiles ( entity  module,
list  body,
entity  proc_id,
int  pn,
tiling  tile,
Pbase  initial_basis,
Pbase  tile_basis_in_tile_basis,
Pbase  tile_basis_in_initial_basis,
Psysteme  iteration_domain,
int  first_parallel_level,
int  last_parallel_level 
)

make_scanning_over_tiles()

generates a nest of loops to enumerate all tiles containing at least one iteration in iteration_domain, and even sometimes zero because a rational projection is used; empty tiles are taken care of at a lower level to make sure that no iterations are performed.

The following system is built:

-> -> B i <= b

-> --> -> t1 = P t0 + o

-> -1 -> --> -—> 0 <= k P ( i - t1 ) <= (k-1)

where (B,b) defines the iteration domain, t1 is the tile origin in the initial basis, t0 is the tile origin in the tile basis, P is the partitioning matrix, o is the partitioning origin, i is an iteration, and k is the denominator of the inverse of P.

i and t1 are eliminated to obtain constraints on t0 only. These constraints are used to derive the loop bounds.

This piece of code could also be used to generate tiled code for a shared memory machine without any change.

Notes:

  • the outermost loop is assumed parallel;
  • the outermost loop is statically distributed over the processors if proc_id is defined as a formal parameter (compute code)
  • proc_id has to be derived from the outermost loop index for the memory code, when it is a local variable

Algorithm described in PPoPP'91

only fully-dimensional partitioning for the time being

add change of basis equations to iteration domain: tile_basis_in_tile_basis to tile_basis_in_initial_basis; they would be of no use for a shared memory machine

add the tile membership inequalities

update the basis for system tile_domain

get rid of initial indices; they would be preserved to generate shared memory code

get rid of tile_basis_in_initial_basis; we might as well (?) keep them and get rid of tile_basis_in_tile_basis

apply a row echelon transformation

transform these constraints into a loop nest with the right body, starting with the innermost loop

optimization : Loop indices that are constant and don't appear in the program body are not generated

distribute work statically on processors using the outermost loop (assumed parallel!) if proc_id is properly defined; this should not be the case for bank tiles

I may need a definition for PROC_ID = MOD(I_0, PROCESSOR_NUMBER)

I need new labels and new continues for my loops! make_loop_label() needs (at least) a module name

Now, s is certainly a block; prefix it with proc_id def

Parameters
moduleodule
bodyody
proc_idroc_id
pnn
tileile
initial_basisnitial_basis
tile_basis_in_tile_basisile_basis_in_tile_basis
tile_basis_in_initial_basisile_basis_in_initial_basis
iteration_domainteration_domain
first_parallel_levelirst_parallel_level
last_parallel_levelast_parallel_level

Definition at line 227 of file code.c.

239 {
240  pips_assert("true", last_parallel_level==last_parallel_level);
242  entity ind;
243  Psysteme tile_domain = sc_dup(iteration_domain);
244  Psysteme ordered_tile_domain = SC_UNDEFINED;
245  Psysteme sctmp;
246  int id = base_dimension(initial_basis);
247  int td = base_dimension(tile_basis_in_tile_basis);
248  int l,t;
249  int keep_indice[11];
250  Value min,max;
251  int first_indice;
252  debug(8,"make_scanning_over_tiles", "begin for module %s\n",
254 
255  /* only fully-dimensional partitioning for the time being */
256  pips_assert("make_scanning_over_tiles",id==td);
257 
258  /* add change of basis equations to iteration domain:
259  tile_basis_in_tile_basis to tile_basis_in_initial_basis;
260  they would be of no use for a shared memory machine */
261 
262  tile_change_of_basis(tile_domain,initial_basis,
263  tile_basis_in_tile_basis,
264  tile_basis_in_initial_basis,tile);
265 
266  /* add the tile membership inequalities */
267  tile_domain = sc_append(tile_domain,
269  tile_basis_in_initial_basis,
270  initial_basis));
271 
272  /* update the basis for system tile_domain */
273  base_rm(sc_base(tile_domain));
274  sc_base(tile_domain) = BASE_NULLE;
275  sc_creer_base(tile_domain);
276 
277  tile_domain=sc_normalize(tile_domain);
278 
279  ifdebug(8) {
280  (void) fprintf(stderr, "Tile basis -> initial basis:\n");
281  sc_fprint(stderr, tile_domain,(string(*)(Variable)) entity_local_name);
282  }
283 
284  /* get rid of initial indices; they would be preserved to generate
285  shared memory code */
286  for(l=1; l <= id; l++) {
287  entity ind = (entity) variable_of_rank(initial_basis, l);
288  tile_domain = sc_projection_pure(tile_domain, (Variable) ind);
289  }
290 
291  /* get rid of tile_basis_in_initial_basis; we might as well (?) keep
292  them and get rid of tile_basis_in_tile_basis */
293  for(l=1; l <= td; l++) {
294  entity ind = (entity) variable_of_rank(tile_basis_in_initial_basis, l);
295  tile_domain = sc_projection_pure(tile_domain, (Variable) ind);
296  }
297 
298  ifdebug(8) {
299  (void) fprintf(stderr, "Constraints on tile indices:\n");
300  sc_fprint(stderr, tile_domain, (string(*)(Variable))entity_local_name);
301  }
302 
303  /* apply a row echelon transformation */
304  ordered_tile_domain =
305  new_loop_bound(tile_domain, tile_basis_in_tile_basis);
306  sc_transform_eg_in_ineg(ordered_tile_domain);
307 
308  ifdebug(8) {
309  (void) fprintf(stderr, "Ordered constraints on tile indices:\n");
310  sc_fprint(stderr, ordered_tile_domain, (string(*)(Variable))entity_local_name);
311  }
312 
313 
314 
315  /* transform these constraints into a loop nest with the right body,
316  starting with the innermost loop */
317  s = make_block_statement(body);
318 
319  pips_debug(9, "body statement:");
321 
322  for(t = td; t >= 1; t--) {
323  keep_indice[t]=true;
324  sctmp = sc_dup(ordered_tile_domain);
325  sc_minmax_of_variable(sctmp,
326  variable_of_rank(tile_basis_in_tile_basis, t),
327  &min,
328  &max);
329  ind = (entity) variable_of_rank(tile_basis_in_tile_basis, t);
330  if ( value_eq(min,max) && !reference_in_statement_p(s,ind)) {
331  fprintf(stderr,"indice de tuile inutile %d, %s\n",t,
332  entity_local_name(ind));
333  keep_indice[t] = false;
334  }
335  }
336 
337  for (t=1;t<=td && keep_indice[t]== false;t++);
338  first_indice = (t==td+1) ? td:t;
339  ifdebug(7)
340  fprintf(stderr,"first tile index %d, %s\n",first_indice,
342  ((entity) variable_of_rank(tile_basis_in_tile_basis, t)));
343 
344  for(t = td; t >= 1; t--)
345  {
346  expression lower;
347  expression upper;
348  range r;
349  loop new_l;
350  entity new_label;
353 
354  ind = (entity) variable_of_rank(tile_basis_in_tile_basis, t);
355 
356  /* optimization : Loop indices that are constant and
357  don't appear in the program body are not generated */
358 
359  if (keep_indice[t]){
360 
362  tile_basis_in_tile_basis,
363  ordered_tile_domain,
364  &lower, &upper);
365 
366  /* distribute work statically on processors using the outermost
367  loop (assumed parallel!) if proc_id is properly defined;
368  this should not be the case for bank tiles */
369  if(t !=first_parallel_level ||
370  !storage_formal_p(entity_storage(proc_id)))
371  r = make_range(lower, upper, int_to_expression(1));
372  else {
373  normalized n = NORMALIZE_EXPRESSION(lower);
374  if(normalized_linear_p(n)
376  lower = entity_to_expression(proc_id);
377  else
378  lower = MakeBinaryCall
380  lower,
381  entity_to_expression(proc_id));
382  r = make_range(lower, upper, int_to_expression(pn));
383  }
384 
385  /* I may need a definition for PROC_ID = MOD(I_0, PROCESSOR_NUMBER) */
386  if(t==first_parallel_level &&
387  !storage_formal_p(entity_storage(proc_id))) {
389  (entity_to_expression(proc_id),
393  int_to_expression(pn)));
394  }
395  else ps = statement_undefined;
396 
397  /* I need new labels and new continues for my loops!
398  make_loop_label() needs (at least) a module name */
399  new_label = make_loop_label(9000, module);
400  cs = make_continue_statement(new_label);
401 
404  CONS(STATEMENT, cs, NIL));
405  else
407  CONS(STATEMENT, cs,
408  NIL)));
409 
410  /* Now, s is certainly a block; prefix it with proc_id def */
411  if(ps != statement_undefined)
413  CONS(STATEMENT, ps,
415 
416  new_l = make_loop(ind, r, s,
417  new_label,
419  NIL);
420  s = loop_to_statement(new_l);
421  }
422  }
423 
424  statement_comments(s) =
425  strdup(concatenate("\nC To scan the tile set for ",
426  module_local_name(module), "\n", NULL));
427 
428  ifdebug(8) {
429  (void) fprintf(stderr, "Loop nest over tiles:\n");
431  }
432 
433  pips_debug(8,"end\n");
434 
435  return s;
436 }
#define value_eq(v1, v2)
bool operators on values
static bool reference_in_statement_p(statement l, entity v)
Definition: code.c:83
statement make_assign_statement(expression, expression)
Definition: statement.c:583
#define PLUS_OPERATOR_NAME
#define MOD_INTRINSIC_NAME
entity local_name_to_top_level_entity(const char *n)
This function try to find a top-level entity from a local name.
Definition: entity.c:1450
expression entity_to_expression(entity e)
if v is a constant, returns a constant call.
Definition: expression.c:165
#define storage_formal_p(x)
Definition: ri.h:2522
Psysteme sc_normalize(Psysteme ps)
Psysteme sc_normalize(Psysteme ps): normalisation d'un systeme d'equation et d'inequations lineaires ...

References base_dimension, BASE_NULLE, base_rm, concatenate(), CONS, debug(), entity_local_name(), entity_storage, entity_to_expression(), fprintf(), gen_nconc(), ifdebug, instruction_block, instruction_block_p, int_to_expression(), is_execution_sequential, local_name_to_top_level_entity(), loop_to_statement, make_assign_statement(), make_block_statement(), make_bound_expression(), make_continue_statement(), make_execution(), make_loop(), make_loop_label(), make_range(), MakeBinaryCall(), max, min, MOD_INTRINSIC_NAME, module, module_local_name(), new_loop_bound(), NIL, NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, pips_assert, pips_debug, PLUS_OPERATOR_NAME, reference_in_statement_p(), sc_append(), sc_creer_base(), sc_dup(), sc_fprint(), sc_minmax_of_variable(), sc_normalize(), sc_transform_eg_in_ineg(), STATEMENT, statement_comments, statement_instruction, statement_undefined, storage_formal_p, strdup(), tile_change_of_basis(), tile_membership(), tiling_tile, UU, value_eq, variable_of_rank(), VECTEUR_NUL_P, and wp65_debug_print_text().

Referenced by loop_nest_to_wp65_code().

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

◆ make_store_blocks()

void make_store_blocks ( entity  initial_module,
entity  compute_module,
entity  memory_module,
entity  var,
entity  shared_variable,
entity  local_variable,
list  lrefs,
hash_table  r_to_ud,
Psysteme  sc_domain,
Pbase  index_base,
Pbase  bank_indices,
Pbase  tile_indices,
Pbase  loop_body_indices,
entity  Proc_id,
int  pn,
int  bn,
int  ls,
statement store_block,
statement bank_store_block,
int  first_parallel_level,
int  last_parallel_level 
)

is true if it is the generation of code for bank false if it is for engine

is true if the generated code must be a RECEIVE, false if it must be a SEND

Cases where the references are scalar variables

In the other cases the references must be classified in lists of uniform dependent references

For each list of uniform dependent references, "store_block" and "bank_store_block" are computed

Parameters
initial_modulenitial_module
compute_moduleompute_module
memory_moduleemory_module
varar
shared_variablehared_variable
local_variableocal_variable
lrefsrefs
r_to_ud_to_ud
sc_domainc_domain
index_basendex_base
bank_indicesank_indices
tile_indicesile_indices
loop_body_indicesoop_body_indices
Proc_idroc_id
pnn
bnn
lss
store_blocktore_block
bank_store_blockank_store_block
first_parallel_levelirst_parallel_level
last_parallel_levelast_parallel_level

Definition at line 1166 of file code.c.

1189 {
1190  pips_assert("true", last_parallel_level==last_parallel_level
1191  && first_parallel_level==first_parallel_level);
1192  list ldr;
1193  list lldr = NIL;
1194  list lrs;
1195  Psysteme sc_image,sc_array_function;
1196  int n,dim_h;
1197  Pbase const_base;
1198  Pbase new_index_base= BASE_NULLE;
1199  Pbase new_tile_indices = BASE_NULLE;
1200  reference r;
1201  bool bank_code; /* is true if it is the generation
1202  of code for bank false if it is
1203  for engine */
1204  bool receive_code; /* is true if the generated code
1205  must be a RECEIVE, false if it
1206  must be a SEND*/
1207  statement stat1,stat2,sb,bsb;
1208  cons * bst_sb = NIL;
1209  cons * bst_bsb = NIL;
1210  Pbase var_id;
1211  Pvecteur ppid = vect_new((char *) Proc_id, VALUE_ONE);
1212  Psysteme sc_image2= SC_UNDEFINED;
1213  debug(8,"make_store_blocks",
1214  "begin variable=%s, shared_variable=%s, local_variable=%s\n",
1215  entity_local_name(var), entity_local_name(shared_variable),
1216  entity_local_name(local_variable));
1217 
1218  ifdebug(8) {
1219  list crefs;
1220  (void) fprintf(stderr, "Associated reference list:");
1221  for(crefs=lrefs; !ENDP(crefs); POP(crefs)) {
1222  reference r1 = REFERENCE(CAR(crefs));
1223  print_reference(r1);
1224  if(ENDP(CDR(crefs)))
1225  (void) putc('\n', stderr);
1226  else
1227  (void) putc(',', stderr);
1228  }
1229  }
1230 
1231 
1232  /* Cases where the references are scalar variables */
1233 
1234  for (lrs =lrefs ; !ENDP(lrs) ; POP(lrs)) {
1235  r = REFERENCE(CAR(lrs));
1236  if (reference_indices(r) ==NIL) {
1237  receive_code = false;
1238  *store_block=make_movement_scalar_wp65(compute_module,
1239  receive_code,
1240  r,Proc_id);
1241  receive_code = true;
1242  *bank_store_block=
1243  make_movement_scalar_wp65(memory_module,receive_code,
1244  r,(entity) bank_indices->var);
1245  return;
1246  }
1247  }
1248 
1249  /* In the other cases the references must be classified in lists of
1250  uniform dependent references */
1251 
1252  for ( lrs = lrefs; lrs != NIL ; lrs = CDR(lrs) ) {
1253  r = REFERENCE(CAR(lrefs));
1254  if ( (intptr_t)hash_get(r_to_ud, r) == (intptr_t)is_action_write)
1255  lldr = classify_reference(lldr,r);
1256  }
1257 
1258  /* For each list of uniform dependent references, "store_block" and
1259  "bank_store_block" are computed */
1260 
1261  for (ldr = lldr;ldr != NIL;ldr = CDR(ldr)) {
1262 
1263  sc_array_function=
1264  build_sc_with_several_uniform_ref(initial_module,
1265  LIST(CAR(ldr)),
1266  sc_domain,&new_index_base);
1267  new_index_base = vect_add(new_index_base,
1268  vect_dup(index_base));
1269 
1270  sc_image = sc_image_computation(initial_module,
1271  var,sc_domain,
1272  sc_array_function,new_index_base,
1273  &const_base,Proc_id,bank_indices,
1274  tile_indices,&new_tile_indices,
1275  pn,bn,ls,
1276  &n,&dim_h);
1277  nullify_offsets();
1278  sc_image2 = sc_dup(sc_image);
1279  bank_code = true ;
1280  receive_code = true;
1281  var_id = (Pbase) vect_new(vecteur_var(ppid),
1282  vecteur_val(ppid));
1283  stat1 = movement_computation(memory_module,false,bank_code,
1284  receive_code,
1285  shared_variable,sc_image,
1286  const_base,bank_indices,
1287  new_tile_indices,
1288  var_id,loop_body_indices,n,dim_h);
1289  initialize_offsets(ldr);
1290  bank_code = false ;
1291  receive_code = false;
1292  var_id = (Pbase) vect_new(vecteur_var(bank_indices),
1293  vecteur_val(bank_indices));
1294  stat2 = movement_computation(compute_module,false,bank_code,
1295  receive_code,
1296  local_variable,sc_image2,
1297  const_base,bank_indices,
1298  new_tile_indices,
1299  var_id,loop_body_indices,n,dim_h);
1300 
1301  bst_sb = CONS(STATEMENT,stat2,bst_sb);
1302  bst_bsb =CONS(STATEMENT,stat1,bst_bsb);
1303  }
1304  sb = make_block_statement(bst_sb);
1305  bsb=make_block_statement(bst_bsb);
1306  *store_block = sb;
1307  *bank_store_block = bsb;
1308 
1309  debug(8,"make_store_blocks", "end\n");
1310 }

References BASE_NULLE, build_sc_with_several_uniform_ref(), CAR, CDR, classify_reference(), CONS, debug(), ENDP, entity_local_name(), false, fprintf(), hash_get(), ifdebug, initialize_offsets(), intptr_t, is_action_write, LIST, make_block_statement(), make_movement_scalar_wp65(), movement_computation(), NIL, nullify_offsets(), pips_assert, POP, print_reference(), REFERENCE, reference_indices, sc_dup(), sc_image_computation(), STATEMENT, true, VALUE_ONE, Svecteur::var, vect_add(), vect_dup(), vect_new(), vecteur_val, and vecteur_var.

Referenced by make_all_movement_blocks().

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

◆ make_store_map()

void make_store_map ( void  )

◆ make_tile_constraints()

Psysteme make_tile_constraints ( matrice  P,
Pbase  b 
)

Psysteme make_tile_constraints(P, b):

convert a partitioning matrice into a system of linear constraints for a tile whose origin is 0, i.e. generate constraints over local indices:

-> -1 -> -—> 0 <= k P b <= (k-1)

where k is the denominator of P inverse.

FI: such functions should be put together in a file, linear.c

pips_assert("make_tile_constraints", k > 1);

Definition at line 591 of file variable.c.

594 {
595  Psysteme tc = sc_new();
596 
597  int d = base_dimension(b);
598  Value k = DENOMINATOR(P);
599  int i,j;
600 
601  matrice IP = matrice_new(d,d);
602  Pcontrainte c1;
603 
604  debug(8,"make_tile_constraints", "begin\n");
605 
606  pips_assert("make_tile_constraints", value_one_p(k));
607 
608  ifdebug(8) {
609  (void) fprintf(stderr,"Partitioning matrix P:\n");
610  matrice_fprint(stderr, P, d, d);
611  }
612 
613  matrice_general_inversion(P, IP, d);
614  matrice_normalize(IP, d, d);
615  k = DENOMINATOR(IP);
616 
617  /* pips_assert("make_tile_constraints", k > 1); */
618 
619  ifdebug(8) {
620  (void) fprintf(stderr,"Inverse of partitioning matrix, IP:\n");
621  matrice_fprint(stderr, IP, d, d);
622  }
623 
624  for ( i=1; i<=d; i++) {
626 
627  for ( j=1; j<=d; j++) {
629  variable_of_rank(b,i),
630  value_uminus(ACCESS(IP, d, j, i)));
631 
632  }
633  sc_add_inegalite(tc, c);
634  c1 = contrainte_dup(c);
635  contrainte_chg_sgn(c1);
637  sc_add_inegalite(tc, c1);
638  }
639 
640  sc_creer_base(tc);
641  matrice_free(IP);
642 
643  ifdebug(8) {
644  sc_fprint(stderr, tc, (string(*)(Variable))entity_local_name);
645  }
646 
647  debug(8,"make_tile_constraints", "end\n");
648 
649  return (tc);
650 }
#define value_minus(v1, v2)
#define value_uminus(val)
unary operators on values
#define value_one_p(val)
#define contrainte_vecteur(c)
passage au champ vecteur d'une contrainte "a la Newgen"
Pcontrainte contrainte_dup(Pcontrainte c_in)
Pcontrainte contrainte_dup(Pcontrainte c_in): allocation d'une contrainte c_out prenant la valeur de ...
Definition: alloc.c:132
Pcontrainte contrainte_new(void)
package contrainte - allocations et desallocations
Definition: alloc.c:47
void contrainte_chg_sgn(Pcontrainte)
void contrainte_chg_sgn(Pcontrainte eq): changement de signe d'une contrainte, i.e.
Definition: unaires.c:56
#define DENOMINATOR(matrix)
int DENOMINATEUR(matrix): acces au denominateur global d'une matrice matrix La combinaison *(&()) est...
Definition: matrice-local.h:93
#define matrice_free(m)
Definition: matrice-local.h:78
void matrice_general_inversion(matrice a, matrice inv_a, int n)
void matrice_general_inversion(matrice a; matrice inv_a; int n) calcul de l'inversion du matrice gene...
Definition: inversion.c:222
void matrice_normalize(matrice a, int n, int m)
void matrice_normalize(matrice a, int n, int m)
Definition: matrice.c:125
void matrice_fprint(FILE *, matrice, int, int)
matrice_io.c
Definition: matrice_io.c:62
static int tc
Internal variables
Definition: reindexing.c:107
void sc_add_inegalite(Psysteme p, Pcontrainte i)
void sc_add_inegalite(Psysteme p, Pcontrainte i): macro ajoutant une inegalite i a un systeme p; la b...
Definition: sc_alloc.c:406

References ACCESS, base_dimension, contrainte_chg_sgn(), contrainte_dup(), contrainte_new(), contrainte_vecteur, debug(), DENOMINATOR, entity_local_name(), fprintf(), ifdebug, matrice_fprint(), matrice_free, matrice_general_inversion(), matrice_new, matrice_normalize(), pips_assert, sc_add_inegalite(), sc_creer_base(), sc_fprint(), sc_new(), tc, TCST, value_minus, VALUE_ONE, value_one_p, value_uminus, variable_of_rank(), and vect_add_elem().

Referenced by set_dimensions_of_local_variables().

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

◆ MakeEntityFunction()

entity MakeEntityFunction ( string  sname)
Parameters
snamename

Definition at line 101 of file wp65.c.

102 {
104  return f;
105 }
language make_language_unknown(void)
Definition: ri.c:1259
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
entity make_empty_function(const char *name, type r, language l)
Definition: entity.c:283
type MakeIntegerResult(void)
Definition: type.c:276

References f(), make_empty_function(), make_language_unknown(), and MakeIntegerResult().

Referenced by module_to_wp65_modules().

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

◆ model_fprint()

void model_fprint ( FILE *  fd,
int  pn,
int  bn,
int  ls 
)

model.c

model.c

Reads and prints the target machine description (compatible formats) Temporary version. A more general machine model should be defined by Lei for complexity evaluation.

File: model.c

PUMA, ESPRIT contract 2701

Francois Irigoin 1991 ???

Parameters
fdd
pnn
bnn
lss

Definition at line 50 of file model.c.

51 {
52  fprintf(fd,
53  "Target Machine:\n"
54  "Processor number: %d\n"
55  "Memory bank number: %d\n"
56  "Bank width (i.e. line size): %d\n\n", pn, bn, ls);
57 }

References fprintf().

Referenced by wp65().

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

◆ model_fscan()

void model_fscan ( FILE *  fd,
int ppn,
int pbn,
int pls 
)
Parameters
fdd
ppnpn
pbnbn
plsls

Definition at line 59 of file model.c.

60 {
61  int i1, i2, i3, i4;
62  i1 = fscanf(fd, "Target Machine:\n");
63  i2 = fscanf(fd, "Processor number: %d\n", ppn);
64  i3 = fscanf(fd, "Memory bank number: %d\n", pbn);
65  i4 = fscanf(fd, "Bank width (i.e. line size): %d\n\n", pls);
66  if(i1!=0 && i2!=1 && i3!=1 && i4!=1) {
67  user_error("model_fscan", "Bad format for machine model\n");
68  }
69 }
#define user_error(fn,...)
Definition: misc-local.h:265

References user_error.

Referenced by get_model().

+ Here is the caller graph for this function:

◆ module_to_wp65_modules()

void module_to_wp65_modules ( entity  module,
statement  module_code,
graph  dg,
int  pn,
int  bn,
int  ls,
int  pd,
entity pcompute_module,
statement pcomputational,
entity pmemory_module,
statement pemulator 
)

variable to emulated shared variable

To establish an occurence numbering accross loop nests

Generate two new modules, compute module and memory module

Generate scalar variables that are going to be used all over the compute and memory module

variables related to bank emulation are put together in one basis to decrease the number of parameters; they are used as such when liner systems of constraints are built

skip a potential useless unstructured

generate code for each loop nest in the module and append it to computational and emulator

kill_statement_number_and_ordering(computational); kill_statement_number_and_ordering(emulator);

return results

Parameters
moduleodule
module_codeodule_code
dgg
pnn
bnn
lss
pdd
pcompute_modulecompute_module
pcomputationalcomputational
pmemory_modulememory_module
pemulatoremulator

Definition at line 202 of file wp65.c.

217 {
218  string compute_module_name;
219  string memory_module_name;
221  list l = list_undefined;
222  entity proc_id = entity_undefined;
223  entity proc_id_mm = entity_undefined;
224  entity bank_id = entity_undefined;
225  entity bank_line = entity_undefined;
226  entity bank_offset = entity_undefined;
227  Pbase bank_indices = BASE_NULLE;
229 
230  /* variable to emulated shared variable */
232  /* To establish an occurence numbering accross loop nests */
233  hash_table v_to_nlv = hash_table_make(hash_pointer, 0);
234 
235  entity compute_module;
236  statement computational;
237  entity memory_module;
238  statement emulator;
241  entity div;
242 
243  debug(6,"module_to_wp65_modules","begin\n");
244 
245  /* Generate two new modules, compute module and memory module
246  */
247  compute_module_name = strdup(COMPUTE_ENGINE_NAME);
248  compute_module = make_empty_subroutine(compute_module_name,copy_language(module_language(module)));
249 
250  module_functional_parameters(compute_module)
254  NIL);
255 
256  memory_module_name = strdup(BANK_NAME);
257  memory_module = make_empty_subroutine(memory_module_name,copy_language(module_language(module)));
258 
259  module_functional_parameters(memory_module)
260  = CONS(PARAMETER,
262  4), NIL),
265  NIL);
266  computational = make_block_statement(NIL);
267  emulator = make_block_statement(NIL);
268 
269  div =MakeEntityFunction("idiv");
270  AddEntityToDeclarations(div,compute_module);
271  AddEntityToDeclarations(div,memory_module);
272 
273 
274  /* Generate scalar variables that are going to be used all over
275  the compute and memory module
276  */
278  entity_local_name(memory_module));
279  AddEntityToDeclarations( proc_id_mm,memory_module);
280 
282  entity_local_name(compute_module));
284  make_formal(compute_module, 1));
285  AddEntityToDeclarations( proc_id,compute_module);
286 
288  entity_local_name(compute_module));
289  AddEntityToDeclarations( bank_id,compute_module);
290 
292  entity_local_name(memory_module));
294  make_formal(memory_module, 1));
295  AddEntityToDeclarations( bank_id,memory_module);
296 
298  entity_local_name(compute_module));
299  AddEntityToDeclarations( bank_line,compute_module);
300 
302  entity_local_name(memory_module));
303  AddEntityToDeclarations( bank_line,memory_module);
304 
306  entity_local_name(memory_module));
307  AddEntityToDeclarations( bank_offset,memory_module);
309  entity_local_name(compute_module));
310  AddEntityToDeclarations( bank_offset,compute_module);
311  /* variables related to bank emulation are put together in one basis
312  to decrease the number of parameters; they are used as such when
313  liner systems of constraints are built */
314  bank_indices =
316  (char*)
317  bank_offset),
318  (char *) bank_line),
319  (char *) bank_id);
320 
321  ifdebug(6) {
322  (void) fprintf(stderr,"Bank indices:\n");
323  vect_fprint(stderr, bank_indices, (string(*)(void*))entity_local_name);
324  (void) fprintf(stderr,"Code for the computational module:\n");
325  wp65_debug_print_module(compute_module,computational);
326  (void) fprintf(stderr,"Code for the memory module:\n");
327  wp65_debug_print_module(memory_module,emulator);
328  }
329 
330 
331  /* skip a potential useless unstructured */
332  i = statement_instruction(module_code);
337  }
338 
339  /* generate code for each loop nest in the module and append it
340  to computational and emulator */
341  l = instruction_block(i);
342 
343  compute_communications(l,&fetch_map,&store_map);
344 
346  pn, bn, ls, pd,
347  proc_id, proc_id_mm, bank_indices,
348  v_to_esv, v_to_nlv,
349  compute_module, computational,
350  memory_module, emulator, fetch_map,store_map);
351 
352  i = statement_instruction(computational);
354  CONS(STATEMENT,
355  make_return_statement(compute_module),
356  NIL));
357  i = statement_instruction(emulator);
359  CONS(STATEMENT,
360  make_return_statement(memory_module),
361  NIL));
362 
363 
364  fs = STATEMENT(CAR(instruction_block(statement_instruction(computational))));
365  statement_comments(fs) =
366  strdup(concatenate("\nC WP65 DISTRIBUTED CODE FOR ",
367  module_local_name(module), "\n",
369  ? NULL :statement_comments(fs)),
370  NULL));
371  module_reorder(fs);
373  statement_comments(fs) =
374  strdup(concatenate("\nC BANK DISTRIBUTED CODE FOR ",
375  module_local_name(module), "\n",
377  ? NULL :statement_comments(fs)),
378  NULL));
379  module_reorder(fs);
380  /* kill_statement_number_and_ordering(computational);
381  kill_statement_number_and_ordering(emulator);*/
382 
383 
384  ifdebug(1) {
385  (void) fprintf(stderr,"Final code for the computational module:\n");
386  wp65_debug_print_module(compute_module,computational);
387  (void) fprintf(stderr,"Final code for the memory module:\n");
388  wp65_debug_print_module(memory_module,emulator);
389  }
390 
391  hash_table_free(v_to_esv);
392  hash_table_free(v_to_nlv);
393 
394  /* return results */
395  * pcompute_module = compute_module;
396  * pcomputational = computational;
397  * pmemory_module = memory_module;
398  * pemulator = emulator;
399 
400  debug(6,"module_to_wp65_modules","end\n");
401 
402 }
parameter make_parameter(type a1, mode a2, dummy a3)
Definition: ri.c:1495
mode make_mode(enum mode_utype tag, void *val)
Definition: ri.c:1350
basic make_basic_int(intptr_t _field_)
Definition: ri.c:158
language copy_language(language p)
LANGUAGE.
Definition: ri.c:1202
dummy make_dummy_unknown(void)
Definition: ri.c:617
formal make_formal(entity a1, intptr_t a2)
Definition: ri.c:1067
void compute_communications(list l, statement_mapping *fetch_map, statement_mapping *store_map)
This function associates to each variable the statement in l where it should be communicated Fecth_ma...
#define list_undefined
Undefined list definition :-)
Definition: newgen_list.h:69
statement make_return_statement(entity)
Definition: statement.c:779
void wp65_debug_print_module(entity m, statement s)
#define MAKE_STATEMENT_MAPPING()
Definition: newgen-local.h:43
#define string_undefined_p(s)
Definition: newgen_types.h:41
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
Definition: reorder.c:244
#define unstructured_control
After the modification in Newgen: unstructured = entry:control x exit:control we have create a macro ...
#define module_language(e)
implemented as a macro to allow lhs
#define module_functional_parameters(func)
entity make_empty_subroutine(const char *name, language l)
Definition: entity.c:268
@ is_mode_reference
Definition: ri.h:1676
#define instruction_undefined
Definition: ri.h:1454
@ is_storage_formal
Definition: ri.h:2493
#define PARAMETER(x)
PARAMETER.
Definition: ri.h:1788
#define instruction_unstructured_p(x)
Definition: ri.h:1530
#define control_statement(x)
Definition: ri.h:941
#define instruction_unstructured(x)
Definition: ri.h:1532
#define BANK_IDENTIFIER
Definition: wp65-local.h:42
#define BANK_NAME
#define WP65_SUFFIX "_WP65"
Definition: wp65-local.h:39
#define COMPUTE_ENGINE_NAME
Definition: wp65-local.h:37
#define BANK_LINE_IDENTIFIER
Definition: wp65-local.h:43
#define PROCESSOR_IDENTIFIER
#define MEMORY_EMULATOR_SUFFIX "_BANK"
Definition: wp65-local.h:41
#define BANK_OFFSET_IDENTIFIER
Definition: wp65-local.h:44
entity MakeEntityFunction(string sname)
Definition: wp65.c:101

References AddEntityToDeclarations(), BANK_IDENTIFIER, BANK_LINE_IDENTIFIER, BANK_NAME, BANK_OFFSET_IDENTIFIER, BASE_NULLE, CAR, compute_communications(), COMPUTE_ENGINE_NAME, concatenate(), CONS, control_statement, copy_language(), debug(), dg, entity_local_name(), entity_storage, entity_undefined, fprintf(), gen_nconc(), hash_pointer, hash_table_free(), hash_table_make(), ifdebug, instruction_block, instruction_to_wp65_code(), instruction_undefined, instruction_unstructured, instruction_unstructured_p, is_mode_reference, is_storage_formal, list_undefined, make_basic_int(), make_block_statement(), make_dummy_unknown(), make_empty_subroutine(), make_formal(), make_mode(), make_parameter(), make_return_statement(), make_scalar_integer_entity(), MAKE_STATEMENT_MAPPING, make_storage(), MakeEntityFunction(), MakeTypeVariable(), module, module_functional_parameters, module_language, module_local_name(), module_reorder(), NIL, PARAMETER, PROCESSOR_IDENTIFIER, STATEMENT, statement_comments, statement_instruction, statement_undefined, strdup(), string_undefined_p, unstructured_control, UU, vect_add_variable(), vect_fprint(), and wp65_debug_print_module().

Referenced by wp65().

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

◆ ref_in_implied_do()

expression ref_in_implied_do ( expression  exp)

This function extracts from an implied_do expression the reference having to be computed or printed.

Parameters
expxp

Definition at line 328 of file instruction_to_wp65_code.c.

329 {
331  list call_args = call_arguments(c2);
332  expression last_call = EXPRESSION(CAR(gen_last(call_args)));
333  syntax s = expression_syntax(last_call);
334 
335  return((syntax_call_p(s)
337  "IMPLIED-DO") == 0)) ?
338  ref_in_implied_do(last_call):
339  last_call );
340 }
list gen_last(list l)
Return the last element of a list.
Definition: list.c:578
expression ref_in_implied_do(expression exp)
This function extracts from an implied_do expression the reference having to be computed or printed.
#define syntax_call_p(x)
Definition: ri.h:2734
#define exp
Avoid some warnings from "gcc -Wshadow".
Definition: vasnprintf.c:207

References call_arguments, call_function, CAR, entity_local_name(), exp, EXPRESSION, expression_syntax, gen_last(), syntax_call, and syntax_call_p.

Referenced by translate_IO_ref().

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

◆ ref_in_list_p()

bool ref_in_list_p ( list  lt,
reference  r 
)

references.c

Parameters
ltt

Definition at line 62 of file references.c.

63 {
64  pips_assert("true", lt==lt && r==r);
65  return (false);
66 }

References pips_assert.

Referenced by update_map().

+ Here is the caller graph for this function:

◆ reference_conflicting_p()

bool reference_conflicting_p ( reference  r1,
reference  r2,
graph  dg 
)
Parameters
r11
r22
dgg

Definition at line 513 of file variable.c.

516 {
517  /*
518  graph = vertices:vertex* ;
519  successor = arc_label x vertex ;
520  vertex = vertex_label x successors:successor* ;
521  */
522  list ver1 = graph_vertices(dg);
523 
524  debug(8,"reference_conflicting_p","begin\n");
525  ifdebug(8) {
526  (void) fprintf(stderr,"Reference 1 %p: ", r1);
527  print_reference(r1);
528  (void) fprintf(stderr,"\nReference 2 %p: ", r2);
529  print_reference(r2);
530  (void) fputc('\n',stderr);
531  }
532 
533  MAPL(pm1,{
534  vertex v1 = VERTEX(CAR(pm1));
535  list ver2 = vertex_successors(v1);
536  MAPL(pm2,{
537  successor su = SUCCESSOR(CAR(pm2));
538 
540  list conf_list = dg_arc_label_conflicts(dal);
541 
542  MAPL(pm3,{
543  conflict conf2 = CONFLICT(CAR(pm3));
544 
545  effect e_source = conflict_source(conf2);
546  effect e_sink = conflict_sink(conf2);
547 
548  reference r11 = effect_any_reference(e_source);
549  reference r21 = effect_any_reference(e_sink);
550 
551  ifdebug(8) {
552  (void) fprintf(stderr,"Test with reference 1 %p: ", r1);
553  print_reference(r1);
554  (void) fprintf(stderr," and reference 2 %p: ", r2);
555  print_reference(r2);
556  (void) fputc('\n',stderr);
557  (void) fprintf(stderr,"Test with reference 11 %p: ", r11);
558  print_reference(r11);
559  (void) fprintf(stderr," and reference 21 %p: ", r21);
560  print_reference(r21);
561  (void) fputc('\n',stderr);
562  (void) fputc('\n',stderr);
563  }
564 
565  if( (reference_equal_p(r11,r1) && reference_equal_p(r21,r2))
566  || (reference_equal_p(r11,r2) && reference_equal_p(r21,r1)) ) {
567  debug(8,"reference_conflicting_p","return TRUE\n");
568  return true;
569  }
570  },conf_list);
571  },ver2);
572  },ver1);
573 
574  debug(8,"reference_conflicting_p","return FALSE\n");
575  return false;
576 }
struct _newgen_struct_dg_arc_label_ * dg_arc_label
Definition: dg.h:60
#define conflict_sink(x)
Definition: dg.h:167
#define CONFLICT(x)
CONFLICT.
Definition: dg.h:134
#define dg_arc_label_conflicts(x)
Definition: dg.h:201
#define conflict_source(x)
Definition: dg.h:165
#define effect_any_reference(e)
FI: cannot be used as a left hand side.
#define successor_arc_label(x)
Definition: graph.h:116
#define vertex_successors(x)
Definition: graph.h:154
#define SUCCESSOR(x)
SUCCESSOR.
Definition: graph.h:86
#define graph_vertices(x)
Definition: graph.h:82
#define VERTEX(x)
VERTEX.
Definition: graph.h:122
bool reference_equal_p(reference r1, reference r2)
Definition: expression.c:1500

References CAR, CONFLICT, conflict_sink, conflict_source, debug(), dg, dg_arc_label_conflicts, effect_any_reference, fprintf(), graph_vertices, ifdebug, MAPL, print_reference(), reference_equal_p(), SUCCESSOR, successor_arc_label, VERTEX, and vertex_successors.

Referenced by reference_conflicting_test_and_update().

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

◆ reference_conflicting_test_and_update()

bool reference_conflicting_test_and_update ( reference  r,
graph  dg,
hash_table  v_to_lllv,
hash_table  llv_to_lcr,
hash_table  r_to_llv,
hash_table  r_to_ud 
)

reference_conflicting_test_and_update():

Build, incrementally, connected component in the dependence graph. Input dependences should be used to save local memory space. Mappings are updated.

Too many local variables might be created if two connected components had to be fused. This is not likely to happen with real code. In that case, the function would stop with pips_error().

referenced variable

short cut for identical references; not necessarily a good idea for the body translation process; design to save time in transfer code generation

should go one step forwards and take care of use-def, easier by introducing a "use and def" value or by adding the new reference directly

we need to remember there is a use and a def

this is very clumsy as we may keep a large number of identical def after one use and vice-versa; we need a use-and-def value or we have to keep all references and filter them for data movements

update llv_to_lcr by side-effect

should not happen too often: the regions associated with two references do not intersect together but each of them intersect a third one on which we bump afterwards; the two initial llv's should be merged...

update llv_to_lcr by side-effect

save current_llv for a future (?) merge

no need to study conflicts with other references in the same connected component

Parameters
dgg
v_to_lllv_to_lllv
llv_to_lcrlv_to_lcr
r_to_llv_to_llv
r_to_ud_to_ud

Definition at line 401 of file variable.c.

410 {
411  list current_llv = list_undefined;
412  entity rv; /* referenced variable */
413  list lllv;
414  list cllv;
415  bool conflicting = false;
416 
417  debug(8,"reference_conflicting_test_and_update", "begin\n");
418 
419  rv = reference_variable(r);
420 
421  ifdebug(8) {
422  (void) fprintf(stderr, "reference %p to %s:",
423  r, entity_local_name(rv));
424  print_reference(r);
425  (void) putc('\n', stderr);
426  }
427 
428  if((lllv = (list) hash_get(v_to_lllv, (char *) rv))
429  == (list) HASH_UNDEFINED_VALUE) {
430  debug(8, "reference_conflicting_test_and_update",
431  "no local variables for reference %p to %s\n",
432  r, entity_local_name(rv));
433 
434  debug(8,"reference_conflicting_test_and_update", "return FALSE\n");
435  return false;
436  }
437 
438  for(cllv = lllv; !ENDP(cllv); POP(cllv)) {
439  list llv = LIST(CAR(cllv));
440  list lcr = (list) hash_get(llv_to_lcr, (char *) llv);
441  list ccr;
442 
443  for(ccr = lcr; !ENDP(ccr); POP(ccr)) {
444  reference r2 = REFERENCE(CAR(ccr));
445  entity rv2 = reference_variable(r2);
446 
447  ifdebug(8) {
448  (void) fprintf(stderr, "conflict_p with reference %p to %s:",
449  r2, entity_local_name(rv2));
450  print_reference(r2);
451  (void) putc('\n', stderr);
452  }
453 
454  if(reference_equal_p(r, r2)) {
455  if(hash_get(r_to_ud,(char*) r)==hash_get(r_to_ud,(char*) r2)){
456  /* short cut for identical references; not necessarily a good
457  idea for the body translation process; design to save
458  time in transfer code generation */
459  /* should go one step forwards and take care of use-def,
460  easier by introducing a "use and def" value or by adding
461  the new reference directly */
462 
463  debug(8,"reference_conflicting_test_and_update",
464  "reference equality and same use, return TRUE\n");
465  }
466  else {
467  /* we need to remember there is a use and a def */
468  /* this is very clumsy as we may keep a large number
469  of identical def after one use and vice-versa;
470  we need a use-and-def value or we have to keep
471  all references and filter them for data movements */
472  /* update llv_to_lcr by side-effect */
473  lcr = gen_nconc(lcr, CONS(REFERENCE, r, NIL));
474  debug(8,"reference_conflicting_test_and_update",
475  "reference equality and same use, return TRUE\n");
476  }
477  hash_put(r_to_llv, (char *) r, (char *) llv);
478  return true;
479  }
480  else if(reference_conflicting_p(r, r2, dg)) {
481  if(conflicting) {
482  /* should not happen too often: the regions associated
483  with two references do not intersect together but
484  each of them intersect a third one on which we bump
485  afterwards; the two initial llv's should be merged...
486  */
487  pips_assert("reference_conflicting_test_and_update",
488  current_llv != llv);
489  pips_internal_error("local variable merge not implemented");
490  }
491  else {
492  conflicting = true;
493  /* update llv_to_lcr by side-effect */
494  lcr = gen_nconc(lcr, CONS(REFERENCE, r, NIL));
495  hash_put(r_to_llv, (char *) r, (char *) llv);
496  /* save current_llv for a future (?) merge */
497  current_llv = llv;
498  /* no need to study conflicts with other references
499  in the *same* connected component */
500  debug(8,"reference_conflicting_test_and_update",
501  "Conflict! Look for conflicts with other components\n");
502  break;
503  }
504  }
505  }
506  }
507 
508  debug(8,"reference_conflicting_test_and_update", "return %d\n",
509  conflicting);
510  return conflicting;
511 }
bool reference_conflicting_p(reference r1, reference r2, graph dg)
Definition: variable.c:513

References CAR, CONS, debug(), dg, ENDP, entity_local_name(), fprintf(), gen_nconc(), hash_get(), hash_put(), HASH_UNDEFINED_VALUE, ifdebug, LIST, list_undefined, NIL, pips_assert, pips_internal_error, POP, print_reference(), REFERENCE, reference_conflicting_p(), reference_equal_p(), and reference_variable.

Referenced by loop_nest_to_local_variables().

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

◆ reference_conversion_computation()

list reference_conversion_computation ( entity  compute_module,
list lt,
expression  expr,
Pbase  initial_basis,
Pbase  tile_indices,
Pbase  tile_local_indices,
tiling  tile 
)

the called function is assumed to be unchanged

Parameters
compute_moduleompute_module
ltt
exprxpr
initial_basisnitial_basis
tile_indicesile_indices
tile_local_indicesile_local_indices
tileile

Definition at line 799 of file code.c.

807 {
808  syntax s = expression_syntax(expr);
809 
810  switch(syntax_tag(s)) {
811  case is_syntax_reference: {
813  entity rv = reference_variable(r);
814  int i;
815 
816  if((i=rank_of_variable(initial_basis, (Variable) rv)) > 0) {
817 
818  entity ent1 = make_new_module_variable(compute_module,200);
819  Pvecteur pv2 = vect_new((Variable) ent1, VALUE_ONE);
820  Pvecteur pvt = VECTEUR_NUL;
821  expression exp1,exp2;
823  Pvecteur pv = make_loop_indice_equation(initial_basis,tile, pvt,
824  tile_indices,
825  tile_local_indices,i);
826  AddEntityToDeclarations(ent1,compute_module);
827  reference_variable(r) = ent1 ;
828  exp1= make_vecteur_expression(pv);
829  exp2 = make_vecteur_expression(pv2);
830  stat = make_assign_statement(exp2,exp1);
831  *lt = gen_nconc(*lt,CONS(STATEMENT,stat,NIL));
832  }
833  return (*lt);
834  break;
835  }
836  case is_syntax_call:
837  /* the called function is assumed to be unchanged */
838  MAPL(ce, {
839  *lt = reference_conversion_computation(compute_module,lt,
840  EXPRESSION(CAR(ce)),initial_basis,
841  tile_indices, tile_local_indices,tile);
842  },
844  return (*lt);
845  break;
846  default:
847  pips_internal_error("Unexpected syntax tag %d", syntax_tag(s));
848  break;
849  }
850  return(*lt);
851 }
int rank_of_variable(Pbase base, Variable var)
this function returns the rank of the variable var in the base 0 encodes TCST, but I do not know why,...
Definition: base.c:497
Pvecteur make_loop_indice_equation(Pbase loop_indices, tiling tile, Pvecteur tile_delay, Pvecteur tile_indices, Pvecteur tile_local_indices, int rank)
PACKAGE MOVEMENTS.
Definition: build_sc_tile.c:51
list reference_conversion_computation(entity compute_module, list *lt, expression expr, Pbase initial_basis, Pbase tile_indices, Pbase tile_local_indices, tiling tile)
Definition: code.c:799

References AddEntityToDeclarations(), call_arguments, CAR, CONS, EXPRESSION, expression_syntax, gen_nconc(), is_syntax_call, is_syntax_reference, make_assign_statement(), make_loop_indice_equation(), make_new_module_variable(), make_vecteur_expression(), MAPL, NIL, pips_internal_error, rank_of_variable(), reference_variable, STATEMENT, statement_undefined, syntax_call, syntax_reference, syntax_tag, VALUE_ONE, vect_new(), and VECTEUR_NUL.

Referenced by reference_conversion_statement().

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

◆ reference_conversion_expression()

void reference_conversion_expression ( expression  e,
hash_table  r_to_llv,
Pvecteur  offsets,
Pbase  initial_basis,
Pbase  local_basis 
)

no pipeline, select the first entity by default

the called function is assumed to be unchanged

Parameters
r_to_llv_to_llv
offsetsffsets
initial_basisnitial_basis
local_basisocal_basis

Definition at line 864 of file code.c.

871 {
872  syntax s = expression_syntax(e);
873  int i;
874  debug(8,"reference_conversion_expression", "begin expression:");
875  ifdebug(8) {
876  print_words(stderr, Words_Expression(e));
877  (void) fputc('\n', stderr);
878  }
879 
880  switch(syntax_tag(s)) {
881  case is_syntax_reference: {
883  entity rv = reference_variable(r);
884  list llv;
885 
886  if((llv = (list) hash_get(r_to_llv, (char *) r))
887  != (list) HASH_UNDEFINED_VALUE) {
888  /* no pipeline, select the first entity by default */
889  entity new_v = ENTITY(CAR(llv));
890  reference_variable(r) = new_v;
891  }
892  else
893  if ((i=rank_of_variable(initial_basis,
894  (Variable) rv)) > 0)
895 
897  (entity) variable_of_rank(local_basis, i);
898 
899  MAPL(ce, {
901  r_to_llv, offsets,
902  initial_basis, local_basis);
903  },
904  reference_indices(r));
905  break;
906  }
907  case is_syntax_range:
908  pips_internal_error("Ranges are not (yet) handled");
909  break;
910  case is_syntax_call:
911  /* the called function is assumed to be unchanged */
912  MAPL(ce, {
914  r_to_llv, offsets,
915  initial_basis, local_basis);
916  },
918  break;
919  default:
920  pips_internal_error("Unexpected syntax tag %d", syntax_tag(s));
921  break;
922  }
923 
924  debug(8,"reference_conversion_expression", "end expression:\n");
925  ifdebug(8) {
926  print_words(stderr, Words_Expression(e));
927  (void) fputc('\n', stderr);
928  }
929 }
void reference_conversion_expression(expression e, hash_table r_to_llv, Pvecteur offsets, Pbase initial_basis, Pbase local_basis)
Definition: code.c:864
list Words_Expression(expression obj)
of string
Definition: misc.c:2616
void print_words(FILE *fd, cons *lw)
Definition: print.c:263

References call_arguments, CAR, debug(), ENTITY, EXPRESSION, expression_syntax, hash_get(), HASH_UNDEFINED_VALUE, ifdebug, is_syntax_call, is_syntax_range, is_syntax_reference, MAPL, pips_internal_error, print_words(), rank_of_variable(), reference_indices, reference_variable, syntax_call, syntax_reference, syntax_tag, variable_of_rank(), and Words_Expression().

Referenced by reference_conversion_statement().

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

◆ reference_conversion_statement()

list reference_conversion_statement ( entity  module,
statement  body,
list lt,
hash_table  r_to_llv,
Pvecteur  offsets,
Pbase  initial_basis,
Pbase  tile_indices,
Pbase  local_basis,
tiling  tile 
)

void reference_conversion_statement(body, r_to_llv, offsets, initial_basis, local_basis):

All references in body which appear in r_to_llv are replaced by references to one of the local variables associated via the r_to_llv hash_table; the choice of one specific local variable is a function of offsets, which is used to generate pipelined code (not implemented).

Statement numbers are set to STATEMENT_NUMBER_UNDEFINED.

the function is assumed to be unchanged

Parameters
moduleodule
bodyody
ltt
r_to_llv_to_llv
offsetsffsets
initial_basisnitial_basis
tile_indicesile_indices
local_basisocal_basis
tileile

Definition at line 723 of file code.c.

733 {
735 
736  pips_debug(8, "begin statement: \n");
737  ifdebug(8) {
739  }
740 
742 
743  switch(instruction_tag(i)) {
745  MAPL(cs, {
747  r_to_llv, offsets,
748  initial_basis,tile_indices, local_basis,tile);
749  },
750  instruction_block(i));
751  return(*lt);
752  break;
753  case is_instruction_test:
754  pips_internal_error("Reference conversion not implemented for tests");
755  break;
756  case is_instruction_loop:
757 
758 
761  lt, r_to_llv, offsets,
762  initial_basis,
763  tile_indices,local_basis,tile);
764  return(*lt);
765  break;
766  case is_instruction_goto:
767  pips_internal_error("Unexpected goto (in restructured code)");
768  break;
769  case is_instruction_call:
770  /* the function is assumed to be unchanged */
772  {
774  initial_basis,
775  tile_indices,
776  local_basis, tile);
778  r_to_llv, offsets,
779  initial_basis, local_basis);
780  },
782  return(*lt);
783  break;
785  pips_internal_error("Reference conversion not implemented for unstructureds");
786  break;
787  default:
788  break;
789  }
790 
791  debug(8,"reference_conversion_statement", "return statement: \n");
792  ifdebug(8) {
794  }
795  return(*lt);
796 }
#define STATEMENT_NUMBER_UNDEFINED
default values
Polymorphic argument.
Definition: printf-args.h:92

References call_arguments, CAR, debug(), entity_undefined, EXPRESSION, ifdebug, instruction_block, instruction_call, instruction_loop, instruction_tag, is_instruction_block, is_instruction_call, is_instruction_goto, is_instruction_loop, is_instruction_test, is_instruction_unstructured, loop_body, MAP, MAPL, module, pips_debug, pips_internal_error, reference_conversion_computation(), reference_conversion_expression(), STATEMENT, statement_instruction, statement_number, STATEMENT_NUMBER_UNDEFINED, and wp65_debug_print_text().

Referenced by make_compute_block().

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

◆ reference_in_list_p()

bool reference_in_list_p ( reference  r,
list  lwr 
)

This function tests whether at least one array indice of Reference r belongs to List lwr or not.

Parameters
lwrwr

Definition at line 130 of file references.c.

131 {
132  list lref2;
133  bool result = false;
134  for (lref2 = lwr;
135  lref2 != NULL && !result;
136  result = result || reference_equal_p(r,REFERENCE(CAR(lref2))),
137  lref2 = CDR(lref2)) ;
138  return(result);
139 }

References CAR, CDR, REFERENCE, and reference_equal_p().

Referenced by array_indice_in_list_p(), call_instruction_to_communications(), and make_all_movement_blocks().

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

◆ reference_list_add()

void reference_list_add ( list l1,
list l2 
)

This function adds all the references of l2 to l1 if they don't appear in l1.

Parameters
l11
l22

Definition at line 175 of file references.c.

176 {
177  list lref2 =*l2 ;
178  for(; lref2!= NIL;
179  reference_list_update(l1, REFERENCE(CAR(lref2))),
180  lref2 = CDR(lref2));
181 }

References CAR, CDR, NIL, REFERENCE, and reference_list_update().

Referenced by concat_data_list(), loop_instruction_to_communications(), and statement_to_communications().

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

◆ reference_list_print()

void reference_list_print ( list  l)

This function prints the references belonging to l.

Definition at line 186 of file references.c.

187 {
188  list lref;
189  for (lref = l;
190  lref != NIL;
191  (void) fprintf(stderr,
192  "%s,",
194  lref = CDR(lref));
195  (void) fprintf(stderr,"\n");
196 }

References CAR, CDR, entity_local_name(), fprintf(), NIL, REFERENCE, and reference_variable.

Referenced by call_instruction_to_communications(), call_to_wp65_code(), insert_array_scalar_access_movement(), and loop_nest_to_wp65_code().

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

◆ reference_list_update()

void reference_list_update ( list l,
reference  r 
)

This function add Reference r to List l, if r doesn't belong to l.

Definition at line 161 of file references.c.

162 {
163  list lref1 =*l ;
164  if (*l != NIL) {
165  for(; lref1!= NIL && !(reference_equal_p(REFERENCE(CAR(lref1)),r)) ;
166  lref1 = CDR(lref1));
167  if (lref1 == NIL)
168  *l= gen_nconc(*l, CONS(REFERENCE,r,NIL));
169  }
170  else *l = CONS(REFERENCE,r,NIL);
171 }

References CAR, CDR, CONS, gen_nconc(), NIL, REFERENCE, and reference_equal_p().

Referenced by call_instruction_to_communications(), loop_instruction_to_communications(), and reference_list_add().

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

◆ reference_scalar_defined_p()

void reference_scalar_defined_p ( reference  r)

Definition at line 199 of file references.c.

200 {
202  && r!=NULL && reference_variable(r)!=NULL
203  && reference_indices(r) == NIL);
204 }
#define reference_undefined_p(x)
Definition: ri.h:2303

References assert, NIL, reference_indices, reference_undefined_p, and reference_variable.

Referenced by loop_nest_to_wp65_code().

+ Here is the caller graph for this function:

◆ reference_translation()

entity reference_translation ( reference  r,
Pbase  initial_basis,
Pbase  local_basis 
)
Parameters
initial_basisnitial_basis
local_basisocal_basis

Definition at line 855 of file code.c.

856 {
857  int i;
858  entity rv = reference_variable(r);
859  if((i=rank_of_variable(initial_basis, (Variable) rv)) > 0)
860  return((entity) variable_of_rank(local_basis, i));
861  else return(entity_undefined);
862 }

References entity_undefined, rank_of_variable(), reference_variable, and variable_of_rank().

+ Here is the call graph for this function:

◆ reset_fetch_map()

void reset_fetch_map ( void  )

◆ reset_store_map()

void reset_store_map ( void  )

◆ search_parallel_loops()

void search_parallel_loops ( statement  ,
statement  ,
graph  ,
bool  [11] 
)

◆ set_dimensions_of_local_variable_family()

void set_dimensions_of_local_variable_family ( list  llv,
Psysteme  tc,
list  lr,
tiling  tile,
int  dimn 
)

void set_dimensions_of_local_variable_family(llv, tc, lr):

The algorithm used is not general; references are assumed equal up to a translation;

A general algorithm, as would be necessary for instance if a dependence was detected in the transposition algorithm between M(I,J) and M(J,I), would preserve some translation information for each reference in lr so as to generate proper new references to the local variable.

let's use the first reference to find out the number of dimensions

referenced variable

referenced variable type

referenced variable dimension list

dimension number

dimensions for the local variables

computation of the initial bounds of Entity rv

pips_assert("set_dimensions_of_local_variable_family",

pour tenir compte des offsets numeriques dans les fonctions d'acces

parameter ==> min = max = 1

ips_internal_error("unbounded domain for phi, %s", "check tile bounds and subscript expressions");

update types

sharing is not legal under NewGen rules; to avoid it lvd is duplicated at the CONS level, except the first time

Parameters
llvlv
tcThe algorithm used is not general; references are assumed equal up to a translation;

A general algorithm, as would be necessary for instance if a dependence was detected in the transposition algorithm between M(I,J) and M(J,I), would preserve some translation information for each reference in lr so as to generate proper new references to the local variable. list of local variables with same dimensions used at different pipeline stages

Parameters
lrr
tileThe algorithm used is not general; references are assumed equal up to a translation;

A general algorithm, as would be necessary for instance if a dependence was detected in the transposition algorithm between M(I,J) and M(J,I), would preserve some translation information for each reference in lr so as to generate proper new references to the local variable. non-empty list of associated references

Parameters
dimnimn

Definition at line 689 of file variable.c.

696 {
697  /* let's use the first reference to find out the number of dimensions */
698  reference r;
699  entity rv; /* referenced variable */
700  type rvt; /* referenced variable type */
701  list rvld; /* referenced variable dimension list */
702  int d = -1; /* dimension number */
703  list lvd = NIL; /* dimensions for the local variables */
704  bool first_ref;
705  matrice P = (matrice) tiling_tile(tile);
706  debug(8,"set_dimensions_of_local_variable_family","begin\n");
707 
708  r = REFERENCE(CAR(lr));
709  rv = reference_variable(r);
710  rvt = entity_type(rv);
711  rvld = variable_dimensions(type_variable(rvt));
712 
713  debug(8,"set_dimensions_of_local_variable_family","entity=%s\n",
714  entity_name(rv));
715 
716  for( d = 1; !ENDP(rvld); POP(rvld), d++) {
717  Value imax = VALUE_MIN;
718  Value gmin = VALUE_MAX;
719  Value gmax = VALUE_MIN;
720  list cr = list_undefined;
722 
723 
724  /* computation of the initial bounds of Entity rv */
725  dimension dim1 = DIMENSION(CAR(rvld));
726  expression lower= dimension_lower(dim1);
727  normalized norm1 = NORMALIZE_EXPRESSION(lower);
728  expression upper= dimension_upper(dim1);
729  normalized norm2 = NORMALIZE_EXPRESSION(upper);
730  if (normalized_linear_p(norm1) && normalized_linear_p(norm2)) {
731  gmin = vect_coeff(TCST,(Pvecteur) normalized_linear(norm1));
732  value_decrement(gmin);
733  gmax = vect_coeff(TCST,(Pvecteur) normalized_linear(norm2));
734  value_decrement(gmax);
735  imax = gmax;
736  }
737  first_ref = true;
738  for(cr = lr; !ENDP(cr); POP(cr)) {
739  entity phi = make_phi_entity(d);
740  expression e;
741  normalized n;
742  Pvecteur vec;
743  Pcontrainte eg;
744  Psysteme s;
745  Value min, max, coef;
746  r = REFERENCE(CAR(cr));
748  n = NORMALIZE_EXPRESSION(e);
749 
750  /* pips_assert("set_dimensions_of_local_variable_family", */
751  if (normalized_linear_p(n)) {
752  vec = vect_dup((Pvecteur) normalized_linear(n));
753  vect_add_elem(&vec, (Variable) phi, VALUE_MONE);
754  eg = contrainte_make(vec);
755 
756  /* pour tenir compte des offsets numeriques dans les
757  fonctions d'acces */
758  coef =vect_coeff(TCST,vec);
759  if (value_pos_p(coef)) value_addto(gmax,coef);
760  else value_addto(gmin,coef);
761 
762  s = sc_dup(tc);
763  sc_add_egalite(s, eg);
764  vect_add_variable(sc_base(s), (Variable) phi);
765 
766  s = sc_normalize(s);
767  ifdebug(8) {
768  (void) fprintf(stderr,
769  "System on phi for dimension %d:\n", d);
770  sc_fprint(stderr, s, (string(*)(Variable))entity_local_name);
771  }
772 
773 
774  if(!sc_minmax_of_variable(s, (Variable) phi,
775  &min, &max))
776  pips_internal_error("empty domain for phi");
777 
778  if(value_min_p(min) || value_max_p(max)) {
779  Value divis= ACCESS(P,dimn,d,d);
780  /* parameter ==> min = max = 1 */
781  /*pips_internal_error("unbounded domain for phi, %s",
782  "check tile bounds and subscript expressions"); */
783  min= VALUE_ZERO;
784  max= value_lt(divis,VALUE_CONST(999)) &&
785  value_gt(divis,VALUE_ONE)? value_div(imax,divis): imax;
786  }
787 
788  debug(8,"set_dimensions_of_local_variable_family",
789  "bounds for dimension %d: [%d:%d]\n", d, min, max);
790 
791  gmin = first_ref? value_max(gmin, min): value_min(gmin, min);
792  gmax = first_ref? value_min(gmax, max): value_max(gmax, max);
793 
794  if (value_gt(gmin,gmax)) gmax = gmin;
795  first_ref=false;
796  }
797  }
800  NIL);
801 
802  debug(8,"set_dimensions_of_local_variable_family",
803  "bounds for dimension %d: [%d:%d]\n", d, gmin, gmax);
804 
805  lvd = gen_nconc(lvd, CONS(DIMENSION, dimd, NIL));
806  }
807 
808  /* update types */
809  MAPL(clv,
810  {
811  entity lv = ENTITY(CAR(clv));
812  type tlv = entity_type(lv);
813  variable tv = type_variable(tlv);
814 
815  /* sharing is not legal under NewGen rules; to avoid
816  it lvd is duplicated at the CONS level, except the first time */
817  if(clv!=llv)
818  lvd = gen_copy_seq(lvd);
819  variable_dimensions(tv) = lvd;
820  },
821  llv);
822 
823  ifdebug(8) {
824  MAPL(clv,
825  {
826  entity lv = ENTITY(CAR(clv));
827  print_sentence(stderr,Sentence_Variable(lv));
828  },
829  llv);
830  }
831 
832  pips_debug(8,"end\n");
833 }
#define value_pos_p(val)
#define value_gt(v1, v2)
#define value_min(v1, v2)
#define value_decrement(ref)
#define VALUE_TO_INT(val)
#define VALUE_MIN
#define value_min_p(val)
#define value_max(v1, v2)
#define value_addto(ref, val)
#define VALUE_MAX
#define value_max_p(val)
#define value_lt(v1, v2)
#define value_div(v1, v2)
entity make_phi_entity(int)
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
expression find_ith_expression(list le, int r)
find_ith_expression() is obsolet; use find_ith_argument() instead
Definition: expression.c:1161
Value vect_coeff(Variable var, Pvecteur vect)
Variable vect_coeff(Variable var, Pvecteur vect): coefficient de coordonnee var du vecteur vect —> So...
Definition: unaires.c:228

References ACCESS, CAR, CONS, contrainte_make(), debug(), DIMENSION, dimension_lower, dimension_undefined, dimension_upper, ENDP, ENTITY, entity_local_name(), entity_name, entity_type, find_ith_expression(), fprintf(), gen_copy_seq(), gen_nconc(), ifdebug, int_to_expression(), list_undefined, make_dimension(), make_phi_entity(), MAPL, max, min, NIL, NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, pips_debug, pips_internal_error, POP, print_sentence(), REFERENCE, reference_indices, reference_variable, sc_add_egalite(), sc_dup(), sc_fprint(), sc_minmax_of_variable(), sc_normalize(), Sentence_Variable(), tc, TCST, tiling_tile, type_variable, value_addto, VALUE_CONST, value_decrement, value_div, value_gt, value_lt, VALUE_MAX, value_max, value_max_p, VALUE_MIN, value_min, value_min_p, VALUE_MONE, VALUE_ONE, value_pos_p, VALUE_TO_INT, VALUE_ZERO, variable_dimensions, vect_add_elem(), vect_add_variable(), vect_coeff(), and vect_dup().

Referenced by set_dimensions_of_local_variables().

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

◆ set_dimensions_of_local_variables()

void set_dimensions_of_local_variables ( hash_table  v_to_lllv,
Pbase  basis,
tiling  tile,
hash_table  llv_to_lcr 
)
Parameters
v_to_lllv_to_lllv
basisasis
tileile
llv_to_lcrlv_to_lcr

Definition at line 652 of file variable.c.

657 {
658  Psysteme tc = SC_UNDEFINED;
659  matrice P = (matrice) tiling_tile(tile);
660 
661  debug(8,"set_dimensions_of_local_variables","begin\n");
662 
663  tc = make_tile_constraints(P, basis);
664 
665  HASH_MAP(v, clllv, {
666  list cllv;
667  for(cllv = (list) clllv; !ENDP(cllv); POP(cllv)) {
668  list llv = LIST(CAR(cllv));
669  list lr = (list) hash_get(llv_to_lcr, (char *) llv);
671  }
672  }, v_to_lllv);
673 
674  sc_rm(tc);
675 
676  debug(8,"set_dimensions_of_local_variables","end\n");
677 }
Psysteme make_tile_constraints(matrice P, Pbase b)
Psysteme make_tile_constraints(P, b):
Definition: variable.c:591
void set_dimensions_of_local_variable_family(list llv, Psysteme tc, list lr, tiling tile, int dimn)
void set_dimensions_of_local_variable_family(llv, tc, lr):
Definition: variable.c:689
void sc_rm(Psysteme ps)
void sc_rm(Psysteme ps): liberation de l'espace memoire occupe par le systeme de contraintes ps;
Definition: sc_alloc.c:277

References CAR, debug(), ENDP, hash_get(), HASH_MAP, LIST, make_tile_constraints(), POP, sc_rm(), set_dimensions_of_local_variable_family(), tc, tiling_tile, and vect_size().

Referenced by loop_nest_to_local_variables().

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

◆ set_fetch_map()

void set_fetch_map ( statement_mapping  )

◆ set_store_map()

void set_store_map ( statement_mapping  )

◆ statement_fetch_undefined_p()

bool statement_fetch_undefined_p ( statement  )

◆ statement_store_undefined_p()

bool statement_store_undefined_p ( statement  )

◆ statement_to_communications()

void statement_to_communications ( statement  stmt,
statement  st_level1,
statement  st_level2,
list lwr,
list lwr_local,
statement_mapping fetch_map,
statement_mapping store_map,
hash_table  r_to_ud,
list lpv 
)

This function associates to each variable in stmt the statement where it should be communicated.

The lwr list corresponds to the list of variables that have been updated before the current statement bloc. The lwr_local list corresponds to the list of variables that are updated in the current statement bloc.

Parameters
stmttmt
st_level1t_level1
st_level2t_level2
lwrwr
lwr_localwr_local
fetch_mapetch_map
store_maptore_map
r_to_ud_to_ud
lpvpv

Definition at line 191 of file communications.c.

196 {
198 
199  debug(8, "statement_to_communications", "begin with tag %d\n",
200  instruction_tag(inst));
201 
202  switch(instruction_tag(inst)) {
203  case is_instruction_block: {
204  ifdebug(7)
205  (void) fprintf(stderr,
206  "statement_to_communications-instruction block- begin\n");
207  st_level2 = STATEMENT(CAR(instruction_block(inst)));
208  MAPL( sts, {
209  statement s = STATEMENT(CAR(sts));
210  statement_to_communications(s,st_level1, st_level2,
211  lwr,lwr_local,
212  fetch_map,store_map,
213  r_to_ud,lpv);
214  }, instruction_block(inst));
215  ifdebug(7)
216  (void) fprintf(stderr,
217  "statement_to_communications-instruction block- end\n");
218  break;
219  }
220  case is_instruction_test:
221  (void) fprintf(stderr,"not implemented\n");
222  break;
223  case is_instruction_loop: {
224  ifdebug(7)
225  (void) fprintf(stderr,
226  "statement_to_communications-instruction loop- begin\n");
228  lwr, lwr_local,
229  fetch_map,store_map,
230  r_to_ud,lpv);
231  reference_list_add(lwr, lwr_local);
232  ifdebug(7)
233  (void) fprintf(stderr,
234  "statement_to_communications-instruction loop- end\n");
235  break;
236  }
237  case is_instruction_call: {
238  ifdebug(7)
239  (void) fprintf(stderr,"statement_to_communications-instruction call- begin\n");
240  call_instruction_to_communications(stmt, st_level1, st_level2,
241  lwr, lwr_local,
242  fetch_map,store_map,r_to_ud,lpv);
243  ifdebug(7)
244  (void) fprintf(stderr,"statement_to_communications-instruction call- end\n");
245  break;
246  }
247  case is_instruction_goto: {
248  pips_internal_error("Unexpected goto");
249  break;}
251  pips_internal_error("Sorry: unstructured not implemented");
252  break;}
253  default:
254  pips_internal_error("Bad instruction tag");
255  }
256 }
void loop_instruction_to_communications(statement stmt, statement st_level1, statement st_level2, list *lwr, list *lwr_local, statement_mapping *fetch_map, statement_mapping *store_map, hash_table r_to_ud, list *lpv)
This function associates to each variable in the loop the statement where it should be communicated (...
void call_instruction_to_communications(statement s, statement st_level1, statement st_level2, list *lwr, list *lwr_local, statement_mapping *fetch_map, statement_mapping *store_map, hash_table r_to_ud, list *lpv)
This function associates to each variable in the call statement the statement where it should be comm...

References call_instruction_to_communications(), CAR, debug(), fprintf(), ifdebug, instruction_block, instruction_tag, is_instruction_block, is_instruction_call, is_instruction_goto, is_instruction_loop, is_instruction_test, is_instruction_unstructured, loop_instruction_to_communications(), MAPL, pips_internal_error, reference_list_add(), STATEMENT, and statement_instruction.

Referenced by compute_communications(), and loop_instruction_to_communications().

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

◆ store_map_undefined_p()

bool store_map_undefined_p ( void  )

◆ store_statement_fetch()

void store_statement_fetch ( statement  ,
list   
)

◆ store_statement_store()

void store_statement_store ( statement  ,
list   
)

◆ test_run_time_communications()

bool test_run_time_communications ( list  list_statement_block,
statement_mapping  fetch_map,
statement_mapping  store_map 
)

just to avoid warning

Parameters
list_statement_blockist_statement_block
fetch_mapetch_map
store_maptore_map

Definition at line 733 of file communications.c.

735 {
736  bool ok ;
737  int nbcall =0;
738  MAPL(st1,
740  switch(instruction_tag(inst)) {
741  case is_instruction_block: {
742  ok = false;
743  MAPL(st2, {
744  ok = (ok) ? ok :
746  STATEMENT(CAR(st2)),
747  NIL),
748  fetch_map,store_map);
749  },
750  instruction_block(inst));
751  return ok;
752  break; }
753  case is_instruction_loop: {
756  NIL),
757  fetch_map,store_map));
758  break;}
759  case is_instruction_call: {
760  list lt = (list) GET_STATEMENT_MAPPING(fetch_map,STATEMENT(CAR(st1)));
761  if (lt != (list) HASH_UNDEFINED_VALUE) {
762  nbcall ++;
763  return (true);
764  } else
765  return(false);
766  break;
767  }
768  default:
769  break;
770  }
771  },
772  list_statement_block);
773  /* just to avoid warning */
774  return (true);
775 }
bool test_run_time_communications(list list_statement_block, statement_mapping fetch_map, statement_mapping store_map)
static bool ok

References CAR, CONS, GET_STATEMENT_MAPPING, HASH_UNDEFINED_VALUE, instruction_block, instruction_loop, instruction_tag, is_instruction_block, is_instruction_call, is_instruction_loop, loop_body, MAPL, NIL, ok, STATEMENT, and statement_instruction.

◆ tile_change_of_basis()

void tile_change_of_basis ( Psysteme  tile_domain,
Pbase  initial_basis,
Pbase  tile_basis,
Pbase  tile_init_basis,
tiling  tile 
)
Parameters
tile_domainile_domain
initial_basisnitial_basis
tile_basisile_basis
tile_init_basisile_init_basis
tileile

Definition at line 161 of file code.c.

163 {
164  int dim = base_dimension(initial_basis);
165  int l,c;
166  for(l=1; l <= dim; l++) {
167  Pcontrainte eq;
168  Pvecteur v = VECTEUR_NUL;
169  int td = base_dimension(tile_basis);
170  for(c=1; c<=td; c++)
171  vect_add_elem(&v, variable_of_rank(tile_basis, c),
172  (Value) ACCESS((matrice) tiling_tile(tile), dim, l, c));
173 
174  vect_add_elem(&v, variable_of_rank(tile_init_basis, l), VALUE_MONE);
175  vect_add_elem(&v, TCST,
176  vect_coeff(variable_of_rank(initial_basis, l),
177  (Pvecteur) tiling_origin(tile)));
178  eq = contrainte_make(v);
179  sc_add_egalite(tile_domain, eq);
180  }
181 }
#define tiling_origin(x)
Definition: tiling.h:70

References ACCESS, base_dimension, contrainte_make(), eq, sc_add_egalite(), TCST, tiling_origin, tiling_tile, VALUE_MONE, variable_of_rank(), vect_add_elem(), vect_coeff(), and VECTEUR_NUL.

Referenced by make_scanning_over_one_tile(), and make_scanning_over_tiles().

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

◆ tile_membership()

Psysteme tile_membership ( matrice  P,
Pbase  origin,
Pbase  member 
)

Psysteme tile_membership(P, origin, member):

builds a linear constraint system to express the fact that iteration "member" belongs to a P tile with origin "origin". "origin" and "member" are expressed in the initial basis.

pips_assert("tile_membership", k > 1);

Parameters
originrigin
memberember

Definition at line 1469 of file code.c.

1473 {
1474  Psysteme m = sc_new();
1475  int d = base_dimension(origin);
1476  matrice IP = matrice_new(d,d);
1477  Pcontrainte c1;
1478  int i, j;
1479  Value k;
1480 
1481  debug(8,"tile_membership", "begin\n");
1482 
1483  pips_assert("tile_membership", d == base_dimension(member));
1484  pips_assert("tile_membership", value_one_p(DENOMINATOR(P)));
1485 
1486  ifdebug(8) {
1487  (void) fprintf(stderr,"Partitioning matrix P:\n");
1488  matrice_fprint(stderr, P, d, d);
1489  }
1490 
1491  matrice_general_inversion(P, IP, d);
1492  matrice_normalize(IP, d, d);
1493  k = DENOMINATOR(IP);
1494 
1495 /* pips_assert("tile_membership", k > 1); */
1496 
1497  ifdebug(8) {
1498  (void) fprintf(stderr,"Inverse of partitioning matrix, IP:\n");
1499  matrice_fprint(stderr, IP, d, d);
1500  }
1501 
1502  for ( i=1; i<=d; i++) {
1504 
1505  for ( j=1; j<=d; j++) {
1508  value_uminus(ACCESS(IP, d, j, i)));
1511  ACCESS(IP, d, j, i));
1512  }
1513  sc_add_inegalite(m, c);
1514  c1 = contrainte_dup(c);
1515  contrainte_chg_sgn(c1);
1517  sc_add_inegalite(m, c1);
1518  }
1519 
1520  sc_creer_base(m);
1521  matrice_free(IP);
1522 
1523  ifdebug(8) {
1524  (void) fprintf(stderr,"Tile membership conditions:\n");
1525  sc_fprint(stderr, m, (string(*)(Variable))entity_local_name);
1526  }
1527 
1528  debug(8,"tile_membership", "end\n");
1529 
1530  return m;
1531 }
static bool member(region reg, list reg_list)
tests if reg and any member of reg_list are same_reg_ignore_action
static statement origin
Definition: simdizer.c:411

References ACCESS, base_dimension, contrainte_chg_sgn(), contrainte_dup(), contrainte_new(), contrainte_vecteur, debug(), DENOMINATOR, entity_local_name(), fprintf(), ifdebug, matrice_fprint(), matrice_free, matrice_general_inversion(), matrice_new, matrice_normalize(), member(), origin, pips_assert, sc_add_inegalite(), sc_creer_base(), sc_fprint(), sc_new(), TCST, value_minus, VALUE_ONE, value_one_p, value_uminus, variable_of_rank(), and vect_add_elem().

Referenced by make_scanning_over_one_tile(), and make_scanning_over_tiles().

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

◆ translate_IO_ref()

reference translate_IO_ref ( call  c,
hash_table  v_to_esv,
bool  loop_or_call_print 
)

This function translates a reference in I/O statement into its corresponding emulated shared memory reference.

scan the argument list till IOLIST' arguments

implied-do case: the array reference is the first argument in the last argument list of the implied do call

Parameters
v_to_esv_to_esv
loop_or_call_printoop_or_call_print

Definition at line 346 of file instruction_to_wp65_code.c.

347 {
348  pips_assert("true", loop_or_call_print==loop_or_call_print);
349  list pio,pc = NIL;
350  bool iolist_reached = false;
351  expression exp;
352  syntax s;
354  if (same_string_p(entity_local_name(call_function(c)), "WRITE")) {
355  pio = pc = call_arguments(c);
356  /* scan the argument list till IOLIST' arguments*/
357  while (!ENDP(pio) && (!iolist_reached)) {
358  call c1;
359  expression arg;
360  s = expression_syntax(EXPRESSION(CAR(pio)));
361  c1=syntax_call(s);
362  arg = EXPRESSION(CAR(CDR(pio)));
363 
364  if (((strcmp(entity_local_name(call_function(c1)),"FMT=")==0) &&
365  (strcmp(expression_to_string(arg),"*")==0))
366  ||((strcmp(entity_local_name(call_function(c1)),"UNIT=")==0)
367  &&
368  (strcmp(expression_to_string(arg),"*")==0)))
369  pio = CDR(CDR(pio));
370  else
371  if (strcmp(entity_local_name(call_function(c1)),
372  "IOLIST=")==0) {
373  iolist_reached = true;
374  pio = CDR(pio);
375  }
376  }
377  exp = EXPRESSION(CAR(pio));
378  /* implied-do case: the array reference is the first argument
379  in the last argument list of the implied do call */
381  if (syntax_call_p(s) &&
383  "IMPLIED-DO") == 0)) {
386  }
387  if (syntax_reference_p(s)) {
389  reference ref1 = syntax_reference(sy1);
391  entity ent1=(entity)hash_get(v_to_esv,
392  (char *) reference_variable(ref1));
393  reference newr = make_reference(ent1,indic);
395  result = ref1;
396  }
397  }
398  else
399  pips_user_error("function calls are not handled in this version\n");
400  return result;
401 }
syntax make_syntax(enum syntax_utype tag, void *val)
Definition: ri.c:2491
list gen_full_copy_list(list l)
Copy a list structure with element copy.
Definition: list.c:535
#define pips_user_error
Definition: misc-local.h:147
#define same_string_p(s1, s2)
string expression_to_string(expression e)
Definition: expression.c:77
#define reference_undefined
Definition: ri.h:2302

References call_arguments, call_function, CAR, CDR, ENDP, entity_local_name(), exp, EXPRESSION, expression_syntax, expression_to_string(), gen_full_copy_list(), hash_get(), is_syntax_reference, make_reference(), make_syntax(), NIL, pips_assert, pips_user_error, ref_in_implied_do(), reference_indices, reference_undefined, reference_variable, same_string_p, syntax_call, syntax_call_p, syntax_reference, and syntax_reference_p.

Referenced by generate_io_wp65_code().

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

◆ uniform_dependence_p()

bool uniform_dependence_p ( reference  r1,
reference  r2 
)

This function checks if two references have a uniform dependence.

It assumes that some verifications have been made before. The two references r1 and r2 must reference the same array with the same dimension.

FI: could/should be moved in ri-util/expression.c

Parameters
r11
r22

Definition at line 939 of file code.c.

941 {
942 
943  bool uniform = true;
944  cons * ind1, *ind2;
945 
946  debug(8,"uniform_dependence_p", "begin\n");
947 
948  ind1 = reference_indices(r1);
949  ind2 = reference_indices(r2);
950  for (; uniform && ind1 != NULL && ind2!= NULL;
951  ind1 = CDR(ind1), ind2=CDR(ind2))
952  {
953  expression expr1= EXPRESSION(CAR(ind1));
954  expression expr2= EXPRESSION(CAR(ind2));
955  normalized norm1 = (normalized) NORMALIZE_EXPRESSION(expr1);
956  normalized norm2 = (normalized) NORMALIZE_EXPRESSION(expr2);
957  if (normalized_linear_p(norm1) && normalized_linear_p(norm2)) {
958  Pvecteur pv1 = (Pvecteur) normalized_linear(norm1);
959  Pvecteur pv2 = (Pvecteur) normalized_linear(norm2);
960  Pvecteur pv3 = vect_substract(pv1,pv2);
961  if (vect_size(pv3) >1 ||
962  ((vect_size (pv3)==1) && (vecteur_var(pv3) != TCST)))
963  uniform = false;
964  vect_rm(pv3);
965  }
966  }
967  debug(8,"uniform_dependence_p", "end\n");
968  return(uniform);
969 }
void vect_rm(Pvecteur v)
void vect_rm(Pvecteur v): desallocation des couples de v;
Definition: alloc.c:78

References CAR, CDR, debug(), EXPRESSION, NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, reference_indices, TCST, vect_rm(), vect_size(), vect_substract(), and vecteur_var.

Referenced by classify_reference().

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

◆ update_map()

void update_map ( statement_mapping  m,
statement  st,
reference  r 
)
Parameters
stt

Definition at line 68 of file references.c.

69 {
70  list lt;
71 
72  lt = (list) GET_STATEMENT_MAPPING(m,st);
73  if (lt != (list) HASH_UNDEFINED_VALUE) {
74  if (!ref_in_list_p(lt,r)) {
75  lt = gen_nconc(lt, CONS(REFERENCE,r, NIL));
76  ifdebug(9)
77  (void) fprintf(stderr,
78  "ajout de la ref: %s au statement %"PRIdPTR"\n",
80  statement_number(st));
81  }
82  }
83  else {
84  lt= CONS(REFERENCE,r, NIL);
85  ifdebug(9)
86  (void) fprintf (stderr,
87  "ajout de la ref: %s au statement %"PRIdPTR"\n",
89  statement_number(st));
90  }
91  SET_STATEMENT_MAPPING(m,st,lt);
92 }
#define SET_STATEMENT_MAPPING(map, stat, val)
Definition: newgen-local.h:47
bool ref_in_list_p(list lt, reference r)
references.c
Definition: references.c:62

References CONS, entity_local_name(), fprintf(), gen_nconc(), GET_STATEMENT_MAPPING, HASH_UNDEFINED_VALUE, ifdebug, NIL, ref_in_list_p(), REFERENCE, reference_variable, SET_STATEMENT_MAPPING, and statement_number.

Referenced by call_instruction_to_communications().

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

◆ update_statement_fetch()

void update_statement_fetch ( statement  ,
list   
)

◆ update_statement_store()

void update_statement_store ( statement  ,
list   
)

◆ variable_list_add()

void variable_list_add ( list l1,
list l2 
)

This function adds all the references of l2 to l1 if they don't appear in l1.

Parameters
l11
l22

Definition at line 225 of file references.c.

226 {
227  list lvar2 =*l2 ;
228  for(; lvar2!= NIL;
229  variable_list_update(l1,REFERENCE(CAR(lvar2))),
230  lvar2 = CDR(lvar2));
231 }
void variable_list_update(list *l, reference r)
This function adds the reference r to List l, if the reference_variable(r) doesn't belong to l.
Definition: references.c:208

References CAR, CDR, NIL, REFERENCE, and variable_list_update().

Referenced by concat_data_list().

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

◆ variable_list_update()

void variable_list_update ( list l,
reference  r 
)

This function adds the reference r to List l, if the reference_variable(r) doesn't belong to l.

Definition at line 208 of file references.c.

209 {
210  list lvar1 =*l ;
211  if (*l != NIL) {
212  for(;
213  lvar1!= NIL
216  lvar1 = CDR(lvar1));
217  if (lvar1 == NIL)
218  *l= gen_nconc(*l, CONS(REFERENCE,r,NIL));
219  }
220  else *l = CONS(REFERENCE,r,NIL);
221 }

References CAR, CDR, CONS, entity_local_name(), gen_nconc(), NIL, REFERENCE, and reference_variable.

Referenced by variable_list_add().

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

◆ wp65()

bool wp65 ( const  string)

Let's modify the old code instead of copy it but do not tell pipsdbm; else we would get a copy of the code, not consistent with the dependence graph

fprintf(stderr,"refs du code\n"); debug_refs(s); fprintf(stderr,"refs du dg\n"); debug_refs(dg);

fprintf(stderr,"refs du code\n"); debug_refs(s); fprintf(stderr,"refs du dg\n"); debug_refs(dg);

Put final code for the computational module in a text resource of the database

Put final code for the memory module in a text resource of the database

reset_current_module_statement();

Parameters
stringnput_module_name

Definition at line 128 of file wp65.c.

129 {
130  entity module = module_name_to_entity(input_module_name);
131  /* Let's modify the old code instead of copy it but do not tell
132  pipsdbm; else we would get a *copy* of the code, not consistent
133  with the dependence graph */
134  statement s;
135  entity compute_module = entity_undefined;
136  statement computational = statement_undefined;
137  entity memory_module = entity_undefined;
138  statement emulator = statement_undefined;
139  int pn, bn, ls, pd = PIPELINE_DEPTH;
140  graph dg;
141  string ppp;
142 
143  s = (statement) db_get_memory_resource(DBR_CODE, input_module_name,true);
144  dg = (graph) db_get_memory_resource(DBR_DG, input_module_name, true);
146  debug_on("WP65_DEBUG_LEVEL");
147  debug(8, "wp65", "begin\n");
148 
149  get_model(&pn, &bn, &ls);
150  ifdebug(1) model_fprint(stderr, pn, bn ,ls);
151 
152  regions_init();
156 
157  /* fprintf(stderr,"refs du code\n"); debug_refs(s);
158  fprintf(stderr,"refs du dg\n"); debug_refs(dg); */
159 
161 
162  /* fprintf(stderr,"refs du code\n"); debug_refs(s);
163  fprintf(stderr,"refs du dg\n"); debug_refs(dg); */
164 
166  pn, bn, ls, pd,
167  &compute_module, &computational,
168  &memory_module, &emulator);
169 
170  (void) variable_declaration_coherency_p(compute_module,computational);
171  (void) variable_declaration_coherency_p(memory_module,emulator);
172 
173 
174  /* Put final code for the computational module in a text resource
175  of the database */
177  make_text_resource(input_module_name,
178  DBR_WP65_COMPUTE_FILE,
179  WP65_COMPUTE_EXT,
180  text_module(compute_module,computational));
182 
183  /* Put final code for the memory module in a text resource
184  of the database */
185  make_text_resource(input_module_name,
186  DBR_WP65_BANK_FILE,
187  WP65_BANK_EXT,
188  text_module(memory_module,emulator));
189 
190  debug(8, "wp65", "end\n");
191 
192  /* reset_current_module_statement(); */
196  debug_off();
197 
198 return true;
199 
200 }
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
void regions_init(void)
struct _newgen_struct_graph_ * graph
Definition: graph.h:31
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
void get_model(int *ppn, int *pbn, int *pls)
Definition: model.c:71
void model_fprint(FILE *fd, int pn, int bn, int ls)
Code Generation for Distributed Memory Machines.
Definition: model.c:50
hash_table set_ordering_to_statement(statement s)
To be used instead of initialize_ordering_to_statement() to make sure that the hash table ots is in s...
Definition: ordering.c:172
void reset_ordering_to_statement(void)
Reset the mapping from ordering to statement.
Definition: ordering.c:185
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
#define PRETTYPRINT_PARALLEL
void set_string_property(const char *, const char *)
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479
bool variable_declaration_coherency_p(entity module, statement st)
Definition: module.c:203
#define PIPELINE_DEPTH
These values should be read in model.rc (FI, 20/11/91) #define PROCESSOR_NUMBER 4 #define BANK_NUMBER...
Definition: wp65-local.h:58
void module_to_wp65_modules(entity module, statement module_code, graph dg, int pn, int bn, int ls, int pd, entity *pcompute_module, statement *pcomputational, entity *pmemory_module, statement *pemulator)
Definition: wp65.c:202
static void translate_unary_into_binary_ref(statement stat)
Definition: wp65.c:88
bool wp65(const string input_module_name)
Definition: wp65.c:128

References close_prettyprint(), db_get_memory_resource(), debug(), debug_off, debug_on, dg, empty_text(), entity_undefined, free(), get_model(), get_string_property(), ifdebug, init_prettyprint(), make_text_resource(), model_fprint(), module, module_name_to_entity(), module_to_wp65_modules(), PIPELINE_DEPTH, PRETTYPRINT_PARALLEL, regions_init(), reset_current_module_entity(), reset_ordering_to_statement(), set_current_module_entity(), set_ordering_to_statement(), set_string_property(), statement_undefined, strdup(), text_module(), translate_unary_into_binary_ref(), and variable_declaration_coherency_p().

+ Here is the call graph for this function:

◆ wp65_conform_p()

bool wp65_conform_p ( statement  s)

there should be only one instruction: do not put a STOP in the source file

Definition at line 508 of file wp65.c.

509 {
511 
513  /* there should be only one instruction: do not put a STOP in the
514  source file */
517  if(control_predecessors(c) == NIL && control_successors(c) == NIL) {
519  }
520  else {
521  debug(1,"wp65_conform_p",
522  "program body is an unstructured with at least two nodes\n");
523  return false;
524  }
525  }
526 
527  if(!instruction_block_p(i)) {
528  debug(1,"wp65_conform_p","program body is not a block\n");
529  return false;
530  }
531  else {
532  list ls = instruction_block(i);
533  MAPL(pm,{
534  statement s1 = STATEMENT(CAR(pm));
537  debug(1,"wp65_conform_p",
538  "program body contains a non-perfectly nested loop\n");
539  return false;
540  }
541  }
542  },ls);
543  }
544  return true;
545 }
bool perfectly_nested_loop_p(statement stat)
Test if a statement is a perfect loop-nest.
Definition: loop.c:543
bool stop_statement_p(statement)
Test if a statement is a Fortran STOP.
Definition: statement.c:263
#define control_predecessors(x)
Definition: ri.h:943
#define control_successors(x)
Definition: ri.h:945

References assignment_statement_p(), CAR, control_predecessors, control_statement, control_successors, debug(), instruction_block, instruction_block_p, instruction_unstructured, instruction_unstructured_p, MAPL, NIL, perfectly_nested_loop_p(), return_statement_p(), s1, STATEMENT, statement_instruction, stop_statement_p(), and unstructured_control.

+ Here is the call graph for this function:

Variable Documentation

◆ offset_dim1

Value offset_dim1
extern

WP65_INCLUDED.

cproto-generated files code.c

WP65_INCLUDED.

Definition at line 67 of file code.c.

Referenced by initialize_offsets(), and nullify_offsets().

◆ offset_dim2

Value offset_dim2
extern

Definition at line 68 of file code.c.

Referenced by initialize_offsets(), and nullify_offsets().