PIPS
BDSC.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 BDSC.c:

Go to the source code of this file.

Data Structures

struct  min_start_time
 Global variables. More...
 

Typedefs

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

Functions

static bool ready_node (statement st)
 
static void update_priority_values (statement ready_st)
 
void allocate_task_to_cluster (statement ready_st, int cl_p, int order)
 BDSC.c. More...
 
static void move_task_to_cluster (statement ready_st, int cl_p)
 
static bool MCW (statement ready_st, int cl, int M)
 
static min_start_time tlevel_decrease (statement ready_st, int M)
 
static bool zeroing_multiple_edges (statement ready_st, int order, int M)
 
static int end_idle_clusters (statement ready_st, int nbclusters)
 pply the second priority : load balancing : length_cluster(c_i) < tlevel(ready_st) and forall node n_y in c_i scheduled(successors(n_y)) = true or successors(n_y) \subset successors(ready_st) More...
 
static int min_start_time_cluster (int nbclusters)
 pply the third priority if bounded number of processors is exceeded start-time(ready_st) = min(length_cluster(c_i)) tlevel(ready_st) can be increased. More...
 
static double max_start_time_cluster (int nbclusters)
 sed to compute the parallel task time of a task More...
 
static bool DSRW (statement ready_st, statement unready_st, int order, int M)
 
static statement select_task_with_highest_priority (list tasks, statement ready)
 
static gen_array_t schedule_failsafe ()
 
static void cancel_schedule (gen_array_t annotations_s, list stmts)
 
static void initialization_clusters (bool first_p)
 eset to zero for each new sequence to handle More...
 
static void update_parallel_task (int ordering, int nbclusters)
 
static int find_cluster (statement ready_task, int nbclusters, int P, int M, int order, list stmts, gen_array_t annotations_s)
 
int BDSC (sequence seq, int P, int M, int ordering)
 
int DSC (sequence seq, int ordering)
 

Typedef Documentation

◆ arc_label

Instantiation of the dependence graph:

Definition at line 43 of file BDSC.c.

◆ vertex_label

Definition at line 44 of file BDSC.c.

Function Documentation

◆ allocate_task_to_cluster()

void allocate_task_to_cluster ( statement  ready_st,
int  cl_p,
int  order 
)

BDSC.c.

Parameters
ready_steady_st
cl_pl_p
orderrder

Definition at line 100 of file BDSC.c.

100  {
102  list vertices = graph_vertices(kdg);
103  an->scheduled = true;
104  an->order_sched = order;
105  an->cluster = cl_p;
108  else
110  //delete ready_st from successors(tasks(cl_p))
111  FOREACH(VERTEX, pre, vertices) {
112  statement parent = vertex_to_statement(pre);
114  if(anp->cluster == cl_p)
115  {
116  FOREACH(SUCCESSOR, su, (vertex_successors(pre))) {
117  vertex v = successor_vertex(su);
118  statement child = vertex_to_statement(v);
119  if(statement_equal_p(child, ready_st)){
120  double *ec = (double *)malloc(sizeof(double));
121  *ec = 0;
122  gen_array_addto(anp->edge_cost,(int)statement_ordering(ready_st), ec);
123  gen_array_addto(annotations, (int)statement_ordering(parent), anp);
124  }
125  }
126  }
127  }
128 
129  cluster *cl = gen_array_item(clusters, cl_p);
130  double time = cl->time;
131  double time1 = (time > an->tlevel) ? (time + an->task_time) : (an->tlevel + an->task_time);
132  cl->time = time1;
135  cl->data = l_data;
136  }
137  gen_array_addto(clusters, cl_p, cl);
138  update_priority_values(ready_st);
139  return;
140 }
static void update_priority_values(statement ready_st)
Definition: BDSC.c:81
persistant_statement_to_cluster stmt_to_cluster
Definition: HBDSC.c:56
graph kdg
Global variables.
Definition: HBDSC.c:52
void update_persistant_statement_to_cluster(persistant_statement_to_cluster f, intptr_t k, intptr_t v)
Definition: ri.c:1543
void extend_persistant_statement_to_cluster(persistant_statement_to_cluster f, intptr_t k, intptr_t v)
Definition: ri.c:1546
bool bound_persistant_statement_to_cluster_p(persistant_statement_to_cluster f, intptr_t k)
Definition: ri.c:1552
gen_array_t clusters
Definition: SDG.c:63
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
list RegionsMustUnion(list l1, list l2, bool(*union_combinable_p)(effect, effect))
list RegionsMustUnion(list l1, list l2, union_combinable_p) input : two lists of regions output : a l...
list regions_dup(list)
bool r_w_combinable_p(effect, effect)
void * malloc(YYSIZE_T)
#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
size_t gen_length(const list l)
Definition: list.c: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
statement vertex_to_statement(vertex v)
Vertex_to_statement looks for the statement that is pointed to by vertex v.
Definition: util.c:45
static vertex statement_to_vertex(statement s, graph g)
Definition: impact_check.c:227
static bool statement_equal_p(statement s1, statement s2)
Definition: unstructured.c:55
#define statement_ordering(x)
Definition: ri.h:2454
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References annotations, bound_persistant_statement_to_cluster_p(), annotation::cluster, clusters, annotation::data, cluster::data, annotation::edge_cost, extend_persistant_statement_to_cluster(), FOREACH, gen_array_addto(), gen_array_item(), gen_length(), graph_vertices, kdg, malloc(), annotation::order_sched, r_w_combinable_p(), regions_dup(), RegionsMustUnion(), annotation::scheduled, statement_equal_p(), statement_ordering, statement_to_vertex(), stmt_to_cluster, SUCCESSOR, successor_vertex, annotation::task_time, cluster::time, annotation::tlevel, update_persistant_statement_to_cluster(), update_priority_values(), VERTEX, vertex_successors, and vertex_to_statement().

