]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Adjust parallelism of loops in gang-single parts of OpenACC kernels regions: "struct...
authorThomas Schwinge <thomas@codesourcery.com>
Fri, 1 Feb 2019 17:12:05 +0000 (18:12 +0100)
committerThomas Schwinge <thomas@codesourcery.com>
Tue, 3 Mar 2020 11:17:13 +0000 (12:17 +0100)
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)

gcc/ChangeLog.omp
gcc/omp-oacc-kernels.c

index dda0e6b3409d986684e01ff0c438852c381fb9c1..6ec668e2ebe45472e4d002d89e41b52299ea1b1e 100644 (file)
@@ -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.
index 87ac7dd045f2af176996028f77f56f4bc87a3e61..d65e6c6c6cbd99bef2738905a6aac1445ac75d7b 100644 (file)
@@ -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.  */