Add user-friendly diagnostics for OpenACC loop parallelism assigned (was: [PATCH 3/3] Add user-friendly OpenACC diagnostics regarding detected parallelism)

Thomas Schwinge thomas@codesourcery.com
Fri Dec 14 21:03:00 GMT 2018


Hi!

On Thu, 26 Jul 2018 07:14:21 -0700, Cesar Philippidis <cesar@codesourcery.com> wrote:
> On 07/26/2018 01:33 AM, Richard Biener wrote:
> > On Wed, Jul 25, 2018 at 5:30 PM Cesar Philippidis
> > <cesar@codesourcery.com> wrote:
> >>
> >> This patch

Thanks!

> >> teaches GCC to inform the user how it assigned parallelism
> >> to each OpenACC loop at compile time

Hence, I changed that diagnostig to "assigned OpenACC [...] loop
parallelism" instead of "Detected parallelism <acc loop [...]>".

> >> using the -fopt-info-note-omp
> >> flag. For instance, given the acc parallel loop nest:
> >>
> >>   #pragma acc parallel loop
> >>   for (...)
> >>     #pragma acc loop vector
> >>     for (...)
> >>
> >> GCC will report somthing like
> >>
> >>   foo.c:4:0: note: Detected parallelism <acc loop gang worker>
> >>   foo.c:6:0: note: Detected parallelism <acc loop vector>
> >>
> >> Note how only the inner loop specifies vector parallelism. In this
> >> example, GCC automatically assigned gang and worker parallelism to the
> >> outermost loop. Perhaps, going forward, it would be useful to
> >> distinguish which parallelism was specified by the user and which was
> >> assigned by the compiler. But that can be added in a follow up patch.

ACK.

> The attached revised patch now uses MSG_OPTIMIZED_LOCATIONS for the
> diagnostics.

> Is this OK for trunk?

I further changed that to make it build ;-) at all, and also emit
diagnostics for OpenACC kernels constructs, and also added considerably
more testsuite coverage.

Committed to trunk in r267146:

commit 75180da2a558d3106e26173326933f65b417182c
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Fri Dec 14 20:41:58 2018 +0000

    Add user-friendly diagnostics for OpenACC loop parallelism assigned
    
            gcc/
            * omp-offload.c (inform_oacc_loop): New function.
            (execute_oacc_device_lower): Use it to display loop parallelism.
            gcc/testsuite/
            * c-c++-common/goacc/note-parallelism.c: New test.
            * gfortran.dg/goacc/note-parallelism.f90: New test.
            * c-c++-common/goacc/classify-kernels-unparallelized.c: Update.
            * c-c++-common/goacc/classify-kernels.c: Likewise.
            * c-c++-common/goacc/classify-parallel.c: Likewise.
            * c-c++-common/goacc/classify-routine.c: Likewise.
            * c-c++-common/goacc/kernels-1.c: Likewise.
            * c-c++-common/goacc/kernels-double-reduction-n.c: Likewise.
            * c-c++-common/goacc/kernels-double-reduction.c: Likewise.
            * gfortran.dg/goacc/classify-kernels-unparallelized.f95: Likewise.
            * gfortran.dg/goacc/classify-kernels.f95: Likewise.
            * gfortran.dg/goacc/classify-parallel.f95: Likewise.
            * gfortran.dg/goacc/classify-routine.f95: Likewise.
            * gfortran.dg/goacc/kernels-loop-inner.f95: Likewise.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@267146 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/ChangeLog                                      |   6 +
 gcc/omp-offload.c                                  |  49 +++++++-
 gcc/testsuite/ChangeLog                            |  18 +++
 .../goacc/classify-kernels-unparallelized.c        |   3 +-
 .../c-c++-common/goacc/classify-kernels.c          |   3 +-
 .../c-c++-common/goacc/classify-parallel.c         |   3 +-
 .../c-c++-common/goacc/classify-routine.c          |   3 +-
 gcc/testsuite/c-c++-common/goacc/kernels-1.c       |  10 +-
 .../goacc/kernels-double-reduction-n.c             |   3 +-
 .../c-c++-common/goacc/kernels-double-reduction.c  |   3 +-
 .../c-c++-common/goacc/note-parallelism.c          | 115 ++++++++++++++++++
 .../goacc/classify-kernels-unparallelized.f95      |   3 +-
 .../gfortran.dg/goacc/classify-kernels.f95         |   3 +-
 .../gfortran.dg/goacc/classify-parallel.f95        |   3 +-
 .../gfortran.dg/goacc/classify-routine.f95         |   3 +-
 .../gfortran.dg/goacc/kernels-loop-inner.f95       |   3 +-
 .../gfortran.dg/goacc/note-parallelism.f90         | 131 +++++++++++++++++++++
 17 files changed, 346 insertions(+), 16 deletions(-)