Referenced by BDSC(), DSC(), DSRW(), find_cluster(), hierarchical_schedule(), and zeroing_multiple_edges().

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

◆ BDSC()

int BDSC ( sequence  seq,
int  P,
int  M,
int  ordering 
)

canf instruction should be scheduled in the master cluster (by convention 0)

f(get_bool_property("BDSC_DISTRIBUTED_MEMORY")) zeroing_p = zeroing_multiple_edges(ready_task, order,M); function Not validated else

Parameters
seqeq
orderingrdering

Definition at line 535 of file BDSC.c.

535  {
536  if(P <= 0)
537  return 0;
538  int nbclusters = 0;
539  int order = 0, cl_p = -1;
540  list unscheduled_tasks = NIL;
541  list ready_tasks = NIL, unready_tasks = NIL;
542  list stmts = sequence_statements(seq);
543  statement ready_task = statement_undefined, unready_task = statement_undefined;
544  gen_array_t annotations_s = schedule_failsafe();
545  bool other_rules_p = false, scanf_p = false;
550  FOREACH(statement, st, stmts){
551  if(!declaration_statement_p(st)) {
552  unscheduled_tasks = CONS(STATEMENT, st, unscheduled_tasks);
553  if(ready_node(st))
554  ready_tasks = CONS(STATEMENT, st, ready_tasks);
555  else
556  unready_tasks = CONS(STATEMENT, st, unready_tasks);
557  }
558  }
559  while(gen_length(unscheduled_tasks) > 0 ){
560  ready_task = select_task_with_highest_priority(ready_tasks, statement_undefined);
561  unready_task = select_task_with_highest_priority(unready_tasks, ready_task);
562  other_rules_p = false, scanf_p = false;
563  if(statement_call_p(ready_task)){
564  entity f = call_function(statement_call(ready_task));
567  scanf_p = true;
568  }
569  if(scanf_p){
570  /*scanf instruction should be scheduled in the master cluster
571  (by convention 0)*/
572  allocate_task_to_cluster(ready_task, 0, order);
573  if(nbclusters == 0)
574  nbclusters ++;
575  }
576  else{
577  if(statement_undefined_p(unready_task)){
578  cl_p = -1;
579  statement min_pred = ready_task;
580  bool zeroing_p = true;
581  /*if(get_bool_property("BDSC_DISTRIBUTED_MEMORY"))
582  zeroing_p = zeroing_multiple_edges(ready_task, order,M);
583  //function Not validated
584  else*/
585  {
586  min_start_time min_pred_s = tlevel_decrease(ready_task,M);
587  min_pred = min_pred_s.min_tau;
588  if(min_pred != statement_undefined)
589  {
591  cl_p = anp->cluster;
592  allocate_task_to_cluster(ready_task,cl_p, order);
593  }
594  }
595  if(min_pred == statement_undefined || !zeroing_p)
596  other_rules_p = true;
597  }
598  else {
599  other_rules_p = DSRW(ready_task, unready_task,order,M);
600  }
601  if(other_rules_p)
602  nbclusters = find_cluster(ready_task, nbclusters, P, M, order, stmts, annotations_s);
603  if(nbclusters == -1)//not enough memorry
604  return -1;
605  }
606  gen_remove_once(&unscheduled_tasks, ready_task);
607  FOREACH(statement, st, unready_tasks){
608  if(ready_node(st))
609  gen_remove_once(&unready_tasks, st);
610  }
611  ready_tasks = NIL;
612  FOREACH(statement, st, unscheduled_tasks) {
613  if(ready_node(st))
614  ready_tasks = CONS(STATEMENT, st, ready_tasks);
615  }
616  order ++;
617  }
618  gen_array_free(annotations_s);
619  update_parallel_task(ordering, nbclusters);
620  return nbclusters;
621 }
static statement select_task_with_highest_priority(list tasks, statement ready)
Definition: BDSC.c:431
static gen_array_t schedule_failsafe()
Definition: BDSC.c:451
static void initialization_clusters(bool first_p)
eset to zero for each new sequence to handle
Definition: BDSC.c:487
void allocate_task_to_cluster(statement ready_st, int cl_p, int order)
BDSC.c.
Definition: BDSC.c:100
static int find_cluster(statement ready_task, int nbclusters, int P, int M, int order, list stmts, gen_array_t annotations_s)
Definition: BDSC.c:511
static bool DSRW(statement ready_st, statement unready_st, int order, int M)
Definition: BDSC.c:407
static bool ready_node(statement st)
Definition: BDSC.c:59
static void update_parallel_task(int ordering, int nbclusters)
Definition: BDSC.c:503
static min_start_time tlevel_decrease(statement ready_st, int M)
Definition: BDSC.c:175
void gen_array_free(gen_array_t a)
Definition: array.c:70
void bottom_level(graph dg, gen_array_t annotations)
Second parameter is the bottom level (latest start time) for each node.
Definition: cost_model.c:223
void top_level(graph dg, gen_array_t annotations)
Definition: cost_model.c:211
void priorities(gen_array_t annotations)
Definition: cost_model.c:253
void gen_remove_once(list *pl, const void *o)
Remove the first occurence of o in list pl:
Definition: list.c:691
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
call statement_call(statement)
Get the call of a statement.
Definition: statement.c:1406
bool statement_call_p(statement)
Definition: statement.c:364
bool declaration_statement_p(statement)
Had to be optimized according to Beatrice Creusillet.
Definition: statement.c:224
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
#define ENTITY_FSCANF_P(e)
#define ENTITY_SCANF_P(e)
#define ENTITY_ISOC99_SSCANF_P(e)
#define ENTITY_ISOC99_SCANF_P(e)
#define ENTITY_SSCANF_P(e)
#define ENTITY_ISOC99_FSCANF_P(e)
#define call_function(x)
Definition: ri.h:709
#define sequence_statements(x)
Definition: ri.h:2360
#define statement_undefined_p(x)
Definition: ri.h:2420
#define statement_undefined
Definition: ri.h:2419
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
Global variables.
Definition: BDSC.c:53
statement min_tau
Definition: BDSC.c:55

