diff mbox series

[committed] Propagate attributes, including optimization and target node, to OMP outlined regions (PR tree-optimization/82374)

Message ID 20171004080110.GS18588@tucnak
State New
Headers show
Series [committed] Propagate attributes, including optimization and target node, to OMP outlined regions (PR tree-optimization/82374) | expand

Commit Message

Jakub Jelinek Oct. 4, 2017, 8:01 a.m. UTC
Hi!

This patch propagates attributes, including opt and target nodes, from
the containing function to the OMP/OACC outlined region functions.

Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk.

2017-10-04  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/82374
	* omp-low.c (create_omp_child_function): Copy DECL_ATTRIBUTES,
	DECL_FUNCTION_SPECIFIC_OPTIMIZATION,
	DECL_FUNCTION_SPECIFIC_TARGET and DECL_FUNCTION_VERSIONED from
	current_function_decl to the new decl.

	* gcc.dg/gomp/pr82374.c: New test.


	Jakub

Comments

Thomas Schwinge Oct. 4, 2017, 11:15 a.m. UTC | #1
Hi!

On Wed, 4 Oct 2017 10:01:10 +0200, Jakub Jelinek <jakub@redhat.com> wrote:
> This patch propagates attributes, including opt and target nodes, from
> the containing function to the OMP/OACC outlined region functions.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk.

Hmm, in your testing, why didn't you observe this breaking a few OpenACC
test cases?  Committed to trunk r253402, as obvious:

commit da7a1a683a84d32e9d7be6a5d00925fdfa125430
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Wed Oct 4 11:13:24 2017 +0000

    Adjust test cases for attributes propagation changes for OMP outlined regions
    
            PR tree-optimization/82374
            * c-c++-common/goacc/kernels-double-reduction-n.c: Adjust for
            attributes propagation changes for OMP outlined regions.
            * c-c++-common/goacc/kernels-double-reduction.c: Likewise.
            * c-c++-common/goacc/kernels-reduction.c: Likewise.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@253402 138bc75d-0d04-0410-961f-82ee72b054a4
---
 gcc/testsuite/ChangeLog                                       | 8 ++++++++
 gcc/testsuite/c-c++-common/goacc/kernels-double-reduction-n.c | 2 +-
 gcc/testsuite/c-c++-common/goacc/kernels-double-reduction.c   | 2 +-
 gcc/testsuite/c-c++-common/goacc/kernels-reduction.c          | 2 +-
 4 files changed, 11 insertions(+), 3 deletions(-)

diff --git gcc/testsuite/ChangeLog gcc/testsuite/ChangeLog
index 2c96f3a..4ac50d0 100644
--- gcc/testsuite/ChangeLog
+++ gcc/testsuite/ChangeLog
@@ -1,3 +1,11 @@
+2017-10-04  Thomas Schwinge  <thomas@codesourcery.com>
+
+	PR tree-optimization/82374
+	* c-c++-common/goacc/kernels-double-reduction-n.c: Adjust for
+	attributes propagation changes for OMP outlined regions.
+	* c-c++-common/goacc/kernels-double-reduction.c: Likewise.
+	* c-c++-common/goacc/kernels-reduction.c: Likewise.
+
 2017-10-04  Richard Sandiford  <richard.sandiford@linaro.org>
 
 	PR tree-optimization/82413
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 27ea2e9..10b364b 100644
--- gcc/testsuite/c-c++-common/goacc/kernels-double-reduction-n.c
+++ gcc/testsuite/c-c++-common/goacc/kernels-double-reduction-n.c
@@ -27,7 +27,7 @@ foo (unsigned int n)
 
 /* Check that only one loop is analyzed, and that it can be parallelized.  */
 /* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops1" } } */
-/* { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc kernels parallelized, oacc function \\(, , \\), oacc kernels, omp target entrypoint\\)\\)" 1 "parloops1" } } */
+/* { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc kernels parallelized, oacc function \\(, , \\), oacc kernels, omp target entrypoint, noclone, noinline\\)\\)" 1 "parloops1" } } */
 /* { dg-final { scan-tree-dump-not "FAILED:" "parloops1" } } */
 /* { dg-final { scan-tree-dump-times "parallelizing outer loop" 1 "parloops1" } } */
 
