PIPS
SDG.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 "prettyprint.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 SDG.c:

Go to the source code of this file.

Data Structures

struct  cpv
 

Macros

#define dot_print_label_string(ftg, str)
 print the string str in file descriptor fd, removing all
More...
 

Typedefs

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

Functions

static void get_private_entities_walker (loop l, set s)
 
static set get_private_entities (void *s)
 
static void check_private_variables_call_walker (call c, struct cpv *p)
 
static bool check_private_variables_loop_walker (loop l, struct cpv *p)
 
static list private_variables (statement stat)
 
bool statement_equal_p (statement s1, statement s2)
 
vertex statement_to_vertex (statement s, graph g)
 
static list enclosed_statements_ast (statement stmt, list children_s)
 
static bool same_level_p (statement s1, statement s2, bool found_p)
 
static statement in_same_sequence (statement child, sequence seq)
 
static bool test_dependence_using_regions (statement s1, statement s2)
 for precision in dependences in arrays, we use array regions in this function More...
 
static bool sequence_dg (statement stmt)
 
static bool statement_in_sequence_p (statement s, statement stmt, bool found_p)
 
static graph clean_sdg (statement module_stmt, graph tg)
 Second step to form a clustered DG (SDG), delete dependences between statement s1 and another statement S2 if s1 is not in a sequence and redondont dependences. More...
 
graph partitioning_sdg (statement module_stmt)
 
static string prettyprint_dot_label (statement s, string label1)
 
static void print_sdg_task (FILE *ftg, gen_array_t annotations, statement stmt)
 return a dot graph for SDG, print only nodes that have at least one successor More...
 
void print_SDGs (statement stmt, graph tg, FILE *ftg, gen_array_t annotations)
 
bool sequence_dependence_graph (char *module_name)
 

Variables

static transformer p_transformer
 
static graph sdg
 
int NBCLUSTERS
 parameters of BDSC, to be recovered using pips properties More...
 
int MEMORY_SIZE
 
string INSTRUMENTED_FILE
 
gen_array_t annotations
 Global variables. More...
 
gen_array_t clusters
 
static int count = 0
 

Macro Definition Documentation

◆ dot_print_label_string

#define dot_print_label_string (   ftg,
  str 
)
Value:
fprintf(ftg," [fontsize=24,fontcolor=black, label=\""); \
while ( *str ) { \
char c = *str++; \
if ( c == '"' ) { /**some char must be escaped */ \
(void) putc( '\\', ftg); \
} \
(void) putc( c, ftg); \
}\
fprintf(ftg," \"]; \n");
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...

print the string str in file descriptor fd, removing all

Definition at line 469 of file SDG.c.

Typedef Documentation

◆ arc_label

Instantiation of the dependence graph:

Definition at line 45 of file SDG.c.

◆ vertex_label

Definition at line 46 of file SDG.c.

Function Documentation

◆ check_private_variables_call_walker()

static void check_private_variables_call_walker ( call  c,
struct cpv p 
)
static

Definition at line 88 of file SDG.c.

89 {
91  if(set_belong_p(s,p->e)){
92  p->rm=true;
94  }
95  set_free(s);
96 }
void gen_recurse_stop(void *obj)
Tells the recursion not to go in this object.
Definition: genClib.c:3251
void set_free(set)
Definition: set.c:332
bool set_belong_p(const set, const void *)
Definition: set.c:194
set get_referenced_entities(void *elem)
retrieves the set of entities used in elem beware that this entities may be formal parameters,...
Definition: entity.c:3063
FI: I do not understand why the type is duplicated at the set level.
Definition: set.c:59
entity e
Definition: outlining.c:163
bool rm
Definition: outlining.c:164

References cpv::e, gen_recurse_stop(), get_referenced_entities(), cpv::rm, set_belong_p(), and set_free().

Referenced by private_variables().

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

◆ check_private_variables_loop_walker()

static bool check_private_variables_loop_walker ( loop  l,
struct cpv p 
)
static

Definition at line 98 of file SDG.c.

99 {
100  return !has_entity_with_same_name(p->e,loop_locals(l));
101 }
bool has_entity_with_same_name(entity, list)
inlining.c
Definition: inlining.c:256
#define loop_locals(x)
Definition: ri.h:1650

References cpv::e, has_entity_with_same_name(), and loop_locals.

Referenced by private_variables().

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

◆ clean_sdg()

static graph clean_sdg ( statement  module_stmt,
graph  tg 
)
static

Second step to form a clustered DG (SDG), delete dependences between statement s1 and another statement S2 if s1 is not in a sequence and redondont dependences.

Definition at line 421 of file SDG.c.

