PIPS
HBDSC.c File Reference
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include "boolean.h"
#include <stdbool.h>
#include <limits.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 "complexity.h"
#include "dg.h"
#include "graph.h"
#include "ricedg.h"
#include "chains.h"
#include "task_parallelization.h"
+ Include dependency graph for HBDSC.c:

Go to the source code of this file.

Macros

#define MAX_ITER   1
 

Typedefs

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

Functions

static gen_array_t schedule_failsafe ()
 
static void cancel_schedule (gen_array_t annotations_s, list stmts)
 
static void cancel_schedule_stmt (gen_array_t annotations_s, statement st)
 
static double critical_path_length (int nbclusters)
 
static void initialization_clusters (bool first_p)
 eset to zero for each new sequence to handle More...
 
static list rebuild_topological_sort (list stages)
 
list topological_sort (statement stmt)
 
static double transfer_cost (statement s, int nbclusters)
 
static void hierarchical_schedule_step (statement stmt, int P, int M, bool dsc_p)
 
int hierarchical_schedule (statement stmt, int k, int P, int M, bool dsc_p)
 
bool hbdsc_parallelization (char *module_name)
 he main function for performing the hierarchical scheduling (scheduled SDG) using BDSC and generating the graph (unstructured) BDSC-based top-down hierarchical scheduling More...
 
bool dsc_code_parallelization (char *module_name)
 he main function for performing the hierarchical scheduling (scheduled SDG) using DSC and generating SPIRE More...
 

Variables

graph kdg
 Global variables. More...
 
graph ddg
 
statement return_st = statement_undefined
 
persistant_statement_to_cluster stmt_to_cluster
 

Macro Definition Documentation

◆ MAX_ITER

#define MAX_ITER   1

Definition at line 54 of file HBDSC.c.

Typedef Documentation

◆ arc_label

Instantiation of the dependence graph:

Definition at line 43 of file HBDSC.c.

◆ vertex_label

Definition at line 44 of file HBDSC.c.

Function Documentation

◆ cancel_schedule()

static void cancel_schedule ( gen_array_t  annotations_s,
list  stmts 
)
static

Definition at line 79 of file HBDSC.c.

80 {
81  FOREACH(STATEMENT, s, stmts){
82  annotation *vs = gen_array_item(annotations_s,(int)statement_ordering(s));
84  item->scheduled = vs->scheduled;
85  item->cluster = vs->cluster;
88  item->edge_cost = vs->edge_cost;
90  }
91  return;
92 }
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
bool bound_persistant_statement_to_cluster_p(persistant_statement_to_cluster f, intptr_t k)
Definition: ri.c:1552
gen_array_t annotations
Global variables.
Definition: SDG.c:62
void gen_array_addto(gen_array_t a, size_t i, void *what)
Definition: array.c:87
void * gen_array_item(const gen_array_t a, size_t i)
Definition: array.c:143
#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(x)
Definition: ri.h:2454
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413

References annotations, bound_persistant_statement_to_cluster_p(), annotation::cluster, annotation::edge_cost, FOREACH, gen_array_addto(), gen_array_item(), annotation::scheduled, STATEMENT, statement_ordering, stmt_to_cluster, and update_persistant_statement_to_cluster().

Referenced by cancel_schedule_stmt(), and hierarchical_schedule().

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

◆ cancel_schedule_stmt()

static void cancel_schedule_stmt ( gen_array_t  annotations_s,
statement  st 
)
static

Definition at line 93 of file HBDSC.c.

94 {
96  switch(instruction_tag(inst)){
99  break;
100  case is_instruction_loop:
101  cancel_schedule_stmt(annotations_s, loop_body(statement_loop(st)));
102  break;
103  default:
104  break;
105  }
106  return;
107 }
static void cancel_schedule_stmt(gen_array_t annotations_s, statement st)
Definition: HBDSC.c:93
static void cancel_schedule(gen_array_t annotations_s, list stmts)
Definition: HBDSC.c:79
sequence statement_sequence(statement)
Get the sequence of a statement sequence.
Definition: statement.c:1328
loop statement_loop(statement)
Get the loop of a statement.
Definition: statement.c:1374
#define is_instruction_block
soft block->sequence transition
#define loop_body(x)
Definition: ri.h:1644
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define sequence_statements(x)
Definition: ri.h:2360
#define statement_instruction(x)
Definition: ri.h:2458

