PIPS
tiling.c
Go to the documentation of this file.
1 /*
2 
3  $Id: tiling.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6 
7  This file is part of PIPS.
8 
9  PIPS is free software: you can redistribute it and/or modify it
10  under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  any later version.
13 
14  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
15  WARRANTY; without even the implied warranty of MERCHANTABILITY or
16  FITNESS FOR A PARTICULAR PURPOSE.
17 
18  See the GNU General Public License for more details.
19 
20  You should have received a copy of the GNU General Public License
21  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
22 
23 */
24 #ifdef HAVE_CONFIG_H
25  #include "pips_config.h"
26 #endif
27 /* Code Generation for Distributed Memory Machines
28  *
29  * Functions to decide a specific tiling for a loop nest
30  *
31  * File: tiling.c
32  *
33  * PUMA, ESPRIT contract 2701
34  *
35  * Francois Irigoin, Corinne Ancourt, Lei Zhou
36  * 1991
37  */
38 
39 #include <stdlib.h>
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <limits.h>
43 #include "genC.h"
44 #include "misc.h"
45 #include "linear.h"
46 #include "ri.h"
47 #include "effects.h"
48 
49 #include "ri-util.h"
50 #include "effects-util.h"
51 
52 #include "matrice.h"
53 #include "tiling.h"
54 
55 /* loop_nest_to_tile():
56  *
57  */
58 tiling loop_nest_to_tile(sc, ls, base_index,first_parallel_level,last_parallel_level,perfect_nested_level)
59 Psysteme sc;
60 int ls;
61 Pbase base_index;
62 int first_parallel_level;
63 int last_parallel_level;
64 int perfect_nested_level;
65 {
66 
67  tiling tile;
68  matrice M;
69  Pvecteur porigin = VECTEUR_NUL;
70  Pvecteur pv;
71  int vs = vect_size((Pvecteur)(base_index));
72  Psysteme sc_proj;
73  Value min,max;
74  bool faisable;
75  int i;
76 
77  /* Because the number of elements per bank ligne is usefull to
78  optimize the tiling, parameter ls is used temporarily to build it.
79  Because ls is the number of bytes of each bank ligne, it is
80  divided by the assumed number of bytes needed for the
81  location of one element (4 for int and real) */
82 
83  int lsd = ls/4;
84 
85  /* build the diagonal matrix: ls x I */
86 
87  M = matrice_new(vs,vs);
88  matrice_nulle(M,vs,vs);
89  for (i =1; i<= vs && i < first_parallel_level; i++)
90  ACCESS(M,vs,i,i) = VALUE_ONE;
91  for (; i<= vs && i <= last_parallel_level; i++)
92  ACCESS(M,vs,i,i) = int_to_value(lsd);
93  for (i = MIN(perfect_nested_level+1,last_parallel_level+1); i<= vs; i++)
94  ACCESS(M,vs,i,i) = VALUE_CONST(999);
95 
96 
97  /* build origin tile vector as the first iteration to minimize
98  the number of partial tiles (heuristics) */
99 
100  for (pv = base_index; !VECTEUR_NUL_P(pv); pv = pv->succ) {
101  Variable var = vecteur_var(pv);
102  sc_proj = sc_dup(sc);
103  faisable = sc_minmax_of_variable(sc_proj,var, &min, &max);
104  if (faisable)
105  /* vect_chg_coeff(&porigin,var,min);*/
106  vect_chg_coeff(&porigin,var,VALUE_ONE);
107  else
108  pips_internal_error("illegal empty iteration domain");
109 
110  }
111 
112  tile = make_tiling(M, porigin);
113  return tile;
114 }
tiling make_tiling(matrice a1, Pvecteur a2)
Definition: tiling.c:56
tiling loop_nest_to_tile(Psysteme sc, int ls, Pbase base_index, int first_parallel_level, int last_parallel_level, int perfect_nested_level)
Code Generation for Distributed Memory Machines.
Definition: tiling.c:58
#define int_to_value(i)
end LINEAR_VALUE_IS_INT
#define VALUE_CONST(val)
#define MIN(x, y)
minimum and maximum if they are defined somewhere else, they are very likely to be defined the same w...
int Value
#define VALUE_ONE
#define min(a, b)
#define max(a, b)
int vect_size(Pvecteur v)
package vecteur - reductions
Definition: reductions.c:47
#define ACCESS(matrix, column, i, j)
Macros d'acces aux elements d'une matrice.
Definition: matrice-local.h:86
#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_nulle(matrice Z, int n, int m)
void matrice_nulle(matrice Z, int n, int m): Initialisation de la matrice Z a la valeur matrice nulle
Definition: matrice.c:311
#define pips_internal_error
Definition: misc-local.h:149
Psysteme sc_dup(Psysteme ps)
Psysteme sc_dup(Psysteme ps): should becomes a link.
Definition: sc_alloc.c:176
bool sc_minmax_of_variable(Psysteme ps, Variable var, Value *pmin, Value *pmax)
void sc_minmax_of_variable(Psysteme ps, Variable var, Value *pmin, *pmax): examine un systeme pour tr...
Definition: sc_eval.c:143
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
#define vecteur_var(v)
#define VECTEUR_NUL
DEFINITION DU VECTEUR NUL.
#define VECTEUR_NUL_P(v)
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
void vect_chg_coeff(Pvecteur *ppv, Variable var, Value val)
void vect_chg_coeff(Pvecteur *ppv, Variable var, Value val): mise de la coordonnee var du vecteur *pp...
Definition: unaires.c:143