From patchwork Mon Aug 15 07:12:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Pop X-Patchwork-Id: 110000 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id B372EB720B for ; Mon, 15 Aug 2011 17:15:24 +1000 (EST) Received: (qmail 13819 invoked by alias); 15 Aug 2011 07:14:26 -0000 Received: (qmail 13519 invoked by uid 22791); 15 Aug 2011 07:14:21 -0000 X-SWARE-Spam-Status: No, hits=-2.6 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, TW_GB, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mail-gy0-f175.google.com (HELO mail-gy0-f175.google.com) (209.85.160.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 15 Aug 2011 07:14:02 +0000 Received: by mail-gy0-f175.google.com with SMTP id 4so3147441gyg.20 for ; Mon, 15 Aug 2011 00:14:01 -0700 (PDT) Received: by 10.91.3.11 with SMTP id f11mr1537849agi.88.1313392441549; Mon, 15 Aug 2011 00:14:01 -0700 (PDT) Received: from napoca (adsl-99-184-92-236.dsl.austtx.sbcglobal.net [99.184.92.236]) by mx.google.com with ESMTPS id d7sm4928804anb.14.2011.08.15.00.13.59 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 15 Aug 2011 00:14:01 -0700 (PDT) Received: by napoca (sSMTP sendmail emulation); Mon, 15 Aug 2011 02:13:58 -0500 From: Sebastian Pop To: skimo@kotnet.org, tobias@grosser.es Cc: gcc-patches@gcc.gnu.org, Sebastian Pop Subject: [PATCH 13/20] add pbb->schedule Date: Mon, 15 Aug 2011 02:12:52 -0500 Message-Id: <1313392379-1525-13-git-send-email-sebpop@gmail.com> In-Reply-To: <1313392379-1525-1-git-send-email-sebpop@gmail.com> References: <1313392379-1525-1-git-send-email-sebpop@gmail.com> X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org --- gcc/graphite-poly.c | 6 ++++ gcc/graphite-poly.h | 6 ++++ gcc/graphite-sese-to-poly.c | 55 ++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 64 insertions(+), 3 deletions(-) diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c index ce0649b..3d81372 100644 --- a/gcc/graphite-poly.c +++ b/gcc/graphite-poly.c @@ -881,6 +881,9 @@ new_poly_bb (scop_p scop, void *black_box) PBB_DOMAIN (pbb) = NULL; pbb->domain = NULL; + pbb->schedule = NULL; + pbb->transformed = NULL; + pbb->saved = NULL; PBB_SCOP (pbb) = scop; pbb_set_black_box (pbb, black_box); PBB_TRANSFORMED (pbb) = NULL; @@ -906,6 +909,9 @@ free_poly_bb (poly_bb_p pbb) ppl_delete_Pointset_Powerset_C_Polyhedron (PBB_DOMAIN (pbb)); isl_set_free (pbb->domain); + isl_map_free (pbb->schedule); + isl_map_free (pbb->transformed); + isl_map_free (pbb->saved); if (PBB_TRANSFORMED (pbb)) poly_scattering_free (PBB_TRANSFORMED (pbb)); diff --git a/gcc/graphite-poly.h b/gcc/graphite-poly.h index 3483ef0..b6e5277 100644 --- a/gcc/graphite-poly.h +++ b/gcc/graphite-poly.h @@ -1521,6 +1521,9 @@ store_scattering_pbb (poly_bb_p pbb) poly_scattering_free (PBB_SAVED (pbb)); PBB_SAVED (pbb) = poly_scattering_copy (PBB_TRANSFORMED (pbb)); + + isl_map_free (pbb->saved); + pbb->saved = isl_map_copy (pbb->transformed); } /* Stores the SCOP_TRANSFORMED_SCHEDULE to SCOP_SAVED_SCHEDULE. */ @@ -1568,6 +1571,9 @@ restore_scattering_pbb (poly_bb_p pbb) poly_scattering_free (PBB_TRANSFORMED (pbb)); PBB_TRANSFORMED (pbb) = poly_scattering_copy (PBB_SAVED (pbb)); + + isl_map_free (pbb->transformed); + pbb->transformed = isl_map_copy (pbb->saved); } /* Restores the scattering for all the pbbs in the SCOP. */ diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c index 20bcf1f..9407a8d 100644 --- a/gcc/graphite-sese-to-poly.c +++ b/gcc/graphite-sese-to-poly.c @@ -407,6 +407,16 @@ build_scop_bbs (scop_p scop) sbitmap_free (visited); } +/* Return an ISL identifier for the polyhedral basic block PBB. */ + +static isl_id * +isl_id_for_pbb (scop_p s, poly_bb_p pbb) +{ + char name[50]; + snprintf (name, sizeof (name), "S_%d", pbb_index (pbb)); + return isl_id_alloc (s->ctx, name, pbb); +} + /* Converts the STATIC_SCHEDULE of PBB into a scattering polyhedron. We generate SCATTERING_DIMENSIONS scattering dimensions. @@ -441,7 +451,8 @@ build_scop_bbs (scop_p scop) | 0 0 1 0 0 0 0 0 -5 = 0 */ static void -build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t static_schedule, +build_pbb_scattering_polyhedrons (isl_aff *static_sched, + ppl_Linear_Expression_t static_schedule, poly_bb_p pbb, int scattering_dimensions) { int i; @@ -452,9 +463,11 @@ build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t static_schedule, ppl_Coefficient_t c; ppl_dimension_type dim = scattering_dimensions + nb_iterators + nb_params; mpz_t v; + isl_int val; gcc_assert (scattering_dimensions >= used_scattering_dimensions); + isl_int_init (val); mpz_init (v); ppl_new_Coefficient (&c); PBB_TRANSFORMED (pbb) = poly_scattering_new (); @@ -463,6 +476,15 @@ build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t static_schedule, PBB_NB_SCATTERING_TRANSFORM (pbb) = scattering_dimensions; + { + isl_dim *dc = isl_set_get_dim (pbb->domain); + isl_dim *dm = isl_dim_add (isl_dim_from_domain (dc), + isl_dim_out, scattering_dimensions); + pbb->schedule = isl_map_universe (dm); + pbb->schedule = isl_map_set_tuple_id (pbb->schedule, isl_dim_in, + isl_id_for_pbb (scop, pbb)); + } + for (i = 0; i < scattering_dimensions; i++) { ppl_Constraint_t cstr; @@ -481,6 +503,20 @@ build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t static_schedule, mpz_neg (v, v); ppl_assign_Coefficient_from_mpz_t (c, v); ppl_Linear_Expression_add_to_inhomogeneous (expr, c); + + { + isl_constraint *c = isl_equality_alloc + (isl_map_get_dim (pbb->schedule)); + + if (0 != isl_aff_get_coefficient (static_sched, isl_dim_set, + i / 2, &val)) + gcc_unreachable (); + + isl_int_neg (val, val); + c = isl_constraint_set_constant (c, val); + c = isl_constraint_set_coefficient_si (c, isl_dim_out, i, 1); + pbb->schedule = isl_map_add_constraint (pbb->schedule, c); + } } /* Iterations of this loop. */ @@ -492,6 +528,10 @@ build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t static_schedule, ppl_assign_Coefficient_from_mpz_t (c, v); ppl_Linear_Expression_add_to_coefficient (expr, scattering_dimensions + loop, c); + + loop = (i + 1) / 2; + pbb->schedule = isl_map_equate (pbb->schedule, isl_dim_in, loop, + isl_dim_out, i); } ppl_new_Constraint (&cstr, expr, PPL_CONSTRAINT_TYPE_EQUAL); @@ -500,10 +540,12 @@ build_pbb_scattering_polyhedrons (ppl_Linear_Expression_t static_schedule, ppl_delete_Constraint (cstr); } + isl_int_clear (val); mpz_clear (v); ppl_delete_Coefficient (c); PBB_ORIGINAL (pbb) = poly_scattering_copy (PBB_TRANSFORMED (pbb)); + pbb->transformed = isl_map_copy (pbb->schedule); } /* Build for BB the static schedule. @@ -551,6 +593,8 @@ build_scop_scattering (scop_p scop) ppl_Linear_Expression_t static_schedule; ppl_Coefficient_t c; mpz_t v; + isl_dim *dc = isl_set_get_dim (scop->context); + isl_aff *static_sched = isl_aff_zero (isl_local_space_from_dim (dc)); mpz_init (v); ppl_new_Coefficient (&c); @@ -564,6 +608,8 @@ build_scop_scattering (scop_p scop) ppl_assign_Coefficient_from_mpz_t (c, v); ppl_Linear_Expression_add_to_coefficient (static_schedule, 0, c); + static_sched = isl_aff_add_coefficient_si (static_sched, isl_dim_set, 0, -1); + FOR_EACH_VEC_ELT (poly_bb_p, SCOP_BBS (scop), i, pbb) { gimple_bb_p gbb = PBB_BLACK_BOX (pbb); @@ -587,11 +633,14 @@ build_scop_scattering (scop_p scop) ppl_assign_Linear_Expression_from_Linear_Expression (static_schedule, common); - build_pbb_scattering_polyhedrons (common, pbb, nb_scat_dims); - + static_sched = isl_aff_add_coefficient_si (static_sched, isl_dim_set, + prefix, 1); + build_pbb_scattering_polyhedrons (static_sched, common, pbb, + nb_scat_dims); ppl_delete_Linear_Expression (common); } + isl_aff_free (static_sched); mpz_clear (v); ppl_delete_Coefficient (c); ppl_delete_Linear_Expression (static_schedule);