PIPS
bdt_read_paf.c File Reference
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include "boolean.h"
#include "arithmetique.h"
#include "vecteur.h"
#include "contrainte.h"
#include "ray_dte.h"
#include "sommet.h"
#include "sg.h"
#include "sc.h"
#include "polyedre.h"
#include "matrice.h"
#include "matrix.h"
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "ri-util.h"
#include "constants.h"
#include "misc.h"
#include "paf_ri.h"
#include "graph.h"
#include "paf-util.h"
+ Include dependency graph for bdt_read_paf.c:

Go to the source code of this file.

Macros

#define POSITIVE   1
 
#define NEGATIVE   0
 
#define INS_NAME_LENGTH   4
 
#define DOT   "."
 
#define BDT_STRING   "bdt"
 

Typedefs

typedef dfg_arc_label arc_label
 Name : bdt_read_paf.c Package : paf-util Author : Alexis Platonoff Date : april 1993 Historic : More...
 
typedef dfg_vertex_label vertex_label
 

Functions

bdt bdt_read_paf (char *s)
 =========================================================================== More...
 
bool same_predicate_p (predicate p1, predicate p2)
 =========================================================================== More...
 
void reorganize_bdt (bdt base)
 =========================================================================== More...
 
void bdt_init_new_base ()
 =========================================================================== More...
 
void bdt_init_new_ins (char *s_ins)
 =========================================================================== More...
 
void bdt_new_shedule (string s_func __attribute__((unused)))
 =========================================================================== More...
 
void bdt_save_pred (int option)
 =========================================================================== More...
 
void bdt_elim_last_pred ()
 =========================================================================== More...
 
void bdt_save_int (int i)
 =========================================================================== More...
 
void bdt_save_id (string s)
 =========================================================================== More...
 
void bdt_init_op_exp (string op_name)
 =========================================================================== More...
 
void bdt_save_exp ()
 =========================================================================== More...
 

Variables

static int crt_ins
 Static global variables. More...
 
static list pred_l
 Current stmt (an integer) More...
 
static list lin_exp_l
 Current list of predicates. More...
 
static expression crt_exp
 Current list of linear expressions. More...
 
bdt base
 Current expression. More...
 

Macro Definition Documentation

◆ BDT_STRING

#define BDT_STRING   "bdt"

Definition at line 85 of file bdt_read_paf.c.

◆ DOT

#define DOT   "."

Definition at line 84 of file bdt_read_paf.c.

◆ INS_NAME_LENGTH

#define INS_NAME_LENGTH   4

Definition at line 83 of file bdt_read_paf.c.

◆ NEGATIVE

#define NEGATIVE   0

Definition at line 82 of file bdt_read_paf.c.

◆ POSITIVE

#define POSITIVE   1

Definition at line 81 of file bdt_read_paf.c.

Typedef Documentation

◆ arc_label

Name : bdt_read_paf.c Package : paf-util Author : Alexis Platonoff Date : april 1993 Historic :

Documents: Comments : These functions are used to store a timing function (BDT) in a Newgen structure from the reading of a file generate by the PAF parallelizer: ".bdt" file, which contains the BDT functions.

Each BDT function is associated with an instruction and a predicate. The Newgen structure is called "bdt" which is a list of BDT function of type "schedule". These two Newgen structures are defined in the file paf_ri.f.tex (see comments on them in this file). We also use the library of PIPS and its RI Newgen structure.

The ".bdt" file is read with Yacc and Lex programs (parse.y and scan.l). The Newgen structure "bdt" is update during the parsing of the file.

Definition at line 76 of file bdt_read_paf.c.

◆ vertex_label

Definition at line 77 of file bdt_read_paf.c.

Function Documentation

◆ bdt_elim_last_pred()

void bdt_elim_last_pred ( void  )

===========================================================================

void bdt_elim_last_pred(): When POSITIVE and NEGATIVE cases of one predicate have been completed, we eliminate the corresponding expression which is the first one of the list "pred_l".

Definition at line 312 of file bdt_read_paf.c.

