Commit 2abae5f1 by Sebastian Pop

New Graphite files.

2009-07-30  Sebastian Pop  <sebastian.pop@amd.com>

	* ChangeLog.graphite: New.
	* graphite-blocking.c: New.
	* graphite-clast-to-gimple.c: New.
	* graphite-clast-to-gimple.h: New.
	* graphite-dependences.c: New.
	* graphite-dependences.h: New.
	* graphite-interchange.c: New.
	* graphite-poly.c: New.
	* graphite-poly.h: New.
	* graphite-ppl.c: New.
	* graphite-ppl.h: New.
	* graphite-scop-detection.c: New.
	* graphite-scop-detection.h: New.
	* graphite-sese-to-poly.c: New.
	* graphite-sese-to-poly.h: New.
	* sese.c: New.
	* sese.h: New.

From-SVN: r150300
parent e7c705bb
2009-07-30 Sebastian Pop <sebastian.pop@amd.com>
* ChangeLog.graphite: New.
* graphite-blocking.c: New.
* graphite-clast-to-gimple.c: New.
* graphite-clast-to-gimple.h: New.
* graphite-dependences.c: New.
* graphite-dependences.h: New.
* graphite-interchange.c: New.
* graphite-poly.c: New.
* graphite-poly.h: New.
* graphite-ppl.c: New.
* graphite-ppl.h: New.
* graphite-scop-detection.c: New.
* graphite-scop-detection.h: New.
* graphite-sese-to-poly.c: New.
* graphite-sese-to-poly.h: New.
* sese.c: New.
* sese.h: New.
2009-07-30 Sebastian Pop <sebastian.pop@amd.com>
* tree-chrec.c (evolution_function_right_is_integer_cst): New.
* tree-chrec.h (evolution_function_right_is_integer_cst): Declared.
......
This source diff could not be displayed because it is too large. You can view the blob instead.
/* Heuristics and transform for loop blocking and strip mining on
polyhedral representation.
Copyright (C) 2009 Free Software Foundation, Inc.
Contributed by Sebastian Pop <sebastian.pop@amd.com> and
Pranav Garg <pranav.garg2107@gmail.com>.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "ggc.h"
#include "tree.h"
#include "rtl.h"
#include "output.h"
#include "basic-block.h"
#include "diagnostic.h"
#include "tree-flow.h"
#include "toplev.h"
#include "tree-dump.h"
#include "timevar.h"
#include "cfgloop.h"
#include "tree-chrec.h"
#include "tree-data-ref.h"
#include "tree-scalar-evolution.h"
#include "tree-pass.h"
#include "domwalk.h"
#include "value-prof.h"
#include "pointer-set.h"
#include "gimple.h"
#include "params.h"
#ifdef HAVE_cloog
#include "cloog/cloog.h"
#include "ppl_c.h"
#include "sese.h"
#include "graphite-ppl.h"
#include "graphite.h"
#include "graphite-poly.h"
/* Strip mines with a factor STRIDE the loop around PBB at depth
LOOP_DEPTH. The following example comes from the wiki page:
http://gcc.gnu.org/wiki/Graphite/Strip_mine
The strip mine of a loop with a tile of 64 can be obtained with a
scattering function as follows:
$ cat ./albert_strip_mine.cloog
# language: C
c
# parameter {n | n >= 0}
1 3
# n 1
1 1 0
1
n
1 # Number of statements:
1
# {i | 0 <= i <= n}
2 4
# i n 1
1 1 0 0
1 -1 1 0
0 0 0
1
i
1 # Scattering functions
3 6
# NEW OLD i n 1
1 -64 0 1 0 0
1 64 0 -1 0 63
0 0 1 -1 0 0
1
NEW OLD
#the output of CLooG is like this:
#$ cloog ./albert_strip_mine.cloog
# for (NEW=0;NEW<=floord(n,64);NEW++) {
# for (OLD=max(64*NEW,0);OLD<=min(64*NEW+63,n);OLD++) {
# S1(i = OLD) ;
# }
# }
*/
static bool
pbb_strip_mine_loop_depth (poly_bb_p pbb, int loop_depth, int stride)
{
ppl_dimension_type iter, dim;
ppl_Polyhedron_t res = PBB_TRANSFORMED_SCATTERING (pbb);
ppl_dimension_type strip = psct_scattering_dim_for_loop_depth (pbb,
loop_depth);
psct_add_scattering_dimension (pbb, strip);
iter = psct_iterator_dim (pbb, loop_depth);
ppl_Polyhedron_space_dimension (res, &dim);
/* Lower bound of the striped loop. */
{
ppl_Constraint_t new_cstr;
ppl_Linear_Expression_t expr;
ppl_new_Linear_Expression_with_dimension (&expr, dim);
ppl_set_coef (expr, strip, -1 * stride);
ppl_set_coef (expr, iter, 1);
ppl_new_Constraint (&new_cstr, expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
ppl_delete_Linear_Expression (expr);
ppl_Polyhedron_add_constraint (res, new_cstr);
ppl_delete_Constraint (new_cstr);
}
/* Upper bound of the striped loop. */
{
ppl_Constraint_t new_cstr;
ppl_Linear_Expression_t expr;
ppl_new_Linear_Expression_with_dimension (&expr, dim);
ppl_set_coef (expr, strip, stride);
ppl_set_coef (expr, iter, -1);
ppl_set_inhomogeneous (expr, stride - 1);
ppl_new_Constraint (&new_cstr, expr, PPL_CONSTRAINT_TYPE_GREATER_OR_EQUAL);
ppl_delete_Linear_Expression (expr);
ppl_Polyhedron_add_constraint (res, new_cstr);
ppl_delete_Constraint (new_cstr);
}
return true;
}
/* Returns true when strip mining with STRIDE of the loop around PBB
at depth LOOP_DEPTH is profitable. */
static bool
pbb_strip_mine_profitable_p (poly_bb_p pbb,
graphite_dim_t loop_depth,
int stride)
{
Value niter, strip_stride;
bool res;
value_init (strip_stride);
value_init (niter);
value_set_si (strip_stride, stride);
pbb_number_of_iterations (pbb, loop_depth, niter);
res = value_gt (niter, strip_stride);
value_clear (strip_stride);
value_clear (niter);
return res;
}
/* Strip mines all the loops around PBB. Nothing profitable in all this:
this is just a driver function. */
static bool
pbb_do_strip_mine (poly_bb_p pbb)
{
graphite_dim_t loop_depth;
int stride = 64;
bool transform_done = false;
for (loop_depth = 0; loop_depth < pbb_dim_iter_domain (pbb); loop_depth++)
if (pbb_strip_mine_profitable_p (pbb, loop_depth, stride))
transform_done |= pbb_strip_mine_loop_depth (pbb, loop_depth, stride);
return transform_done;
}
/* Strip mines all the loops in SCOP. Nothing profitable in all this:
this is just a driver function. */
bool
scop_do_strip_mine (scop_p scop)
{
poly_bb_p pbb;
int i;
bool transform_done = false;
for (i = 0; VEC_iterate (poly_bb_p, SCOP_BBS (scop), i, pbb); i++)
transform_done |= pbb_do_strip_mine (pbb);
return transform_done;
}
#endif
/* Translation of CLAST (CLooG AST) to Gimple.
Copyright (C) 2009 Free Software Foundation, Inc.
Contributed by Sebastian Pop <sebastian.pop@amd.com>.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#ifndef GCC_GRAPHITE_CLAST_TO_GIMPLE_H
#define GCC_GRAPHITE_CLAST_TO_GIMPLE_H
/* Data structure for CLooG program representation. */
typedef struct cloog_prog_clast {
CloogProgram *prog;
struct clast_stmt *stmt;
} cloog_prog_clast;
/* Stores BB's related PBB. */
typedef struct bb_pbb_def
{
basic_block bb;
poly_bb_p pbb;
}bb_pbb_def;
extern bool gloog (scop_p, htab_t);
extern cloog_prog_clast scop_to_clast (scop_p);
extern void debug_clast_stmt (struct clast_stmt *);
extern void print_clast_stmt (FILE *, struct clast_stmt *);
extern void debug_clast_name_indexes (htab_t);
extern void mark_loops_parallel (htab_t);
extern void free_aux_in_new_loops (void);
/* Hash function for data base element BB_PBB. */
static inline hashval_t
bb_pbb_map_hash (const void *bb_pbb)
{
return (hashval_t)(((const bb_pbb_def *)bb_pbb)->bb->index);
}
/* Compare data base element BB_PBB1 and BB_PBB2. */
static inline int
eq_bb_pbb_map (const void *bb_pbb1, const void *bb_pbb2)
{
const bb_pbb_def *bp1 = (const bb_pbb_def *) bb_pbb1;
const bb_pbb_def *bp2 = (const bb_pbb_def *) bb_pbb2;
return (bp1->bb->index == bp2->bb->index);
}
#endif
/* Graphite polyhedral representation.
Copyright (C) 2009 Free Software Foundation, Inc.
Contributed by Konrad Trifunovic <konrad.trifunovic@gmail.com>
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#ifndef GCC_GRAPHITE_DEPENDENCES_H
#define GCC_GRAPHITE_DEPENDENCES_H
extern bool graphite_legal_transform (scop_p);
extern bool dependency_between_pbbs_p (poly_bb_p, poly_bb_p, int);
typedef struct poly_dr_pair *poly_dr_pair_p;
typedef struct poly_dr_pair
{
/* Source polyhedral data reference of the dependence. */
poly_dr_p source;
/* Sink data reference of the dependence. */
poly_dr_p sink;
/* Data dependence polyhedron descibing dependence
between SOURCE and SINK data references. */
ppl_Pointset_Powerset_C_Polyhedron_t ddp;
}poly_dr_pair;
#define PDRP_SOURCE(PDRP) (PDR->source)
#define PDRP_SINK(PDRP) (PDR->sink)
#define PDRP_DDP(PDRP) (PDR->ddp)
extern int eq_poly_dr_pair_p (const void *, const void *);
extern hashval_t hash_poly_dr_pair_p (const void *);
#endif
/* Gimple Represented as Polyhedra.
Copyright (C) 2009 Free Software Foundation, Inc.
Contributed by Sebastian Pop <sebastian.pop@inria.fr>
and Tobias Grosser <grosser@fim.uni-passau.de>.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#ifndef GCC_GRAPHITE_PPL_H
#define GCC_GRAPHITE_PPL_H
#include "double-int.h"
#include "tree.h"
CloogMatrix *new_Cloog_Matrix_from_ppl_Polyhedron (ppl_const_Polyhedron_t);
CloogDomain *new_Cloog_Domain_from_ppl_Polyhedron (ppl_const_Polyhedron_t);
CloogDomain * new_Cloog_Domain_from_ppl_Pointset_Powerset (
ppl_Pointset_Powerset_C_Polyhedron_t);
void new_C_Polyhedron_from_Cloog_Matrix (ppl_Polyhedron_t *, CloogMatrix *);
void insert_constraint_into_matrix (CloogMatrix *, int, ppl_const_Constraint_t);
ppl_Polyhedron_t ppl_strip_loop (ppl_Polyhedron_t, ppl_dimension_type, int);
int ppl_lexico_compare_linear_expressions (ppl_Linear_Expression_t,
ppl_Linear_Expression_t);
void ppl_print_polyhedron_matrix (FILE *, ppl_const_Polyhedron_t);
void ppl_print_powerset_matrix (FILE *, ppl_Pointset_Powerset_C_Polyhedron_t);
void debug_ppl_polyhedron_matrix (ppl_Polyhedron_t);
void debug_ppl_powerset_matrix (ppl_Pointset_Powerset_C_Polyhedron_t);
void ppl_read_polyhedron_matrix (ppl_Polyhedron_t *, FILE *);
void ppl_insert_dimensions (ppl_Polyhedron_t, int, int);
void ppl_insert_dimensions_pointset (ppl_Pointset_Powerset_C_Polyhedron_t, int,
int);
void ppl_set_inhomogeneous_gmp (ppl_Linear_Expression_t, Value);
void ppl_set_coef_gmp (ppl_Linear_Expression_t, ppl_dimension_type, Value);
/* Assigns to RES the value of the INTEGER_CST T. */
static inline void
tree_int_to_gmp (tree t, Value res)
{
double_int di = tree_to_double_int (t);
mpz_set_double_int (res, di, TYPE_UNSIGNED (TREE_TYPE (t)));
}
/* Converts a GMP constant VAL to a tree and returns it. */
static inline tree
gmp_cst_to_tree (tree type, Value val)
{
tree t = type ? type : integer_type_node;
Value tmp;
double_int di;
value_init (tmp);
value_assign (tmp, val);
di = mpz_get_double_int (t, tmp, true);
value_clear (tmp);
return double_int_to_tree (t, di);
}
/* Set the inhomogeneous term of E to the integer X. */
static inline void
ppl_set_inhomogeneous (ppl_Linear_Expression_t e, int x)
{
Value v;
value_init (v);
value_set_si (v, x);
ppl_set_inhomogeneous_gmp (e, v);
value_clear (v);
}
/* Set the inhomogeneous term of E to the tree X. */
static inline void
ppl_set_inhomogeneous_tree (ppl_Linear_Expression_t e, tree x)
{
Value v;
value_init (v);
tree_int_to_gmp (x, v);
ppl_set_inhomogeneous_gmp (e, v);
value_clear (v);
}
/* Set E[I] to integer X. */
static inline void
ppl_set_coef (ppl_Linear_Expression_t e, ppl_dimension_type i, int x)
{
Value v;
value_init (v);
value_set_si (v, x);
ppl_set_coef_gmp (e, i, v);
value_clear (v);
}
/* Set E[I] to tree X. */
static inline void
ppl_set_coef_tree (ppl_Linear_Expression_t e, ppl_dimension_type i, tree x)
{
Value v;
value_init (v);
tree_int_to_gmp (x, v);
ppl_set_coef_gmp (e, i, v);
value_clear (v);
}
/* Sets RES to the max of V1 and V2. */
static inline void
value_max (Value res, Value v1, Value v2)
{
if (value_compare (v1, v2) < 0)
value_assign (res, v2);
value_assign (res, v1);
}
#endif
/* Detection of Static Control Parts (SCoP) for Graphite.
Copyright (C) 2009 Free Software Foundation, Inc.
Contributed by Sebastian Pop <sebastian.pop@amd.com> and
Tobias Grosser <grosser@fim.uni-passau.de>.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
extern void build_scops (VEC (scop_p, heap) **);
extern void build_scop_bbs (scop_p);
extern int nb_reductions_in_loop (loop_p);
extern void dot_all_scops (VEC (scop_p, heap) *);
extern void dot_scop (scop_p);
/* Conversion of SESE regions to Polyhedra.
Copyright (C) 2009 Free Software Foundation, Inc.
Contributed by Sebastian Pop <sebastian.pop@amd.com>.
This file is part of GCC.
GCC is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3, or (at your option)
any later version.
GCC is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3. If not see
<http://www.gnu.org/licenses/>. */
#ifndef GCC_GRAPHITE_SESE_TO_POLY_H
#define GCC_GRAPHITE_SESE_TO_POLY_H
bool build_poly_scop (scop_p);
void check_poly_representation (scop_p);
#endif
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment