Hi! On Fri, 01 Feb 2019 00:59:30 +0100, I wrote: > From c7713be32fc5eace2b1e9c20447da849d23f6076 Mon Sep 17 00:00:00 2001 > From: =?UTF-8?q?Gerg=C3=B6=20Barany?= <ge...@codesourcery.com> > Date: Wed, 23 Jan 2019 22:11:11 -0800 > Subject: [PATCH 6/9] Adjust parallelism of loops in gang-single parts of > OpenACC kernels regions
> transform_kernels_loop_clauses (gimple *omp_for, > + 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; > + gimple *body = gimple_omp_body (omp_for); > + walk_gimple_seq (body, adjust_nested_loop_clauses, NULL, &wi); It makes sense to me, but not to GCC 4.6 ;-) -- pushed to openacc-gcc-8-branch the attached commit 5885db6f8466e13ddfab046bae3149a992a30926 'Adjust parallelism of loops in gang-single parts of OpenACC kernels regions: "struct adjust_nested_loop_clauses_wi_info"'. Grüße Thomas
>From 5885db6f8466e13ddfab046bae3149a992a30926 Mon Sep 17 00:00:00 2001 From: Thomas Schwinge <tho...@codesourcery.com> Date: Fri, 1 Feb 2019 18:12:05 +0100 Subject: [PATCH] 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. --- gcc/ChangeLog.openacc | 5 +++++ gcc/omp-oacc-kernels.c | 29 +++++++++++++++++------------ 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/gcc/ChangeLog.openacc b/gcc/ChangeLog.openacc index 433653b2b38..a3472637729 100644 --- a/gcc/ChangeLog.openacc +++ b/gcc/ChangeLog.openacc @@ -1,3 +1,8 @@ +2019-02-01 Thomas Schwinge <tho...@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-31 Thomas Schwinge <tho...@codesourcery.com> * doc/invoke.texi (-fopenacc-kernels): Update. diff --git a/gcc/omp-oacc-kernels.c b/gcc/omp-oacc-kernels.c index a8860c98e11..d1db4924b1c 100644 --- a/gcc/omp-oacc-kernels.c +++ b/gcc/omp-oacc-kernels.c @@ -409,14 +409,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) @@ -430,13 +435,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: @@ -580,11 +585,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. */ -- 2.17.1