PIPS
spire_generation.c File Reference
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include "boolean.h"
#include <stdbool.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "database.h"
#include "misc.h"
#include "text.h"
#include "text-util.h"
#include "ri-util.h"
#include "effects-util.h"
#include "accel-util.h"
#include "effects-generic.h"
#include "effects-simple.h"
#include "pipsdbm.h"
#include "resources.h"
#include "control.h"
#include "conversion.h"
#include "properties.h"
#include "semantics.h"
#include "transformations.h"
#include "effects-convex.h"
#include "complexity_ri.h"
#include "dg.h"
#include "graph.h"
#include "ricedg.h"
#include "chains.h"
#include "task_parallelization.h"
+ Include dependency graph for spire_generation.c:

Go to the source code of this file.

Typedefs

typedef dg_arc_label arc_label
 Instantiation of the dependence graph: More...
 
typedef dg_vertex_label vertex_label
 

Functions

static statement cluster_stage_spire (persistant_statement_to_cluster stmt_to_cluster, graph tg, list cluster_stage, int p)
 return SPIRE for a cluster stage More...
 
void cluster_stage_spire_generation (persistant_statement_to_cluster stmt_to_cluster, graph tg, statement stmt, int P)
 he main function More...
 
bool spire_shared_unstructured_to_structured (char *module_name)
 
bool spire_distributed_unstructured_to_structured (char *module_name)
 

Variables

list com_declarations_to_add
 spire_generation.c More...
 

Typedef Documentation

◆ arc_label

Instantiation of the dependence graph:

Definition at line 42 of file spire_generation.c.

◆ vertex_label

Definition at line 43 of file spire_generation.c.

Function Documentation

◆ cluster_stage_spire()

static statement cluster_stage_spire ( persistant_statement_to_cluster  stmt_to_cluster,
graph  tg,
list  cluster_stage,
int  p 
)
static

return SPIRE for a cluster stage

Definition at line 54 of file spire_generation.c.