diff --git gcc/ChangeLog gcc/ChangeLog
index 527164c4f9ec..7fb4958da485 100644
--- gcc/ChangeLog
+++ gcc/ChangeLog
@@ -1,3 +1,9 @@
+2018-12-14  Thomas Schwinge  <thomas@codesourcery.com>
+	    Cesar Philippidis  <cesar@codesourcery.com>
+
+	* omp-offload.c (inform_oacc_loop): New function.
+	(execute_oacc_device_lower): Use it to display loop parallelism.
+
 2018-12-14  Jakub Jelinek  <jakub@redhat.com>
 
 	PR c++/82294
diff --git gcc/omp-offload.c gcc/omp-offload.c
index 0abf0283c9e2..4457e1a3079b 100644
--- gcc/omp-offload.c
+++ gcc/omp-offload.c
@@ -823,7 +823,7 @@ dump_oacc_loop_part (FILE *file, gcall *from, int depth,
     }
 }
 
-/* Dump OpenACC loops LOOP, its siblings and its children.  */
+/* Dump OpenACC loop LOOP, its children, and its siblings.  */
 
 static void
 dump_oacc_loop (FILE *file, oacc_loop *loop, int depth)
@@ -866,6 +866,31 @@ debug_oacc_loop (oacc_loop *loop)
   dump_oacc_loop (stderr, loop, 0);
 }
 
+/* Provide diagnostics on OpenACC loop LOOP, its children, and its
+   siblings.  */
+
+static void
+inform_oacc_loop (const oacc_loop *loop)
+{
+  const char *gang
+    = loop->mask & GOMP_DIM_MASK (GOMP_DIM_GANG) ? " gang" : "";
+  const char *worker
+    = loop->mask & GOMP_DIM_MASK (GOMP_DIM_WORKER) ? " worker" : "";
+  const char *vector
+    = loop->mask & GOMP_DIM_MASK (GOMP_DIM_VECTOR) ? " vector" : "";
+  const char *seq = loop->mask == 0 ? " seq" : "";
+  const dump_user_location_t loc
+    = dump_user_location_t::from_location_t (loop->loc);
+  dump_printf_loc (MSG_OPTIMIZED_LOCATIONS, loc,
+		   "assigned OpenACC%s%s%s%s loop parallelism\n", gang, worker,
+		   vector, seq);
+
+  if (loop->child)
+    inform_oacc_loop (loop->child);
+  if (loop->sibling)
+    inform_oacc_loop (loop->sibling);
+}
+
 /* DFS walk of basic blocks BB onwards, creating OpenACC loop
    structures as we go.  By construction these loops are properly
    nested.  */
@@ -1533,6 +1558,28 @@ execute_oacc_device_lower ()
       dump_oacc_loop (dump_file, loops, 0);
       fprintf (dump_file, "\n");
     }
+  if (dump_enabled_p ())
+    {
+      oacc_loop *l = loops;
+      /* OpenACC kernels constructs are special: they currently don't use the
+	 generic oacc_loop infrastructure.  */
+      if (is_oacc_kernels)
+	{
+	  /* Create a fake oacc_loop for diagnostic purposes.  */
+	  l = new_oacc_loop_raw (NULL,
+				 DECL_SOURCE_LOCATION (current_function_decl));
+	  l->mask = used_mask;
+	}
+      else
+	{
+	  /* Skip the outermost, dummy OpenACC loop  */
+	  l = l->child;
+	}
+      if (l)
+	inform_oacc_loop (l);
+      if (is_oacc_kernels)
+	free_oacc_loop (l);
+    }
 
   /* Offloaded targets may introduce new basic blocks, which require
      dominance information to update SSA.  */
diff --git gcc/testsuite/ChangeLog gcc/testsuite/ChangeLog
index 4af1cf9423d2..6b035b34ecfd 100644
--- gcc/testsuite/ChangeLog
+++ gcc/testsuite/ChangeLog
@@ -1,3 +1,21 @@
+2018-12-14  Thomas Schwinge  <thomas@codesourcery.com>
+	    Cesar Philippidis  <cesar@codesourcery.com>
+
+	* c-c++-common/goacc/note-parallelism.c: New test.
+	* gfortran.dg/goacc/note-parallelism.f90: New test.
+	* c-c++-common/goacc/classify-kernels-unparallelized.c: Update.
+	* c-c++-common/goacc/classify-kernels.c: Likewise.
+	* c-c++-common/goacc/classify-parallel.c: Likewise.
+	* c-c++-common/goacc/classify-routine.c: Likewise.
+	* c-c++-common/goacc/kernels-1.c: Likewise.
+	* c-c++-common/goacc/kernels-double-reduction-n.c: Likewise.
+	* c-c++-common/goacc/kernels-double-reduction.c: Likewise.
+	* gfortran.dg/goacc/classify-kernels-unparallelized.f95: Likewise.
+	* gfortran.dg/goacc/classify-kernels.f95: Likewise.
+	* gfortran.dg/goacc/classify-parallel.f95: Likewise.
+	* gfortran.dg/goacc/classify-routine.f95: Likewise.
+	* gfortran.dg/goacc/kernels-loop-inner.f95: Likewise.
+
 2018-12-14  Alexandre Oliva <aoliva@redhat.com>
 
 	PR c++/86823
diff --git gcc/testsuite/c-c++-common/goacc/classify-kernels-unparallelized.c gcc/testsuite/c-c++-common/goacc/classify-kernels-unparallelized.c
index 626f6b4fe687..d4c4b2ca237a 100644
--- gcc/testsuite/c-c++-common/goacc/classify-kernels-unparallelized.c
+++ gcc/testsuite/c-c++-common/goacc/classify-kernels-unparallelized.c
@@ -2,6 +2,7 @@
    OpenACC kernels.  */
 
 /* { dg-additional-options "-O2" }
+   { dg-additional-options "-fopt-info-optimized-omp" }
    { dg-additional-options "-fdump-tree-ompexp" }
    { dg-additional-options "-fdump-tree-parloops1-all" }
    { dg-additional-options "-fdump-tree-oaccdevlow" } */
@@ -18,7 +19,7 @@ extern unsigned int f (unsigned int);
 
 void KERNELS ()
 {
-#pragma acc kernels copyin (a[0:N], b[0:N]) copyout (c[0:N])
+#pragma acc kernels copyin (a[0:N], b[0:N]) copyout (c[0:N]) /* { dg-message "optimized: assigned OpenACC seq loop parallelism" } */
   for (unsigned int i = 0; i < N; i++)
     c[i] = a[f (i)] + b[f (i)];
 }
diff --git gcc/testsuite/c-c++-common/goacc/classify-kernels.c gcc/testsuite/c-c++-common/goacc/classify-kernels.c
index 95037e6120ea..16e9b9e31d16 100644
--- gcc/testsuite/c-c++-common/goacc/classify-kernels.c
+++ gcc/testsuite/c-c++-common/goacc/classify-kernels.c
@@ -2,6 +2,7 @@
    kernels.  */
 
 /* { dg-additional-options "-O2" }
+   { dg-additional-options "-fopt-info-optimized-omp" }
    { dg-additional-options "-fdump-tree-ompexp" }
    { dg-additional-options "-fdump-tree-parloops1-all" }
    { dg-additional-options "-fdump-tree-oaccdevlow" } */
@@ -14,7 +15,7 @@ extern unsigned int *__restrict c;
 
 void KERNELS ()
 {
-#pragma acc kernels copyin (a[0:N], b[0:N]) copyout (c[0:N])
+#pragma acc kernels copyin (a[0:N], b[0:N]) copyout (c[0:N]) /* { dg-message "optimized: assigned OpenACC gang loop parallelism" } */
   for (unsigned int i = 0; i < N; i++)
     c[i] = a[i] + b[i];
 }
diff --git gcc/testsuite/c-c++-common/goacc/classify-parallel.c gcc/testsuite/c-c++-common/goacc/classify-parallel.c
index 4f97301f5cf0..66a6d1336638 100644
--- gcc/testsuite/c-c++-common/goacc/classify-parallel.c
+++ gcc/testsuite/c-c++-common/goacc/classify-parallel.c
@@ -2,6 +2,7 @@
    parallel.  */
 
 /* { dg-additional-options "-O2" }
+   { dg-additional-options "-fopt-info-optimized-omp" }
    { dg-additional-options "-fdump-tree-ompexp" }
    { dg-additional-options "-fdump-tree-oaccdevlow" } */
 
