From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30761 invoked by alias); 2 Sep 2015 18:46:50 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 30751 invoked by uid 89); 2 Sep 2015 18:46:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL,BAYES_00,SPF_PASS autolearn=ham version=3.3.2 X-HELO: mx2.suse.de Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (CAMELLIA256-SHA encrypted) ESMTPS; Wed, 02 Sep 2015 18:46:48 +0000 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 1E677ACBC for ; Wed, 2 Sep 2015 18:46:45 +0000 (UTC) Date: Wed, 02 Sep 2015 18:46:00 -0000 From: Martin Jambor To: GCC Patches Subject: [hsa] Stricter target_follows_kernelizable_pattern Message-ID: <20150902184644.GI2685@virgil.suse.cz> Mail-Followup-To: GCC Patches MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) X-IsSubscribed: yes X-SW-Source: 2015-09/txt/msg00182.txt.bz2 Hi, the patch below makes target_follows_kernelizable_pattern stricter by adding a few checks for clauses that have to preclude kernelization. Committed to the branch. Thanks, Martin 2015-09-02 Martin Jambor * omp-low.c (target_follows_kernelizable_pattern): Parallel num_thread clause and non-automatic loop schedule preclude kernelization. --- gcc/ChangeLog.hsa | 6 ++++++ gcc/omp-low.c | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/gcc/omp-low.c b/gcc/omp-low.c index 6c2bbe7..d6c521f 100644 --- a/gcc/omp-low.c +++ b/gcc/omp-low.c @@ -2832,9 +2832,23 @@ target_follows_kernelizable_pattern (gomp_target *target, tree *group_size_p, gomp_parallel *par; if (!stmt || !(par = dyn_cast (stmt))) return NULL; + + tree clauses = gimple_omp_parallel_clauses (par); + tree num_threads_clause = find_omp_clause (clauses, OMP_CLAUSE_NUM_THREADS); + if (num_threads_clause) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_NOTE, tloc, + "Will not turn target construct into a " + "simple GPGPU kernel because there is a num_threads " + "clause of the parallel construct that " + "is likely to require looping \n"); + return NULL; + } + stmt = single_stmt_in_seq_skip_bind (gimple_omp_body (par), tloc, "parallel"); - /* FIXME: We are currently ignoring parallel clauses and potentially also - sharing clauses of teams and distribute, if there are any. We need to + /* FIXME: We are currently ignoring parallel sharing clauses and potentially + also sharing clauses of teams and distribute, if there are any. We need to check they can be skipped. */ gomp_for *gfor; if (!stmt || !(gfor = dyn_cast (stmt))) @@ -2859,6 +2873,20 @@ target_follows_kernelizable_pattern (gomp_target *target, tree *group_size_p, return NULL; } + clauses = gimple_omp_for_clauses (gfor); + tree for_sched_clause = find_omp_clause (clauses, OMP_CLAUSE_SCHEDULE); + + if (for_sched_clause + && OMP_CLAUSE_SCHEDULE_KIND (for_sched_clause) != OMP_CLAUSE_SCHEDULE_AUTO) + { + if (dump_enabled_p ()) + dump_printf_loc (MSG_NOTE, tloc, + "Will not turn target construct into a simple GPGPU " + "kernel because the inner loop has non-automatic " + "scheduling clause\n"); + return NULL; + } + if (teams) gather_inner_locals (gimple_omp_body (teams), kri); if (dist) -- 2.4.6