313 {
314  extern list pred_l;
315 
316  pred_l = CDR(pred_l);
317 }
static list pred_l
Current stmt (an integer)
Definition: bdt_read_paf.c:90
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
The structure used to build lists in NewGen.
Definition: newgen_list.h:41

References CDR, and pred_l.

◆ bdt_init_new_base()

void bdt_init_new_base ( void  )

===========================================================================

void bdt_init_new_base() : initializes the computation of the BDT, i.e. the creation of the BDT in the "base" variable.

Definition at line 207 of file bdt_read_paf.c.

208 {
209  extern bdt base;
210 
211  base = make_bdt(NIL);
212 }
bdt make_bdt(list a)
Definition: paf_ri.c:54
bdt base
Current expression.
Definition: bdt_read_paf.c:100
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47

References base, make_bdt(), and NIL.

+ Here is the call graph for this function:

◆ bdt_init_new_ins()

void bdt_init_new_ins ( char *  s_ins)

===========================================================================

void bdt_init_new_ins(char *s_ins): initializes the computation of the current statement for which we are now parsing its BDT. This statement is represented by its ordering contained in its name "s_ins". Also, we initialize "lin_exp_l" used for the parsing of the lisp expressions and "pred_l" used for the parsing of the predicates.

In PAF, a statement name is a string "ins_#", where "#" is the number associated with the statement. We get this number.

Parameters
s_ins_ins

Definition at line 221 of file bdt_read_paf.c.

223 {
224  extern int crt_ins;
225  extern list pred_l, lin_exp_l;
226 
227  /* In PAF, a statement name is a string "ins_#", where "#" is the number
228  * associated with the statement. We get this number.
229  */
230  crt_ins = atoi(strdup(s_ins + INS_NAME_LENGTH));
231 
232  pred_l = NIL;
233  lin_exp_l = NIL;
234 }
static int crt_ins
Static global variables.
Definition: bdt_read_paf.c:89
#define INS_NAME_LENGTH
Definition: bdt_read_paf.c:83
static list lin_exp_l
Current list of predicates.
Definition: bdt_read_paf.c:91
char * strdup()

References crt_ins, INS_NAME_LENGTH, lin_exp_l, NIL, pred_l, and strdup().

+ Here is the call graph for this function:

◆ bdt_init_op_exp()

void bdt_init_op_exp ( string  op_name)

===========================================================================

void bdt_init_op_exp(string op_name): initializes a new lisp expression with the operation "op_name". This expression is put at the beginning of "lin_exp_l", it is the expression the parser is currently reading.

If "op_name" is the string "0" then the operator used is "crt_op_name", else the operator name is contained in "op_name".

Parameters
op_namep_name

Definition at line 379 of file bdt_read_paf.c.

381 {
382  extern list lin_exp_l;
383 
385 }
lisp_expression make_lisp_expression(string a1, list a2)
Definition: paf_ri.c:348
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
#define LISP_EXPRESSION(x)
LISP_EXPRESSION.
Definition: paf_ri.h:457

References CONS, lin_exp_l, LISP_EXPRESSION, make_lisp_expression(), and NIL.

+ Here is the call graph for this function:

◆ bdt_new_shedule()

void bdt_new_shedule ( string s_func   __attribute__(unused))

===========================================================================