@@ -13,7 +14,7 @@ extern unsigned int *__restrict c;
 
 void PARALLEL ()
 {
-#pragma acc parallel loop copyin (a[0:N], b[0:N]) copyout (c[0:N])
+#pragma acc parallel loop copyin (a[0:N], b[0:N]) copyout (c[0:N]) /* { dg-message "optimized: assigned OpenACC gang vector loop parallelism" } */
   for (unsigned int i = 0; i < N; i++)
     c[i] = a[i] + b[i];
 }
diff --git gcc/testsuite/c-c++-common/goacc/classify-routine.c gcc/testsuite/c-c++-common/goacc/classify-routine.c
index fd89fc1ec662..a723d2cdf513 100644
--- gcc/testsuite/c-c++-common/goacc/classify-routine.c
+++ gcc/testsuite/c-c++-common/goacc/classify-routine.c
@@ -2,6 +2,7 @@
    routine.  */
 
 /* { dg-additional-options "-O2" }
+   { dg-additional-options "-fopt-info-optimized-omp" }
    { dg-additional-options "-fdump-tree-ompexp" }
    { dg-additional-options "-fdump-tree-oaccdevlow" } */
 
@@ -15,7 +16,7 @@ extern unsigned int *__restrict c;
 #pragma acc routine worker
 void ROUTINE ()
 {
-#pragma acc loop
+#pragma acc loop /* { dg-message "optimized: assigned OpenACC worker vector loop parallelism" } */
   for (unsigned int i = 0; i < N; i++)
     c[i] = a[i] + b[i];
 }