422 {
423  list vertices = graph_vertices(tg);
424  statement s;
425  FOREACH(VERTEX, pre, vertices)
426  {
427  s = vertex_to_statement(pre);
428  bool found_p = statement_in_sequence_p(s, module_stmt, false);
429  if(!found_p)
430  {
432  vertex_successors(pre) = NIL;
433  }
434  else{
435  int count;
436  list ls = NIL, lv = NIL;
437  FOREACH(SUCCESSOR, su, (vertex_successors(pre))) {
438  vertex ssu = successor_vertex(su);
439  statement child = vertex_to_statement(ssu);
440  count = gen_occurences(child, ls);
441  if(count == 0 && statement_ordering(s)<statement_ordering(child))
442  {
443  ls = CONS(STATEMENT, child,ls);
444  if(gen_occurences(su, lv) == 0)
445  lv = CONS(SUCCESSOR,su,lv);
446  }
447  }
448  vertex_successors(pre) = lv;
449  }
450  }
451  return tg;
452 }
static bool statement_in_sequence_p(statement s, statement stmt, bool found_p)
Definition: SDG.c:366
static int count
Definition: SDG.c:519
#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
#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
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#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
int gen_occurences(const void *vo, const list l)
count occurences of vo in l
Definition: list.c:746
statement vertex_to_statement(vertex v)
Vertex_to_statement looks for the statement that is pointed to by vertex v.
Definition: util.c:45
#define statement_ordering(x)
Definition: ri.h:2454
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References CONS, count, FOREACH, gen_free_list(), gen_occurences(), graph_vertices, NIL, STATEMENT, statement_in_sequence_p(), statement_ordering, SUCCESSOR, successor_vertex, VERTEX, vertex_successors, and vertex_to_statement().

Referenced by partitioning_sdg().

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

◆ enclosed_statements_ast()

static list enclosed_statements_ast ( statement  stmt,
list  children_s 
)
static

Definition at line 141 of file SDG.c.

142 {
144  switch(instruction_tag(inst))
145  {
146  case is_instruction_block :
147  {
148  MAPL( stmt_ptr,
149  {
150  statement local_stmt = STATEMENT(CAR( stmt_ptr ));
151  children_s = CONS( STATEMENT, local_stmt, children_s);
152  children_s = enclosed_statements_ast(local_stmt,children_s);
153  },
154  instruction_block( inst ) );
155  break;
156  }
157  case is_instruction_test :
158  {
159  test t = instruction_test(inst);
160  children_s = CONS( STATEMENT, test_true(t), children_s);
161  children_s = CONS( STATEMENT, test_false(t), children_s);
162  children_s = enclosed_statements_ast(test_true(t),children_s);
163  children_s = enclosed_statements_ast(test_false(t),children_s);
164  break;
165  }
166  case is_instruction_loop :
167  {
168  loop l = statement_loop(stmt);
169  statement body = loop_body(l);
170  children_s = CONS( STATEMENT, body, children_s);
171  children_s = enclosed_statements_ast(body,children_s);
172  break;
173  }
175  {
177  statement body = forloop_body(l);
178  children_s = CONS( STATEMENT, body, children_s);
179  children_s = enclosed_statements_ast(body,children_s);
180  break;
181  }
183  {
185  statement body = whileloop_body(l);
186  children_s = CONS( STATEMENT, body, children_s);
187  children_s = enclosed_statements_ast(body,children_s);
188  break;
189  }
190  case is_instruction_call:
191  //children_s = CONS( STATEMENT, stmt, children_s);
192  break;
193  default:
194  break;
195  }
196  return children_s;
197 }
static list enclosed_statements_ast(statement stmt, list children_s)
Definition: SDG.c:141
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#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
loop statement_loop(statement)
Get the loop of a statement.
Definition: statement.c:1374
whileloop statement_whileloop(statement)
Get the whileloop of a statement.
Definition: statement.c:1383
forloop statement_forloop(statement)
Get the forloop of a statement.
Definition: statement.c:1426
#define is_instruction_block
soft block->sequence transition
#define instruction_block(i)
#define loop_body(x)
Definition: ri.h:1644
#define test_false(x)
Definition: ri.h:2837
@ is_instruction_whileloop
Definition: ri.h:1472
@ is_instruction_test
Definition: ri.h:1470
@ is_instruction_call
Definition: ri.h:1474
@ is_instruction_forloop
Definition: ri.h:1477
@ is_instruction_loop
Definition: ri.h:1471
#define instruction_tag(x)
Definition: ri.h:1511
#define test_true(x)
Definition: ri.h:2835
#define whileloop_body(x)
Definition: ri.h:3162
#define statement_instruction(x)
Definition: ri.h:2458
#define instruction_test(x)
Definition: ri.h:1517
#define forloop_body(x)
Definition: ri.h:1372
Definition: statement.c:54

References CAR, CONS, forloop_body, instruction_block, instruction_tag, instruction_test, is_instruction_block, is_instruction_call, is_instruction_forloop, is_instruction_loop, is_instruction_test, is_instruction_whileloop, loop_body, MAPL, STATEMENT, statement_forloop(), statement_instruction, statement_loop(), statement_whileloop(), test_false, test_true, and whileloop_body.