References cancel_schedule(), instruction_tag, is_instruction_block, is_instruction_loop, loop_body, sequence_statements, statement_instruction, statement_loop(), and statement_sequence().

Referenced by hierarchical_schedule_step().

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

◆ critical_path_length()

static double critical_path_length ( int  nbclusters)
static

Definition at line 108 of file HBDSC.c.

108  {
109  double max = -1;
110  int cl;
111  for(cl = 0; cl < nbclusters; cl++)
112  {
113  cluster *cl_s = gen_array_item(clusters, cl);
114  double time = cl_s->time;
115  if(time > max)
116  max = time;
117  }
118  return max;
119 }
gen_array_t clusters
Definition: SDG.c:63
#define max(a, b)

References clusters, gen_array_item(), max, and cluster::time.

Referenced by hierarchical_schedule().

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

◆ dsc_code_parallelization()

bool dsc_code_parallelization ( char *  module_name)

he main function for performing the hierarchical scheduling (scheduled SDG) using DSC and generating SPIRE

The proper effect to detect the I/O operations:

omplexities (task processing time)

roperties to set the parameters of BDSC

ost model generation

SC-based top-down hierarchical scheduling

Reorder the module, because new statements have been generated.

Parameters
module_nameodule_name

Definition at line 473 of file HBDSC.c.

474 {
475  statement module_stat;
476  if (!get_bool_property("COMPLEXITY_EARLY_EVALUATION"))
477  set_bool_property("COMPLEXITY_EARLY_EVALUATION", true);
478  module_stat = (statement)db_get_memory_resource(DBR_CODE, module_name, true);
479  set_ordering_to_statement(module_stat);
481  set_current_module_statement(module_stat);
484  db_get_memory_resource(DBR_TRANSFORMERS, module_name, true));
485  /* The proper effect to detect the I/O operations: */
490  db_get_memory_resource(DBR_REGIONS, module_name, true));
495 
496  kdg = (graph) db_get_memory_resource (DBR_DG, module_name, true );
497 
498  /*Complexities (task processing time)*/
500 
501  /*Properties to set the parameters of BDSC*/
502  NBCLUSTERS = 1;//INT_MAX;
503  MEMORY_SIZE = -1;
504  INSTRUMENTED_FILE = strdup(get_string_property("BDSC_INSTRUMENTED_FILE"));
505  /*cost model generation */
508  if(sizeof(INSTRUMENTED_FILE) == 8)
510  else
512 
514  /*DSC-based top-down hierarchical scheduling*/
515  hierarchical_schedule(module_stat, 0, NBCLUSTERS, MEMORY_SIZE, true);
516  /* Reorder the module, because new statements have been generated. */
517  module_reorder(module_stat);
518  DB_PUT_MEMORY_RESOURCE(DBR_CODE, module_name, module_stat);
534  return true;
535 }
int hierarchical_schedule(statement stmt, int k, int P, int M, bool dsc_p)
Definition: HBDSC.c:311
graph kdg
Global variables.
Definition: HBDSC.c:52
persistant_statement_to_cluster make_persistant_statement_to_cluster(void)
Definition: ri.c:1537
int MEMORY_SIZE
Definition: SDG.c:58
string INSTRUMENTED_FILE
Definition: SDG.c:59
int NBCLUSTERS
parameters of BDSC, to be recovered using pips properties
Definition: SDG.c:57
gen_array_t gen_array_make(size_t size)
declarations...
Definition: array.c:40
void gen_array_free(gen_array_t a)
Definition: array.c:70
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
void reset_complexity_map(void)
void set_complexity_map(statement_mapping)
void parse_instrumented_file(char *file_name, graph dg, gen_array_t annotations)
Definition: cost_model.c:296
void initialization(graph dg, gen_array_t annotations)
Definition: cost_model.c:267
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
char * get_string_property(const char *)
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
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
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
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
void set_bool_property(const char *, bool)
bool module_reorder(statement body)
Reorder a module and recompute order to statement if any.
Definition: reorder.c:244
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479
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)
void free_value_mappings(void)
Normal call to free the mappings.
Definition: value.c:1212

