aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2019-02-01 18:12:05 +0100
committerThomas Schwinge <thomas@codesourcery.com>2020-03-03 12:17:13 +0100
commit7464b711af2667697b98e7d25890e62f13d68a25 (patch)
tree87e8115c9e29b8ff4ca5d5eb405cacaaeb3ed768
parent4c05daa5dda4b17a55372865e74208bb7585820b (diff)
downloadgcc-7464b711af2667697b98e7d25890e62f13d68a25.zip
gcc-7464b711af2667697b98e7d25890e62f13d68a25.tar.gz
gcc-7464b711af2667697b98e7d25890e62f13d68a25.tar.bz2
Adjust parallelism of loops in gang-single parts of OpenACC kernels regions: "struct adjust_nested_loop_clauses_wi_info"
The current code apparently is too freaky at least for for GCC 4.6: [...]/gcc/omp-oacc-kernels.c: In function 'tree_node* transform_kernels_loop_clauses(gimple*, tree, tree, tree, tree)': [...]/gcc/omp-oacc-kernels.c:584:10: error: expected identifier before numeric constant [...]/gcc/omp-oacc-kernels.c: In lambda function: [...]/gcc/omp-oacc-kernels.c:584:25: error: expected '{' before '=' token [...]/gcc/omp-oacc-kernels.c: In function 'tree_node* transform_kernels_loop_clauses(gimple*, tree, tree, tree, tree)': [...]/gcc/omp-oacc-kernels.c:584:25: warning: lambda expressions only available with -std=c++0x or -std=gnu++0x [enabled by default] [...]/gcc/omp-oacc-kernels.c:584:28: error: no match for 'operator=' in '{} = & loop_gang_clause' [...] gcc/ * omp-oacc-kernels.c (struct adjust_nested_loop_clauses_wi_info): New. (adjust_nested_loop_clauses, transform_kernels_loop_clauses): Use it. (cherry picked from openacc-gcc-9-branch commit 528fe932e95d72cf1983e550fb924d5a0b9ed4ed)
-rw-r--r--gcc/ChangeLog.omp5
-rw-r--r--gcc/omp-oacc-kernels.c29
2 files changed, 22 insertions, 12 deletions
diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp
index dda0e6b..6ec668e 100644
--- a/gcc/ChangeLog.omp
+++ b/gcc/ChangeLog.omp
@@ -1,3 +1,8 @@
+2019-02-01 Thomas Schwinge <thomas@codesourcery.com>
+
+ * omp-oacc-kernels.c (struct adjust_nested_loop_clauses_wi_info): New.
+ (adjust_nested_loop_clauses, transform_kernels_loop_clauses): Use it.
+
2019-01-23 Thomas Schwinge <thomas@codesourcery.com>
* doc/invoke.texi (-fopenacc-kernels): Update.
diff --git a/gcc/omp-oacc-kernels.c b/gcc/omp-oacc-kernels.c
index 87ac7dd..d65e6c6 100644
--- a/gcc/omp-oacc-kernels.c
+++ b/gcc/omp-oacc-kernels.c
@@ -411,14 +411,19 @@ add_parent_or_loop_num_clause (tree parent_clause, tree loop_clause,
nested loops. It adds an auto clause unless there is already an
independent/seq/auto clause or a gang/worker/vector annotation. */
+struct adjust_nested_loop_clauses_wi_info
+{
+ tree *loop_gang_clause_ptr;
+ tree *loop_worker_clause_ptr;
+ tree *loop_vector_clause_ptr;
+};
+
static tree
adjust_nested_loop_clauses (gimple_stmt_iterator *gsi_p, bool *,
struct walk_stmt_info *wi)
{
- tree **clauses = (tree **) wi->info;
- tree *gang_num_clause = clauses[GOMP_DIM_GANG];
- tree *worker_num_clause = clauses[GOMP_DIM_WORKER];
- tree *vector_length_clause = clauses[GOMP_DIM_VECTOR];
+ struct adjust_nested_loop_clauses_wi_info *wi_info
+ = (struct adjust_nested_loop_clauses_wi_info *) wi->info;
gimple *stmt = gsi_stmt (*gsi_p);
if (gimple_code (stmt) == GIMPLE_OMP_FOR)
@@ -432,13 +437,13 @@ adjust_nested_loop_clauses (gimple_stmt_iterator *gsi_p, bool *,
switch (OMP_CLAUSE_CODE (loop_clause))
{
case OMP_CLAUSE_GANG:
- outer_clause_ptr = gang_num_clause;
+ outer_clause_ptr = wi_info->loop_gang_clause_ptr;
break;
case OMP_CLAUSE_WORKER:
- outer_clause_ptr = worker_num_clause;
+ outer_clause_ptr = wi_info->loop_worker_clause_ptr;
break;
case OMP_CLAUSE_VECTOR:
- outer_clause_ptr = vector_length_clause;
+ outer_clause_ptr = wi_info->loop_vector_clause_ptr;
break;
case OMP_CLAUSE_INDEPENDENT:
case OMP_CLAUSE_SEQ:
@@ -582,11 +587,11 @@ transform_kernels_loop_clauses (gimple *omp_for,
Turn these into worker/vector annotations on the parallel region. */
struct walk_stmt_info wi;
memset (&wi, 0, sizeof (wi));
- tree *num_clauses[GOMP_DIM_MAX]
- = { [GOMP_DIM_GANG] = &loop_gang_clause,
- [GOMP_DIM_WORKER] = &loop_worker_clause,
- [GOMP_DIM_VECTOR] = &loop_vector_clause };
- wi.info = num_clauses;
+ struct adjust_nested_loop_clauses_wi_info wi_info;
+ wi_info.loop_gang_clause_ptr = &loop_gang_clause;
+ wi_info.loop_worker_clause_ptr = &loop_worker_clause;
+ wi_info.loop_vector_clause_ptr = &loop_vector_clause;
+ wi.info = &wi_info;
gimple *body = gimple_omp_body (omp_for);
walk_gimple_seq (body, adjust_nested_loop_clauses, NULL, &wi);
/* Check if there were conflicting numbers of workers or vector lanes. */