From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1534) id ADC66385800A; Thu, 13 May 2021 21:05:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org ADC66385800A MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Tobias Burnus To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-8412] OpenMP: detach - fix firstprivate handling X-Act-Checkin: gcc X-Git-Author: Tobias Burnus X-Git-Refname: refs/heads/releases/gcc-11 X-Git-Oldrev: e218c2985d21dbdf747f39aa478cf696f85f226b X-Git-Newrev: 211a9230491f340cfc23dfe92ad481548a2d511b Message-Id: <20210513210535.ADC66385800A@sourceware.org> Date: Thu, 13 May 2021 21:05:35 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 13 May 2021 21:05:35 -0000 https://gcc.gnu.org/g:211a9230491f340cfc23dfe92ad481548a2d511b commit r11-8412-g211a9230491f340cfc23dfe92ad481548a2d511b Author: Tobias Burnus 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 + +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