Referenced by sequence_dg().

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

◆ get_private_entities()

static set get_private_entities ( void *  s)
static

Definition at line 73 of file SDG.c.

74 {
75  set tmp = set_make(set_pointer);
77  return tmp;
78 }
static void get_private_entities_walker(loop l, set s)
Definition: SDG.c:67
#define gen_context_recurse(start, ctxt, domain_number, flt, rwt)
Definition: genC.h:285
bool gen_true2(__attribute__((unused)) gen_chunk *u1, __attribute__((unused)) void *u2)
Definition: genClib.c:2785
@ set_pointer
Definition: newgen_set.h:44
set set_make(set_type)
Create an empty set of any type but hash_private.
Definition: set.c:102
#define loop_domain
newgen_language_domain_defined
Definition: ri.h:218

References gen_context_recurse, gen_true2(), get_private_entities_walker(), loop_domain, set_make(), and set_pointer.

Referenced by private_variables().

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

◆ get_private_entities_walker()

static void get_private_entities_walker ( loop  l,
set  s 
)
static

Definition at line 67 of file SDG.c.

68 {
70 }
set set_append_list(set, const list)
add list l items to set s, which is returned.
Definition: set.c:460

References loop_locals, and set_append_list().

Referenced by get_private_entities().

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

◆ in_same_sequence()

static statement in_same_sequence ( statement  child,
sequence  seq 
)
static

Definition at line 246 of file SDG.c.

247 {
248  statement enclosing_st = statement_undefined;
249  bool found_p;
250  list stmts = sequence_statements(seq);
251  FOREACH(STATEMENT, st, stmts){
252  found_p = same_level_p(child, st, false);
253  if(found_p){
254  enclosing_st = st;
255  return st;
256  }
257  }
258  return enclosing_st;
259 }
static bool same_level_p(statement s1, statement s2, bool found_p)
Definition: SDG.c:199
#define sequence_statements(x)
Definition: ri.h:2360
#define statement_undefined
Definition: ri.h:2419

References FOREACH, same_level_p(), sequence_statements, STATEMENT, and statement_undefined.

Referenced by sequence_dg().

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

◆ partitioning_sdg()

graph partitioning_sdg ( statement  module_stmt)
Parameters
module_stmtodule_stmt

Definition at line 455 of file SDG.c.

456 {
458  return clean_sdg(module_stmt, sdg);
459 }
static graph clean_sdg(statement module_stmt, graph tg)
Second step to form a clustered DG (SDG), delete dependences between statement s1 and another stateme...
Definition: SDG.c:421
static graph sdg
Definition: SDG.c:54
static bool sequence_dg(statement stmt)
Definition: SDG.c:321
#define gen_recurse(start, domain_number, flt, rwt)
Definition: genC.h:283
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
Definition: genClib.c:2752
#define statement_domain
newgen_sizeofexpression_domain_defined
Definition: ri.h:362

References clean_sdg(), gen_null(), gen_recurse, sdg, sequence_dg(), and statement_domain.

Referenced by sequence_dependence_graph().

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

◆ prettyprint_dot_label()

static string prettyprint_dot_label ( statement  s,
string  label1 
)
static

Definition at line 481 of file SDG.c.

481  {
482  string label2="";
483  // saving comments
484  string i_comments = statement_comments(s);
485  // remove them
487  // Get the text without comments
488  text txt = Text_Statement(entity_undefined, 0, s);
489  // Restoring comments
490  statement_comments(s) = i_comments;
491  label2 = strdup (concatenate (label1, text_to_string(txt),"\\n", NULL));
492  free_text(txt);
493  return label2;
494  }
void free_text(text p)
Definition: text.c:74
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
#define string_undefined
Definition: newgen_types.h:40
text Text_Statement(entity, int, statement)
#define entity_undefined
Definition: ri.h:2761
#define statement_comments(x)
Definition: ri.h:2456
char * strdup()
string text_to_string(text t)
SG: moved here from ricedg.
Definition: print.c:239

References concatenate(), entity_undefined, free_text(), statement_comments, strdup(), string_undefined, Text_Statement(), and text_to_string().

Referenced by print_sdg_task().

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

◆ print_sdg_task()

static void print_sdg_task ( FILE *  ftg,
gen_array_t  annotations,
statement  stmt 
)
static

return a dot graph for SDG, print only nodes that have at least one successor

Definition at line 500 of file SDG.c.

