public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r11-8412] OpenMP: detach - fix firstprivate handling
@ 2021-05-13 21:05 Tobias Burnus
0 siblings, 0 replies; only message in thread
From: Tobias Burnus @ 2021-05-13 21:05 UTC (permalink / raw)
To: gcc-cvs
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2021-05-13 21:05 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-13 21:05 [gcc r11-8412] OpenMP: detach - fix firstprivate handling Tobias Burnus
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).