References allocate_task_to_cluster(), annotations, bottom_level(), call_function, annotation::cluster, CONS, declaration_statement_p(), DSRW(), ENTITY_FSCANF_P, ENTITY_ISOC99_FSCANF_P, ENTITY_ISOC99_SCANF_P, ENTITY_ISOC99_SSCANF_P, ENTITY_SCANF_P, ENTITY_SSCANF_P, f(), find_cluster(), FOREACH, gen_array_free(), gen_array_item(), gen_length(), gen_remove_once(), initialization_clusters(), kdg, min_start_time::min_tau, NIL, priorities(), ready_node(), schedule_failsafe(), select_task_with_highest_priority(), sequence_statements, STATEMENT, statement_call(), statement_call_p(), statement_ordering, statement_undefined, statement_undefined_p, tlevel_decrease(), top_level(), and update_parallel_task().

Referenced by hierarchical_schedule().

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

◆ cancel_schedule()

static void cancel_schedule ( gen_array_t  annotations_s,
list  stmts 
)
static

Definition at line 471 of file BDSC.c.

472 {
473  FOREACH(STATEMENT, s, stmts){
474  annotation *vs = gen_array_item(annotations_s,(int)statement_ordering(s));
476  item->scheduled = vs->scheduled;
477  item->cluster = vs->cluster;
480  item->edge_cost = vs->edge_cost;
482  }
483  return;
484 }

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 find_cluster().

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

◆ DSC()

int DSC ( sequence  seq,
int  ordering 
)
Parameters
seqeq
orderingrdering

Definition at line 623 of file BDSC.c.

