On 02/22/2017 12:17 AM, Thomas Schwinge wrote:
> On Mon, 20 Feb 2017 20:42:59 -0800, Cesar Philippidis 
> <ce...@codesourcery.com> wrote:

>> --- a/gcc/omp-low.c
>> +++ b/gcc/omp-low.c
> 
>> +/* Provide diagnostics on OpenACC loops LOOP, its siblings and its
>> +   children.  */
>> +
>> +static void
>> +inform_oacc_loop (oacc_loop *loop)
>> +{
>> +  const char *seq = loop->mask == 0 ? " SEQ" : "";
>> +  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" : "";
>> +
>> +  inform (loop->loc, "ACC LOOP%s%s%s%s", seq, gang, worker, vector);
> 
> Likewise.

This is now lower case.

> Per
> <8737f68y3r.fsf@euler.schwinge.homeip.net">http://mid.mail-archive.com/8737f68y3r.fsf@euler.schwinge.homeip.net>
> I'm suggesting this to be done a bit differently: instead of "inform",
> this would then use the appropriate "-fopt-info-note-omp" option group
> output.

Thank you for finding that. I see that you want to rename
OPTGROUP_OPENMP to OPTGROUP_OMP. In order to keep gomp-4_0-branch
somewhat consistent with trunk, I keep the original OPENMP name. We can
fix that later.

> If that's not yet there, possibly there could be some new flag added for
> "-fopt-info" to display the "rich" location, which will also print the
> original source code?

No it doesn't support rich locations yet. But that's a good idea to
support it. But we can add that later. For the time being, the line
number shall suffice.

Cesar

2017-02-23  Cesar Philippidis  <ce...@codesourcery.com>

	gcc/
	* omp-low.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.


diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index b25fe27..40f2003 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -20399,6 +20399,30 @@ debug_oacc_loop (oacc_loop *loop)
   dump_oacc_loop (stderr, loop, 0);
 }
 
+/* Provide diagnostics on OpenACC loops LOOP, its siblings and its
+   children.  */
+
+static void
+inform_oacc_loop (oacc_loop *loop)
+{
+  const char *seq = loop->mask == 0 ? " seq" : "";
+  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" : "";
+
+  dump_printf_loc (MSG_NOTE, loop->loc,
+		   "Detected parallelism <acc loop%s%s%s%s>\n", seq, gang,
+		   worker, vector);
+
+  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.  */
@@ -21069,6 +21093,8 @@ execute_oacc_device_lower ()
       dump_oacc_loop (dump_file, loops, 0);
       fprintf (dump_file, "\n");
     }
+  if (dump_enabled_p () && loops->child)
+    inform_oacc_loop (loops->child);
 
   /* Offloaded targets may introduce new basic blocks, which require
      dominance information to update SSA.  */