54  {
55  int i = -1;
56  list list_cl = NIL;
57  statement stmt_spawn = statement_undefined, stmt_finish = statement_undefined;
58  int stage_mod = gen_length(cluster_stage);
59  // int minus; FI: minus is not really used...
60  int Ps = p - stage_mod;// + 1; // plus one if we use the current cluster
61  bool costly_p = false;
62  FOREACH(LIST, list_stmts, cluster_stage){
63  FOREACH(statement, st, list_stmts){
64  if(!get_bool_property("COSTLY_TASKS_ONLY") | costly_task(st)){
65  costly_p = true;
67  if(Ps > 0){
69  }
70  }
71  }
72  int physical_cluster = i;
73  instruction ins_spawn = make_instruction_sequence(make_sequence(list_stmts));
74  if(costly_p){
75  // FI: minus is not used
76  // minus = (NBCLUSTERS==p)?0:1;
77  physical_cluster = NBCLUSTERS - p + i;// + 1 ;
78  FOREACH(statement, st, list_stmts){
80  }
81  entity k_ent = make_constant_entity(i2a(physical_cluster), is_basic_int, 4);
82  stmt_spawn = make_statement(
87  ins_spawn,
88  NIL, NULL, empty_extensions(),
90  }
91  else
92  stmt_spawn = make_statement(
97  ins_spawn,
98  NIL, NULL, empty_extensions(),
100  gen_consistent_p((gen_chunk*)stmt_spawn);
101  gen_consistent_p((gen_chunk*) stmt_spawn);
102  list_cl = CONS(STATEMENT, stmt_spawn, list_cl);
103  }
107  stmt_finish = make_statement(
112  ins_finish,
113  NIL, NULL, empty_extensions(),
114  sync);
115  gen_consistent_p((gen_chunk*)stmt_finish);
116  return stmt_finish;
117 }
persistant_statement_to_cluster stmt_to_cluster
Definition: HBDSC.c:56
void update_persistant_statement_to_cluster(persistant_statement_to_cluster f, intptr_t k, intptr_t v)
Definition: ri.c:1543
statement make_statement(entity a1, intptr_t a2, intptr_t a3, string a4, instruction a5, list a6, string a7, extensions a8, synchronization a9)
Definition: ri.c:2222
instruction make_instruction_sequence(sequence _field_)
Definition: ri.c:1169
intptr_t apply_persistant_statement_to_cluster(persistant_statement_to_cluster f, intptr_t k)
Definition: ri.c:1540
synchronization make_synchronization_none(void)
Definition: ri.c:2424
sequence make_sequence(list a)
Definition: ri.c:2125
synchronization make_synchronization_barrier(void)
Definition: ri.c:2430
synchronization make_synchronization_spawn(entity _field_)
Definition: ri.c:2427
int NBCLUSTERS
parameters of BDSC, to be recovered using pips properties
Definition: SDG.c:57
entity make_constant_entity(string name, tag bt, size_t size)
For historical reason, call the Fortran version.
Definition: constant.c:301
bool costly_task(statement st)
cost_model.c
Definition: cost_model.c:52
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
#define LIST(x)
Definition: genC.h:93
int gen_consistent_p(gen_chunk *obj)
GEN_CONSISTENT_P dynamically checks the type correctness of OBJ.
Definition: genClib.c:2398
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
size_t gen_length(const list l)
Definition: list.c:150
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
#define STATEMENT_ORDERING_UNDEFINED
mapping.h inclusion
Definition: newgen-local.h:35
char * i2a(int)
I2A (Integer TO Ascii) yields a string for a given Integer.
Definition: string.c:121
#define STATEMENT_NUMBER_UNDEFINED
default values
#define empty_comments
Empty comments (i.e.
entity entity_empty_label(void)
Definition: entity.c:1105
extensions empty_extensions(void)
extension.c
Definition: extension.c:43
@ is_basic_int
Definition: ri.h:571
#define statement_ordering(x)
Definition: ri.h:2454
#define statement_undefined
Definition: ri.h:2419
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
void cluster_stage_spire_generation(persistant_statement_to_cluster stmt_to_cluster, graph tg, statement stmt, int P)
he main function
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
A gen_chunk is used to store every object.
Definition: genC.h:58

References apply_persistant_statement_to_cluster(), cluster_stage_spire_generation(), CONS, costly_task(), empty_comments, empty_extensions(), entity_empty_label(), FOREACH, gen_consistent_p(), gen_length(), gen_nreverse(), get_bool_property(), i2a(), is_basic_int, LIST, make_constant_entity(), make_instruction_sequence(), make_sequence(), make_statement(), make_synchronization_barrier(), make_synchronization_none(), make_synchronization_spawn(), NBCLUSTERS, NIL, STATEMENT, STATEMENT_NUMBER_UNDEFINED, statement_ordering, STATEMENT_ORDERING_UNDEFINED, statement_undefined, stmt_to_cluster, and update_persistant_statement_to_cluster().

Referenced by cluster_stage_spire_generation().

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

◆ cluster_stage_spire_generation()

void cluster_stage_spire_generation ( persistant_statement_to_cluster  stmt_to_cluster,
graph  tg,
statement  stmt,
int  P 
)

he main function

Parameters
stmt_to_clustertmt_to_cluster
tgg
stmttmt

Definition at line 120 of file spire_generation.c.

121 {
123  if(!get_bool_property("COSTLY_TASKS_ONLY") | costly_task(stmt)){
124  statement st_finish = statement_undefined;
126  switch(instruction_tag(inst)){
127  case is_instruction_block:{
128  list cluster_stages = topological_sort(stmt);
129  list list_cl = NIL;
130  FOREACH(LIST, cluster_stage, cluster_stages) {
131  st_finish = cluster_stage_spire(stmt_to_cluster, tg, cluster_stage, P);
132  gen_consistent_p((gen_chunk*)st_finish);
133  list_cl = CONS(STATEMENT, st_finish, list_cl);
134  }
136  statement_instruction(stmt) = ins_seq;
139  gen_free_list(cluster_stages);
140  break;
141  }
142  case is_instruction_test:{
143  test t = instruction_test(inst);
146  break;
147  }
148  case is_instruction_loop :{
149  loop l = statement_loop(stmt);
150  statement body = loop_body(l);
152  break;
153  }
154  default:
155  break;
156  }
157  }
159  return;
160 }
list topological_sort(statement stmt)
Definition: HBDSC.c:192
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
loop statement_loop(statement)
Get the loop of a statement.
Definition: statement.c:1374
statement add_declaration_statement_at_beginning(statement, entity)
Definition: statement.c:2795
#define is_instruction_block
soft block->sequence transition
#define loop_body(x)
Definition: ri.h:1644
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define test_false(x)
Definition: ri.h:2837
@ is_instruction_test
Definition: ri.h:1470
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define test_true(x)
Definition: ri.h:2835
#define statement_declarations(x)
Definition: ri.h:2460
#define statement_instruction(x)
Definition: ri.h:2458
#define instruction_test(x)
Definition: ri.h:1517
static statement cluster_stage_spire(persistant_statement_to_cluster stmt_to_cluster, graph tg, list cluster_stage, int p)
return SPIRE for a cluster stage
Definition: statement.c:54

References add_declaration_statement_at_beginning(), cluster_stage_spire(), CONS, costly_task(), ENTITY, FOREACH, gen_consistent_p(), gen_free_list(), gen_nreverse(), get_bool_property(), instruction_tag, instruction_test, is_instruction_block, is_instruction_loop, is_instruction_test, LIST, loop_body, make_instruction_sequence(), make_sequence(), NIL, STATEMENT, statement_declarations, statement_instruction, statement_loop(), statement_undefined, stmt_to_cluster, test_false, test_true, and topological_sort().

Referenced by cluster_stage_spire(), spire_distributed_unstructured_to_structured(), and spire_shared_unstructured_to_structured().

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

◆ spire_distributed_unstructured_to_structured()

bool spire_distributed_unstructured_to_structured ( char *  module_name)

The proper effect to detect the I/O operations:

Reorder the module, because new statements have been generated.

Parameters
module_nameodule_name

Definition at line 192 of file spire_generation.c.

193 {
194  statement module_stat = (statement) db_get_memory_resource(DBR_CODE, module_name, true);
195  statement module_stat_i = copy_statement(module_stat);
196  set_ordering_to_statement(module_stat);
198  set_current_module_statement(module_stat);
201  db_get_memory_resource(DBR_TRANSFORMERS, module_name, true));
202  /* The proper effect to detect the I/O operations: */
207  db_get_memory_resource(DBR_REGIONS, module_name, true));
209  db_get_memory_resource(DBR_IN_REGIONS, module_name, true));
211  db_get_memory_resource(DBR_OUT_REGIONS, module_name, true));
214 
215  kdg = (graph) db_get_memory_resource (DBR_SDG, module_name, true );
217  stmt_to_cluster_i = (persistant_statement_to_cluster)db_get_memory_resource(DBR_SCHEDULE, module_name, true);
219 
220  NBCLUSTERS = get_int_property("BDSC_NB_CLUSTERS");
221  MEMORY_SIZE = get_int_property("BDSC_MEMORY_SIZE");
223  char *rtl_prefix = "_rtl";
224  FOREACH(entity, e, entities) {
225  if (strncmp(entity_local_name(e), rtl_prefix, strlen(rtl_prefix)) == 0){
227  }
228  }
233  module_stat = add_declaration_statement(module_stat, e);
235  insert_statement(module_stat, return_st, false);
236  /* Reorder the module, because new statements have been generated. */
237  module_reorder(module_stat);
238  DB_PUT_MEMORY_RESOURCE(DBR_DISTRIBUTED_SPIRE_CODE, strdup(module_name), module_stat);
239  DB_PUT_MEMORY_RESOURCE(DBR_CODE, strdup(module_name), module_stat_i);
252  return true;
253 }
graph kdg
Global variables.
Definition: HBDSC.c:52
statement return_st
Definition: HBDSC.c:53
int get_int_property(const string)
statement copy_statement(statement p)
STATEMENT.
Definition: ri.c:2186
persistant_statement_to_cluster copy_persistant_statement_to_cluster(persistant_statement_to_cluster p)
PERSISTANT_STATEMENT_TO_CLUSTER.
Definition: ri.c:1501
int MEMORY_SIZE
Definition: SDG.c:58
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
void communications_construction(graph tg, statement stmt, persistant_statement_to_cluster st_to_cluster, int kp)
void set_methods_for_convex_effects(void)
methods.c
Definition: methods.c:235
void init_convex_rw_prettyprint(const char *)
void set_rw_effects(statement_effects)
void reset_out_effects(void)
void reset_proper_rw_effects(void)
void set_proper_rw_effects(statement_effects)
void set_cumulated_rw_effects(statement_effects)
void set_out_effects(statement_effects)
void set_in_effects(statement_effects)
void reset_in_effects(void)
void generic_effects_reset_all_methods(void)
void reset_cumulated_rw_effects(void)
void reset_rw_effects(void)
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
struct _newgen_struct_graph_ * graph
Definition: graph.h:31
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
void reset_current_module_statement(void)
Reset the current module statement.
Definition: static.c:221
statement set_current_module_statement(statement)
Set the current module statement.
Definition: static.c:165
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
Definition: genClib.c:2780
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
#define DB_PUT_MEMORY_RESOURCE(res_name, own_name, res_val)
conform to old interface.
Definition: pipsdbm-local.h:66
void insert_statement(statement, statement, bool)
This is the normal entry point.
Definition: statement.c:2570
statement add_declaration_statement(statement, entity)
Definition: statement.c:2790
list gen_filter_tabulated(bool(*)(gen_chunk *), int)
returns the list of entities with this caracteristics.
Definition: tabulated.c:144
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
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
Definition: reorder.c:244
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479
struct _newgen_struct_persistant_statement_to_cluster_ * persistant_statement_to_cluster
Definition: ri.h:263
#define statement_undefined_p(x)
Definition: ri.h:2420
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
char * strdup()
void module_to_value_mappings(entity m)
void module_to_value_mappings(entity m): build hash tables between variables and values (old,...
Definition: mappings.c:624
void set_transformer_map(statement_mapping)
void reset_precondition_map(void)
void set_precondition_map(statement_mapping)
void reset_transformer_map(void)
list com_declarations_to_add
spire_generation.c
void gen_clear_tabulated_element(gen_chunk *obj)
GEN_CLEAR_TABULATED_ELEMENT only clears the entry for object OBJ in the gen_tabulated_ and gen_tabula...
Definition: tabulated.c:251
void free_value_mappings(void)
Normal call to free the mappings.
Definition: value.c:1212

References add_declaration_statement(), cluster_stage_spire_generation(), com_declarations_to_add, communications_construction(), copy_persistant_statement_to_cluster(), copy_statement(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, entity_domain, entity_local_name(), FOREACH, free_value_mappings(), gen_clear_tabulated_element(), gen_filter_tabulated(), gen_true(), generic_effects_reset_all_methods(), get_current_module_entity(), get_int_property(), init_convex_rw_prettyprint(), insert_statement(), kdg, MEMORY_SIZE, module_name(), module_name_to_entity(), module_reorder(), module_to_value_mappings(), NBCLUSTERS, NIL, reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), reset_in_effects(), reset_ordering_to_statement(), reset_out_effects(), reset_precondition_map(), reset_proper_rw_effects(), reset_rw_effects(), reset_transformer_map(), return_st, set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_in_effects(), set_methods_for_convex_effects(), set_ordering_to_statement(), set_out_effects(), set_precondition_map(), set_proper_rw_effects(), set_rw_effects(), set_transformer_map(), statement_undefined_p, stmt_to_cluster, and strdup().

+ Here is the call graph for this function:

◆ spire_shared_unstructured_to_structured()

bool spire_shared_unstructured_to_structured ( char *  module_name)
Parameters
module_nameodule_name

Definition at line 163 of file spire_generation.c.

164 {
165  statement module_stat = (statement) db_get_memory_resource(DBR_CODE, module_name, true);
166  statement module_stat_i = copy_statement(module_stat);
167  set_ordering_to_statement(module_stat);
169  set_current_module_statement(module_stat);
170 
171  kdg = (graph) db_get_memory_resource (DBR_SDG, module_name, true );
173  gen_consistent_p((gen_chunk*)stmt_to_cluster_i);
175  NBCLUSTERS = get_int_property("BDSC_NB_CLUSTERS");
176  MEMORY_SIZE = get_int_property("BDSC_MEMORY_SIZE");
179  insert_statement(module_stat, return_st, false);
180  module_reorder(module_stat);
181  gen_consistent_p((gen_chunk*)module_stat);
182  DB_PUT_MEMORY_RESOURCE(DBR_SHARED_SPIRE_CODE, strdup(module_name), module_stat);
183  DB_PUT_MEMORY_RESOURCE(DBR_CODE, strdup(module_name), module_stat_i);
184 
189  return true;
190 }

References cluster_stage_spire_generation(), copy_persistant_statement_to_cluster(), copy_statement(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, gen_consistent_p(), get_int_property(), insert_statement(), kdg, MEMORY_SIZE, module_name(), module_name_to_entity(), module_reorder(), NBCLUSTERS, reset_current_module_entity(), reset_current_module_statement(), reset_ordering_to_statement(), return_st, set_current_module_entity(), set_current_module_statement(), set_ordering_to_statement(), statement_undefined_p, stmt_to_cluster, and strdup().

+ Here is the call graph for this function:

Variable Documentation

◆ com_declarations_to_add

list com_declarations_to_add