diff --git gcc/testsuite/c-c++-common/goacc/kernels-double-reduction.c gcc/testsuite/c-c++-common/goacc/kernels-double-reduction.c
index 0841e90..c026346 100644
--- gcc/testsuite/c-c++-common/goacc/kernels-double-reduction.c
+++ gcc/testsuite/c-c++-common/goacc/kernels-double-reduction.c
@@ -27,7 +27,7 @@ foo (void)
 
 /* Check that only one loop is analyzed, and that it can be parallelized.  */
 /* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops1" } } */
-/* { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc kernels parallelized, oacc function \\(, , \\), oacc kernels, omp target entrypoint\\)\\)" 1 "parloops1" } } */
+/* { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc kernels parallelized, oacc function \\(, , \\), oacc kernels, omp target entrypoint, noclone, noinline\\)\\)" 1 "parloops1" } } */
 /* { dg-final { scan-tree-dump-not "FAILED:" "parloops1" } } */
 /* { dg-final { scan-tree-dump-times "parallelizing outer loop" 1 "parloops1" } } */
 
diff --git gcc/testsuite/c-c++-common/goacc/kernels-reduction.c gcc/testsuite/c-c++-common/goacc/kernels-reduction.c
index 4a18272..5921b88 100644
--- gcc/testsuite/c-c++-common/goacc/kernels-reduction.c
+++ gcc/testsuite/c-c++-common/goacc/kernels-reduction.c
@@ -26,7 +26,7 @@ foo (void)
 
 /* Check that only one loop is analyzed, and that it can be parallelized.  */
 /* { dg-final { scan-tree-dump-times "SUCCESS: may be parallelized" 1 "parloops1" } } */
-/* { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc kernels parallelized, oacc function \\(, , \\), oacc kernels, omp target entrypoint\\)\\)" 1 "parloops1" } } */
+/* { dg-final { scan-tree-dump-times "(?n)__attribute__\\(\\(oacc kernels parallelized, oacc function \\(, , \\), oacc kernels, omp target entrypoint, noclone, noinline\\)\\)" 1 "parloops1" } } */
 /* { dg-final { scan-tree-dump-not "FAILED:" "parloops1" } } */
 
 /* Check that the loop has been split off into a function.  */


Grüße
 Thomas


> 2017-10-04  Jakub Jelinek  <jakub@redhat.com>
> 
> 	PR tree-optimization/82374
> 	* omp-low.c (create_omp_child_function): Copy DECL_ATTRIBUTES,
> 	DECL_FUNCTION_SPECIFIC_OPTIMIZATION,
> 	DECL_FUNCTION_SPECIFIC_TARGET and DECL_FUNCTION_VERSIONED from
> 	current_function_decl to the new decl.
> 
> 	* gcc.dg/gomp/pr82374.c: New test.
> 
> --- gcc/omp-low.c.jj	2017-09-05 23:32:02.000000000 +0200
> +++ gcc/omp-low.c	2017-10-03 12:25:13.956261522 +0200
> @@ -1626,6 +1626,14 @@ create_omp_child_function (omp_context *
>    DECL_CONTEXT (decl) = NULL_TREE;
>    DECL_INITIAL (decl) = make_node (BLOCK);
>    BLOCK_SUPERCONTEXT (DECL_INITIAL (decl)) = decl;
> +  DECL_ATTRIBUTES (decl) = DECL_ATTRIBUTES (current_function_decl);
> +  DECL_FUNCTION_SPECIFIC_OPTIMIZATION (decl)
> +    = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (current_function_decl);
> +  DECL_FUNCTION_SPECIFIC_TARGET (decl)
> +    = DECL_FUNCTION_SPECIFIC_TARGET (current_function_decl);
> +  DECL_FUNCTION_VERSIONED (decl)
> +    = DECL_FUNCTION_VERSIONED (current_function_decl);
> +
>    if (omp_maybe_offloaded_ctx (ctx))
>      {
>        cgraph_node::get_create (decl)->offloadable = 1;
> --- gcc/testsuite/gcc.dg/gomp/pr82374.c.jj	2017-10-03 13:09:15.515879118 +0200
> +++ gcc/testsuite/gcc.dg/gomp/pr82374.c	2017-10-03 13:08:56.000000000 +0200
> @@ -0,0 +1,31 @@
> +/* PR tree-optimization/82374 */
> +/* { dg-do compile } */
> +/* { dg-options "-O2 -fno-tree-vectorize -fdump-tree-vect-details" } */
> +/* { dg-additional-options "-mavx -mno-avx2" { target i?86-*-* x86_64-*-* } } */
> +/* { dg-additional-options "-mvsx" { target powerpc_vsx_ok } } */
> +
> +#define SIZE (1024 * 1024 * 1024)
> +
> +float a[SIZE];
> +float b[SIZE];
> +float c[SIZE];
> +float d[SIZE];
> +
> +__attribute__((optimize ("O2", "tree-vectorize"))) void
> +foo (void)
> +{
> +  int i;
> +#pragma omp parallel for
> +  for (i = 0; i < SIZE; i++)
> +    c[i] = a[i] + b[i];
> +}
> +
> +__attribute__((optimize ("O2", "tree-vectorize"))) void
> +bar (void)
> +{
> +  int i;
> +  for (i = 0; i < SIZE; i++)
> +    d[i] = a[i] + b[i];
> +}
> +
> +/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target { { i?86-*-* x86_64-*-* } || { powerpc_vsx_ok } } } } } */
> 
> 	Jakub
Rainer Orth Oct. 5, 2017, 7:59 a.m. UTC | #2
Hi Jakub,