void bdt_new_shedule(char *s_func): the parser has found all the predicates of a schedule. We create this new schedule and put it in "base". This predicate is formed with the list of expressions of "pred_l". The function expressions_to_predicate() translates this list of expressions into a predicate. The schedule statement number is the current one (crt_ins"). The schedule has one dimension, the corresponding expression is found in "crt_exp".

Definition at line 245 of file bdt_read_paf.c.

246 {
247  extern int crt_ins;
248  extern expression crt_exp;
249  extern list pred_l, lin_exp_l;
250 
256 
257  lin_exp_l = NIL;
259 }
schedule make_schedule(intptr_t a1, predicate a2, list a3)
Definition: paf_ri.c:613
static expression crt_exp
Current list of linear expressions.
Definition: bdt_read_paf.c:92
predicate expressions_to_predicate(list)
===========================================================================
Definition: utils.c:826
#define SCHEDULE(x)
SCHEDULE.
Definition: paf_ri.h:682
#define bdt_schedules(x)
Definition: paf_ri.h:226
#define EXPRESSION(x)
EXPRESSION.
Definition: ri.h:1217
#define expression_undefined
Definition: ri.h:1223

References base, bdt_schedules, CONS, crt_exp, crt_ins, EXPRESSION, expression_undefined, expressions_to_predicate(), lin_exp_l, make_schedule(), NIL, pred_l, and SCHEDULE.

+ Here is the call graph for this function:

◆ bdt_read_paf()

bdt bdt_read_paf ( char *  s)

===========================================================================

bdt bdt_read_paf(char *s) : computes the BDT of the PAF program name given in argument and returns it.

bdtyyparse() do the parsing over the ".bdt" file and put the timing function into the global variable "base" which is returned.

Definition at line 110 of file bdt_read_paf.c.

112 {
113  extern bdt base;
114 
115  FILE *bdt_file;
116  char *bdt_file_name;
117 
118  bdt_file_name = strdup(concatenate(s, DOT, BDT_STRING, (char *) NULL));
119 
120  if( (bdt_file = fopen(bdt_file_name, "r")) == NULL)
121  {
122  fprintf(stderr, "Cannot open file %s\n", bdt_file_name);
123  exit(1);
124  }
125 
126 #if defined(HAS_BDTYY)
127 
128  bdtyyin = bdt_file;
129  (void) bdtyyparse();
130 
131 #else
132 
133  pips_internal_error("not bdtyy{in,parse} compiled in (HAS_BDTYY undef)");
134 
135 #endif
136 
137  fclose(bdt_file);
138 
140 
141  return(base);
142 }
#define BDT_STRING
Definition: bdt_read_paf.c:85
void reorganize_bdt(bdt base)
===========================================================================
Definition: bdt_read_paf.c:171
#define DOT
Definition: bdt_read_paf.c:84
#define pips_internal_error
Definition: misc-local.h:149
#define exit(code)
Definition: misc-local.h:54
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...

References base, BDT_STRING, concatenate(), DOT, exit, fprintf(), pips_internal_error, reorganize_bdt(), and strdup().

+ Here is the call graph for this function:

◆ bdt_save_exp()

void bdt_save_exp ( void  )

===========================================================================

void bdt_save_exp(): the parser has completed the reading of one lisp expression, this is the first lisp expression of "lin_exp_l". We extract it from this list and translate it into a Pips expression. If there is no other lisp expression in "lin_exp_l", then this expression becomes the current expression, else it becomes an argument of the next lisp expression which is now the first object of "lin_exp_l".

Definition at line 395 of file bdt_read_paf.c.

396 {
397  extern expression crt_exp;
398 
399  expression aux_exp;
400  lisp_expression aux_le;
401 
402  aux_le = LISP_EXPRESSION(CAR(lin_exp_l));
403  aux_exp = lisp_exp_to_ri_exp(aux_le);
404 
406 
407  if(lin_exp_l == NIL)
408  crt_exp = aux_exp;
409  else
410  {
413  CONS(EXPRESSION, aux_exp, NIL));
414  }
415 }
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
expression lisp_exp_to_ri_exp(lisp_expression)
===========================================================================
Definition: utils.c:755
#define lisp_expression_args(x)
Definition: paf_ri.h:489

References CAR, CDR, CONS, crt_exp, EXPRESSION, gen_nconc(), lin_exp_l, lisp_exp_to_ri_exp(), LISP_EXPRESSION, lisp_expression_args, and NIL.

+ Here is the call graph for this function:

◆ bdt_save_id()

void bdt_save_id ( string  s)

===========================================================================

void bdt_save_id(string s): The parser has found a variable as a part of a lisp expression. We save it in our global variable "lin_exp_l".

If "lin_exp_l" is empty, then this variable becomes the current expression. If not, it becomes an argument of the first lisp expression of "lin_exp_l".

Definition at line 352 of file bdt_read_paf.c.

