public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tobias Burnus <burnus@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r11-8412] OpenMP: detach - fix firstprivate handling
Date: Thu, 13 May 2021 21:05:35 +0000 (GMT)	[thread overview]
Message-ID: <20210513210535.ADC66385800A@sourceware.org> (raw)

https://gcc.gnu.org/g:211a9230491f340cfc23dfe92ad481548a2d511b

commit r11-8412-g211a9230491f340cfc23dfe92ad481548a2d511b
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Thu May 13 00:12:31 2021 +0200

    OpenMP: detach - fix firstprivate handling
    
    gcc/ChangeLog:
    
            * omp-low.c (finish_taskreg_scan): Use the proper detach decl.
    
    libgomp/ChangeLog:
    
            * testsuite/libgomp.c-c++-common/task-detach-12.c: New test.
            * testsuite/libgomp.fortran/task-detach-12.f90: New test.
    
    (cherry picked from commit d21963ce7a87db3d4a6921a0fa98b72ea6f4e7f5)

Diff:
---
 gcc/omp-low.c                                      |  2 +-
 .../libgomp.c-c++-common/task-detach-12.c          | 19 +++++++++++++++++++
 .../testsuite/libgomp.fortran/task-detach-12.f90   | 22 ++++++++++++++++++++++
 3 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/gcc/omp-low.c b/gcc/omp-low.c
index 1bb7f2b3561..0817ee7091a 100644
--- a/gcc/omp-low.c
+++ b/gcc/omp-low.c
@@ -2460,7 +2460,7 @@ finish_taskreg_scan (omp_context *ctx)
 	  TYPE_FIELDS (ctx->record_type) = field;
 	  if (ctx->srecord_type)
 	    {
-	      field = lookup_sfield (OMP_CLAUSE_DECL (detach_clause), ctx);
+	      field = lookup_sfield (OMP_CLAUSE_DECL (c), ctx);
 	      p = &TYPE_FIELDS (ctx->srecord_type);
 	      while (*p)
 		if (*p == field)
diff --git a/libgomp/testsuite/libgomp.c-c++-common/task-detach-12.c b/libgomp/testsuite/libgomp.c-c++-common/task-detach-12.c
new file mode 100644
index 00000000000..65833189cd6
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c-c++-common/task-detach-12.c
@@ -0,0 +1,19 @@
+/* { dg-do run } */
+/* { dg-options "-fopenmp" } */
+
+#include <omp.h>
+
+int
+main ()
+{
+  struct S { int a[7]; } s = { { 1, 2, 3, 4, 5, 6, 7 } };
+  omp_event_handle_t x;
+  #pragma omp parallel master
+  #pragma omp task firstprivate (s) detach (x)
+    {
+      if (s.a[3] != 4)
+	__builtin_abort ();
+      omp_fulfill_event (x);
+    }
+  return 0;
+}
diff --git a/libgomp/testsuite/libgomp.fortran/task-detach-12.f90 b/libgomp/testsuite/libgomp.fortran/task-detach-12.f90
new file mode 100644
index 00000000000..88546fe473b
--- /dev/null
+++ b/libgomp/testsuite/libgomp.fortran/task-detach-12.f90
@@ -0,0 +1,22 @@
+program test
+    use omp_lib
+    implicit none
+    integer(omp_event_handle_kind) :: oevent, ievent
+    integer :: i
+    integer, allocatable :: temp(:)
+    ALLOCATE(temp(5))
+
+    !$omp parallel num_threads(3)
+    !$omp single
+    DO i=1,5
+    !$omp task firstprivate(i) firstprivate(temp)  detach(oevent)
+          temp(:) = 0;
+          temp(1) = -1;
+          !print *,temp
+          call omp_fulfill_event(oevent)
+    !$omp end task
+    ENDDO
+    !$omp taskwait
+    !$omp end single
+    !$omp end parallel
+end program


                 reply	other threads:[~2021-05-13 21:05 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210513210535.ADC66385800A@sourceware.org \
    --to=burnus@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).