PIPS
build_sc_machine.c File Reference
#include <stdio.h>
#include "genC.h"
#include "linear.h"
#include "ri.h"
#include "ri-util.h"
#include "misc.h"
#include "matrice.h"
#include "tiling.h"
#include "movements.h"
+ Include dependency graph for build_sc_machine.c:

Go to the source code of this file.

Functions

Psysteme build_sc_machine (int pn, int bn, int ls, Psysteme sc_array_function, entity proc_id, Pbase bank_indices, entity entity_var)
 PACKAGE MOVEMENTS. More...
 

Function Documentation

◆ build_sc_machine()

Psysteme build_sc_machine ( int  pn,
int  bn,
int  ls,
Psysteme  sc_array_function,
entity  proc_id,
Pbase  bank_indices,
entity  entity_var 
)

PACKAGE MOVEMENTS.

build_sc_machine.c

Corinne Ancourt - septembre 1991 this function builds the following system of constraints depending on the machine. It describes the implementation of array elements in the memory in function of bank, ligne size, ligne bank,...

bn is the number of banks, ls the ligne size, ms the first array dimension bank is a variable giving the bank id., ligne a variable corresponding to a ligne in the bank, ofs a variable corresponding to an offset in a ligne of the bank.

if COLUMN_MAJOR is true the system is the following one

 (VAR1-1) + (VAR2-1) *ms == bn*ls* ligne +ls*bank+ofs,
   1 <= bank <= bn ,
   1 <= proc <= pn ,
   0 <= ofs <= ls-1

else it is

  (VAR1-1) * ms + (VAR2-1) == bn*ls*ligne +ls*bank+ofs,
    1 <= bank <= bn ,
    1 <= proc <= pn ,
    0 <= ofs <= ls-1

Si l'on veut utiliser le nombre d'octets il faut remplacer l'equation par deux inequations du type

if COLUMN_MAJOR is true the system is the following one

(VAR1-1) + (VAR2-1) ms <= bn*ls (ligne-1) +ls*(bank-1)+ofs, bn*ls* (ligne-1) +ls*(bank-1)+ofs <= (VAR1) + (VAR2-1) *ms

else it is

(VAR1-1) * ms + (VAR2-1) <= bn*ls*(ligne-1) +ls*(bank-1)+ofs, bn*ls*(ligne-1) +ls*(bank-1)+ofs <= (VAR1-1) * ms + (VAR2)

nb_bytes = SizeOfElements(bas);

bank_indices is assumed to belong the three variables bank_id, L and O (see documentation for more details)

if COLUMN_MAJOR is true then build the constraint
(VAR1-1) + (VAR2-1) *ms == bn*ls*L +ls*bank_id+O, else build the constraint (VAR1-1) * ms + (VAR2-1) == bn*ls*L +ls*bank_id+O, VAR1 and VAR2 correspond to the image array function indices

to deal with MONO dimensional array

to deal with MONO dimensional array

build the constraints 0 <= bank_id <= bn-1

build the constraints 0 <= proc_id <= pn-1

build the constraints 0 <= O <= ls -1

build the constraints 0 <= L

Parameters
pnn
bnn
lss
sc_array_functionc_array_function
proc_idroc_id
bank_indicesank_indices
entity_varntity_var

Definition at line 70 of file build_sc_machine.c.