354 {
355  extern list lin_exp_l;
356  extern expression crt_exp;
357  expression aux_exp;
358 
359  aux_exp = make_id_expression(s);
360 
361  if(lin_exp_l == NIL)
362  crt_exp = aux_exp;
363  else
364  {
367  CONS(EXPRESSION, aux_exp, NIL));
368  }
369 }
expression make_id_expression(string)
===========================================================================
Definition: utils.c:672

References CAR, CONS, crt_exp, EXPRESSION, gen_nconc(), lin_exp_l, LISP_EXPRESSION, lisp_expression_args, make_id_expression(), and NIL.

+ Here is the call graph for this function:

◆ bdt_save_int()

void bdt_save_int ( int  i)

===========================================================================

void bdt_save_int(int i): The parser has found an integer as a part of a lisp expression. We save it in our global variable "lin_exp_l".

If "lin_exp_l" is empty, then this integer becomes the current expression. If not, it becomes an argument of the first lisp expression of "lin_exp_l".

Definition at line 326 of file bdt_read_paf.c.

328 {
329  extern list lin_exp_l;
330  extern expression crt_exp;
331  expression aux_exp;
332 
333  aux_exp = int_to_expression(i);
334 
335  if(lin_exp_l == NIL)
336  crt_exp = aux_exp;
337  else
338  {
341  CONS(EXPRESSION, aux_exp, NIL));
342  }
343 }
expression int_to_expression(_int i)
transform an int into an expression and generate the corresponding entity if necessary; it is not cle...
Definition: expression.c:1188

References CAR, CONS, crt_exp, EXPRESSION, gen_nconc(), int_to_expression(), lin_exp_l, LISP_EXPRESSION, lisp_expression_args, and NIL.

+ Here is the call graph for this function:

◆ bdt_save_pred()

void bdt_save_pred ( int  option)

===========================================================================

void bdt_save_pred(int option): computes one expression of the predicate. Each expression is used twice ; indeed, an expression may be greater or equal than zero (>=) and smaller than zero (<). "option" says in which case we are: POSITIVE indicates that the predicate is >=, with NEGATIVE it is <. However, the C3 library always represents its inequalities with <=. So, the inequality "A >= 0" becomes "-A <= 0" and "A < 0" becomes "A + 1 <= 0".

This function updates the global list "pred_l" that contains the current list of predicates. When a new predicate expression is parsed, the POSITIVE is always considered first (that is why only in that case we use "crt_exp"). When the NEGATICE case is considered, the corresponding expression (used in the POSITIVE case) is the first expression of the list "pred_l". So, we only have to replace this expression by it equivalent for the NEGATIVE case (that is why the expression is multiplied by -1).

option == NEGATIVE

Initialization of global variables

Parameters
optionption

Definition at line 277 of file bdt_read_paf.c.

279 {
280  extern list pred_l, lin_exp_l;
281  extern expression crt_exp;
282 
283  expression aux_pred;
284 
285  if(option == POSITIVE)
286  {
288  pips_internal_error("current expression is undefined");
289 
292  }
293  else
294  /* option == NEGATIVE */
295  {
296  aux_pred = make_op_exp(PLUS_OPERATOR_NAME,
298  int_to_expression(1));
299 
300  pred_l = CONS(EXPRESSION, aux_pred, CDR(pred_l));
301  }
302 
303 /* Initialization of global variables */
304  lin_exp_l = NIL;
305 }
#define POSITIVE
Definition: bdt_read_paf.c:81
expression negate_expression(expression)
===========================================================================
Definition: utils.c:792
#define PLUS_OPERATOR_NAME
expression make_op_exp(char *op_name, expression exp1, expression exp2)
================================================================
Definition: expression.c:2012

References CAR, CDR, CONS, crt_exp, EXPRESSION, expression_undefined, int_to_expression(), lin_exp_l, make_op_exp(), negate_expression(), NIL, pips_internal_error, PLUS_OPERATOR_NAME, POSITIVE, and pred_l.

+ Here is the call graph for this function:

◆ reorganize_bdt()

void reorganize_bdt ( bdt  base)

===========================================================================

void reorganize_bdt(bdt base):