623  {
624  int M = -1;
625  int nbclusters = 0;
626  int order = 0, cl_p = -1;
627  list unscheduled_tasks = NIL;
628  list ready_tasks = NIL, unready_tasks = NIL;
629  list stmts = sequence_statements(seq);
630  statement ready_task = statement_undefined, unready_task = statement_undefined;
631  gen_array_t annotations_s = schedule_failsafe();
632  bool other_rules_p = false;
636  FOREACH(statement, st, stmts){
637  unscheduled_tasks = CONS(STATEMENT, st, unscheduled_tasks);
638  if(ready_node(st))
639  ready_tasks = CONS(STATEMENT, st, ready_tasks);
640  else
641  unready_tasks = CONS(STATEMENT, st, unready_tasks);
642  }
643  while(gen_length(unscheduled_tasks) > 0 ){
644  ready_task = select_task_with_highest_priority(ready_tasks, statement_undefined);
645  unready_task = select_task_with_highest_priority(unready_tasks, ready_task);
646  other_rules_p = false;
647  if(statement_undefined_p(unready_task)){
648  cl_p = -1;
649  statement min_pred = ready_task;
650  bool zeroing_p = true;
651  if(get_bool_property("BDSC_DISTRIBUTED_MEMORY"))
652  zeroing_p = zeroing_multiple_edges(ready_task, order,M);
653  else
654  {
655  min_start_time min_pred_s = tlevel_decrease(ready_task,M);
656  min_pred = min_pred_s.min_tau;
657  if(min_pred != statement_undefined)
658  {
660  cl_p = anp->cluster;
661  allocate_task_to_cluster(ready_task,cl_p, order);
662  }
663  }
664  if(min_pred == statement_undefined || !zeroing_p)
665  other_rules_p = true;
666  }
667  else {
668  other_rules_p = DSRW(ready_task, unready_task,order,M);
669  }
670  if(other_rules_p){
671  cluster *cl_s = (cluster *)malloc(sizeof(cluster));
672  cl_s->time = 0;
673  cl_s->data = NIL;
674  int i = nbclusters++;
675  gen_array_addto(clusters, i, cl_s);
676  allocate_task_to_cluster(ready_task, i, order);
677  }
678  gen_remove_once(&unscheduled_tasks, ready_task);
679  FOREACH(statement, st, unready_tasks){
680  if(ready_node(st))
681  gen_remove_once(&unready_tasks, st);
682  }
683  ready_tasks = NIL;
684  FOREACH(statement, st, unscheduled_tasks) {
685  if(ready_node(st))
686  ready_tasks = CONS(STATEMENT, st, ready_tasks);
687  }
688  order ++;
689  }
690  gen_array_free(annotations_s);
691  update_parallel_task(ordering, nbclusters);
692  return nbclusters;
693 }
static bool zeroing_multiple_edges(statement ready_st, int order, int M)
Definition: BDSC.c:225
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....

References allocate_task_to_cluster(), annotations, bottom_level(), annotation::cluster, clusters, CONS, cluster::data, DSRW(), FOREACH, gen_array_addto(), gen_array_free(), gen_array_item(), gen_length(), gen_remove_once(), get_bool_property(), kdg, malloc(), min_start_time::min_tau, NIL, priorities(), ready_node(), schedule_failsafe(), select_task_with_highest_priority(), sequence_statements, STATEMENT, statement_ordering, statement_undefined, statement_undefined_p, cluster::time, tlevel_decrease(), top_level(), update_parallel_task(), and zeroing_multiple_edges().

Referenced by hierarchical_schedule().

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

◆ DSRW()

static bool DSRW ( statement  ready_st,
statement  unready_st,
int  order,
int  M 
)
static

Definition at line 407 of file BDSC.c.

407  {
408  int cl_p; bool DSRW_p = false;
409  min_start_time r_min_pred_s = tlevel_decrease(ready_st, M);
410  statement r_min_pred = r_min_pred_s.min_tau;
411  if(r_min_pred != statement_undefined)
412  {
413  min_start_time u_min_pred_s = tlevel_decrease(unready_st,M);
414  double ptlevel_before = u_min_pred_s.min_tlevel;
415  annotation *anp = gen_array_item(annotations, (int)statement_ordering(r_min_pred));
416  cl_p = anp->cluster;
417  u_min_pred_s = tlevel_decrease(unready_st,M);
418  double ptlevel_after = u_min_pred_s.min_tlevel;
419  if(ptlevel_after > ptlevel_before){
420  DSRW_p = true;
421  }
422  else
423  allocate_task_to_cluster(ready_st,cl_p, order);
424  }
425  if ((r_min_pred == statement_undefined) || DSRW_p)
426  return true;
427  else
428  return false;
429 }
double min_tlevel
Definition: BDSC.c:54

References allocate_task_to_cluster(), annotations, annotation::cluster, gen_array_item(), min_start_time::min_tau, min_start_time::min_tlevel, statement_ordering, statement_undefined, and tlevel_decrease().

Referenced by BDSC(), and DSC().

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

◆ end_idle_clusters()

static int end_idle_clusters ( statement  ready_st,
int  nbclusters 
)
static

pply the second priority : load balancing : length_cluster(c_i) < tlevel(ready_st) and forall node n_y in c_i scheduled(successors(n_y)) = true or successors(n_y) \subset successors(ready_st)

Definition at line 328 of file BDSC.c.