diff --git a/gcc/testsuite/c-c++-common/goacc/note-parallelism.c b/gcc/testsuite/c-c++-common/goacc/note-parallelism.c
new file mode 100644
index 0000000..ddbce99
--- /dev/null
+++ b/gcc/testsuite/c-c++-common/goacc/note-parallelism.c
@@ -0,0 +1,76 @@
+/* Test the output of -fopt-info-not-openmp.  */
+
+/* { dg-additional-options "-fopt-info-note-openmp" } */
+
+int
+main ()
+{
+  int x, y, z;
+
+#pragma acc parallel loop seq
+  for (x = 0; x < 10; x++)
+    ;
+
+#pragma acc parallel loop gang
+  for (x = 0; x < 10; x++)
+    ;
+
+#pragma acc parallel loop worker
+  for (x = 0; x < 10; x++)
+    ;
+
+#pragma acc parallel loop vector
+  for (x = 0; x < 10; x++)
+    ;
+
+#pragma acc parallel loop gang vector
+  for (x = 0; x < 10; x++)
+    ;
+
+#pragma acc parallel loop gang worker
+  for (x = 0; x < 10; x++)
+    ;
+
+#pragma acc parallel loop worker vector
+  for (x = 0; x < 10; x++)
+    ;
+
+#pragma acc parallel loop gang worker vector
+  for (x = 0; x < 10; x++)
+    ;
+
+#pragma acc parallel loop
+  for (x = 0; x < 10; x++)
+    ;
+
+#pragma acc parallel loop
+  for (x = 0; x < 10; x++)
+#pragma acc loop
+    for (y = 0; y < 10; y++)
+      ;
+
+#pragma acc parallel loop gang
+  for (x = 0; x < 10; x++)
+#pragma acc loop worker
+    for (y = 0; y < 10; y++)
+#pragma acc loop vector
+      for (z = 0; z < 10; z++)
+	;
+
+  return 0;
+}
+
+/* { dg-message "note-parallelism.c:10:9: note: Detected parallelism <acc loop seq>" "" { target *-*-* } 0 } */
+/* { dg-message "note-parallelism.c:14:9: note: Detected parallelism <acc loop gang>" "" { target *-*-* } 0 } */
+/* { dg-message "note-parallelism.c:18:9: note: Detected parallelism <acc loop worker>" "" { target *-*-* } 0 } */
+/* { dg-message "note-parallelism.c:22:9: note: Detected parallelism <acc loop vector>" "" { target *-*-* } 0 } */
+/* { dg-message "note-parallelism.c:26:9: note: Detected parallelism <acc loop gang vector>" "" { target *-*-* } 0 } */
+/* { dg-message "note-parallelism.c:30:9: note: Detected parallelism <acc loop gang worker>" "" { target *-*-* } 0 } */
+/* { dg-message "note-parallelism.c:34:9: note: Detected parallelism <acc loop worker vector>" "" { target *-*-* } 0 } */
+/* { dg-message "note-parallelism.c:38:9: note: Detected parallelism <acc loop gang worker vector>" "" { target *-*-* } 0 } */
+/* { dg-message "note-parallelism.c:42:9: note: Detected parallelism <acc loop gang vector>" "" { target *-*-* } 0 } */
+/* { dg-message "note-parallelism.c:46:9: note: Detected parallelism <acc loop gang worker>" "" { target *-*-* } 0 } */
+/* { dg-message "note-parallelism.c:48:9: note: Detected parallelism <acc loop vector>" "" { target *-*-* } 0 } */
+/* { dg-message "note-parallelism.c:52:9: note: Detected parallelism <acc loop gang>" "" { target *-*-* } 0 } */
+/* { dg-message "note-parallelism.c:54:9: note: Detected parallelism <acc loop worker>" "" { target *-*-* } 0 } */
+/* { dg-message "note-parallelism.c:56:9: note: Detected parallelism <acc loop vector>" "" { target *-*-* } 0 } */
diff --git a/gcc/testsuite/gfortran.dg/goacc/note-parallelism.f90 b/gcc/testsuite/gfortran.dg/goacc/note-parallelism.f90
new file mode 100644
index 0000000..ae6f341
--- /dev/null
+++ b/gcc/testsuite/gfortran.dg/goacc/note-parallelism.f90
@@ -0,0 +1,77 @@
+! Test the output of -fopt-info-note-openmp.
+
+! { dg-additional-options "-fopt-info-note-openmp" }
+
+program test
+  implicit none
+
+  integer x, y, z
+
+  !$acc parallel loop seq
+  do x = 1, 10
+  end do
+
+  !$acc parallel loop gang
+  do x = 1, 10
+  end do
+
+  !$acc parallel loop worker
+  do x = 1, 10
+  end do
+
+  !$acc parallel loop vector
+  do x = 1, 10
+  end do
+
+  !$acc parallel loop gang vector
+  do x = 1, 10
+  end do
+
+  !$acc parallel loop gang worker
+  do x = 1, 10
+  end do
+
+  !$acc parallel loop worker vector
+  do x = 1, 10
+  end do
+
+  !$acc parallel loop gang worker vector
+  do x = 1, 10
+  end do
+
+  !$acc parallel loop
+  do x = 1, 10
+  end do
+
+  !$acc parallel loop
+  do x = 1, 10
+     !$acc loop
+     do y = 1, 10
+     end do
+  end do
+
+  !$acc parallel loop gang
+  do x = 1, 10
+     !$acc loop worker
+     do y = 1, 10
+        !$acc loop vector
+        do z = 1, 10
+        end do
+     end do
+  end do
+end program test
+
+! { dg-message "note-parallelism.f90:10:0: note: Detected parallelism <acc loop seq>" "" { target *-*-* } 0 }
+! { dg-message "note-parallelism.f90:14:0: note: Detected parallelism <acc loop gang>" "" { target *-*-* } 0 }
+! { dg-message "note-parallelism.f90:18:0: note: Detected parallelism <acc loop worker>" "" { target *-*-* } 0 }
+! { dg-message "note-parallelism.f90:22:0: note: Detected parallelism <acc loop vector>" "" { target *-*-* } 0 }
+! { dg-message "note-parallelism.f90:26:0: note: Detected parallelism <acc loop gang vector>" "" { target *-*-* } 0 }
+! { dg-message "note-parallelism.f90:30:0: note: Detected parallelism <acc loop gang worker>" "" { target *-*-* } 0 }
+! { dg-message "note-parallelism.f90:34:0: note: Detected parallelism <acc loop worker vector>" "" { target *-*-* } 0 }
+! { dg-message "note-parallelism.f90:38:0: note: Detected parallelism <acc loop gang worker vector>" "" { target *-*-* } 0 }
+! { dg-message "note-parallelism.f90:42:0: note: Detected parallelism <acc loop gang vector>" "" { target *-*-* } 0 }
+! { dg-message "note-parallelism.f90:46:0: note: Detected parallelism <acc loop gang worker>" "" { target *-*-* } 0 }
+! { dg-message "note-parallelism.f90:48:0: note: Detected parallelism <acc loop vector>" "" { target *-*-* } 0 }
+! { dg-message "note-parallelism.f90:53:0: note: Detected parallelism <acc loop gang>" "" { target *-*-* } 0 }
+! { dg-message "note-parallelism.f90:55:0: note: Detected parallelism <acc loop worker>" "" { target *-*-* } 0 }
+! { dg-message "note-parallelism.f90:57:0: note: Detected parallelism <acc loop vector>" "" { target *-*-* } 0 }

Reply via email to