500  {
501  string ver = "";
502  ver = prettyprint_dot_label(stmt,ver);
503  fprintf( ftg,"%d",(int)statement_ordering(stmt) );
504  if(strlen(ver)>1000)
505  ver = "too large statement label with ordering \\n";
508  if(an->cluster != -1)
509  {
510  ver = strdup (concatenate (ver, "cluster = ", NULL));ver = strdup (concatenate (ver, i2a(an->cluster),"\\n", NULL));
511  ver = strdup (concatenate (ver, "order = ", NULL)); ver = strdup (concatenate (ver, i2a(an->order_sched),"\\n", NULL));
512  ver = strdup (concatenate (ver, "time = ", NULL)); ver = strdup (concatenate (ver, i2a(an->task_time),"\\n", NULL));
513  }
514  }
515  dot_print_label_string( ftg, ver);
516  return;
517 }
#define dot_print_label_string(ftg, str)
print the string str in file descriptor fd, removing all
Definition: SDG.c:469
gen_array_t annotations
Global variables.
Definition: SDG.c:62
static string prettyprint_dot_label(statement s, string label1)
Definition: SDG.c:481
size_t gen_array_nitems(const gen_array_t a)
Definition: array.c:131
void * gen_array_item(const gen_array_t a, size_t i)
Definition: array.c:143
char * i2a(int)
I2A (Integer TO Ascii) yields a string for a given Integer.
Definition: string.c:121

References annotations, annotation::cluster, concatenate(), dot_print_label_string, fprintf(), gen_array_item(), gen_array_nitems(), i2a(), annotation::order_sched, prettyprint_dot_label(), statement_ordering, strdup(), and annotation::task_time.

Referenced by print_SDGs().

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

◆ print_SDGs()

void print_SDGs ( statement  stmt,
graph  tg,
FILE *  ftg,
gen_array_t  annotations 
)
Parameters
stmttmt
tgg
ftgtg
annotationsnnotations

Definition at line 520 of file SDG.c.

520  {
522  switch(instruction_tag(inst))
523  {
524  case is_instruction_block :
525  {
527  list stmts = sequence_statements(seq);
528  fprintf( ftg, "subgraph cluster%d { color = blue; \n ",count );
529  FOREACH(STATEMENT, s, stmts) {
530  list vertices = graph_vertices(tg);
531  annotation *anp = NULL;
532  FOREACH(VERTEX, pre, vertices) {
533  statement parent = vertex_to_statement(pre);
534  if(statement_equal_p(parent, s)){
536  anp = gen_array_item(annotations, (int)statement_ordering(parent));
537  print_sdg_task(ftg, annotations, parent);
538  FOREACH(SUCCESSOR, su, (vertex_successors(pre))) {
539  vertex s = successor_vertex(su);
540  statement child = vertex_to_statement(s);
541  print_sdg_task(ftg, annotations, child);
544  if(an->cluster!=-1)
545  {//FFT
546  double edge_c = (intptr_t)(gen_array_item(anp->edge_cost,statement_ordering(child)));
547  fprintf( ftg,"%d -> %d [style=filled,color=blue,fontsize=16,label=\"%ld\",color=black];\n", (int)statement_ordering(parent),(int)statement_ordering(child),(long)(edge_c));
548  }
549  }
550  else
551  fprintf( ftg,"%d -> %d [style=filled,color=blue,fontsize=16,color=black];\n", (int)statement_ordering(parent),(int)statement_ordering(child));
552  }
553  }
554  }
555  }
556  fprintf( ftg, "} \n " );
557  count ++;
558  stmts = sequence_statements(seq);
559  FOREACH(STATEMENT, s, stmts)
560  print_SDGs(s,tg, ftg, annotations);
561  break;
562  }
563  case is_instruction_test:
564  {
565  test t = instruction_test(inst);
566  print_SDGs(test_true(t),tg, ftg, annotations);
567  print_SDGs(test_false(t),tg, ftg, annotations);
568  break;
569  }
570  case is_instruction_loop :
571  {
572  loop l = statement_loop(stmt);
573  print_SDGs(loop_body(l),tg, ftg, annotations);
574  break;
575  }
577  {
579  print_SDGs(forloop_body(l),tg, ftg, annotations);
580  break;
581  }
583  {
586  break;
587  }
588  default:
589  break;
590  }
591  return;
592 }
bool statement_equal_p(statement s1, statement s2)
Definition: SDG.c:123
void print_SDGs(statement stmt, graph tg, FILE *ftg, gen_array_t annotations)
Definition: SDG.c:520
static void print_sdg_task(FILE *ftg, gen_array_t annotations, statement stmt)
return a dot graph for SDG, print only nodes that have at least one successor
Definition: SDG.c:500
sequence statement_sequence(statement)
Get the sequence of a statement sequence.
Definition: statement.c:1328
#define intptr_t
Definition: stdint.in.h:294