328  {
329  list vertices = graph_vertices(kdg);
331  double min_time = an->tlevel, time_cluster;
332  bool found_p;
333  int min_cluster = -1;
334  vertex ready_vertex = statement_to_vertex(ready_st, kdg);
335  for(int cl = 0; cl < nbclusters; cl++){
336  cluster *cl_s = gen_array_item(clusters, cl); ;
337  time_cluster = cl_s->time;
338  if(time_cluster <= min_time)
339  {
340  found_p = true;
341  FOREACH(VERTEX, pre, vertices) {
342  statement parent = vertex_to_statement(pre);
344  if(anp->cluster == cl){
345  FOREACH(SUCCESSOR, su, (vertex_successors(pre))) {
346  vertex v = successor_vertex(su);
347  statement child = vertex_to_statement(v);
349  if(!anc->scheduled)
350  {
351  FOREACH(SUCCESSOR, su_r, vertex_successors(ready_vertex)) {
353  {
354  found_p = false;
355  break;
356  }
357  }
358  }
359  }
360  }
361  }
362  if(found_p)
363  {
364  min_time = min_time > time_cluster ? time_cluster : min_time;
365  min_cluster = (min_time > time_cluster || min_cluster == -1) ? cl : min_cluster;
366  }
367  }
368  }
369  return min_cluster;
370 }

References annotations, annotation::cluster, clusters, FOREACH, gen_array_item(), graph_vertices, kdg, annotation::scheduled, statement_equal_p(), statement_ordering, statement_to_vertex(), SUCCESSOR, successor_vertex, cluster::time, annotation::tlevel, VERTEX, vertex_successors, and vertex_to_statement().

Referenced by find_cluster().

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

◆ find_cluster()

static int find_cluster ( statement  ready_task,
int  nbclusters,
int  P,
int  M,
int  order,
list  stmts,
gen_array_t  annotations_s 
)
static

Definition at line 511 of file BDSC.c.

512 {
513  //second priority: load balancing
514  int cl_p = end_idle_clusters(ready_task, nbclusters);
515  if(cl_p == -1 || (MEMORY_SIZE != -1 && !MCW(ready_task,cl_p,M)))
516  { //third priority: PCW
517  if(nbclusters < P && (MEMORY_SIZE == -1 || MCW(ready_task,nbclusters,M)))
518  cl_p = nbclusters ++;
519  else
520  {
521  cl_p = min_start_time_cluster(nbclusters);
522  if(MEMORY_SIZE != -1 && !MCW(ready_task,cl_p,M))
523  {
524  cancel_schedule(annotations_s, stmts);
525  fprintf (stderr, "OUUPS, Not Enough Memory but let's try the hierarchical enclosed tasks\n");
526  return -1;
527  }
528  }
529  }
530  allocate_task_to_cluster(ready_task,cl_p, order);
531  return nbclusters;
532 }
static int end_idle_clusters(statement ready_st, int nbclusters)
pply the second priority : load balancing : length_cluster(c_i) < tlevel(ready_st) and forall node n_...
Definition: BDSC.c:328
static void cancel_schedule(gen_array_t annotations_s, list stmts)
Definition: BDSC.c:471
static bool MCW(statement ready_st, int cl, int M)
Definition: BDSC.c:163
static int min_start_time_cluster(int nbclusters)
pply the third priority if bounded number of processors is exceeded start-time(ready_st) = min(length...
Definition: BDSC.c:376
int MEMORY_SIZE
Definition: SDG.c:58
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...

References allocate_task_to_cluster(), cancel_schedule(), end_idle_clusters(), fprintf(), MCW(), MEMORY_SIZE, and min_start_time_cluster().

Referenced by BDSC().

+ 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 487 of file BDSC.c.

488 {
489  int i;
490  cluster *cl_s;
491  for(i=0;i<NBCLUSTERS;i++){
492  if(first_p)
493  cl_s = (cluster *)malloc(sizeof(cluster));
494  else
495  cl_s = gen_array_item(clusters, i);
496  cl_s->time = 0;
497  cl_s->data = NIL;
498  gen_array_addto(clusters, i, cl_s);
499  }
500  return;
501 }
int NBCLUSTERS
parameters of BDSC, to be recovered using pips properties
Definition: SDG.c:57

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

Referenced by BDSC().

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

◆ max_start_time_cluster()

static double max_start_time_cluster ( int  nbclusters)
static

sed to compute the parallel task time of a task

Definition at line 393 of file BDSC.c.

393  {
394  double max = -1;
395  int cl;
396  for(cl = 0; cl < nbclusters; cl++)
397  {
398  cluster *cl_s = gen_array_item(clusters, cl);
399  double time = cl_s->time;
400  if(time >= max || max == -1)
401  {
402  max = time;
403  }
404  }
405  return max;
406 }
#define max(a, b)

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

Referenced by update_parallel_task().

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

◆ MCW()

static bool MCW ( statement  ready_st,
int  cl,
int  M 
)
static

Definition at line 163 of file BDSC.c.

164 {
166  return true;
167  if(cl != -1){
169  cluster *cl_s = gen_array_item(clusters, cl);
171  return (size_of_regions(l_data) < M);
172  }
173  return false;
174 }
double size_of_regions(list l_data)
Definition: cost_model.c:115
bool w_w_combinable_p(effect, effect)

References annotations, clusters, annotation::data, cluster::data, gen_array_item(), gen_length(), kdg, regions_dup(), RegionsMustUnion(), size_of_regions(), statement_ordering, statement_to_vertex(), vertex_successors, and w_w_combinable_p().

Referenced by find_cluster(), tlevel_decrease(), and zeroing_multiple_edges().

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

◆ min_start_time_cluster()

static int min_start_time_cluster ( int  nbclusters)
static

pply the third priority if bounded number of processors is exceeded start-time(ready_st) = min(length_cluster(c_i)) tlevel(ready_st) can be increased.

Definition at line 376 of file BDSC.c.

376  {
377  double min = -1;
378  int min_cluster = -1, cl;
379  for(cl = 0; cl < nbclusters; cl++)
380  {
381  cluster *cl_s = gen_array_item(clusters, cl);
382  double time = cl_s->time;
383  if(time <= min || min == -1)
384  {
385  min_cluster = cl;
386  min = time;
387  }
388  }
389  return min_cluster;
390 }
#define min(a, b)

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

Referenced by find_cluster().

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

◆ move_task_to_cluster()

static void move_task_to_cluster ( statement  ready_st,
int  cl_p 
)
static

Definition at line 142 of file BDSC.c.

142  {
144  //int cl_i = an->cluster;
146  double time = cl->time;
147  cl->time = time - an->task_time;
148  gen_array_addto(clusters, an->cluster, cl);
149  an->cluster = cl_p;
151  cl = gen_array_item(clusters, cl_p);
152  time = cl->time;
153  cl->time = time > an->tlevel + an->task_time? time : an->tlevel + an->task_time;
156  cl->data = l_data;
157  }
158  gen_array_addto(clusters, cl_p, cl);
159  update_priority_values(ready_st);
160  return;
161 }

