From patchwork Fri Nov 6 23:35:43 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Pop X-Patchwork-Id: 541161 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id E70E21402D5 for ; Sat, 7 Nov 2015 10:35:55 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=Zb6UBW1W; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; q=dns; s= default; b=syHIx4zYMj+m7FywALgM0PDPHCcbi3rYw30+FR2rlHz9EbJzd7WAv eCe+FbCDhAn9vG7NzAs5vDo8TtYsUMy8IN3B4+5HX4ocXgfz4t7UWb6vlb4Kdjgc KLjY9RULQnPh8T9Be6mw4TPppY3MSA3dq//ekoM1IG9yK8xTgBw9cA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :to:cc:subject:date:message-id:in-reply-to:references; s= default; bh=b2/kAyrWBXZ+bWkpQsw3V2+fD9M=; b=Zb6UBW1W3Hsftyh+p8zr l1ZrQ6ySTTETB7FrjYL6GIG7ZDuATWySCdMTaLPvPNH2fEZISE8uLhyfxaSj8K9F 4E55bYPHHvwb3Lalfu0T5YbDJmYJ0s3NQEUduCEiebqys4NkpeTu9FvMxRzwuISA liMqI2NYm05CoLoZ9tEHx7Q= Received: (qmail 114007 invoked by alias); 6 Nov 2015 23:35:49 -0000 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 Received: (qmail 113968 invoked by uid 89); 6 Nov 2015 23:35:48 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=1.7 required=5.0 tests=AWL, BAYES_50, KAM_LAZY_DOMAIN_SECURITY, TVD_RCVD_IP autolearn=no version=3.3.2 X-HELO: mailhost.sarc.sas Received: from 72-48-121-251.static.grandenetworks.net (HELO mailhost.sarc.sas) (72.48.121.251) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 06 Nov 2015 23:35:46 +0000 Received: from cc01.spa.sarc.sas (cc01.spa.sarc.sas [172.31.207.194]) by mailhost.sarc.sas (Postfix) with ESMTP id 2F20A2E0E2; Fri, 6 Nov 2015 17:35:45 -0600 (CST) Received: by cc01.spa.sarc.sas (Postfix, from userid 12626) id 0FDF156C5F1; Fri, 6 Nov 2015 17:35:44 -0600 (CST) From: Sebastian Pop To: sebpop@gmail.com Cc: gcc-patches@gcc.gnu.org, hiraditya@gmail.com, Abderrazek Zaafrani Subject: [PATCH 2/2] add original schedule to scop Date: Fri, 6 Nov 2015 17:35:43 -0600 Message-Id: <1446852943-31874-2-git-send-email-s.pop@samsung.com> In-Reply-To: <1446852943-31874-1-git-send-email-s.pop@samsung.com> References: <1446852943-31874-1-git-send-email-s.pop@samsung.com> From: Abderrazek Zaafrani * graphite-optimize-isl.c (optimize_isl): Call isl_union_map_is_equal. * graphite-poly.c (new_scop): Initialize original_schedule. (free_scop): Free original_schedule. * graphite-poly.h (struct scop): Add field original_schedule. * graphite-sese-to-poly.c (build_scop_original_schedule): New. (build_poly_scop): Call build_scop_original_schedule. --- gcc/graphite-optimize-isl.c | 20 ++++++++++++++---- gcc/graphite-poly.c | 2 ++ gcc/graphite-poly.h | 3 +++ gcc/graphite-sese-to-poly.c | 50 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 71 insertions(+), 4 deletions(-) diff --git a/gcc/graphite-optimize-isl.c b/gcc/graphite-optimize-isl.c index 0d85975..c09264b 100644 --- a/gcc/graphite-optimize-isl.c +++ b/gcc/graphite-optimize-isl.c @@ -441,11 +441,23 @@ optimize_isl (scop_p scop) #else isl_union_map *schedule_map = get_schedule_map (schedule); #endif - apply_schedule_map_to_scop (scop, schedule_map); - isl_schedule_free (schedule); - isl_union_map_free (schedule_map); - return true; + if (isl_union_map_is_equal (scop->original_schedule, schedule_map)) + { + if (dump_file && dump_flags) + fprintf (dump_file, "\nISL schedule same as original schedule\n"); + + isl_schedule_free (schedule); + isl_union_map_free (schedule_map); + return false; + } + else + { + apply_schedule_map_to_scop (scop, schedule_map); + isl_schedule_free (schedule); + isl_union_map_free (schedule_map); + return true; + } } #endif /* HAVE_isl */ diff --git a/gcc/graphite-poly.c b/gcc/graphite-poly.c index 2aa40c0..36c3061 100644 --- a/gcc/graphite-poly.c +++ b/gcc/graphite-poly.c @@ -305,6 +305,7 @@ new_scop (edge entry, edge exit) scop->must_waw_no_source = NULL; scop->may_waw_no_source = NULL; scop_set_region (scop, region); + scop->original_schedule = NULL; scop->pbbs.create (3); scop->poly_scop_p = false; scop->drs.create (3); @@ -341,6 +342,7 @@ free_scop (scop_p scop) isl_union_map_free (scop->may_waw); isl_union_map_free (scop->must_waw_no_source); isl_union_map_free (scop->may_waw_no_source); + isl_union_map_free (scop->original_schedule); XDELETE (scop); } diff --git a/gcc/graphite-poly.h b/gcc/graphite-poly.h index 5298f85..b35431a 100644 --- a/gcc/graphite-poly.h +++ b/gcc/graphite-poly.h @@ -436,6 +436,9 @@ struct scop *must_war, *may_war, *must_war_no_source, *may_war_no_source, *must_waw, *may_waw, *must_waw_no_source, *may_waw_no_source; + /* Original schedule of the SCoP. */ + isl_union_map *original_schedule; + /* True when the scop has been converted to its polyhedral representation. */ bool poly_scop_p; diff --git a/gcc/graphite-sese-to-poly.c b/gcc/graphite-sese-to-poly.c index 394a281..ba45199 100644 --- a/gcc/graphite-sese-to-poly.c +++ b/gcc/graphite-sese-to-poly.c @@ -426,6 +426,55 @@ build_scop_minimal_scattering (scop_p scop) isl_aff_free (static_sched); } +/* Build the original schedule showing the orginal order of execution + of statement instances. + + The following example shows the original schedule: + + for (i: ...) + { + for (j: ...) + { + A + } + B + } + C + for (i: ...) + { + D + } + + Static schedules for A to D expressed in a union map: + + { S_A[i0, i1] -> [i0, i1]; S_B[i0] -> [i0]; S_C[] -> []; S_9[i0] -> [i0] } + +*/ + +static void +build_scop_original_schedule (scop_p scop) +{ + isl_space *space = isl_set_get_space (scop->param_context); + isl_union_map *res = isl_union_map_empty (space); + + int i; + poly_bb_p pbb; + FOR_EACH_VEC_ELT (scop->pbbs, i, pbb) + { + int nb_dimensions = isl_set_dim (pbb->domain, isl_dim_set); + isl_space *dc = isl_set_get_space (pbb->domain); + isl_space *dm = isl_space_add_dims (isl_space_from_domain (dc), + isl_dim_out, nb_dimensions); + isl_map *mp = isl_map_universe (dm); + for (int i = 0; i < nb_dimensions; i++) + mp = isl_map_equate (mp, isl_dim_in, i, isl_dim_out, i); + + res = isl_union_map_add_map (res, mp); + } + scop->original_schedule = res; +} + + static isl_pw_aff *extract_affine (scop_p, tree, __isl_take isl_space *space); /* Extract an affine expression from the chain of recurrence E. */ @@ -1799,6 +1848,7 @@ build_poly_scop (scop_p scop) build_scop_drs (scop); build_scop_minimal_scattering (scop); + build_scop_original_schedule (scop); /* This SCoP has been translated to the polyhedral representation. */