References annotations, annotation::cluster, count, annotation::edge_cost, FOREACH, forloop_body, fprintf(), gen_array_item(), gen_array_nitems(), graph_vertices, instruction_tag, instruction_test, intptr_t, is_instruction_block, is_instruction_forloop, is_instruction_loop, is_instruction_test, is_instruction_whileloop, loop_body, print_sdg_task(), sequence_statements, STATEMENT, statement_equal_p(), statement_forloop(), statement_instruction, statement_loop(), statement_ordering, statement_sequence(), statement_whileloop(), SUCCESSOR, successor_vertex, test_false, test_true, VERTEX, vertex_successors, vertex_to_statement(), and whileloop_body.

Referenced by hbdsc_parallelization(), and sequence_dependence_graph().

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

◆ private_variables()

static list private_variables ( statement  stat)
static

Definition at line 104 of file SDG.c.

105 {
106  set s = get_private_entities(stat);
107  list l =NIL;
108  SET_FOREACH(entity,e,s) {
109  struct cpv p = { .e=e, .rm=false };
113  0);
114  if(!p.rm)
115  l=CONS(ENTITY,e,l);
116  }
117  set_free(s);
118 
119  return l;
120 }
static void check_private_variables_call_walker(call c, struct cpv *p)
Definition: SDG.c:88
static bool check_private_variables_loop_walker(loop l, struct cpv *p)
Definition: SDG.c:98
static set get_private_entities(void *s)
Definition: SDG.c:73
void gen_context_multi_recurse(void *o, void *context,...)
Multi-recursion with context function visitor.
Definition: genClib.c:3373
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
Definition: genClib.c:2780
#define SET_FOREACH(type_name, the_item, the_set)
enumerate set elements in their internal order.
Definition: newgen_set.h:78
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
#define call_domain
newgen_callees_domain_defined
Definition: ri.h:58
Definition: outlining.c:162

References call_domain, check_private_variables_call_walker(), check_private_variables_loop_walker(), CONS, cpv::e, ENTITY, gen_context_multi_recurse(), gen_null(), gen_true(), get_private_entities(), loop_domain, NIL, cpv::rm, SET_FOREACH, and set_free().

Referenced by test_dependence_using_regions().

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

◆ same_level_p()

static bool same_level_p ( statement  s1,
statement  s2,
bool  found_p 
)
static

Definition at line 199 of file SDG.c.

200 {
201 
202  if(statement_equal_p(s1, s2))
203  return true;
204  else {
206  switch(instruction_tag(inst)){
207  case is_instruction_block :{
208  MAPL( stmt_ptr,
209  {
210  statement local_stmt = STATEMENT(CAR( stmt_ptr ));
211  found_p = found_p || same_level_p(s1, local_stmt, found_p);
212  },
213  instruction_block(inst));
214  break;
215  }
216  case is_instruction_test :{
217  test t = instruction_test(inst);
218  found_p = found_p || same_level_p(s1, test_true(t), found_p);
219  return found_p || same_level_p(s1, test_false(t), found_p);
220  break;
221  }
222  case is_instruction_loop :{
223  loop l = statement_loop(s2);
224  statement body = loop_body(l);
225  return found_p || same_level_p(s1, body, found_p);
226  break;
227  }
228  case is_instruction_forloop :{
229  forloop l = statement_forloop(s2);
230  statement body = forloop_body(l);
231  return found_p || same_level_p(s1, body, found_p);
232  break;
233  }
236  statement body = whileloop_body(l);
237  return found_p || same_level_p(s1, body, found_p);
238  break;
239  }
240  default:
241  break;
242  }
243  }
244  return found_p;
245 }
s1
Definition: set.c:247

References CAR, forloop_body, instruction_block, instruction_tag, instruction_test, is_instruction_block, is_instruction_forloop, is_instruction_loop, is_instruction_test, is_instruction_whileloop, loop_body, MAPL, s1, STATEMENT, statement_equal_p(), statement_forloop(), statement_instruction, statement_loop(), statement_whileloop(), test_false, test_true, and whileloop_body.

Referenced by in_same_sequence().

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

◆ sequence_dependence_graph()

bool sequence_dependence_graph ( char *  module_name)

The proper effect to detect the I/O operations:

dg contains the original dependences before clustering and scheduling, it is saved to not make a side effect on the original dg when constructing the SDG

Parameters
module_nameodule_name

Definition at line 593 of file SDG.c.

