From patchwork Sat Oct 10 12:09:58 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom de Vries X-Patchwork-Id: 528612 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 21B8F14030B for ; Sat, 10 Oct 2015 23:11:01 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=TDROr8Nu; 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=SzuOYFdra/QHWZ/eM 2ORj22zuCtsejB2cembV+7dXoyJ3aVR+hHcmt/2wl6iWgw6jH30Pkq6T7TwzV8EA U0J7gtRA9Ow3yzMHNM8xQ91Kpx3OMmLzvUSJOwXcm1dJGFO0d+hdlRq3IcRCos4q 7iH5sBYHs85xC903K6587HZXXw= 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 :subject:to:references:cc:from:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=1uGFT82N7Q43ffWp1EmV1mQ LVAY=; b=TDROr8NuFO51LKJ/0PYMMAWHTAAQJE4QHe9ZDqXtskW7XvY1iKRc6cn GClOn8T8vQlwytvDniD8o6qiXs9VVxBPgeEOTJZlIjyp3wethKheeQDStIwfaqLm rKlrEqN6IJ3c/LB4nyLyTp+enGMDKSPLyzRxRlRhgBQp6/07AjEw= Received: (qmail 128841 invoked by alias); 10 Oct 2015 12:10:53 -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 128825 invoked by uid 89); 10 Oct 2015 12:10:51 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: fencepost.gnu.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (208.118.235.10) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 10 Oct 2015 12:10:49 +0000 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47626) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1Zksz9-0002NM-AA for gcc-patches@gnu.org; Sat, 10 Oct 2015 08:10:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zksz5-0005fI-QY for gcc-patches@gnu.org; Sat, 10 Oct 2015 08:10:47 -0400 Received: from relay1.mentorg.com ([192.94.38.131]:64679) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zksz5-0005fB-AG for gcc-patches@gnu.org; Sat, 10 Oct 2015 08:10:43 -0400 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-01.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1Zksz4-0002ta-Ab from Tom_deVries@mentor.com ; Sat, 10 Oct 2015 05:10:42 -0700 Received: from [127.0.0.1] (137.202.0.76) by SVR-IES-FEM-01.mgc.mentorg.com (137.202.0.104) with Microsoft SMTP Server id 14.3.224.2; Sat, 10 Oct 2015 13:10:40 +0100 Subject: [PATCH, 5/5] Add param parloops-schedule To: Bernd Schmidt References: <560100FF.9060904@mentor.com> <5601343C.9010104@redhat.com> <56114774.9090108@mentor.com> <561394CA.1050504@redhat.com> <5618F121.4070100@mentor.com> CC: "gcc-patches@gnu.org" From: Tom de Vries Message-ID: <56190016.7050707@mentor.com> Date: Sat, 10 Oct 2015 14:09:58 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 MIME-Version: 1.0 In-Reply-To: <5618F121.4070100@mentor.com> X-detected-operating-system: by eggs.gnu.org: Windows NT kernel [generic] [fuzzy] X-Received-From: 192.94.38.131 On 10/10/15 13:06, Tom de Vries wrote: > OK, I'll repost with the patch split up, as follows: > > 1 Handle simple latch in expand_omp_for_generic > 2 Add missing phis in expand_omp_for_generic > 3 Handle original loop tree in expand_omp_for_generic > 4 Support DEFPARAMENUM in params.def > 5 Add param parloops-schedule this patch adds a param parloop-schedule=, which sets the omp schedule for loops parallelized by parloops. Thanks, - Tom Add param parloops-schedule 2015-09-10 Tom de Vries PR tree-optimization/67476 * doc/invoke.texi (@item parloops-schedule): New item. * params.def (PARAM_PARLOOPS_SCHEDULE): New DEFPARAMENUM5. * tree-parloops.c: Include params-enum.h. (create_parallel_loop): Handle PARAM_PARLOOPS_SCHEDULE. * testsuite/libgomp.c/autopar-3.c: New test. * testsuite/libgomp.c/autopar-4.c: New test. * testsuite/libgomp.c/autopar-5.c: New test. * testsuite/libgomp.c/autopar-6.c: New test. * testsuite/libgomp.c/autopar-7.c: New test. * testsuite/libgomp.c/autopar-8.c: New test. --- gcc/doc/invoke.texi | 4 ++++ gcc/params.def | 12 ++++++++++++ gcc/tree-parloops.c | 26 +++++++++++++++++++++++++- libgomp/testsuite/libgomp.c/autopar-3.c | 4 ++++ libgomp/testsuite/libgomp.c/autopar-4.c | 4 ++++ libgomp/testsuite/libgomp.c/autopar-5.c | 4 ++++ libgomp/testsuite/libgomp.c/autopar-6.c | 4 ++++ libgomp/testsuite/libgomp.c/autopar-7.c | 4 ++++ libgomp/testsuite/libgomp.c/autopar-8.c | 4 ++++ 9 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 libgomp/testsuite/libgomp.c/autopar-3.c create mode 100644 libgomp/testsuite/libgomp.c/autopar-4.c create mode 100644 libgomp/testsuite/libgomp.c/autopar-5.c create mode 100644 libgomp/testsuite/libgomp.c/autopar-6.c create mode 100644 libgomp/testsuite/libgomp.c/autopar-7.c create mode 100644 libgomp/testsuite/libgomp.c/autopar-8.c diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 1b44b44..dea29d8 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -11132,6 +11132,10 @@ automaton. The default is 50. Chunk size of omp schedule for loops parallelized by parloops. The default is 0. +@item parloops-schedule +Schedule type of omp schedule for loops parallelized by parloops (static, +dynamic, guided, auto, runtime). The default is static. + @item max-ssa-name-query-depth Maximum depth of recursion when querying properties of SSA names in things like fold routines. One level of recursion corresponds to following a diff --git a/gcc/params.def b/gcc/params.def index 8b8b9fe..dd07301 100644 --- a/gcc/params.def +++ b/gcc/params.def @@ -35,6 +35,11 @@ along with GCC; see the file COPYING3. If not see - The maximum acceptable value for the parameter (if greater than the minimum). + The DEFPARAMENUM macro is similar, but instead of the minumum and maximum + arguments, it contains a list of allowed strings, corresponding to + integer values 0..-1. Note that the default argument needs to be + specified as one of the allowed strings, rather than an integer value. + Be sure to add an entry to invoke.texi summarizing the parameter. */ /* When branch is predicted to be taken with probability lower than this @@ -1153,6 +1158,13 @@ DEFPARAM (PARAM_PARLOOPS_CHUNK_SIZE, "Chunk size of omp schedule for loops parallelized by parloops", 0, 0, 0) +DEFPARAMENUM5 (PARAM_PARLOOPS_SCHEDULE, + "parloops-schedule", + "Schedule type of omp schedule for loops parallelized by " + "parloops (static, dynamic, guided, auto, runtime)", + static, + static, dynamic, guided, auto, runtime) + DEFPARAM (PARAM_MAX_SSA_NAME_QUERY_DEPTH, "max-ssa-name-query-depth", "Maximum recursion depth allowed when querying a property of an" diff --git a/gcc/tree-parloops.c b/gcc/tree-parloops.c index 741392b..62e561c 100644 --- a/gcc/tree-parloops.c +++ b/gcc/tree-parloops.c @@ -58,6 +58,7 @@ along with GCC; see the file COPYING3. If not see #include "cgraph.h" #include "tree-ssa.h" #include "params.h" +#include "params-enum.h" /* This pass tries to distribute iterations of loops into several threads. The implementation is straightforward -- for each loop we test whether its @@ -2086,8 +2087,31 @@ create_parallel_loop (struct loop *loop, tree loop_fn, tree data, gimple_cond_set_lhs (cond_stmt, cvar_base); type = TREE_TYPE (cvar); t = build_omp_clause (loc, OMP_CLAUSE_SCHEDULE); - OMP_CLAUSE_SCHEDULE_KIND (t) = OMP_CLAUSE_SCHEDULE_STATIC; int chunk_size = PARAM_VALUE (PARAM_PARLOOPS_CHUNK_SIZE); + enum PARAM_PARLOOPS_SCHEDULE_KIND schedule_type \ + = (enum PARAM_PARLOOPS_SCHEDULE_KIND) PARAM_VALUE (PARAM_PARLOOPS_SCHEDULE); + switch (schedule_type) + { + case PARAM_PARLOOPS_SCHEDULE_KIND_static: + OMP_CLAUSE_SCHEDULE_KIND (t) = OMP_CLAUSE_SCHEDULE_STATIC; + break; + case PARAM_PARLOOPS_SCHEDULE_KIND_dynamic: + OMP_CLAUSE_SCHEDULE_KIND (t) = OMP_CLAUSE_SCHEDULE_DYNAMIC; + break; + case PARAM_PARLOOPS_SCHEDULE_KIND_guided: + OMP_CLAUSE_SCHEDULE_KIND (t) = OMP_CLAUSE_SCHEDULE_GUIDED; + break; + case PARAM_PARLOOPS_SCHEDULE_KIND_auto: + OMP_CLAUSE_SCHEDULE_KIND (t) = OMP_CLAUSE_SCHEDULE_AUTO; + chunk_size = 0; + break; + case PARAM_PARLOOPS_SCHEDULE_KIND_runtime: + OMP_CLAUSE_SCHEDULE_KIND (t) = OMP_CLAUSE_SCHEDULE_RUNTIME; + chunk_size = 0; + break; + default: + gcc_unreachable (); + } if (chunk_size != 0) OMP_CLAUSE_SCHEDULE_CHUNK_EXPR (t) = build_int_cst (integer_type_node, chunk_size); diff --git a/libgomp/testsuite/libgomp.c/autopar-3.c b/libgomp/testsuite/libgomp.c/autopar-3.c new file mode 100644 index 0000000..1c25a44 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/autopar-3.c @@ -0,0 +1,4 @@ +/* { dg-do run } */ +/* { dg-additional-options "-ftree-parallelize-loops=4 -ffast-math --param parloops-schedule=dynamic" } */ + +#include "autopar-1.c" diff --git a/libgomp/testsuite/libgomp.c/autopar-4.c b/libgomp/testsuite/libgomp.c/autopar-4.c new file mode 100644 index 0000000..78c77d9 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/autopar-4.c @@ -0,0 +1,4 @@ +/* { dg-do run } */ +/* { dg-additional-options "-ftree-parallelize-loops=4 -ffast-math --param parloops-schedule=dynamic --param parloops-chunk-size=100" } */ + +#include "autopar-1.c" diff --git a/libgomp/testsuite/libgomp.c/autopar-5.c b/libgomp/testsuite/libgomp.c/autopar-5.c new file mode 100644 index 0000000..f0acb20 --- /dev/null +++ b/libgomp/testsuite/libgomp.c/autopar-5.c @@ -0,0 +1,4 @@ +/* { dg-do run } */ +/* { dg-additional-options "-ftree-parallelize-loops=4 -ffast-math --param parloops-schedule=guided" } */ + +#include "autopar-1.c" diff --git a/libgomp/testsuite/libgomp.c/autopar-6.c b/libgomp/testsuite/libgomp.c/autopar-6.c new file mode 100644 index 0000000..f6e723e --- /dev/null +++ b/libgomp/testsuite/libgomp.c/autopar-6.c @@ -0,0 +1,4 @@ +/* { dg-do run } */ +/* { dg-additional-options "-ftree-parallelize-loops=4 -ffast-math --param parloops-schedule=guided --param parloops-chunk-size=100" } */ + +#include "autopar-1.c" diff --git a/libgomp/testsuite/libgomp.c/autopar-7.c b/libgomp/testsuite/libgomp.c/autopar-7.c new file mode 100644 index 0000000..5f15508f --- /dev/null +++ b/libgomp/testsuite/libgomp.c/autopar-7.c @@ -0,0 +1,4 @@ +/* { dg-do run } */ +/* { dg-additional-options "-ftree-parallelize-loops=4 -ffast-math --param parloops-schedule=auto" } */ + +#include "autopar-1.c" diff --git a/libgomp/testsuite/libgomp.c/autopar-8.c b/libgomp/testsuite/libgomp.c/autopar-8.c new file mode 100644 index 0000000..6099e9f --- /dev/null +++ b/libgomp/testsuite/libgomp.c/autopar-8.c @@ -0,0 +1,4 @@ +/* { dg-do run } */ +/* { dg-additional-options "-ftree-parallelize-loops=4 -ffast-math --param parloops-schedule=runtime" } */ + +#include "autopar-1.c" -- 1.9.1