References annotations, annotation::cluster, clusters, annotation::data, cluster::data, extend_persistant_statement_to_cluster(), gen_array_addto(), gen_array_item(), gen_length(), kdg, r_w_combinable_p(), regions_dup(), RegionsMustUnion(), statement_ordering, statement_to_vertex(), stmt_to_cluster, annotation::task_time, cluster::time, annotation::tlevel, update_priority_values(), and vertex_successors.

Referenced by zeroing_multiple_edges().

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

◆ ready_node()

static bool ready_node ( statement  st)
static

Definition at line 59 of file BDSC.c.

59  {
60  bool ready_p = true;
61  list vertices = graph_vertices(kdg);
62  FOREACH(VERTEX, pre, vertices) {
63  statement parent = vertex_to_statement(pre);
64  FOREACH(SUCCESSOR, su, (vertex_successors(pre))) {
65  vertex s = successor_vertex(su);
66  statement child = vertex_to_statement(s);
67  if(statement_equal_p(child, st)) {
69  bool sc_p = anp->scheduled;
70  if(!sc_p){
71  ready_p = false;
72  break;
73  }
74  }
75  }
76  }
77  return ready_p;
78 }

References annotations, FOREACH, gen_array_item(), graph_vertices, kdg, annotation::scheduled, statement_equal_p(), statement_ordering, SUCCESSOR, successor_vertex, VERTEX, vertex_successors, and vertex_to_statement().

Referenced by BDSC(), and DSC().

+ 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 451 of file BDSC.c.

451  {
452  gen_array_t annotations_s = gen_array_make(0);
455  annotation *item = (annotation *)malloc(sizeof(annotation));
457  item->scheduled = vs->scheduled;
458  item->cluster = vs->cluster;
461  vertex s = successor_vertex(su);
462  statement child = vertex_to_statement(s);
464  }
465  gen_array_addto(annotations_s, (int)statement_ordering(s), item);
466  }
467  return annotations_s;
468 }
gen_array_t gen_array_make(size_t size)
declarations...
Definition: array.c:40

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 BDSC(), and DSC().

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

◆ select_task_with_highest_priority()

static statement select_task_with_highest_priority ( list  tasks,
statement  ready 
)
static

Definition at line 431 of file BDSC.c.

431  {
432  double max;
433  statement highest_task = statement_undefined;
434  if(!statement_undefined_p(ready)){
436  max = item->prio;
437  }
438  else
439  max = -1;
440  FOREACH(statement, st, tasks) {
442  if(item->prio > max)//just for unexamined nodes
443  {
444  max = item->prio;
445  highest_task = st;
446  }
447  }
448  return highest_task;
449 }

References annotations, FOREACH, gen_array_item(), max, annotation::prio, statement_ordering, statement_undefined, and statement_undefined_p.

Referenced by BDSC(), and DSC().

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

◆ tlevel_decrease()