78 {
79 
80  type t = entity_type(entity_var);
81  Value ms=0;
82  Variable vbank,vligne,vofs;
83  Psysteme sc = sc_init_with_sc(sc_array_function);
84  Pcontrainte pc;
85  Pvecteur pv1,pv2;
86  int nb_bytes=1;
87 
88  debug(8,"build_sc_machine","begin\n");
89  if (type_variable_p(t)) {
90  variable var = type_variable(t);
91  cons * dims = variable_dimensions(var);
92  dimension dim1 = DIMENSION(CAR(dims));
93  expression lower= dimension_lower(dim1);
94  normalized norm1 = NORMALIZE_EXPRESSION(lower);
95  expression upper= dimension_upper(dim1);
96  normalized norm2 = NORMALIZE_EXPRESSION(upper);
97  Value min_ms =VALUE_ZERO, max_ms=VALUE_ZERO;
98  if (normalized_linear_p(norm1) && normalized_linear_p(norm2)) {
99  min_ms = vect_coeff(TCST,(Pvecteur) normalized_linear(norm1));
100  max_ms = vect_coeff(TCST,(Pvecteur) normalized_linear(norm2));
101  }
102  ms = value_plus(value_minus(max_ms,min_ms), VALUE_ONE);
103 
104  /* Si l'on veut utiliser le nombre d'octets il faut remplacer l'equation
105  par deux inequations du type
106 
107  if COLUMN_MAJOR is true the system is the following one
108 
109  (VAR1-1) + (VAR2-1) *ms <= bn*ls* (ligne-1) +ls*(bank-1)+ofs,
110  bn*ls* (ligne-1) +ls*(bank-1)+ofs <= (VAR1) + (VAR2-1) *ms
111 
112  else it is
113 
114  (VAR1-1) * ms + (VAR2-1) <= bn*ls*(ligne-1) +ls*(bank-1)+ofs,
115  bn*ls*(ligne-1) +ls*(bank-1)+ofs <= (VAR1-1) * ms + (VAR2)
116 
117  */
118 
119  /* nb_bytes = SizeOfElements(bas);*/
120 
121  }
122 
123  ifdebug(8) {
124  fprint_string_Value(stderr," MS = ",ms);
125  fprintf(stderr, " \n");
126  }
127 
128  vbank = vecteur_var(bank_indices);
129  vligne = vecteur_var(bank_indices->succ);
130  vofs = vecteur_var(bank_indices->succ->succ);
131  sc->base = vect_add_variable(sc->base,vbank);
132  sc->base = vect_add_variable(sc->base,vligne);
133  sc->base = vect_add_variable(sc->base,vofs);
134 
135  sc->dimension +=3;
136 
137  /* bank_indices is assumed to belong the three variables
138  bank_id, L and O (see documentation for more details) */
139 
140  /* if COLUMN_MAJOR is true then build the constraint
141  (VAR1-1) + (VAR2-1) *ms == bn*ls*L +ls*bank_id+O,
142  else build the constraint
143  (VAR1-1) * ms + (VAR2-1) == bn*ls*L +ls*bank_id+O,
144  VAR1 and VAR2 correspond to the image array function indices */
145  pv1 = vect_new(vbank,int_to_value(-ls));
146  vect_add_elem(&pv1,vligne,int_to_value((-bn*ls)));
147  vect_add_elem(&pv1,vofs,VALUE_MONE);
148  if (COLUMN_MAJOR)
149  pc = sc_array_function->inegalites;
150  else pc = sc_array_function->inegalites->succ;
151  /* to deal with MONO dimensional array */
152  if (pc==NULL) pc= contrainte_make(vect_new(TCST,VALUE_ONE));
153  pv2 = vect_dup(pc->vecteur);
155  pv2 = vect_multiply(pv2,int_to_value(nb_bytes));
156  pv1 = vect_add(pv1,pv2);
157  if (COLUMN_MAJOR)
158  pc = pc->succ;
159  else pc = sc_array_function->inegalites;
160  /* to deal with MONO dimensional array */
161  if (pc==NULL) pc= contrainte_make(vect_new(TCST,VALUE_ONE));
162  pv2 = vect_dup(pc->vecteur);
164  Value nbv = int_to_value(nb_bytes);
165  pv2 = vect_multiply(pv2,value_mult(ms, nbv));
166  pv1 = vect_add(pv1,pv2);
167  pc = contrainte_make(pv1);
168  sc_add_eg(sc,pc);
169 
170  /* build the constraints 0 <= bank_id <= bn-1 */
171 
172  pv2 = vect_new(vbank, VALUE_MONE);
173  pc = contrainte_make(pv2);
174  sc_add_ineg(sc,pc);
175  pv2 = vect_new(vbank, VALUE_ONE);
176  vect_add_elem(&pv2,TCST,int_to_value(- bn+1));
177  pc = contrainte_make(pv2);
178  sc_add_ineg(sc,pc);
179 
180  /* build the constraints 0 <= proc_id <= pn-1 */
181  sc->base = vect_add_variable(sc->base,(char *) proc_id);
182  sc->dimension++;
183  pv2 = vect_new((char *) proc_id, VALUE_MONE);
184  pc = contrainte_make(pv2);
185  sc_add_ineg(sc,pc);
186  pv2 = vect_new((char *) proc_id, VALUE_ONE);
187  vect_add_elem(&pv2,TCST,int_to_value(- pn+1));
188  pc = contrainte_make(pv2);
189  sc_add_ineg(sc,pc);
190 
191 
192  /* build the constraints 0 <= O <= ls -1 */
193 
194  pv2 = vect_new(vofs, VALUE_MONE);
195  pc = contrainte_make(pv2);
196  sc_add_ineg(sc,pc);
197  pv2 = vect_new(vofs, VALUE_ONE);
198  vect_add_elem(&pv2,TCST,int_to_value(- ls +1));
199  pc = contrainte_make(pv2);
200  sc_add_ineg(sc,pc);
201 
202 
203  /* build the constraints 0 <= L */
204 
205  pc = contrainte_make(vect_new(vligne,VALUE_MONE));
206  sc_add_ineg(sc,pc);
207  ifdebug(8) {
208  (void) fprintf(stderr,"Domain Machine :\n");
210  }
211  debug(8,"build_sc_machine","end\n");
212 
213  return(sc);
214 
215 }
#define VALUE_ZERO
#define int_to_value(i)
end LINEAR_VALUE_IS_INT
#define value_minus(v1, v2)
#define VALUE_MONE
int Value
#define value_plus(v1, v2)
binary operators on values
#define VALUE_ONE
#define value_mult(v, w)
whether the default is protected or not this define makes no sense any more...
void fprint_string_Value(FILE *, char *, Value)
Definition: io.c:47
Pbase vect_add_variable(Pbase b, Variable v)
package vecteur - routines sur les bases
Definition: base.c:61
Pcontrainte contrainte_make(Pvecteur pv)
Pcontrainte contrainte_make(Pvecteur pv): allocation et initialisation d'une contrainte avec un vecte...
Definition: alloc.c:73
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
void debug(const int the_expected_debug_level, const char *calling_function_name, const char *a_message_format,...)
ARARGS0.
Definition: debug.c:189
#define COLUMN_MAJOR
Package movements
#define NORMALIZE_EXPRESSION(e)
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
#define normalized_linear_p(x)
Definition: ri.h:1779
#define dimension_lower(x)
Definition: ri.h:980
#define type_variable(x)
Definition: ri.h:2949
#define dimension_upper(x)
Definition: ri.h:982
#define variable_dimensions(x)
Definition: ri.h:3122
#define entity_type(x)
Definition: ri.h:2792
#define normalized_linear(x)
Definition: ri.h:1781
#define type_variable_p(x)
Definition: ri.h:2947
Psysteme sc_init_with_sc(Psysteme sc)
This function returns a new empty system which has been initialized with the same dimension and base ...
Definition: sc_alloc.c:303
void sc_fprint(FILE *fp, Psysteme ps, get_variable_name_t nom_var)
void sc_fprint(FILE * f, Psysteme ps, char * (*nom_var)()): cette fonction imprime dans le fichier po...
Definition: sc_io.c:220
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
Pvecteur vect_multiply(Pvecteur v, Value x)
Pvecteur vect_multiply(Pvecteur v, Value x): multiplication du vecteur v par le scalaire x,...
Definition: scalaires.c:123
#define ifdebug(n)
Definition: sg.c:47
Pvecteur vecteur
struct Scontrainte * succ
Pcontrainte inegalites
Definition: sc-local.h:71
Pbase base
Definition: sc-local.h:75
int dimension
Definition: sc-local.h:74
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
struct Svecteur * succ
Definition: vecteur-local.h:92
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
#define TCST
VARIABLE REPRESENTANT LE TERME CONSTANT.
#define vecteur_var(v)
char *(* get_variable_name_t)(Variable)
Definition: vecteur-local.h:62
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Definition: vecteur-local.h:60
Pvecteur vect_dup(Pvecteur v_in)
Pvecteur vect_dup(Pvecteur v_in): duplication du vecteur v_in; allocation de et copie dans v_out;.
Definition: alloc.c:51
Pvecteur vect_new(Variable var, Value coeff)
Pvecteur vect_new(Variable var,Value coeff): allocation d'un vecteur colineaire au vecteur de base va...
Definition: alloc.c:110
Pvecteur vect_add(Pvecteur v1, Pvecteur v2)
package vecteur - operations binaires
Definition: binaires.c:53
void vect_add_elem(Pvecteur *pvect, Variable var, Value val)
void vect_add_elem(Pvecteur * pvect, Variable var, Value val): addition d'un vecteur colineaire au ve...
Definition: unaires.c:72
Value vect_coeff(Variable var, Pvecteur vect)
Variable vect_coeff(Variable var, Pvecteur vect): coefficient de coordonnee var du vecteur vect —> So...
Definition: unaires.c:228

References Ssysteme::base, CAR, COLUMN_MAJOR, contrainte_make(), debug(), Ssysteme::dimension, DIMENSION, dimension_lower, dimension_upper, entity_local_name(), entity_type, fprint_string_Value(), fprintf(), ifdebug, Ssysteme::inegalites, int_to_value, NORMALIZE_EXPRESSION, normalized_linear, normalized_linear_p, sc_fprint(), sc_init_with_sc(), Scontrainte::succ, Svecteur::succ, TCST, type_variable, type_variable_p, value_minus, VALUE_MONE, value_mult, VALUE_ONE, value_plus, VALUE_ZERO, variable_dimensions, vect_add(), vect_add_elem(), vect_add_variable(), vect_coeff(), vect_dup(), vect_multiply(), vect_new(), Scontrainte::vecteur, and vecteur_var.

Referenced by sc_image_computation().

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