> This patch propagates attributes, including opt and target nodes, from
> the containing function to the OMP/OACC outlined region functions.
>
> Bootstrapped/regtested on x86_64-linux and i686-linux, committed to trunk.
>
> 2017-10-04  Jakub Jelinek  <jakub@redhat.com>
>
> 	PR tree-optimization/82374
> 	* omp-low.c (create_omp_child_function): Copy DECL_ATTRIBUTES,
> 	DECL_FUNCTION_SPECIFIC_OPTIMIZATION,
> 	DECL_FUNCTION_SPECIFIC_TARGET and DECL_FUNCTION_VERSIONED from
> 	current_function_decl to the new decl.
>
> 	* gcc.dg/gomp/pr82374.c: New test.

the new tests FAILs on 32-bit targets (seen on 32-bit Solaris and
Linux/x86_64 -m32):

FAIL: gcc.dg/gomp/pr82374.c (test for excess errors)
UNRESOLVED: gcc.dg/gomp/pr82374.c scan-tree-dump-times vect "vectorized 1 loops" 2

Excess errors:
/vol/gcc/src/hg/trunk/local/gcc/testsuite/gcc.dg/gomp/pr82374.c:9:7: error: size of array 'a' is too large
/vol/gcc/src/hg/trunk/local/gcc/testsuite/gcc.dg/gomp/pr82374.c:10:7: error: size of array 'b' is too large
/vol/gcc/src/hg/trunk/local/gcc/testsuite/gcc.dg/gomp/pr82374.c:11:7: error: size of array 'c' is too large
/vol/gcc/src/hg/trunk/local/gcc/testsuite/gcc.dg/gomp/pr82374.c:12:7: error: size of array 'd' is too large

gcc.dg/gomp/pr82374.c: dump file does not exist

	Rainer
Jakub Jelinek Oct. 5, 2017, 8:14 a.m. UTC | #3
On Thu, Oct 05, 2017 at 09:59:35AM +0200, Rainer Orth wrote:
> Hi Jakub,
> 
> > 2017-10-04  Jakub Jelinek  <jakub@redhat.com>
> >
> > 	PR tree-optimization/82374
> > 	* omp-low.c (create_omp_child_function): Copy DECL_ATTRIBUTES,
> > 	DECL_FUNCTION_SPECIFIC_OPTIMIZATION,
> > 	DECL_FUNCTION_SPECIFIC_TARGET and DECL_FUNCTION_VERSIONED from
> > 	current_function_decl to the new decl.
> >
> > 	* gcc.dg/gomp/pr82374.c: New test.
> 
> the new tests FAILs on 32-bit targets (seen on 32-bit Solaris and
> Linux/x86_64 -m32):
> 
> FAIL: gcc.dg/gomp/pr82374.c (test for excess errors)
> UNRESOLVED: gcc.dg/gomp/pr82374.c scan-tree-dump-times vect "vectorized 1 loops" 2
> 
> Excess errors:
> /vol/gcc/src/hg/trunk/local/gcc/testsuite/gcc.dg/gomp/pr82374.c:9:7: error: size of array 'a' is too large
> /vol/gcc/src/hg/trunk/local/gcc/testsuite/gcc.dg/gomp/pr82374.c:10:7: error: size of array 'b' is too large
> /vol/gcc/src/hg/trunk/local/gcc/testsuite/gcc.dg/gomp/pr82374.c:11:7: error: size of array 'c' is too large
> /vol/gcc/src/hg/trunk/local/gcc/testsuite/gcc.dg/gomp/pr82374.c:12:7: error: size of array 'd' is too large
> 
> gcc.dg/gomp/pr82374.c: dump file does not exist