References annotations, clusters, db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, free_value_mappings(), gen_array_free(), gen_array_make(), generic_effects_reset_all_methods(), get_bool_property(), get_current_module_entity(), get_string_property(), hierarchical_schedule(), init_convex_rw_prettyprint(), initialization(), INSTRUMENTED_FILE, kdg, make_persistant_statement_to_cluster(), MEMORY_SIZE, module_name(), module_name_to_entity(), module_reorder(), module_to_value_mappings(), NBCLUSTERS, parse_instrumented_file(), reset_complexity_map(), 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(), set_bool_property(), set_complexity_map(), 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(), stmt_to_cluster, and strdup().

+ Here is the call graph for this function:

◆ hbdsc_parallelization()

bool hbdsc_parallelization ( char *  module_name)

he main function for performing the hierarchical scheduling (scheduled SDG) using BDSC and generating the graph (unstructured) BDSC-based top-down hierarchical scheduling

The proper effect to detect the I/O operations:

omplexities (task processing time)

roperties to set the parameters of BDSC

ost model generation

Parameters
module_nameodule_name

Definition at line 396 of file HBDSC.c.

397 {
398  statement module_stat;
399  string tg_name = NULL;
400  FILE *ftg;
401  if (!get_bool_property("COMPLEXITY_EARLY_EVALUATION"))
402  set_bool_property("COMPLEXITY_EARLY_EVALUATION", true);
403  module_stat = (statement)db_get_memory_resource(DBR_CODE, module_name, true);
404  set_ordering_to_statement(module_stat);
406  set_current_module_statement(module_stat);
409  db_get_memory_resource(DBR_TRANSFORMERS, module_name, true));
410  /* The proper effect to detect the I/O operations: */
415  db_get_memory_resource(DBR_REGIONS, module_name, true));
420  kdg = (graph) db_get_memory_resource (DBR_SDG, module_name, true );
421  /*Complexities (task processing time)*/
423  /*Properties to set the parameters of BDSC*/
424  NBCLUSTERS = get_int_property("BDSC_NB_CLUSTERS");
425  MEMORY_SIZE = get_int_property("BDSC_MEMORY_SIZE");
426  INSTRUMENTED_FILE = strdup(get_string_property("BDSC_INSTRUMENTED_FILE"));
427 
428  /*cost model generation */
432  if(strlen(INSTRUMENTED_FILE) == 0)
434  else
437  hierarchical_schedule(module_stat, 0, NBCLUSTERS, MEMORY_SIZE, false);
439  "/",module_name,"/",module_name, "_scheduled_sdg.dot", NULL));
440  ftg = safe_fopen(tg_name, "w");
441  fprintf( ftg, "digraph {\n compound=true;ratio=fill; node[fontsize=24,fontname=\"Courier\",labelloc=\"t\"];nodesep=.05;\n" );
442  print_SDGs(module_stat, kdg, ftg, annotations);
443  fprintf( ftg, "\n}\n" );
444  safe_fclose(ftg, tg_name);
445  free(tg_name);
446 
447  DB_PUT_MEMORY_RESOURCE(DBR_SDG, module_name, (char*) kdg);
449  DB_PUT_MEMORY_RESOURCE(DBR_SCHEDULE, module_name, (char*) stmt_to_cluster);
465  return true;
466 }
static void initialization_clusters(bool first_p)
eset to zero for each new sequence to handle
Definition: HBDSC.c:122
int get_int_property(const string)
void print_SDGs(statement stmt, graph tg, FILE *ftg, gen_array_t annotations)
Definition: SDG.c:520
void gen_array_full_free(gen_array_t a)
Definition: array.c:77
FILE * safe_fopen(const char *filename, const char *what)
Definition: file.c:67
int safe_fclose(FILE *stream, const char *filename)
Definition: file.c:77
int gen_consistent_p(gen_chunk *obj)
GEN_CONSISTENT_P dynamically checks the type correctness of OBJ.
Definition: genClib.c:2398
void free(void *)
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
string db_get_current_workspace_directory(void)
Definition: workspace.c:96
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
A gen_chunk is used to store every object.
Definition: genC.h:58