594 {
595  //entity module;
596  statement module_stat;
597  string tg_name = NULL;
598  FILE *ftg;
599  //module = local_name_to_top_level_entity(module_name);
600  module_stat = (statement)db_get_memory_resource(DBR_CODE, module_name, true);
601  set_ordering_to_statement(module_stat);
603  set_current_module_statement(module_stat);
606  db_get_memory_resource(DBR_TRANSFORMERS, module_name, true));
607  /* The proper effect to detect the I/O operations: */
612  db_get_memory_resource(DBR_REGIONS, module_name, true));
617 
618  ddg = (graph) db_get_memory_resource (DBR_DG, module_name, true );
619  /*ddg contains the original dependences before clustering and scheduling, it
620  is saved to not make a side effect on the original dg when
621  constructing the SDG*/
622  sdg = copy_graph(ddg);
623  sdg = partitioning_sdg(module_stat);
625  "/",module_name,"/",module_name, "_sdg.dot", NULL));
626  ftg = safe_fopen(tg_name, "w");
627  fprintf( ftg, "digraph {\n compound=true;ratio=fill; node[fontsize=24,fontname=\"Courier\",labelloc=\"t\"];nodesep=.05;\n" );
628  print_SDGs(module_stat, sdg, ftg, gen_array_make(0));
629  fprintf( ftg, "\n}\n" );
630  safe_fclose(ftg, tg_name);
631  free(tg_name);
632 
634  DB_PUT_MEMORY_RESOURCE(DBR_SDG, module_name, (char*) sdg);
635 
647  return true;
648 }
graph ddg
Definition: HBDSC.c:52
graph copy_graph(graph p)
GRAPH.
Definition: graph.c:20
graph partitioning_sdg(statement module_stmt)
Definition: SDG.c:455
gen_array_t gen_array_make(size_t size)
declarations...
Definition: array.c:40
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
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
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
void free(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
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
string db_get_current_workspace_directory(void)
Definition: workspace.c:96
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479
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 concatenate(), copy_graph(), db_get_current_workspace_directory(), db_get_memory_resource(), DB_PUT_MEMORY_RESOURCE, ddg, fprintf(), free(), free_value_mappings(), gen_array_make(), generic_effects_reset_all_methods(), get_current_module_entity(), init_convex_rw_prettyprint(), module_name(), module_name_to_entity(), module_to_value_mappings(), partitioning_sdg(), print_SDGs(), 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(), sdg, 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(), and strdup().

+ Here is the call graph for this function:

◆ sequence_dg()

static bool sequence_dg ( statement  stmt)
static

pdate the sdg for st(parent) using enclosing_stmt instead of the enclosed one child

Definition at line 321 of file SDG.c.

322 {
325  list stmts = sequence_statements(seq);
326  path pbegin;
327  path pend;
328  FOREACH(STATEMENT, st_g, stmts) {
329  {
330  list children_s = CONS(STATEMENT, st_g, NIL);
331  list ls = NIL;
332  children_s = enclosed_statements_ast(st_g,children_s);
333  vertex pre_g = statement_to_vertex(st_g, sdg);
334  FOREACH(STATEMENT, st, children_s){
335  vertex pre = statement_to_vertex(st, sdg);
336  FOREACH(SUCCESSOR, su, (vertex_successors(pre))) {
337  vertex s = successor_vertex(su);
338  statement child = vertex_to_statement(s);
339  statement enclosing_stmt = statement_undefined;
340  enclosing_stmt = in_same_sequence(child, seq);
341  if(statement_undefined_p(enclosing_stmt))
342  enclosing_stmt = in_same_sequence(st, seq);
343 
345  path_initialize(stmt, st,child, &pbegin, &pend);
346  //p_transformer = compute_path_transformer(stmt, pbegin, pend);
347  /*update the sdg for st(parent) using enclosing_stmt instead of
348  *the enclosed one child*/
349  if(!statement_equal_p(st_g, enclosing_stmt) && test_dependence_using_regions(st_g,enclosing_stmt)){
350  if(statement_ordering(st_g)<statement_ordering(enclosing_stmt)){
351  vertex new_v = statement_to_vertex(enclosing_stmt, sdg);
352  successor_vertex(su) = new_v;
353  if(gen_occurences(su, ls) == 0)
354  ls = CONS(SUCCESSOR, su, ls);
355  }
356  }
357  }
358  }
359  vertex_successors(pre_g) = ls;
360  }
361  }
362  }
363  return true;
364 }
static statement in_same_sequence(statement child, sequence seq)
Definition: SDG.c:246
static transformer p_transformer
Definition: SDG.c:53
vertex statement_to_vertex(statement s, graph g)
Definition: SDG.c:131
static bool test_dependence_using_regions(statement s1, statement s2)
for precision in dependences in arrays, we use array regions in this function
Definition: SDG.c:263
transformer transformer_identity()
Allocate an identity transformer.
Definition: basic.c:110
bool statement_sequence_p(statement)
Statement classes induced from instruction type.
Definition: statement.c:335
#define statement_undefined_p(x)
Definition: ri.h:2420
void path_initialize(statement, statement, statement, path *, path *)
path_transformer.c

References CONS, enclosed_statements_ast(), FOREACH, gen_occurences(), in_same_sequence(), NIL, p_transformer, path_initialize(), sdg, sequence_statements, STATEMENT, statement_equal_p(), statement_ordering, statement_sequence(), statement_sequence_p(), statement_to_vertex(), statement_undefined, statement_undefined_p, SUCCESSOR, successor_vertex, test_dependence_using_regions(), transformer_identity(), vertex_successors, and vertex_to_statement().