diff --git gcc/testsuite/c-c++-common/goacc/kernels-1.c gcc/testsuite/c-c++-common/goacc/kernels-1.c
index 4fcf86eca698..016abbdfe8d8 100644
--- gcc/testsuite/c-c++-common/goacc/kernels-1.c
+++ gcc/testsuite/c-c++-common/goacc/kernels-1.c
@@ -1,7 +1,9 @@
+/* { dg-additional-options "-fopt-info-optimized-omp" } */
+
 int
 kernels_empty (void)
 {
-#pragma acc kernels
+#pragma acc kernels /* { dg-message "optimized: assigned OpenACC seq loop parallelism" } */
   ;
 
   return 0;
@@ -10,7 +12,7 @@ kernels_empty (void)
 int
 kernels_eternal (void)
 {
-#pragma acc kernels
+#pragma acc kernels /* { dg-message "optimized: assigned OpenACC seq loop parallelism" } */
   {
     while (1)
       ;
@@ -22,7 +24,7 @@ kernels_eternal (void)
 int
 kernels_noreturn (void)
 {
-#pragma acc kernels
+#pragma acc kernels /* { dg-message "optimized: assigned OpenACC seq loop parallelism" } */
   __builtin_abort ();
 
   return 0;
@@ -36,7 +38,7 @@ kernels_loop_ptr_it (void)
 {
   float *i;
 
-#pragma acc kernels
+#pragma acc kernels /* { dg-message "optimized: assigned OpenACC seq loop parallelism" } */
   {
 #pragma acc loop
     for (i = &b[0][0][0]; i < &b[0][0][10]; i++)
diff --git gcc/testsuite/c-c++-common/goacc/kernels-double-reduction-n.c gcc/testsuite/c-c++-common/goacc/kernels-double-reduction-n.c
index 10b364b367c0..8f7f415b58d8 100644
--- gcc/testsuite/c-c++-common/goacc/kernels-double-reduction-n.c
+++ gcc/testsuite/c-c++-common/goacc/kernels-double-reduction-n.c
@@ -1,4 +1,5 @@
 /* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fopt-info-optimized-omp" } */
 /* { dg-additional-options "-fdump-tree-parloops1-all" } */
 /* { dg-additional-options "-fdump-tree-optimized" } */
 
@@ -14,7 +15,7 @@ foo (unsigned int n)
   int i, j;
   unsigned int sum = 1;
 
-#pragma acc kernels copyin (a[0:n]) copy (sum)
+#pragma acc kernels copyin (a[0:n]) copy (sum) /* { dg-message "optimized: assigned OpenACC gang loop parallelism" } */
   {
     for (i = 0; i < n; ++i)
       for (j = 0; j < n; ++j)
diff --git gcc/testsuite/c-c++-common/goacc/kernels-double-reduction.c gcc/testsuite/c-c++-common/goacc/kernels-double-reduction.c
index c0263460c1dc..c11d36fb4373 100644
--- gcc/testsuite/c-c++-common/goacc/kernels-double-reduction.c
+++ gcc/testsuite/c-c++-common/goacc/kernels-double-reduction.c
@@ -1,4 +1,5 @@
 /* { dg-additional-options "-O2" } */
+/* { dg-additional-options "-fopt-info-optimized-omp" } */
 /* { dg-additional-options "-fdump-tree-parloops1-all" } */
 /* { dg-additional-options "-fdump-tree-optimized" } */
 
@@ -14,7 +15,7 @@ foo (void)
   int i, j;
   unsigned int sum = 1;
 
-#pragma acc kernels copyin (a[0:N]) copy (sum)
+#pragma acc kernels copyin (a[0:N]) copy (sum) /* { dg-message "optimized: assigned OpenACC gang loop parallelism" } */
   {
     for (i = 0; i < N; ++i)
       for (j = 0; j < N; ++j)
diff --git gcc/testsuite/c-c++-common/goacc/note-parallelism.c gcc/testsuite/c-c++-common/goacc/note-parallelism.c
new file mode 100644
index 000000000000..735df7dfad7a
--- /dev/null
+++ gcc/testsuite/c-c++-common/goacc/note-parallelism.c
@@ -0,0 +1,115 @@
+/* Test the output of "-fopt-info-optimized-omp".  */
+
+/* { dg-additional-options "-fopt-info-optimized-omp" } */
+
+/* See also "../../gfortran.dg/goacc/note-parallelism.f90".  */
+
+int
+main ()
+{
+  int x, y, z;
+
+#pragma acc parallel
+  for (x = 0; x < 10; x++)
+    ;
+
+#pragma acc parallel loop seq /* { dg-message "optimized: assigned OpenACC seq loop parallelism" } */
+  for (x = 0; x < 10; x++)
+    ;
+
+#pragma acc parallel loop gang /* { dg-message "optimized: assigned OpenACC gang loop parallelism" } */
+  for (x = 0; x < 10; x++)
+    ;
+
+#pragma acc parallel loop worker /* { dg-message "optimized: assigned OpenACC worker loop parallelism" } */
+  for (x = 0; x < 10; x++)
+    ;
+
+#pragma acc parallel loop vector /* { dg-message "optimized: assigned OpenACC vector loop parallelism" } */
+  for (x = 0; x < 10; x++)
+    ;
+
+#pragma acc parallel loop gang vector /* { dg-message "optimized: assigned OpenACC gang vector loop parallelism" } */
+  for (x = 0; x < 10; x++)
+    ;
+
+#pragma acc parallel loop gang worker /* { dg-message "optimized: assigned OpenACC gang worker loop parallelism" } */
+  for (x = 0; x < 10; x++)
+    ;
+
+#pragma acc parallel loop worker vector /* { dg-message "optimized: assigned OpenACC worker vector loop parallelism" } */
+  for (x = 0; x < 10; x++)
+    ;
+
+#pragma acc parallel loop gang worker vector /* { dg-message "optimized: assigned OpenACC gang worker vector loop parallelism" } */
+  for (x = 0; x < 10; x++)
+    ;
+
+#pragma acc parallel loop gang /* { dg-message "optimized: assigned OpenACC gang loop parallelism" } */
+  for (x = 0; x < 10; x++)
+#pragma acc loop worker /* { dg-message "optimized: assigned OpenACC worker loop parallelism" } */
+    for (y = 0; y < 10; y++)
+#pragma acc loop vector /* { dg-message "optimized: assigned OpenACC vector loop parallelism" } */
+      for (z = 0; z < 10; z++)
+	;
+
+#pragma acc parallel loop /* { dg-message "optimized: assigned OpenACC gang vector loop parallelism" } */
+  for (x = 0; x < 10; x++)
+    ;
+
+#pragma acc parallel loop /* { dg-message "optimized: assigned OpenACC gang worker loop parallelism" } */
+  for (x = 0; x < 10; x++)
+#pragma acc loop /* { dg-message "optimized: assigned OpenACC vector loop parallelism" } */
+    for (y = 0; y < 10; y++)
+      ;
+
+#pragma acc parallel loop /* { dg-message "optimized: assigned OpenACC gang loop parallelism" } */
+  for (x = 0; x < 10; x++)
+#pragma acc loop /* { dg-message "optimized: assigned OpenACC worker loop parallelism" } */
+    for (y = 0; y < 10; y++)
+#pragma acc loop /* { dg-message "optimized: assigned OpenACC vector loop parallelism" } */
+      for (z = 0; z < 10; z++)
+	;
+
+#pragma acc parallel
+  for (x = 0; x < 10; x++)
+#pragma acc loop /* { dg-message "optimized: assigned OpenACC gang worker loop parallelism" } */
+    for (y = 0; y < 10; y++)
+#pragma acc loop /* { dg-message "optimized: assigned OpenACC vector loop parallelism" } */
+      for (z = 0; z < 10; z++)
+	;
+
+#pragma acc parallel loop seq /* { dg-message "optimized: assigned OpenACC seq loop parallelism" } */
+  for (x = 0; x < 10; x++)
+#pragma acc loop /* { dg-message "optimized: assigned OpenACC gang worker loop parallelism" } */
+    for (y = 0; y < 10; y++)
+#pragma acc loop /* { dg-message "optimized: assigned OpenACC vector loop parallelism" } */
+      for (z = 0; z < 10; z++)
+	;
+
+#pragma acc parallel loop /* { dg-message "optimized: assigned OpenACC gang worker loop parallelism" } */
+  for (x = 0; x < 10; x++)
+#pragma acc loop seq /* { dg-message "optimized: assigned OpenACC seq loop parallelism" } */
+    for (y = 0; y < 10; y++)
+#pragma acc loop /* { dg-message "optimized: assigned OpenACC vector loop parallelism" } */
+      for (z = 0; z < 10; z++)
+	;
+
+#pragma acc parallel loop /* { dg-message "optimized: assigned OpenACC gang worker loop parallelism" } */
+  for (x = 0; x < 10; x++)
+#pragma acc loop /* { dg-message "optimized: assigned OpenACC vector loop parallelism" } */
+    for (y = 0; y < 10; y++)
+#pragma acc loop seq /* { dg-message "optimized: assigned OpenACC seq loop parallelism" } */
+      for (z = 0; z < 10; z++)
+	;
+
+#pragma acc parallel loop seq /* { dg-message "optimized: assigned OpenACC seq loop parallelism" } */
+  for (x = 0; x < 10; x++)
+#pragma acc loop /* { dg-message "optimized: assigned OpenACC gang vector loop parallelism" } */
+    for (y = 0; y < 10; y++)
+#pragma acc loop seq /* { dg-message "optimized: assigned OpenACC seq loop parallelism" } */
+      for (z = 0; z < 10; z++)
+	;
+
+  return 0;
+}
diff --git gcc/testsuite/gfortran.dg/goacc/classify-kernels-unparallelized.f95 gcc/testsuite/gfortran.dg/goacc/classify-kernels-unparallelized.f95
index 4b282cab5ae4..08772428c4c5 100644
--- gcc/testsuite/gfortran.dg/goacc/classify-kernels-unparallelized.f95
+++ gcc/testsuite/gfortran.dg/goacc/classify-kernels-unparallelized.f95
@@ -2,6 +2,7 @@
 ! OpenACC kernels.
 
 ! { dg-additional-options "-O2" }
+! { dg-additional-options "-fopt-info-optimized-omp" }
 ! { dg-additional-options "-fdump-tree-ompexp" }
 ! { dg-additional-options "-fdump-tree-parloops1-all" }
 ! { dg-additional-options "-fdump-tree-oaccdevlow" }
@@ -19,7 +20,7 @@ program main
   call setup(a, b)
 
   !$acc kernels copyin (a(0:n-1), b(0:n-1)) copyout (c(0:n-1))
-  do i = 0, n - 1
+  do i = 0, n - 1 ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
      c(i) = a(f (i)) + b(f (i))
   end do
   !$acc end kernels
diff --git gcc/testsuite/gfortran.dg/goacc/classify-kernels.f95 gcc/testsuite/gfortran.dg/goacc/classify-kernels.f95
index da025c19af87..f2c4736e111c 100644
--- gcc/testsuite/gfortran.dg/goacc/classify-kernels.f95
+++ gcc/testsuite/gfortran.dg/goacc/classify-kernels.f95
@@ -2,6 +2,7 @@
 ! kernels.
 
 ! { dg-additional-options "-O2" }
+! { dg-additional-options "-fopt-info-optimized-omp" }
 ! { dg-additional-options "-fdump-tree-ompexp" }
 ! { dg-additional-options "-fdump-tree-parloops1-all" }
 ! { dg-additional-options "-fdump-tree-oaccdevlow" }
@@ -15,7 +16,7 @@ program main
   call setup(a, b)
 
   !$acc kernels copyin (a(0:n-1), b(0:n-1)) copyout (c(0:n-1))
-  do i = 0, n - 1
+  do i = 0, n - 1 ! { dg-message "optimized: assigned OpenACC gang loop parallelism" }
      c(i) = a(i) + b(i)
   end do
   !$acc end kernels
diff --git gcc/testsuite/gfortran.dg/goacc/classify-parallel.f95 gcc/testsuite/gfortran.dg/goacc/classify-parallel.f95
index e215c79be618..a23ea81609b4 100644
--- gcc/testsuite/gfortran.dg/goacc/classify-parallel.f95
+++ gcc/testsuite/gfortran.dg/goacc/classify-parallel.f95
@@ -2,6 +2,7 @@
 ! parallel.
 
 ! { dg-additional-options "-O2" }
+! { dg-additional-options "-fopt-info-optimized-omp" }
 ! { dg-additional-options "-fdump-tree-ompexp" }
 ! { dg-additional-options "-fdump-tree-oaccdevlow" }
 
@@ -13,7 +14,7 @@ program main
 
   call setup(a, b)
 
-  !$acc parallel loop copyin (a(0:n-1), b(0:n-1)) copyout (c(0:n-1))
+  !$acc parallel loop copyin (a(0:n-1), b(0:n-1)) copyout (c(0:n-1)) ! { dg-message "optimized: assigned OpenACC gang vector loop parallelism" }
   do i = 0, n - 1
      c(i) = a(i) + b(i)
   end do
diff --git gcc/testsuite/gfortran.dg/goacc/classify-routine.f95 gcc/testsuite/gfortran.dg/goacc/classify-routine.f95
index 4ca406742f90..5cf4c13acb81 100644
--- gcc/testsuite/gfortran.dg/goacc/classify-routine.f95
+++ gcc/testsuite/gfortran.dg/goacc/classify-routine.f95
@@ -2,6 +2,7 @@
 ! routine.
 
 ! { dg-additional-options "-O2" }
+! { dg-additional-options "-fopt-info-optimized-omp" }
 ! { dg-additional-options "-fdump-tree-ompexp" }
 ! { dg-additional-options "-fdump-tree-oaccdevlow" }
 
@@ -13,7 +14,7 @@ subroutine ROUTINE
 
   call setup(a, b)
 
-  !$acc loop
+  !$acc loop ! { dg-message "optimized: assigned OpenACC worker vector loop parallelism" }
   do i = 0, n - 1
      c(i) = a(i) + b(i)
   end do
diff --git gcc/testsuite/gfortran.dg/goacc/kernels-loop-inner.f95 gcc/testsuite/gfortran.dg/goacc/kernels-loop-inner.f95
index 333474141526..a3ad591f926c 100644
--- gcc/testsuite/gfortran.dg/goacc/kernels-loop-inner.f95
+++ gcc/testsuite/gfortran.dg/goacc/kernels-loop-inner.f95
@@ -1,4 +1,5 @@
 ! { dg-additional-options "-O2" }
+! { dg-additional-options "-fopt-info-optimized-omp" }
 
 program main
    implicit none
@@ -6,7 +7,7 @@ program main
    integer :: a(100,100), b(100,100)
    integer :: i, j, d
 
-   !$acc kernels
+   !$acc kernels ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
    do i=1,100
      do j=1,100
        a(i,j) = 1
diff --git gcc/testsuite/gfortran.dg/goacc/note-parallelism.f90 gcc/testsuite/gfortran.dg/goacc/note-parallelism.f90
new file mode 100644
index 000000000000..6c8a1bdc6a4c
--- /dev/null
+++ gcc/testsuite/gfortran.dg/goacc/note-parallelism.f90
@@ -0,0 +1,131 @@
+! Test the output of "-fopt-info-optimized-omp".
+
+! { dg-additional-options "-fopt-info-optimized-omp" }
+
+! See also "../../c-c++-common/goacc/note-parallelism.c".
+
+program test
+  implicit none
+
+  integer x, y, z
+
+  !$acc parallel
+  do x = 1, 10
+  end do
+  !$acc end parallel
+
+  !$acc parallel loop seq ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
+  do x = 1, 10
+  end do
+
+  !$acc parallel loop gang ! { dg-message "optimized: assigned OpenACC gang loop parallelis" }
+  do x = 1, 10
+  end do
+
+  !$acc parallel loop worker ! { dg-message "optimized: assigned OpenACC worker loop parallelism" }
+  do x = 1, 10
+  end do
+
+  !$acc parallel loop vector ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
+  do x = 1, 10
+  end do
+
+  !$acc parallel loop gang vector ! { dg-message "optimized: assigned OpenACC gang vector loop parallelism" }
+  do x = 1, 10
+  end do
+
+  !$acc parallel loop gang worker ! { dg-message "optimized: assigned OpenACC gang worker loop parallelism" }
+  do x = 1, 10
+  end do
+
+  !$acc parallel loop worker vector ! { dg-message "optimized: assigned OpenACC worker vector loop parallelism" }
+  do x = 1, 10
+  end do
+
+  !$acc parallel loop gang worker vector ! { dg-message "optimized: assigned OpenACC gang worker vector loop parallelism" }
+  do x = 1, 10
+  end do
+
+  !$acc parallel loop gang ! { dg-message "optimized: assigned OpenACC gang loop parallelism" }
+  do x = 1, 10
+     !$acc loop worker ! { dg-message "optimized: assigned OpenACC worker loop parallelism" }
+     do y = 1, 10
+        !$acc loop vector ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
+        do z = 1, 10
+        end do
+     end do
+  end do
+
+  !$acc parallel loop ! { dg-message "optimized: assigned OpenACC gang vector loop parallelism" }
+  do x = 1, 10
+  end do
+
+  !$acc parallel loop ! { dg-message "optimized: assigned OpenACC gang worker loop parallelism" }
+  do x = 1, 10
+     !$acc loop ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
+     do y = 1, 10
+     end do
+  end do
+
+  !$acc parallel loop ! { dg-message "optimized: assigned OpenACC gang loop parallelism" }
+  do x = 1, 10
+     !$acc loop ! { dg-message "optimized: assigned OpenACC worker loop parallelism" }
+     do y = 1, 10
+        !$acc loop ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
+        do z = 1, 10
+        end do
+     end do
+  end do
+
+  !$acc parallel
+  do x = 1, 10
+     !$acc loop ! { dg-message "optimized: assigned OpenACC gang worker loop parallelism" }
+     do y = 1, 10
+        !$acc loop ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
+        do z = 1, 10
+        end do
+     end do
+  end do
+  !$acc end parallel
+
+  !$acc parallel loop seq ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
+  do x = 1, 10
+     !$acc loop ! { dg-message "optimized: assigned OpenACC gang worker loop parallelism" }
+     do y = 1, 10
+        !$acc loop ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
+        do z = 1, 10
+        end do
+     end do
+  end do
+
+  !$acc parallel loop ! { dg-message "optimized: assigned OpenACC gang worker loop parallelism" }
+  do x = 1, 10
+     !$acc loop seq ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
+     do y = 1, 10
+        !$acc loop ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
+        do z = 1, 10
+        end do
+     end do
+  end do
+
+  !$acc parallel loop ! { dg-message "optimized: assigned OpenACC gang worker loop parallelism" }
+  do x = 1, 10
+     !$acc loop ! { dg-message "optimized: assigned OpenACC vector loop parallelism" }
+     do y = 1, 10
+        !$acc loop seq ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
+        do z = 1, 10
+        end do
+     end do
+  end do
+
+  !$acc parallel loop seq ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
+  do x = 1, 10
+     !$acc loop ! { dg-message "optimized: assigned OpenACC gang vector loop parallelism" }
+     do y = 1, 10
+        !$acc loop seq ! { dg-message "optimized: assigned OpenACC seq loop parallelism" }
+        do z = 1, 10
+        end do
+     end do
+  end do
+
+end program test


Grüße
 Thomas



More information about the Gcc-patches mailing list