References annotations, clusters, concatenate(), db_get_current_workspace_directory(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, fprintf(), free(), free_value_mappings(), gen_array_full_free(), gen_array_make(), gen_consistent_p(), generic_effects_reset_all_methods(), get_bool_property(), get_current_module_entity(), get_int_property(), get_string_property(), hierarchical_schedule(), init_convex_rw_prettyprint(), initialization(), initialization_clusters(), INSTRUMENTED_FILE, kdg, make_persistant_statement_to_cluster(), MEMORY_SIZE, module_name(), module_name_to_entity(), module_to_value_mappings(), NBCLUSTERS, parse_instrumented_file(), print_SDGs(), reset_complexity_map(), 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(), safe_fclose(), safe_fopen(), set_bool_property(), set_complexity_map(), 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(), stmt_to_cluster, and strdup().

◆ hierarchical_schedule()

int hierarchical_schedule ( statement  stmt,
int  k,
int  P,
int  M,
bool  dsc_p 
)

Definition at line 311 of file HBDSC.c.

312 {
313  int nbclusters = 0, nbcl; double cpl;
314  if(!get_bool_property("COSTLY_TASKS_ONLY") | costly_task(stmt)){ //granularity management
317  switch(instruction_tag(inst))
318  {
319  case is_instruction_block:{
321  if(gen_length(sequence_statements(seq))>0){
322  gen_array_t annotations_i = schedule_failsafe(), annotations_s;
323  if(!dsc_p)
324  nbcl = BDSC(seq, P, M, statement_ordering(stmt));
325  else{
326  nbcl = DSC(seq, statement_ordering(stmt));
327  NBCLUSTERS = NBCLUSTERS > nbcl ? NBCLUSTERS:nbcl;
328  }
329  double cpl1 = critical_path_length(nbcl);
330  int iter = 0;
331 
332  do{
333  hierarchical_schedule_step(stmt, P, M, dsc_p);
334  nbclusters = nbcl;
335  cpl = cpl1;
336  annotations_s = schedule_failsafe();
337  cancel_schedule(annotations_i, sequence_statements(seq));
338  if(!dsc_p){
339  nbcl = BDSC(seq, P, M, statement_ordering(stmt));
340  }
341  else{
342  nbcl = DSC(seq, statement_ordering(stmt));
343  NBCLUSTERS = NBCLUSTERS > nbcl ? NBCLUSTERS:nbcl;
344  }
345  cpl1 = critical_path_length(nbcl);
346  if(nbcl == 0){
347  fprintf (stderr, "Unable to schedule with NBCLUSTERS equal to %d\n",P);
348  exit (EXIT_FAILURE);
349  }
350  if(nbcl == -1){
351  fprintf (stderr, "Unable to schedule with MEMORY SIZE equal to %d\n",M);
352  exit (EXIT_FAILURE);
353  }
354  iter ++;
355  } while(cpl1 < cpl && nbcl <= nbclusters && iter <= MAX_ITER);
356  cancel_schedule(annotations_s, sequence_statements(seq));
357  item->task_time = cpl;
358  item->data = NIL;
359  gen_array_free(annotations_i);
360  gen_array_free(annotations_s);
361  }
362  break;
363  }
364  case is_instruction_test : {
365  test t = instruction_test(inst);
366  int nbt = hierarchical_schedule(test_true(t), k, P, M, dsc_p);
367  int nbf = hierarchical_schedule(test_false(t), k, P, M, dsc_p);
368  nbclusters = nbt > nbf? nbt: nbf;
369  break;
370  }
371  case is_instruction_loop :{
372  loop l = statement_loop(stmt);
373  statement body = loop_body(l);
374  nbclusters = hierarchical_schedule(body, k, P, M, dsc_p);
375  break;
376  }
377  case is_instruction_forloop :{
379  statement body = forloop_body(l);
380  nbclusters = hierarchical_schedule(body, k, P, M, dsc_p);
381  break;
382  }
383  default:
384  break;
385  }
386  item->nbclusters = nbclusters;
388  }
389  return nbclusters;
390 }
int DSC(sequence seq, int ordering)
Definition: BDSC.c:623
int BDSC(sequence seq, int P, int M, int ordering)
Definition: BDSC.c:535
void allocate_task_to_cluster(statement ready_st, int cl_p, int order)
BDSC.c.
Definition: BDSC.c:100
static gen_array_t schedule_failsafe()
Definition: HBDSC.c:59
static double critical_path_length(int nbclusters)
Definition: HBDSC.c:108
#define MAX_ITER
Definition: HBDSC.c:54
static void hierarchical_schedule_step(statement stmt, int P, int M, bool dsc_p)
Definition: HBDSC.c:274
bool costly_task(statement st)
cost_model.c
Definition: cost_model.c:52
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
size_t gen_length(const list l)
Definition: list.c:150
forloop statement_forloop(statement)
Get the forloop of a statement.
Definition: statement.c:1426
#define EXIT_FAILURE
Tandem/NSK and other platforms that define EXIT_FAILURE as -1 interfere with proper operation of xarg...
Definition: stdlib.in.h:108
#define exit(code)
Definition: misc-local.h:54
#define test_false(x)
Definition: ri.h:2837
@ is_instruction_test
Definition: ri.h:1470
@ is_instruction_forloop
Definition: ri.h:1477
#define test_true(x)
Definition: ri.h:2835
#define instruction_test(x)
Definition: ri.h:1517
#define forloop_body(x)
Definition: ri.h:1372
Definition: statement.c:54

References allocate_task_to_cluster(), annotations, BDSC(), cancel_schedule(), costly_task(), critical_path_length(), annotation::data, DSC(), exit, EXIT_FAILURE, forloop_body, fprintf(), gen_array_free(), gen_array_item(), gen_length(), get_bool_property(), hierarchical_schedule_step(), instruction_tag, instruction_test, is_instruction_block, is_instruction_forloop, is_instruction_loop, is_instruction_test, loop_body, MAX_ITER, NBCLUSTERS, annotation::nbclusters, NIL, schedule_failsafe(), sequence_statements, statement_forloop(), statement_instruction, statement_loop(), statement_ordering, statement_sequence(), annotation::task_time, test_false, and test_true.

Referenced by dsc_code_parallelization(), hbdsc_parallelization(), and hierarchical_schedule_step().

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

◆ hierarchical_schedule_step()

static void hierarchical_schedule_step ( statement  stmt,
int  P,
int  M,
bool  dsc_p 
)
static

Definition at line 274 of file HBDSC.c.

275 {
276  list cluster_stages = topological_sort(stmt);
277  int nbclustersL, nbclusters, nbclusters_s;
278  double task_time, task_time_s;
279  FOREACH(LIST, cluster_stage, cluster_stages) {
280  int stage_mod = gen_length(cluster_stage);
281  int Ps = P - stage_mod;// + 1;//use current processor
282  FOREACH(LIST, L, cluster_stage){
283  nbclustersL = 0;
284  FOREACH(statement, st, L){
285  if(Ps <= 0){
286  pips_user_warning("NBCLUSTERS is not sufficient to handle nested parts in statement_ordering = %d\n", statement_ordering(st));
287  }
288  else{
289  if(!get_bool_property("COSTLY_TASKS_ONLY") | costly_task(st)){
291  nbclusters = item->nbclusters;
292  task_time = item->task_time;
293  gen_array_t annotations_s = schedule_failsafe();
294  nbclusters_s = hierarchical_schedule(st, (item->cluster == -1)?0:item->cluster, Ps, M, dsc_p);
296  task_time_s = item->task_time;
297  if(nbclusters_s < nbclusters || task_time + transfer_cost(st, nbclusters) < task_time_s + transfer_cost(st, nbclusters_s)){
298  item->nbclusters = nbclusters;
299  cancel_schedule_stmt(annotations_s,st);
300  }
301  nbclustersL = nbclustersL > nbclusters? nbclustersL : nbclusters;
302  gen_array_free(annotations_s);
303  }
304  }
305  }
306  Ps = Ps - nbclustersL;
307  }
308  }
309  return;
310 }
list topological_sort(statement stmt)
Definition: HBDSC.c:192
static double transfer_cost(statement s, int nbclusters)
Definition: HBDSC.c:264
static double task_time(statement s)
Definition: cost_model.c:134
#define LIST(x)
Definition: genC.h:93
#define pips_user_warning
Definition: misc-local.h:146
Definition: pip__tab.h:30
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References annotations, cancel_schedule_stmt(), annotation::cluster, costly_task(), FOREACH, gen_array_free(), gen_array_item(), gen_length(), get_bool_property(), hierarchical_schedule(), LIST, annotation::nbclusters, pips_user_warning, schedule_failsafe(), statement_ordering, task_time(), annotation::task_time, topological_sort(), and transfer_cost().

Referenced by hierarchical_schedule().

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

◆ initialization_clusters()

static void initialization_clusters ( bool  first_p)
static

eset to zero for each new sequence to handle

Definition at line 122 of file HBDSC.c.

123 {
124  int i;
125  cluster *cl_s;
126  for(i=0;i<NBCLUSTERS;i++){
127  if(first_p)
128  cl_s = (cluster *)malloc(sizeof(cluster));
129  else
130  cl_s = gen_array_item(clusters, i);
131  cl_s->time = 0;
132  cl_s->data = NIL;
133  gen_array_addto(clusters, i, cl_s);
134  }
135  return;
136 }
void * malloc(YYSIZE_T)

References clusters, cluster::data, gen_array_addto(), gen_array_item(), malloc(), NBCLUSTERS, NIL, and cluster::time.

Referenced by hbdsc_parallelization().

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

◆ rebuild_topological_sort()

static list rebuild_topological_sort ( list  stages)
static

we suppose that we have only one return statement at the end of the module :(

Definition at line 146 of file HBDSC.c.

146  {
147  list K = NIL, cluster_stages = NIL;
148  int i;
149  FOREACH(LIST, stage, stages) {
150  K=NIL;
151  for(i = 0; i < NBCLUSTERS; i++){
152  list list_stmts = NIL;
153  FOREACH(STATEMENT, st, stage) {
157  list_stmts = CONS(STATEMENT, st, list_stmts);
158  }
159  }
160  /* we suppose that we have only one return statement at the
161  end of the module :( */
162  if(return_statement_p(st))
163  return_st = st;
164  }
165  if(list_stmts != NIL)
166  K = CONS(LIST, list_stmts, K);
167  }
168  if(K == NIL){
169  list list_stmts = NIL;
170  FOREACH(STATEMENT, st, stage) {
174  list_stmts = CONS(STATEMENT, st, list_stmts);
175  }
176  else
177  list_stmts = CONS(STATEMENT, st, list_stmts);
178  }
179  if(return_statement_p(st))
180  return_st = st;
181  }
182  if(list_stmts != NIL){
183  K = CONS(LIST, list_stmts, K);
184  }
185  }
186  if(K != NIL)
187  cluster_stages = CONS(LIST, gen_nreverse(K), cluster_stages);
188  }
189  return cluster_stages;
190 }
statement return_st
Definition: HBDSC.c:53
intptr_t apply_persistant_statement_to_cluster(persistant_statement_to_cluster f, intptr_t k)
Definition: ri.c:1540
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
bool return_statement_p(statement)
Test if a statement is a C or Fortran "return".
Definition: statement.c:172
bool declaration_statement_p(statement)
Had to be optimized according to Beatrice Creusillet.
Definition: statement.c:224

References apply_persistant_statement_to_cluster(), bound_persistant_statement_to_cluster_p(), CONS, declaration_statement_p(), FOREACH, gen_nreverse(), LIST, NBCLUSTERS, NIL, return_st, return_statement_p(), STATEMENT, statement_ordering, and stmt_to_cluster.

Referenced by topological_sort().

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

◆ schedule_failsafe()

static gen_array_t schedule_failsafe ( )
static

Definition at line 59 of file HBDSC.c.

59  {
60  gen_array_t annotations_s = gen_array_make(0);
63  annotation *item = (annotation *)malloc(sizeof(annotation));
65  item->scheduled = vs->scheduled;
66  item->cluster = vs->cluster;
69  vertex s = successor_vertex(su);
70  statement child = vertex_to_statement(s);
72  }
73  gen_array_addto(annotations_s, (int)statement_ordering(s), item);
74  }
75  return annotations_s;
76 }
#define successor_vertex(x)
Definition: graph.h:118
#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
statement vertex_to_statement(vertex v)
Vertex_to_statement looks for the statement that is pointed to by vertex v.
Definition: util.c:45

References annotations, annotation::cluster, annotation::edge_cost, FOREACH, gen_array_addto(), gen_array_item(), gen_array_make(), gen_length(), graph_vertices, kdg, malloc(), annotation::scheduled, statement_ordering, SUCCESSOR, successor_vertex, VERTEX, vertex_successors, and vertex_to_statement().

