diff options
author | spop <spop@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-09-30 21:16:10 +0000 |
---|---|---|
committer | spop <spop@138bc75d-0d04-0410-961f-82ee72b054a4> | 2010-09-30 21:16:10 +0000 |
commit | 8c4b14b0ff2387b3a5fd8fb7cd91ce5d86b10ac1 (patch) | |
tree | 6feb4aded8057ea7f65b1e0847fd6c2f973acaae | |
parent | 2006b4537145bf98d9b2e1026eb74f855d3003c8 (diff) | |
download | gcc-8c4b14b0ff2387b3a5fd8fb7cd91ce5d86b10ac1.tar.gz |
Write OpenScop format.
2010-07-29 Riyadh Baghdadi <baghdadi.mr@gmail.com>
* graphite-cloog-util.c (openscop_print_cloog_matrix): New.
(openscop_print_polyhedron_matrix): New.
* graphite-cloog-util.h (openscop_print_polyhedron_matrix): Declared.
* graphite-poly.c (openscop_print_pdr_polyhedron): Same.
(openscop_print_pdr_powerset): New.
(openscop_print_powerset_matrix): New.
(openscop_print_scattering_function_1): New.
(print_scattering_function): Add support for scattering names and
OpenScop format.
(graphite_write_transforms): Remove.
(apply_poly_transforms): Updated to call print_scop.
(print_pdr_access_layout): Updated to support OpenScop format.
(print_pdr): Same.
(openscop_print_pbb_domain): New.
(print_pbb_body): Added a parameter to allow indicating that pbb_body is
not provided.
(print_pbb): Updated to call the new print_pbb_body.
(openscop_print_scop_context): New.
(print_scop_header): New.
(print_scop): Updated to call print_scop_header.
* graphite-poly.h: Document OpenScop format.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@164770 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ChangeLog | 23 | ||||
-rw-r--r-- | gcc/ChangeLog.graphite | 24 | ||||
-rw-r--r-- | gcc/graphite-cloog-util.c | 39 | ||||
-rw-r--r-- | gcc/graphite-cloog-util.h | 2 | ||||
-rw-r--r-- | gcc/graphite-poly.c | 303 | ||||
-rw-r--r-- | gcc/graphite-poly.h | 49 |
6 files changed, 416 insertions, 24 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 0409d96d21d..b4a7367ae70 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,26 @@ +2010-09-30 Riyadh Baghdadi <baghdadi.mr@gmail.com> + + * graphite-cloog-util.c (openscop_print_cloog_matrix): New. + (openscop_print_polyhedron_matrix): New. + * graphite-cloog-util.h (openscop_print_polyhedron_matrix): Declared. + * graphite-poly.c (openscop_print_pdr_polyhedron): Same. + (openscop_print_pdr_powerset): New. + (openscop_print_powerset_matrix): New. + (openscop_print_scattering_function_1): New. + (print_scattering_function): Add support for scattering names and + OpenScop format. + (graphite_write_transforms): Remove. + (print_pdr_access_layout): Updated to support OpenScop format. + (print_pdr): Same. + (openscop_print_pbb_domain): New. + (print_pbb_body): Added a parameter to allow indicating that pbb_body is + not provided. + (print_pbb): Updated to call the new print_pbb_body. + (openscop_print_scop_context): New. + (print_scop_header): New. + (print_scop): Updated to call print_scop_header. + * graphite-poly.h: Document OpenScop format. + 2010-09-30 Anatoly Sokolov <aesok@post.ru> * config/cris/m32c.c (cris_memory_move_cost): New. diff --git a/gcc/ChangeLog.graphite b/gcc/ChangeLog.graphite index e43d2ce50db..50c1e130acc 100644 --- a/gcc/ChangeLog.graphite +++ b/gcc/ChangeLog.graphite @@ -1,3 +1,27 @@ +2010-07-29 Riyadh Baghdadi <baghdadi.mr@gmail.com> + + * graphite-cloog-util.c (openscop_print_cloog_matrix): New. + (openscop_print_polyhedron_matrix): New. + * graphite-cloog-util.h (openscop_print_polyhedron_matrix): Declared. + * graphite-poly.c (openscop_print_pdr_polyhedron): Same. + (openscop_print_pdr_powerset): New. + (openscop_print_powerset_matrix): New. + (openscop_print_scattering_function_1): New. + (print_scattering_function): Add support for scattering names and + OpenScop format. + (graphite_write_transforms): Remove. + (apply_poly_transforms): Updated to call print_scop. + (print_pdr_access_layout): Updated to support OpenScop format. + (print_pdr): Same. + (openscop_print_pbb_domain): New. + (print_pbb_body): Added a parameter to allow indicating that pbb_body is + not provided. + (print_pbb): Updated to call the new print_pbb_body. + (openscop_print_scop_context): New. + (print_scop_header): New. + (print_scop): Updated to call print_scop_header. + * graphite-poly.h: Document OpenScop format. + 2010-07-29 Sebastian Pop <sebastian.pop@amd.com> * graphite-sese-to-poly.c (rewrite_close_phi_out_of_ssa): Add back diff --git a/gcc/graphite-cloog-util.c b/gcc/graphite-cloog-util.c index 17704580bc0..0bb5d742586 100644 --- a/gcc/graphite-cloog-util.c +++ b/gcc/graphite-cloog-util.c @@ -296,4 +296,43 @@ new_Cloog_Domain_from_ppl_Pointset_Powerset return res; } + +/* Print to FILE the matrix MAT in OpenScop format. OUTPUT is the number + of output dimensions, INPUT is the number of input dimensions, LOCALS + is the number of existentially quantified variables and PARAMS is the + number of parameters. */ + +static void +openscop_print_cloog_matrix (FILE *file, CloogMatrix *mat, + int output, int input, int locals, + int params) +{ + int i, j; + + fprintf (file, "%d %d %d %d %d %d \n", cloog_matrix_nrows (mat), + cloog_matrix_ncolumns (mat), output, input, locals, params); + + for (i = 0; i < cloog_matrix_nrows (mat); i++) + { + for (j = 0; j < cloog_matrix_ncolumns (mat); j++) + fprintf (file, "%6ld ", mpz_get_si (mat->p[i][j])); + fprintf (file, "\n"); + } +} + +/* Print to FILE the polyhedron PH in OpenScop format. OUTPUT is the number + of output dimensions, INPUT is the number of input dimensions, LOCALS is + the number of existentially quantified variables and PARAMS is the number + of parameters. */ + +void +openscop_print_polyhedron_matrix (FILE *file, ppl_const_Polyhedron_t ph, + int output, int input, int locals, + int params) +{ + CloogMatrix *mat = new_Cloog_Matrix_from_ppl_Polyhedron (ph); + openscop_print_cloog_matrix (file, mat, output, input, locals, params); + cloog_matrix_free (mat); +} + #endif diff --git a/gcc/graphite-cloog-util.h b/gcc/graphite-cloog-util.h index d7758ce197d..62e2f94dd82 100644 --- a/gcc/graphite-cloog-util.h +++ b/gcc/graphite-cloog-util.h @@ -32,5 +32,7 @@ CloogScattering *new_Cloog_Scattering_from_ppl_Polyhedron CloogDomain * new_Cloog_Domain_from_ppl_Pointset_Powerset (ppl_Pointset_Powerset_C_Polyhedron_t, int, CloogState *); void new_C_Polyhedron_from_Cloog_Matrix (ppl_Polyhedron_t *, CloogMatrix *); +void openscop_print_polyhedron_matrix (FILE *, ppl_const_Polyhedron_t, int, + int, int, int); #endif /* GRAPHITE_CLOOG_UTIL_H */ diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c index ffd01f92d52..c886e1184be 100644 --- a/gcc/graphite-poly.c +++ b/gcc/graphite-poly.c @@ -44,6 +44,7 @@ along with GCC; see the file COPYING3. If not see #include "pointer-set.h" #include "gimple.h" #include "params.h" +#include "graphite-cloog-util.h" #ifdef HAVE_cloog #include "ppl_c.h" @@ -136,6 +137,159 @@ unify_scattering_dimensions (scop_p scop) return max_scattering; } +/* Print to FILE the pdr PH in OpenScop format. NB_SUBSCRIPTS is the number + of subscripts in PH, ALIAS_SET_DIM is the dimension of the alias set and + NB_PARAMS is the number of parameters in PH. */ + +static void +openscop_print_pdr_polyhedron (FILE *file, ppl_const_Polyhedron_t ph, + int nb_subscripts, int alias_set_dimension, + int nb_params) +{ + int input, locals, output; + ppl_dimension_type alias_set_dim = (ppl_dimension_type) alias_set_dimension; + ppl_dimension_type sub_dim_last = alias_set_dim + nb_subscripts; + ppl_dimension_type *map, i, ph_space_dim = sub_dim_last + 1; + ppl_Polyhedron_t pph; + + ppl_new_C_Polyhedron_from_C_Polyhedron (&pph,ph); + + map = (ppl_dimension_type *) XNEWVEC (ppl_dimension_type, ph_space_dim); + + for (i = 0; i < alias_set_dim - 1; i++) + map[i] = nb_subscripts + 1 + i; + + for (i = alias_set_dim - 1; i < sub_dim_last; i++) + map[i] = i - alias_set_dim + 1; + + ppl_Polyhedron_map_space_dimensions (pph, map, ph_space_dim - 1); + + locals = 0; + input = alias_set_dim - nb_params - 1; + + /* According to OpenScop specification, the alias set column is a part of + the output columns. */ + output = nb_subscripts + 1; + + openscop_print_polyhedron_matrix (file, ph, output, input, locals, nb_params); +} + +/* Print to FILE the powerset PDR. NB_SUBSCRIPTS is the number of subscripts + in PDR, ALIAS_SET_DIM is the dimension of the alias set in PDR and + NB_PARAMS is the number of parameters in PDR. */ + +static void +openscop_print_pdr_powerset (FILE *file, + ppl_Pointset_Powerset_C_Polyhedron_t ps, + int nb_subscripts, + int alias_set_dim, + int nb_params) +{ + size_t nb_disjuncts; + ppl_Pointset_Powerset_C_Polyhedron_iterator_t it, end; + + ppl_new_Pointset_Powerset_C_Polyhedron_iterator (&it); + ppl_new_Pointset_Powerset_C_Polyhedron_iterator (&end); + + ppl_Pointset_Powerset_C_Polyhedron_size (ps, &nb_disjuncts); + fprintf (file, "%d\n", (int) nb_disjuncts); + + for (ppl_Pointset_Powerset_C_Polyhedron_iterator_begin (ps, it), + ppl_Pointset_Powerset_C_Polyhedron_iterator_end (ps, end); + !ppl_Pointset_Powerset_C_Polyhedron_iterator_equal_test (it, end); + ppl_Pointset_Powerset_C_Polyhedron_iterator_increment (it)) + { + ppl_const_Polyhedron_t ph; + + ppl_Pointset_Powerset_C_Polyhedron_iterator_dereference (it, &ph); + openscop_print_pdr_polyhedron (file, ph, nb_subscripts, alias_set_dim, + nb_params); + } + + ppl_delete_Pointset_Powerset_C_Polyhedron_iterator (it); + ppl_delete_Pointset_Powerset_C_Polyhedron_iterator (end); +} + +/* Print to FILE the powerset PS in its OpenScop matrix form. */ + +static void +openscop_print_powerset_matrix (FILE *file, + ppl_Pointset_Powerset_C_Polyhedron_t ps, + int output, int input, int locals, + int params) +{ + size_t nb_disjuncts; + ppl_Pointset_Powerset_C_Polyhedron_iterator_t it, end; + + ppl_new_Pointset_Powerset_C_Polyhedron_iterator (&it); + ppl_new_Pointset_Powerset_C_Polyhedron_iterator (&end); + + ppl_Pointset_Powerset_C_Polyhedron_size (ps, &nb_disjuncts); + fprintf (file, "%d\n", (int) nb_disjuncts); + + for (ppl_Pointset_Powerset_C_Polyhedron_iterator_begin (ps, it), + ppl_Pointset_Powerset_C_Polyhedron_iterator_end (ps, end); + !ppl_Pointset_Powerset_C_Polyhedron_iterator_equal_test (it, end); + ppl_Pointset_Powerset_C_Polyhedron_iterator_increment (it)) + { + ppl_const_Polyhedron_t ph; + + ppl_Pointset_Powerset_C_Polyhedron_iterator_dereference (it, &ph); + openscop_print_polyhedron_matrix (file, ph, output, input, locals, + params); + } + + ppl_delete_Pointset_Powerset_C_Polyhedron_iterator (it); + ppl_delete_Pointset_Powerset_C_Polyhedron_iterator (end); +} + +/* Prints to FILE the scattering function of PBB in OpenScop format, at some + VERBOSITY level. */ + +static void +openscop_print_scattering_function_1 (FILE *file, poly_bb_p pbb, int verbosity) +{ + graphite_dim_t i; + ppl_const_Polyhedron_t ph; + + if (verbosity > 0) + { + fprintf (file, "# scattering bb_%d (\n", pbb_index (pbb)); + fprintf (file, "# eq"); + + for (i = 0; i < pbb_nb_scattering_transform (pbb); i++) + fprintf (file, " s%d", (int) i); + + for (i = 0; i < pbb_nb_local_vars (pbb); i++) + fprintf (file, " lv%d", (int) i); + + for (i = 0; i < pbb_dim_iter_domain (pbb); i++) + fprintf (file, " i%d", (int) i); + + for (i = 0; i < pbb_nb_params (pbb); i++) + fprintf (file, " p%d", (int) i); + + fprintf (file, " cst\n"); + } + + /* Number of disjunct components. Remove this when + PBB_TRANSFORMED_SCATTERING will be a pointset_powerset. */ + fprintf (file, "1\n"); + + ph = PBB_TRANSFORMED_SCATTERING (pbb) + ? PBB_TRANSFORMED_SCATTERING (pbb) + : PBB_ORIGINAL_SCATTERING (pbb); + + openscop_print_polyhedron_matrix (file, ph, + pbb_nb_scattering_transform (pbb), + pbb_dim_iter_domain (pbb), + pbb_nb_local_vars (pbb), + pbb_nb_params (pbb)); + + if (verbosity > 0) + fprintf (file, "#)\n"); +} + /* Prints to FILE the scattering function of PBB, at some VERBOSITY level. */ @@ -201,7 +355,13 @@ print_scattering_function (FILE *file, poly_bb_p pbb, int verbosity) return; } - print_scattering_function_1 (file, pbb, verbosity); + openscop_print_scattering_function_1 (file, pbb, verbosity); + + if (verbosity > 0) + fprintf (file, "# Scattering names are not provided\n"); + + fprintf (file, "0\n"); + } /* Prints to FILE the iteration domain of PBB, at some VERBOSITY @@ -430,23 +590,23 @@ free_poly_bb (poly_bb_p pbb) } static void -print_pdr_access_layout (FILE *file, poly_dr_p pdr) +print_pdr_access_layout (FILE *file, poly_bb_p pbb, poly_dr_p pdr) { graphite_dim_t i; fprintf (file, "# eq"); - for (i = 0; i < pdr_dim_iter_domain (pdr); i++) - fprintf (file, " i%d", (int) i); - - for (i = 0; i < pdr_nb_params (pdr); i++) - fprintf (file, " p%d", (int) i); - - fprintf (file, " alias"); + fprintf (file, " alias"); for (i = 0; i < PDR_NB_SUBSCRIPTS (pdr); i++) fprintf (file, " sub%d", (int) i); + for (i = 0; i < pbb_dim_iter_domain (pbb); i++) + fprintf (file, " i%d", (int) i); + + for (i = 0; i < pbb_nb_params (pbb); i++) + fprintf (file, " p%d", (int) i); + fprintf (file, " cst\n"); } @@ -456,6 +616,8 @@ print_pdr_access_layout (FILE *file, poly_dr_p pdr) void print_pdr (FILE *file, poly_dr_p pdr, int verbosity) { + int alias_set_dim; + if (verbosity > 1) { fprintf (file, "# pdr_%d (", PDR_ID (pdr)); @@ -484,10 +646,16 @@ print_pdr (FILE *file, poly_dr_p pdr, int verbosity) if (verbosity > 0) { fprintf (file, "# data accesses (\n"); - print_pdr_access_layout (file, pdr); + print_pdr_access_layout (file, PDR_PBB (pdr), pdr); } - ppl_print_powerset_matrix (file, PDR_ACCESSES (pdr)); + alias_set_dim = pdr_alias_set_dim (pdr) + 1; + + openscop_print_pdr_powerset (file, + PDR_ACCESSES (pdr), + PDR_NB_SUBSCRIPTS (pdr), + alias_set_dim, + pbb_nb_params (PDR_PBB (pdr))); if (verbosity > 0) fprintf (file, "#)\n"); @@ -548,6 +716,45 @@ free_scop (scop_p scop) XDELETE (scop); } +/* Print to FILE the domain of PBB in OpenScop format, at some VERBOSITY + level. */ + +static void +openscop_print_pbb_domain (FILE *file, poly_bb_p pbb, int verbosity) +{ + graphite_dim_t i; + gimple_bb_p gbb = PBB_BLACK_BOX (pbb); + + if (!PBB_DOMAIN (pbb)) + return; + + if (verbosity > 0) + { + fprintf (file, "\n# Iteration domain of bb_%d (\n", GBB_BB (gbb)->index); + fprintf (file, "# eq"); + + for (i = 0; i < pbb_dim_iter_domain (pbb); i++) + fprintf (file, " i%d", (int) i); + + for (i = 0; i < pbb_nb_params (pbb); i++) + fprintf (file, " p%d", (int) i); + + fprintf (file, " cst\n"); + } + + if (PBB_DOMAIN (pbb)) + openscop_print_powerset_matrix (file, PBB_DOMAIN (pbb), + pbb_dim_iter_domain (pbb), + 0, + 0, + pbb_nb_params (pbb)); + else + fprintf (file, "0\n"); + + if (verbosity > 0) + fprintf (file, "#)\n"); +} + /* Print to FILE the domain of PBB, at some VERBOSITY level. */ void @@ -708,14 +915,25 @@ debug_pdrs (poly_bb_p pbb, int verbosity) print_pdrs (stderr, pbb, verbosity); } -/* Print to FILE the body of PBB, at some VERBOSITY level. */ +/* Print to FILE the body of PBB, at some VERBOSITY level. + If statement_body_provided is false statement body is not printed. */ static void -print_pbb_body (FILE *file, poly_bb_p pbb, int verbosity) +print_pbb_body (FILE *file, poly_bb_p pbb, int verbosity, + bool statement_body_provided) { if (verbosity > 1) fprintf (file, "# Body (\n"); + if (!statement_body_provided) + { + if (verbosity > 0) + fprintf (file, "# Statement body is not provided\n"); + + fprintf (file, "0\n"); + return; + } + if (verbosity > 0) fprintf (file, "# Statement body is provided\n"); fprintf (file, "1\n"); @@ -747,10 +965,10 @@ print_pbb (FILE *file, poly_bb_p pbb, int verbosity) dump_gbb_cases (file, PBB_BLACK_BOX (pbb)); } - print_pbb_domain (file, pbb, verbosity); + openscop_print_pbb_domain (file, pbb, verbosity); print_scattering_function (file, pbb, verbosity); print_pdrs (file, pbb, verbosity); - print_pbb_body (file, pbb, verbosity); + print_pbb_body (file, pbb, verbosity, false); if (verbosity > 1) fprintf (file, "#)\n"); @@ -796,6 +1014,36 @@ print_scop_params (FILE *file, scop_p scop, int verbosity) fprintf (file, "#)\n"); } +/* Print to FILE the context of SCoP in OpenScop format, at some VERBOSITY + level. */ + +static void +openscop_print_scop_context (FILE *file, scop_p scop, int verbosity) +{ + graphite_dim_t i; + + if (verbosity > 0) + { + fprintf (file, "# Context (\n"); + fprintf (file, "# eq"); + + for (i = 0; i < scop_nb_params (scop); i++) + fprintf (file, " p%d", (int) i); + + fprintf (file, " cst\n"); + } + + if (SCOP_CONTEXT (scop)) + openscop_print_powerset_matrix (file, SCOP_CONTEXT (scop), 0, 0, 0, + scop_nb_params (scop)); + else + fprintf (file, "0 %d 0 0 0 %d\n", (int) scop_nb_params (scop) + 2, + (int) scop_nb_params (scop)); + + if (verbosity > 0) + fprintf (file, "# )\n"); +} + /* Print to FILE the context of SCoP, at some VERBOSITY level. */ void @@ -823,23 +1071,32 @@ print_scop_context (FILE *file, scop_p scop, int verbosity) fprintf (file, "# )\n"); } -/* Print to FILE the SCOP, at some VERBOSITY level. */ +/* Print to FILE the SCOP header: context, parameters, and statements + number. */ -void -print_scop (FILE *file, scop_p scop, int verbosity) +static void +print_scop_header (FILE *file, scop_p scop, int verbosity) { - int i; - poly_bb_p pbb; - - fprintf (file, "SCoP #(\n"); + fprintf (file, "SCoP 1\n#(\n"); fprintf (file, "# Language\nGimple\n"); - print_scop_context (file, scop, verbosity); + openscop_print_scop_context (file, scop, verbosity); print_scop_params (file, scop, verbosity); if (verbosity > 0) fprintf (file, "# Number of statements\n"); fprintf (file, "%d\n",VEC_length (poly_bb_p, SCOP_BBS (scop))); +} + +/* Print to FILE the SCOP, at some VERBOSITY level. */ + +void +print_scop (FILE *file, scop_p scop, int verbosity) +{ + int i; + poly_bb_p pbb; + + print_scop_header (file, scop, verbosity); FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb) print_pbb (file, pbb, verbosity); diff --git a/gcc/graphite-poly.h b/gcc/graphite-poly.h index 5f858ebaad5..0e1aa1f0d34 100644 --- a/gcc/graphite-poly.h +++ b/gcc/graphite-poly.h @@ -132,7 +132,54 @@ struct poly_dr dimensions. | i j k a 1 - | 0 0 0 -1 15 = 0 */ + | 0 0 0 -1 15 = 0 + + The difference between the graphite internal format for access data and + the OpenSop format is in the order of columns. + Instead of having: + + | i j k a s0 s1 1 + | 0 0 0 1 0 0 -5 = 0 + |-1 0 0 0 1 0 0 = 0 + | 0 -1 -1 0 0 1 0 = 0 + | 0 0 0 0 1 0 0 >= 0 # The last four lines describe the + | 0 0 0 0 0 1 0 >= 0 # array size. + | 0 0 0 0 -1 0 1335 >= 0 + | 0 0 0 0 0 -1 123 >= 0 + + In OpenScop we have: + + | a s0 s1 i j k 1 + | 1 0 0 0 0 0 -5 = 0 + | 0 1 0 -1 0 0 0 = 0 + | 0 0 1 0 -1 -1 0 = 0 + | 0 1 0 0 0 0 0 >= 0 # The last four lines describe the + | 0 0 1 0 0 0 0 >= 0 # array size. + | 0 -1 0 0 0 0 1335 >= 0 + | 0 0 -1 0 0 0 123 >= 0 + + The OpenScop access function is printed as follows: + + | 1 # The number of disjunct components in a union of access functions. + | R C O I L P # Described bellow. + | a s0 s1 i j k 1 + | 1 0 0 0 0 0 -5 = 0 + | 0 1 0 -1 0 0 0 = 0 + | 0 0 1 0 -1 -1 0 = 0 + | 0 1 0 0 0 0 0 >= 0 # The last four lines describe the + | 0 0 1 0 0 0 0 >= 0 # array size. + | 0 -1 0 0 0 0 1335 >= 0 + | 0 0 -1 0 0 0 123 >= 0 + + Where: + - R: Number of rows. + - C: Number of columns. + - O: Number of output dimensions = alias set + number of subscripts. + - I: Number of input dimensions (iterators). + - L: Number of local (existentially quantified) dimensions. + - P: Number of parameters. + + In the example, the vector "R C O I L P" is "7 7 3 2 0 1". */ ppl_Pointset_Powerset_C_Polyhedron_t accesses; /* Data reference's base object set number, we must assure 2 pdrs are in the |