Parameters
basease

Definition at line 171 of file bdt_read_paf.c.

173 {
174  list sch_l, new_sch_l = NIL, l;
175 
176  for(sch_l = bdt_schedules(base); !ENDP(sch_l); POP(sch_l)) {
177  schedule sch = SCHEDULE(CAR(sch_l));
178  int stmt = schedule_statement(sch);
179  predicate pred = schedule_predicate(sch);
180  bool to_add = true;
181 
182  for(l = new_sch_l; (!ENDP(l)) && to_add; POP(l)) {
183  schedule nsch = SCHEDULE(CAR(l));
184  int nstmt = schedule_statement(nsch);
185  predicate npred = schedule_predicate(nsch);
186 
187  if(stmt == nstmt) {
188  if(same_predicate_p(pred, npred)) {
189  expression nexp = EXPRESSION(CAR(schedule_dims(sch)));
190  schedule_dims(nsch) = gen_nconc(schedule_dims(nsch),
191  CONS(EXPRESSION, nexp, NIL));
192  to_add = false;
193  }
194  }
195  }
196  if(to_add)
197  new_sch_l = gen_nconc(new_sch_l, CONS(SCHEDULE, sch, NIL));
198  }
199  bdt_schedules(base) = new_sch_l;
200 }
bool same_predicate_p(predicate p1, predicate p2)
===========================================================================
Definition: bdt_read_paf.c:145
#define ENDP(l)
Test if a list is empty.
Definition: newgen_list.h:66
#define POP(l)
Modify a list pointer to point on the next element of the list.
Definition: newgen_list.h:59
#define schedule_predicate(x)
Definition: paf_ri.h:715
#define schedule_dims(x)
Definition: paf_ri.h:717
#define schedule_statement(x)
Definition: paf_ri.h:713
Definition: statement.c:54

References base, bdt_schedules, CAR, CONS, ENDP, EXPRESSION, gen_nconc(), NIL, POP, same_predicate_p(), SCHEDULE, schedule_dims, schedule_predicate, and schedule_statement.

Referenced by bdt_read_paf().

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

◆ same_predicate_p()

bool same_predicate_p ( predicate  p1,
predicate  p2 
)

===========================================================================

If the predicate are defined, we consider them as always different

Parameters
p11
p22

Definition at line 145 of file bdt_read_paf.c.

147 {
148 
149  if( (p1 == predicate_undefined) && (p2 == predicate_undefined) )
150  return(true);
151  else if(p1 == predicate_undefined)
152  return(false);
153  else if(p2 == predicate_undefined)
154  return(false);
155 
156  if( (p1 == NULL) && (p2 == NULL) )
157  return(true);
158  else if(p1 == NULL)
159  return(false);
160  else if(p2 == NULL)
161  return(false);
162 
163  /* If the predicate are defined, we consider them as always different */
164  return(false);
165 }
#define predicate_undefined
Definition: ri.h:2046

References predicate_undefined.

Referenced by reorganize_bdt().

+ Here is the caller graph for this function:

Variable Documentation

◆ base

◆ crt_exp

expression crt_exp
static

Current list of linear expressions.

Definition at line 92 of file bdt_read_paf.c.

Referenced by bdt_new_shedule(), bdt_save_exp(), bdt_save_id(), bdt_save_int(), and bdt_save_pred().

◆ crt_ins

int crt_ins
static

Static global variables.

Definition at line 89 of file bdt_read_paf.c.

Referenced by bdt_init_new_ins(), and bdt_new_shedule().

◆ lin_exp_l

list lin_exp_l
static

Current list of predicates.

Definition at line 91 of file bdt_read_paf.c.

Referenced by bdt_init_new_ins(), bdt_init_op_exp(), bdt_new_shedule(), bdt_save_exp(), bdt_save_id(), bdt_save_int(), and bdt_save_pred().

◆ pred_l

list pred_l
static

Current stmt (an integer)

Definition at line 90 of file bdt_read_paf.c.

Referenced by bdt_elim_last_pred(), bdt_init_new_ins(), bdt_new_shedule(), and bdt_save_pred().