Referenced by hierarchical_schedule(), and hierarchical_schedule_step().

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

◆ topological_sort()

list topological_sort ( statement  stmt)
Parameters
stmttmt

Definition at line 192 of file HBDSC.c.

193 {
194  list K = NIL; uint i;
195  list cluster_stages = NIL;
196  list vertices = graph_vertices(kdg);
198  for(i = 0;i<gen_length(vertices);i++){
199  gen_array_addto(I, i, 0);
200  }
202  FOREACH(VERTEX, v, vertices) {
203  statement parent = vertex_to_statement(v);
204  if(statement_equal_p(st,parent)){
205  FOREACH(SUCCESSOR, su, (vertex_successors(v))) {
206  vertex w = successor_vertex(su);
207  statement child = vertex_to_statement(w);
208  gen_array_addto(I, (int)statement_ordering(child), gen_array_item(I, (int)statement_ordering(child)) + 1);
209  }
210  }
211  }
212  }
214  if(gen_array_item(I, statement_ordering(st)) == 0)
215  K = CONS(STATEMENT, st, K);
216  }
217  list L = gen_copy_seq(K);
218  cluster_stages = CONS(LIST, L, cluster_stages);
219  bool insert_p = false;
220  while(K != NIL){
221  statement st = STATEMENT(CAR(gen_last(K)));
222  gen_remove_once(&K, st);
223  FOREACH(VERTEX, pre, vertices) {
224  statement parent = vertex_to_statement(pre);
225  if(statement_equal_p(parent, st)){
226  FOREACH(SUCCESSOR, su, (vertex_successors(pre))) {
227  vertex v = successor_vertex(su);
228  statement child = vertex_to_statement(v);
229  gen_array_addto(I, (int)statement_ordering(child), gen_array_item(I, (int)statement_ordering(child)) - 1);
230  if(gen_array_item(I, statement_ordering(child)) == 0 && gen_occurences(child, K) == 0) {
231  K = CONS(STATEMENT, child, K);
232  insert_p = true;
233  }
234  }
235  break;
236  }
237  }
238  list M = NIL;
239  bool ins_p = true,found_p=false;
240  FOREACH(STATEMENT, stmt, K){
241  found_p = false;
242  FOREACH(STATEMENT, stmtl, L){
243  if(statement_equal_p(stmt,stmtl))
244  found_p = true;
245  }
246  if(!found_p)
247  M = CONS(STATEMENT,stmt,M);
248  else{
249  ins_p = false;
250  found_p = false;
251  }
252  }
253  if( ins_p && gen_length(M) > 0 && insert_p){
254  cluster_stages = CONS(LIST, M, cluster_stages);
255  insert_p = false;
256  L = gen_copy_seq(K);
257  }
258  }
259  gen_array_free(I);
260  return rebuild_topological_sort(cluster_stages);
261 }
static list rebuild_topological_sort(list stages)
Definition: HBDSC.c:146
void gen_remove_once(list *pl, const void *o)
Remove the first occurence of o in list pl:
Definition: list.c:691
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
list gen_last(list l)
Return the last element of a list.
Definition: list.c:578
int gen_occurences(const void *vo, const list l)
count occurences of vo in l
Definition: list.c:746
static bool statement_equal_p(statement s1, statement s2)
Definition: unstructured.c:55