static min_start_time tlevel_decrease ( statement  ready_st,
int  M 
)
static

dge_cost(parent1,ready_st);

Definition at line 175 of file BDSC.c.

175  {
176  list vertices = graph_vertices(kdg);
178  min_start_time min_pred;
179  double time;
180  statement min_predecessor = statement_undefined;
181  double min_tlevel = an->tlevel;
182  FOREACH(VERTEX, pre, vertices) {
183  statement parent = vertex_to_statement(pre);
185  if(anp->scheduled && (MEMORY_SIZE == -1 || MCW(ready_st,anp->cluster,M)))
186  {
187  FOREACH(SUCCESSOR, su, (vertex_successors(pre))) {
188  vertex s = successor_vertex(su);
189  statement child = vertex_to_statement(s);
190  if(statement_equal_p(child, ready_st)) //pre is predecessor of ready_st
191  {
192  cluster *cl_s = gen_array_item(clusters, anp->cluster);
193  double new_tlevel = cl_s->time;
194  FOREACH(VERTEX, pre1, vertices) {// all predecessors minus this parent
195  statement parent1 = vertex_to_statement(pre1);
197  if(anp1->scheduled){
198  FOREACH(SUCCESSOR, su1, (vertex_successors(pre1))) {
199  vertex s1 = successor_vertex(su1);
200  statement child1 = vertex_to_statement(s1);
201  if(statement_equal_p(child1, ready_st))//pre1 is predecessor of ready_st
202  {
203  if (!statement_equal_p(parent, parent1)){
204  double edge_c = *(double *)(gen_array_item(anp1->edge_cost,statement_ordering(ready_st)));
205  time = anp1->tlevel + anp1->task_time + edge_c /*edge_cost(parent1,ready_st);*/ ;
206  new_tlevel = new_tlevel > time ? new_tlevel : time;
207  }
208  }
209  }
210  }
211  }
212  if(new_tlevel <= min_tlevel){
213  min_tlevel = new_tlevel;
214  min_predecessor = parent;
215  }
216  }
217  }
218  }
219  }
220  min_pred.min_tlevel = min_tlevel;
221  min_pred.min_tau = min_predecessor;
222  return min_pred;
223 }
s1
Definition: set.c:247

References annotations, annotation::cluster, clusters, annotation::edge_cost, FOREACH, gen_array_item(), graph_vertices, kdg, MCW(), MEMORY_SIZE, min_start_time::min_tau, min_start_time::min_tlevel, s1, annotation::scheduled, statement_equal_p(), statement_ordering, statement_undefined, SUCCESSOR, successor_vertex, annotation::task_time, cluster::time, annotation::tlevel, VERTEX, vertex_successors, and vertex_to_statement().

Referenced by BDSC(), DSC(), and DSRW().

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

◆ update_parallel_task()

static void update_parallel_task ( int  ordering,
int  nbclusters 
)
static

Definition at line 503 of file BDSC.c.

504 {
505  annotation *item = gen_array_item(annotations,ordering);
506  item->data = NIL;
507  item->task_time = max_start_time_cluster(nbclusters);
508  return;
509 }
static double max_start_time_cluster(int nbclusters)
sed to compute the parallel task time of a task
Definition: BDSC.c:393

References annotations, annotation::data, gen_array_item(), max_start_time_cluster(), NIL, and annotation::task_time.

Referenced by BDSC(), and DSC().

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

◆ update_priority_values()

static void update_priority_values ( statement  ready_st)
static

Definition at line 81 of file BDSC.c.

82 {
83  //update the priorities of ready_st successors
85  vertex s = successor_vertex(su);
86  statement child = vertex_to_statement(s);
88  anc->tlevel = -1;
89  }
91  vertex s = successor_vertex(su);
92  statement child = vertex_to_statement(s);
94  t_level(s, kdg, annotations);
95  anc->prio = anc->tlevel + anc->blevel;
96  }
97  return;
98 }
double t_level(vertex v, graph dg, gen_array_t annotations)
First parameter is the top level (earliest start time) for each node.
Definition: cost_model.c:168

References annotations, annotation::blevel, FOREACH, gen_array_item(), kdg, annotation::prio, statement_ordering, statement_to_vertex(), SUCCESSOR, successor_vertex, t_level(), annotation::tlevel, vertex_successors, and vertex_to_statement().

Referenced by allocate_task_to_cluster(), and move_task_to_cluster().

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

◆ zeroing_multiple_edges()

static bool zeroing_multiple_edges ( statement  ready_st,
int  order,
int  M 
)
static

Definition at line 225 of file BDSC.c.

