From 1f600feab05dc0737a6e11b871fe31b0698ba812 Mon Sep 17 00:00:00 2001 From: Tom de Vries Date: Tue, 13 Oct 2015 10:08:59 +0000 Subject: [PATCH] Add param parloops-schedule 2015-10-13 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. From-SVN: r228756 --- gcc/ChangeLog | 8 ++++++++ gcc/doc/invoke.texi | 4 ++++ gcc/params.def | 12 ++++++++++++ gcc/tree-parloops.c | 26 ++++++++++++++++++++++++- libgomp/ChangeLog | 10 ++++++++++ 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 ++++ 11 files changed, 83 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/ChangeLog b/gcc/ChangeLog index 83e4bfadfd4..d71bcd28bc9 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2015-10-13 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. + 2015-10-13 Tom de Vries * Makefile.in (PARAMS_H, PLUGIN_HEADERS): Add params-enum.h. diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 9e028fc1462..54e9f128634 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -11133,6 +11133,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 8b8b9fe3ff7..dd073019d69 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 741392bf937..62e561c5b4f 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/ChangeLog b/libgomp/ChangeLog index aa03f82d2ee..74a135cd55b 100644 --- a/libgomp/ChangeLog +++ b/libgomp/ChangeLog @@ -1,3 +1,13 @@ +2015-10-13 Tom de Vries + + PR tree-optimization/67476 + * 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. + 2015-10-12 James Norris * testsuite/libgomp.oacc-c-c++-common/vector-loop.c: Fix loop diff --git a/libgomp/testsuite/libgomp.c/autopar-3.c b/libgomp/testsuite/libgomp.c/autopar-3.c new file mode 100644 index 00000000000..1c25a44c789 --- /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 00000000000..78c77d9ff7c --- /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 00000000000..f0acb20e4e6 --- /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 00000000000..f6e723e7867 --- /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 00000000000..5f15508f6b3 --- /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 00000000000..6099e9f457d --- /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" -- 2.30.2