Referenced by partitioning_sdg().

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

◆ statement_equal_p()

bool statement_equal_p ( statement  s1,
statement  s2 
)
Parameters
s11
s22

Definition at line 123 of file SDG.c.

124 {
126 }
#define statement_number(x)
Definition: ri.h:2452

References s1, statement_number, and statement_ordering.

Referenced by print_SDGs(), same_level_p(), sequence_dg(), statement_in_sequence_p(), and statement_to_vertex().

+ Here is the caller graph for this function:

◆ statement_in_sequence_p()

static bool statement_in_sequence_p ( statement  s,
statement  stmt,
bool  found_p 
)
static

Definition at line 366 of file SDG.c.

367 {
369  switch(instruction_tag(inst))
370  {
371  case is_instruction_block :
372  {
373  MAPL( stmt_ptr,
374  {
375  statement local_stmt = STATEMENT(CAR( stmt_ptr ));
376  if(statement_equal_p(s, local_stmt))
377  return true;
378  else
379  found_p = found_p || statement_in_sequence_p(s, local_stmt, found_p);
380  },
381  instruction_block( inst ) );
382  break;
383  }
384  case is_instruction_test :
385  {
386  test t = instruction_test(inst);
387  found_p = found_p || statement_in_sequence_p(s, test_true(t), found_p);
388  return found_p || statement_in_sequence_p(s, test_false(t), found_p);
389  break;
390  }
391  case is_instruction_loop :
392  {
393  loop l = statement_loop(stmt);
394  statement body = loop_body(l);
395  return found_p || statement_in_sequence_p(s, body, found_p);
396  break;
397  }
399  {
401  statement body = forloop_body(l);
402  return found_p || statement_in_sequence_p(s, body, found_p);
403  break;
404  }
406  {
408  statement body = whileloop_body(l);
409  return found_p || statement_in_sequence_p(s, body, found_p);
410  break;
411  }
412  default:
413  break;
414  }
415  return found_p;
416 }

References CAR, forloop_body, instruction_block, instruction_tag, instruction_test, is_instruction_block, is_instruction_forloop, is_instruction_loop, is_instruction_test, is_instruction_whileloop, loop_body, MAPL, STATEMENT, statement_equal_p(), statement_forloop(), statement_instruction, statement_loop(), statement_whileloop(), test_false, test_true, and whileloop_body.

Referenced by clean_sdg().

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

◆ statement_to_vertex()

vertex statement_to_vertex ( statement  s,
graph  g 
)

Definition at line 131 of file SDG.c.

132 {
133  MAP(VERTEX, v, {
135  if (statement_equal_p(s, sv))
136  return v;
137  }, graph_vertices(g));
138  return vertex_undefined;
139 }
#define vertex_undefined
Definition: graph.h:128
#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

References graph_vertices, MAP, statement_equal_p(), VERTEX, vertex_to_statement(), and vertex_undefined.

Referenced by sequence_dg().

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

◆ test_dependence_using_regions()

static bool test_dependence_using_regions ( statement  s1,
statement  s2 
)
static

for precision in dependences in arrays, we use array regions in this function

Definition at line 263 of file SDG.c.

