PIPS
hyperplane.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "misc.h"
#include "text.h"
#include "boolean.h"
#include "vecteur.h"
#include "contrainte.h"
#include "sc.h"
#include "matrice.h"
#include "matrix.h"
#include "sparse_sc.h"
#include "ri-util.h"
#include "effects-util.h"
#include "conversion.h"
#include "hyperplane.h"
+ Include dependency graph for hyperplane.c:

Go to the source code of this file.

Functions

statement hyperplane (list lls, _UNUSED_ bool(*u)(statement))
 package hyperplane More...
 

Function Documentation

◆ hyperplane()

statement hyperplane ( list  lls,
_UNUSED_ bool(*)(statement u 
)

package hyperplane

void hyperplane(cons *lls) Implementation of the hyperplane method "lls" is the list of nested loops

sc initial

sc nouveau

number of index

number of constraints

make the system "sc" of constraints of iteration space

NDEBUG

create the matrix A of coefficients of index in (Psysteme)sci

NDEBUG

NDEBUG

NDEBUG

computation of the hyperplane direction

use the hyperplane direction

computation of the scanning base G

the new matrice of constraints AG = A * G

NDEBUG

create the new system of constraintes (Psysteme scn) with AG and sci

NDEBUG

NDEBUG

NDEBUG

computation of the new iteration space in the new basis G

NDEBUG

(void) fprintf(stderr,"scn after new_loop_bound:\n"); sc_default_dump(scn); has been destroyed

change of basis for index

NDEBUG

NDEBUG

generation of hyperplane code

generation of bounds

loop body generation

Definition at line 61 of file hyperplane.c.

62 {
63  Psysteme sci; /* sc initial */
64  Psysteme scn; /* sc nouveau */
65  Psysteme sc_row_echelon;
67  Pbase base_oldindex = NULL;
68  Pbase base_newindex = NULL;
69  matrice A;
70  matrice G;
71  matrice AG;
72  int n; /* number of index */
73  int m ; /* number of constraints */
74  Value *h;
75  int i;
76  statement s_lhyp;
77  Pvecteur *pvg;
78  Pbase pb;
79  expression lower, upper;
80  Pvecteur pv1;
81  loop l;
82 
83  debug_on("HYPERPLANE_DEBUG_LEVEL");
84 
85  debug(8," hyperplane","Begin:\n");
86 
87  /* make the system "sc" of constraints of iteration space */
88  sci = loop_iteration_domaine_to_sc(lls, &base_oldindex);
89 
90  ifdebug(8) {
91  /*DNDEBUG*/
92  (void) fprintf(stderr,"base_oldindex 0:\n");
93  base_fprint(stderr,base_oldindex,default_variable_to_string);
94  }
95 
96  /* create the matrix A of coefficients of index in (Psysteme)sci */
97  n = base_dimension(base_oldindex);
98  m = sci->nb_ineq;
99  A = matrice_new(m,n);
100  sys_matrice_index(sci, base_oldindex, A, n, m);
101 
102  ifdebug(8) {
103  /*DNDEBUG*/
104  (void) fprintf(stderr,"base_oldindex 1:\n");
105  base_fprint(stderr,base_oldindex,default_variable_to_string);
106  }
107  ifdebug(8) {
108  /*DNDEBUG*/
109  (void) fprintf(stderr,"Matrice A:\n");
110  matrice_fprint(stderr,A,m,n);
111  }
112  ifdebug(8) {
113  /*DNDEBUG*/
114  (void) fprintf(stderr,"sci:\n");
115  sc_default_dump(sci);
116  }
117  /* computation of the hyperplane direction */
118  /* use the hyperplane direction */
119  h = (Value*)(malloc(n*sizeof(Value)));
120 
122  pips_user_error("A proper hyperplane direction was not provided\n");
123  }
124 
125  ifdebug(8) {
126  debug(8," hyperplane","Vector h :");
127  for (i = 0; i<n; i++) {
128  (void) fprintf(stderr," " VALUE_FMT, *(h+i));
129  }
130  (void) fprintf(stderr,"\n");
131  }
132 
133  G = matrice_new(n,n);
134  /* computation of the scanning base G */
136  ifdebug(8) {
137  (void) fprintf(stderr,"The scanning base G is:");
138  matrice_fprint(stderr, G, n, n);
139  }
140 
141  /* the new matrice of constraints AG = A * G */
142  AG = matrice_new(m,n);
143  matrice_multiply(A, G, AG, m, n, n);
144 
145  ifdebug(8) {
146  /*DNDEBUG*/
147  (void) fprintf(stderr,"Matrice AG:\n");
148  matrice_fprint(stderr,AG,m,n);
149  }
150  /* create the new system of constraintes (Psysteme scn) with
151  AG and sci */
152  scn = sc_dup(sci);
153 
154  ifdebug(8) {
155  /*DNDEBUG*/
156  (void) fprintf(stderr,"base_oldindex 2:\n");
157  base_fprint(stderr,base_oldindex,default_variable_to_string);
158  }
159  ifdebug(8) {
160  /*DNDEBUG*/
161  (void) fprintf(stderr,"scn before matrice_index_sys :\n");
162  sc_default_dump(scn);
163  }
164  matrice_index_sys(scn, base_oldindex, AG, n,m );
165 
166  ifdebug(8) {
167  /*DNDEBUG*/
168  (void) fprintf(stderr,"scn after matrice_index_sys :\n");
169  sc_default_dump(scn);
170  }
171 
172  /* computation of the new iteration space in the new basis G */
173  sc_row_echelon = new_loop_bound(scn, base_oldindex);
174 
175  ifdebug(8) {
176  /*DNDEBUG*/
177  /* (void) fprintf(stderr,"scn after new_loop_bound:\n");
178  sc_default_dump(scn);
179  has been destroyed
180  */
181  (void) fprintf(stderr,"sc_row_echelon:\n");
182  sc_default_dump(sc_row_echelon);
183  }
184 
185  /* change of basis for index */
186  change_of_base_index(base_oldindex, &base_newindex);
187 
188  ifdebug(8) {
189  /*DNDEBUG*/
190  (void) fprintf(stderr,"base_oldindex:\n");
191  base_fprint(stderr,base_oldindex,default_variable_to_string);
192  (void) fprintf(stderr,"base_newindex:\n");
193  base_fprint(stderr,base_newindex,default_variable_to_string);
194  }
195 
196  sc_newbase = sc_change_baseindex(sc_dup(sc_row_echelon), base_oldindex, base_newindex);
197 
198  ifdebug(8) {
199  /*DNDEBUG*/
200  (void) fprintf(stderr,"sc_newbase:\n");
202  }
203 
204  /* generation of hyperplane code */
205  /* generation of bounds */
206  for (pb=base_newindex; pb!=NULL; pb=pb->succ) {
207  make_bound_expression(pb->var, base_newindex, sc_newbase, &lower, &upper);
208  }
209 
210  /* loop body generation */
211  pvg = (Pvecteur *)malloc((unsigned)n*sizeof(Svecteur));
212  scanning_base_to_vect(G,n,base_newindex,pvg);
213  pv1 = sc_row_echelon->inegalites->succ->vecteur;
214  (void)vect_change_base(pv1,base_oldindex,pvg);
215 
217  lower = range_upper(loop_range(l));
218  upper= expression_to_expression_newbase(lower, pvg, base_oldindex);
219 
220 
221  s_lhyp = code_generation(lls, pvg, base_oldindex, base_newindex, sc_newbase, true);
222 
223  debug(8," hyperplane","End\n");
224 
225  debug_off();
226 
227  return(s_lhyp);
228 }
#define VALUE_FMT
int Value
void change_of_base_index(Pbase base_oldindex, Pbase *base_newindex)
void change_of_base_index(Pbase base_oldindex, Pbase *base_newindex) change of variable index from ba...
Psysteme sc_change_baseindex(Psysteme sc, Pbase base_old, Pbase base_new)
Psysteme sc_change_baseindex(Psysteme sc, Pbase base_old, Pbase base_new) le changement de base d'ind...
expression expression_to_expression_newbase(expression e_old, pvg, Pbase base_oldindex)
expression expression_to_expression_newbase(expression e_old,Pvecteur pvg[], Pbase base_oldindex) com...
Pvecteur vect_change_base(Pvecteur pv_old, Pbase base_oldindex, pvg)
Pvecteur vect_change_base(Pvecteur pv_old, Pvecteur pvg[], Pbase base_oldindex, Pbase base_newindex) ...
void scanning_base_to_vect(matrice G, int n, Pbase base, pvg)
void scanning_base_to_vect(matrice G,int n,Pbase base,Pvecteur pvg[n]) compute G*base and put the res...
statement code_generation(list lls, Pvecteur pvg[], Pbase base_oldindex, Pbase base_newindex, Psysteme sc_newbase, bool preserve_entry_label_p)
package hyperplane
#define A(i, j)
comp_matrice.c
Definition: comp_matrice.c:63
Psysteme loop_iteration_domaine_to_sc(list, Pbase *)
loop_iteration_domaine_to_sc.c
void * malloc(YYSIZE_T)
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
Psysteme sc_newbase
include <sys/ddi.h>
void scanning_base_hyperplane(Value[], int, matrice)
scanning_base.c
bool interactive_hyperplane_direction(Value *, int)
hyperplane_direction.c
void base_fprint(FILE *f, Pbase b, get_variable_name_t variable_name)
void base_fprint(FILE * f, Pbase b, char * (*variable_name)()): impression d'une base sur le fichier ...
Definition: io.c:342
#define matrice_new(n, m)
Allocation et desallocation d'une matrice.
Definition: matrice-local.h:77
Value * matrice
package matrice
Definition: matrice-local.h:71
void matrice_multiply(matrice a, matrice b, matrice c, int p, int q, int r)
void matrice_multiply(matrice a, matrice b, matrice c, int p, int q, int r): multiply rational matrix...
Definition: matrice.c:82
void matrice_fprint(FILE *, matrice, int, int)
matrice_io.c
Definition: matrice_io.c:62
#define debug_on(env)
Definition: misc-local.h:157
#define debug_off()
Definition: misc-local.h:160
#define pips_user_error
Definition: misc-local.h:147
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
void make_bound_expression(Variable index, Pbase base, Psysteme sc, expression *lower, expression *upper)
void make_bound_expression(variable index, Pbase base, Psysteme sc, expression *lower,...
#define range_upper(x)
Definition: ri.h:2290
#define instruction_loop(x)
Definition: ri.h:1520
#define statement_instruction(x)
Definition: ri.h:2458
#define loop_range(x)
Definition: ri.h:1642
#define STATEMENT(x)
STATEMENT.
Definition: ri.h:2413
Psysteme sc_dup(Psysteme ps)
Psysteme sc_dup(Psysteme ps): should becomes a link.
Definition: sc_alloc.c:176
char * default_variable_to_string(Variable v)
Definition: sc_debug.c:245
void sc_default_dump(Psysteme sc)
void sc_default_dump(Psysteme sc): dump to stderr
Definition: sc_io.c:170
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
Psysteme new_loop_bound(Psysteme scn, Pbase base_index)
Psysteme new_loop_bound(Psysteme scn, Pbase base_index) computation of the new iteration space (given...
#define G(j, a, b)
maybe most of them should be functions?
#define ifdebug(n)
Definition: sg.c:47
void sys_matrice_index(Psysteme, Pbase, matrice, int, int)
Warning! Do not modify this file that is automatically generated!
void matrice_index_sys(Psysteme, Pbase, matrice, int, int)
void matrice_index_sys(Psysteme sc, Pbase base_index, matrice AG, int n, int m) replace the coefficie...
Definition: pip__tab.h:25
Pvecteur vecteur
struct Scontrainte * succ
Pcontrainte inegalites
Definition: sc-local.h:71
int nb_ineq
Definition: sc-local.h:73
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
Variable var
Definition: vecteur-local.h:90
struct Svecteur * succ
Definition: vecteur-local.h:92
#define base_dimension(b)
struct Svecteur Svecteur
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique

References A, base_dimension, base_fprint(), CAR, change_of_base_index(), code_generation(), debug(), debug_off, debug_on, default_variable_to_string(), expression_to_expression_newbase(), fprintf(), G, ifdebug, Ssysteme::inegalites, instruction_loop, interactive_hyperplane_direction(), loop_iteration_domaine_to_sc(), loop_range, make_bound_expression(), malloc(), matrice_fprint(), matrice_index_sys(), matrice_multiply(), matrice_new, Ssysteme::nb_ineq, new_loop_bound(), pips_user_error, range_upper, sc_change_baseindex(), sc_default_dump(), sc_dup(), sc_newbase, scanning_base_hyperplane(), scanning_base_to_vect(), STATEMENT, statement_instruction, Scontrainte::succ, Svecteur::succ, sys_matrice_index(), VALUE_FMT, Svecteur::var, vect_change_base(), and Scontrainte::vecteur.

Referenced by global_parallelization(), and loop_hyperplane().

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