Oops, sorry, somehow I've missed this and also the goacc regressions when
testing the above patch; I've noticed this FAIL last night, just didn't get
to that until this morning, fixed thusly, committed as obvious:

2017-10-05  Jakub Jelinek  <jakub@redhat.com>

	* gcc.dg/gomp/pr82374.c (SIZE): Change from 1G to 1M to make it ilp32
	friendly.

--- gcc/testsuite/gcc.dg/gomp/pr82374.c.jj	2017-10-04 09:50:02.000000000 +0200
+++ gcc/testsuite/gcc.dg/gomp/pr82374.c	2017-10-05 10:06:29.630860238 +0200
@@ -4,7 +4,7 @@
 /* { dg-additional-options "-mavx -mno-avx2" { target i?86-*-* x86_64-*-* } } */
 /* { dg-additional-options "-mvsx" { target powerpc_vsx_ok } } */
 
-#define SIZE (1024 * 1024 * 1024)
+#define SIZE (1024 * 1024)
 
 float a[SIZE];
 float b[SIZE];


	Jakub
diff mbox series

Patch

--- gcc/omp-low.c.jj	2017-09-05 23:32:02.000000000 +0200
+++ gcc/omp-low.c	2017-10-03 12:25:13.956261522 +0200
@@ -1626,6 +1626,14 @@  create_omp_child_function (omp_context *
   DECL_CONTEXT (decl) = NULL_TREE;
   DECL_INITIAL (decl) = make_node (BLOCK);
   BLOCK_SUPERCONTEXT (DECL_INITIAL (decl)) = decl;
+  DECL_ATTRIBUTES (decl) = DECL_ATTRIBUTES (current_function_decl);
+  DECL_FUNCTION_SPECIFIC_OPTIMIZATION (decl)
+    = DECL_FUNCTION_SPECIFIC_OPTIMIZATION (current_function_decl);
+  DECL_FUNCTION_SPECIFIC_TARGET (decl)
+    = DECL_FUNCTION_SPECIFIC_TARGET (current_function_decl);
+  DECL_FUNCTION_VERSIONED (decl)
+    = DECL_FUNCTION_VERSIONED (current_function_decl);
+
   if (omp_maybe_offloaded_ctx (ctx))
     {
       cgraph_node::get_create (decl)->offloadable = 1;
--- gcc/testsuite/gcc.dg/gomp/pr82374.c.jj	2017-10-03 13:09:15.515879118 +0200
+++ gcc/testsuite/gcc.dg/gomp/pr82374.c	2017-10-03 13:08:56.000000000 +0200
@@ -0,0 +1,31 @@ 
+/* PR tree-optimization/82374 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-tree-vectorize -fdump-tree-vect-details" } */
+/* { dg-additional-options "-mavx -mno-avx2" { target i?86-*-* x86_64-*-* } } */
+/* { dg-additional-options "-mvsx" { target powerpc_vsx_ok } } */
+
+#define SIZE (1024 * 1024 * 1024)
+
+float a[SIZE];
+float b[SIZE];
+float c[SIZE];
+float d[SIZE];
+
+__attribute__((optimize ("O2", "tree-vectorize"))) void
+foo (void)
+{
+  int i;
+#pragma omp parallel for
+  for (i = 0; i < SIZE; i++)
+    c[i] = a[i] + b[i];
+}
+
+__attribute__((optimize ("O2", "tree-vectorize"))) void
+bar (void)
+{
+  int i;
+  for (i = 0; i < SIZE; i++)
+    d[i] = a[i] + b[i];
+}
+
+/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 2 "vect" { target { { i?86-*-* x86_64-*-* } || { powerpc_vsx_ok } } } } } */