264 {
265  bool dependence_b = false;
267  list private_ents1 = NIL, private_ents2 = NIL;
268  if(statement_loop_p(s1))
269  private_ents1 = loop_locals(statement_loop(s1));
270  private_ents1= gen_nconc(private_ents1,private_variables(s1));
271  if(statement_loop_p(s2))
272  private_ents2 = loop_locals(statement_loop(s2));
273  private_ents2= gen_nconc(private_ents2, private_variables(s2));
274  FOREACH(ENTITY,e,private_ents1){
275  FOREACH(REGION,reg,l_write_1){
276  if (same_entity_p(region_entity(reg),e))
277  gen_remove(&l_write_1, reg);
278  }
279  }
281  FOREACH(ENTITY,e,private_ents2){
282  FOREACH(REGION,reg,l_write_2){
283  if (same_entity_p(region_entity(reg),e))
284  gen_remove(&l_write_2, reg);
285  }
286  }
287  l_write_2 = convex_regions_transformer_compose(l_write_2, p_transformer);
289  FOREACH(ENTITY,e,private_ents2){
290  FOREACH(REGION,reg,l_read_2) {
291  if (same_entity_p(region_entity(reg),e))
292  gen_remove(&l_read_2, reg);
293  }
294  }
297  FOREACH(ENTITY,e,private_ents1){
298  FOREACH(REGION,reg,l_read_1){
299  if (same_entity_p(region_entity(reg),e))
300  gen_remove(&l_read_1, reg);
301  }
302  }
303  list dependence_rw = RegionsIntersection(regions_dup(l_read_1), regions_dup(l_write_2), r_w_combinable_p);
304  list dependence_wr = RegionsIntersection(regions_dup(l_write_1), regions_dup(l_read_2), w_r_combinable_p);
305  list dependence_ww = RegionsIntersection(regions_dup(l_write_1), regions_dup(l_write_2), w_w_combinable_p);
306  if(gen_length(dependence_rw)==0)
307  {
308  if(gen_length(dependence_wr)==0)
309  {
310  if(gen_length(dependence_ww)>0)
311  dependence_b=true;
312  }
313  else
314  dependence_b=true;
315  }
316  else
317  dependence_b = true;
318  return dependence_b;
319 }
static list private_variables(statement stat)
Definition: SDG.c:104
#define region_entity(reg)
#define REGION
list RegionsIntersection(list l1, list l2, bool(*intersection_combinable_p)(effect, effect))
list RegionsIntersection(list l1,l2, bool (*intersection_combinable_p)(effect, effect)) input : outpu...
list regions_write_regions(list)
list regions_read_regions(list)
list regions_dup(list)
list convex_regions_transformer_compose(list, transformer)
compose.c
bool w_r_combinable_p(effect, effect)
bool w_w_combinable_p(effect, effect)
bool r_w_combinable_p(effect, effect)
list load_statement_local_regions(statement)
void gen_remove(list *cpp, const void *o)
remove all occurences of item o from list *cpp, which is thus modified.
Definition: list.c:685
size_t gen_length(const list l)
Definition: list.c:150
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
bool statement_loop_p(statement)
Definition: statement.c:349
bool same_entity_p(entity e1, entity e2)
predicates on entities
Definition: entity.c:1321

References convex_regions_transformer_compose(), cpv::e, ENTITY, FOREACH, gen_length(), gen_nconc(), gen_remove(), load_statement_local_regions(), loop_locals, NIL, p_transformer, private_variables(), r_w_combinable_p(), REGION, region_entity, regions_dup(), regions_read_regions(), regions_write_regions(), RegionsIntersection(), s1, same_entity_p(), statement_loop(), statement_loop_p(), w_r_combinable_p(), and w_w_combinable_p().

Referenced by sequence_dg().

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

Variable Documentation

◆ annotations

◆ clusters

◆ count

int count = 0
static

Definition at line 519 of file SDG.c.

Referenced by adg_enrichir(), adg_number_of_same_loops(), adg_vertex_to_ordering(), build_convex_constraints_from_vertices(), build_second_comb(), character_occurences_in_string(), clean_sdg(), clear_C_comment(), concatenate(), count_dataflows_on_ref(), create_farkas_poly(), create_var_name(), cycle_to_flow_sensitive_preconditions(), dag_computation_count(), dag_or_cycle_to_flow_sensitive_postconditions_or_transformers(), dag_to_flow_sensitive_preconditions(), dagvtx_dot(), db_unput_resources(), delete_named_resources(), do_loop_unroll_with_epilogue(), entity_all_module_xxx_locations_typed(), entity_all_xxx_locations_typed(), find_kth_points_to_node_in_points_to_path(), FixCInternalLabels(), fprint_functional(), fprint_pla_pp_dims(), general_build_signature(), generate_mmcd_stat_from_ref(), generate_mmcd_stats_from_ref(), get_optimal_opcode(), get_time_ent(), include_trans_in_poly(), lf_count(), make_lInitStats(), make_proto(), mapping_to_domain_list(), mapping_to_value_number(), my_clean_ps(), new_array_elements_backward_substitution_in_transformer(), new_array_elements_forward_substitution_in_transformer(), points_to_subscripts_to_number_of_unbounded_dimensions(), print_make_cache(), print_SDGs(), PRINTF_FETCHARGS(), put_source_ind(), raw_flint_message(), ref_count_rwt(), reference_ith_index(), replace_ref_by_ent(), reset_C_comment(), safe_fread(), safe_fwrite(), sc_fprint(), search_scc_bdt(), simplify_minmax_contrainte(), SimplifyGraph(), stco_renumber_code(), SupressDependances(), switch_cast_to_copy(), tpips_help(), transformer_with_temporary_values_p(), typing_assign_substring(), typing_buffer_inout(), typing_implied_do(), typing_substring(), VASNPRINTF(), and words_any_reference().

◆ INSTRUMENTED_FILE

string INSTRUMENTED_FILE

Definition at line 59 of file SDG.c.

Referenced by dsc_code_parallelization(), and hbdsc_parallelization().

◆ MEMORY_SIZE

◆ NBCLUSTERS

◆ p_transformer

transformer p_transformer
static

Definition at line 53 of file SDG.c.

Referenced by sequence_dg(), and test_dependence_using_regions().

◆ sdg

graph sdg
static

Definition at line 54 of file SDG.c.

Referenced by partitioning_sdg(), sequence_dependence_graph(), and sequence_dg().