References CAR, CONS, FOREACH, gen_array_addto(), gen_array_free(), gen_array_item(), gen_array_make(), gen_copy_seq(), gen_last(), gen_length(), gen_occurences(), gen_remove_once(), graph_vertices, kdg, LIST, NIL, rebuild_topological_sort(), sequence_statements, STATEMENT, statement_equal_p(), statement_ordering, statement_sequence(), SUCCESSOR, successor_vertex, VERTEX, vertex_successors, and vertex_to_statement().

Referenced by cluster_stage_spire_generation(), and hierarchical_schedule_step().

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

◆ transfer_cost()

static double transfer_cost ( statement  s,
int  nbclusters 
)
static

Definition at line 264 of file HBDSC.c.

264  {
265  if(nbclusters == 0 || !get_bool_property("BDSC_DISTRIBUTED_MEMORY"))
266  return 0;
269  double size = size_of_regions(l_in) + size_of_regions(l_out);
270  return size;
271 }
double size_of_regions(list l_data)
Definition: cost_model.c:115
list regions_dup(list)
list load_statement_out_regions(statement)
list load_statement_in_regions(statement)

References get_bool_property(), load_statement_in_regions(), load_statement_out_regions(), regions_dup(), and size_of_regions().

Referenced by hierarchical_schedule_step().

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

Variable Documentation

◆ ddg

graph ddg

Definition at line 52 of file HBDSC.c.

Referenced by sequence_dependence_graph().

◆ kdg

◆ return_st

◆ stmt_to_cluster