226 {
227  list vertices = graph_vertices(kdg);
229  double time;
230  int i, j, min_cluster = -1;
231  bool zeroing_p = false;
232  typedef struct {
234  double time;
235  }zeroing;
236  zeroing *zeroing_can;
237  gen_array_t sorted_predecessors = gen_array_make(0);
238  double min_tlevel = an->tlevel;
239  FOREACH(VERTEX, pre, vertices) {
240  statement parent = vertex_to_statement(pre);
242  if(anp->cluster != -1)
243  {
244  FOREACH(SUCCESSOR, su, (vertex_successors(pre))) {
245  vertex s = successor_vertex(su);
246  statement child = vertex_to_statement(s);
247  if(statement_equal_p(child, ready_st)) //pre is predecessor of ready_st
248  {
249  double edge_c = *(double *)(gen_array_item(anp->edge_cost,statement_ordering(ready_st)));
250  cluster *cl = gen_array_item(clusters, anp->cluster);
251  double new_tlevel = cl->time;
252  time = anp->tlevel + anp->task_time + edge_c;
253  new_tlevel = new_tlevel > time ? new_tlevel : time;
254  if(new_tlevel <= min_tlevel + edge_c){
255  int array_size = gen_array_nitems(sorted_predecessors);
256  zeroing *zer_new = (zeroing *)malloc(sizeof(zeroing));
257  zer_new->predecessor = parent;
258  zer_new->time = new_tlevel;
259  i=0;
260  if(array_size > 0){
261  zeroing_can = gen_array_item(sorted_predecessors, i);
262  while(i< array_size)
263  {
264  zeroing_can = gen_array_item(sorted_predecessors, i);
265  if(new_tlevel <= zeroing_can->time)
266  break;
267  i++;
268  }
269  if(new_tlevel <= zeroing_can->time) //shift
270  {
271  zeroing *zer = gen_array_item(sorted_predecessors, i+1);
272  gen_array_addto(sorted_predecessors, i+1, zeroing_can);
273  gen_array_addto(sorted_predecessors, i, zer_new);
274  for(j = i+1; j< array_size+1; j++)
275  {
276  zeroing_can = gen_array_item(sorted_predecessors, j+1);
277  gen_array_addto(sorted_predecessors, j+1, zer);
278  zer = zeroing_can;
279  }
280  }
281  }
282  if(i == array_size)
283  gen_array_addto(sorted_predecessors, i, zer_new);
284  }
285  }
286  }
287  }
288  }
289  i = 0;
290  while(i<(int)gen_array_nitems(sorted_predecessors)){
291  zeroing *zer= gen_array_item(sorted_predecessors, i);
292  statement min_predecessor = copy_statement(zer->predecessor);
293  annotation *anp = gen_array_item(annotations, (int)statement_ordering(min_predecessor));
294  min_cluster = anp->cluster;
295  if(MEMORY_SIZE == -1 || MCW(ready_st,min_cluster,M))
296  {
297  zeroing_p = true;
298  allocate_task_to_cluster(ready_st, min_cluster,order);
299  break;
300  }
301  i++;
302  }
303  i= i+1;
304  double sum = 0;
305  while(i<(int)gen_array_nitems(sorted_predecessors))
306  {
307  zeroing *zer= gen_array_item(sorted_predecessors, i);
308  statement parent = zer->predecessor;
310  double edge_c = *(double *)(gen_array_item(anp->edge_cost,statement_ordering(ready_st)));
311  sum = sum + anp->task_time;
312  if(sum <= edge_c && (int)(gen_length(vertex_successors(statement_to_vertex(parent,kdg))) == 1)
313  && (MEMORY_SIZE == -1 || MCW(parent,min_cluster,M)))
314  {
315  move_task_to_cluster(parent,min_cluster);
316  }
317  else
318  break;
319  i++;
320  }
321  gen_array_free( sorted_predecessors);
322  return zeroing_p;
323 }
static void move_task_to_cluster(statement ready_st, int cl_p)
Definition: BDSC.c:142
statement copy_statement(statement p)
STATEMENT.
Definition: ri.c:2186
size_t gen_array_nitems(const gen_array_t a)
Definition: array.c:131
static int array_size(dim)
ARRAY_SIZE returns the number of elements in the array whose dimension list is DIM.
Definition: genClib.c:155
successor predecessor
Definition: hierarchize.c:82
t_real sum(int n1, int n2, int n3, t_real u[n1][n2][n3])
Definition: stencil.c:57

References allocate_task_to_cluster(), annotations, array_size(), annotation::cluster, clusters, copy_statement(), annotation::edge_cost, FOREACH, gen_array_addto(), gen_array_free(), gen_array_item(), gen_array_make(), gen_array_nitems(), gen_length(), graph_vertices, kdg, malloc(), MCW(), MEMORY_SIZE, move_task_to_cluster(), statement_equal_p(), statement_ordering, statement_to_vertex(), SUCCESSOR, successor_vertex, sum(), annotation::task_time, cluster::time, annotation::tlevel, VERTEX, vertex_successors, and vertex_to_statement().

Referenced by DSC().

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