From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1534) id 89C443858D32; Mon, 30 Jan 2023 08:57:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 89C443858D32 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1675069031; bh=Yx/tEczkdpxlsLgFnVsBmWvSxR2sGfa0RUuKCY+3ZZo=; h=From:To:Subject:Date:From; b=J6PjOueHgq+1E8YImlpVuBqcaZbgU5NOgmctbXOEbcV5wVw+S/VCJkyydu9XNZsNz GyOi9x57jxyALLCZQIWBRemSfgCNepM2lCv4MJG5ZcPfSL4/Hm/9PAeJ+KjcvqVV8W 6jZ5chgtd1MzuhVHV0/TJmXc8zHsCG3w7KAYUDyE= 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 r12-9090] OpenMP/Fortran: Fix has_device_addr clause splitting [PR108558] X-Act-Checkin: gcc X-Git-Author: Tobias Burnus X-Git-Refname: refs/heads/releases/gcc-12 X-Git-Oldrev: 355fe4fa4c53764c09cf72bba1f04926fd489368 X-Git-Newrev: 591ec4820aa4e6d757ddc76cae1d92d445daf72c Message-Id: <20230130085711.89C443858D32@sourceware.org> Date: Mon, 30 Jan 2023 08:57:11 +0000 (GMT) List-Id: https://gcc.gnu.org/g:591ec4820aa4e6d757ddc76cae1d92d445daf72c commit r12-9090-g591ec4820aa4e6d757ddc76cae1d92d445daf72c Author: Tobias Burnus Date: Fri Jan 27 11:32:19 2023 +0100 OpenMP/Fortran: Fix has_device_addr clause splitting [PR108558] gcc/fortran/ChangeLog: PR fortran/108558 * trans-openmp.cc (gfc_split_omp_clauses): Handle has_device_addr. libgomp/ChangeLog: PR fortran/108558 * testsuite/libgomp.fortran/has_device_addr.f90: New test. (cherry picked from commit 2325c8920bbc99edcc9fffaa79577c528df41eb8) Diff: --- gcc/fortran/trans-openmp.cc | 2 + .../testsuite/libgomp.fortran/has_device_addr.f90 | 59 ++++++++++++++++++++++ 2 files changed, 61 insertions(+) diff --git a/gcc/fortran/trans-openmp.cc b/gcc/fortran/trans-openmp.cc index 43d59abe9e0..2d6f2438110 100644 --- a/gcc/fortran/trans-openmp.cc +++ b/gcc/fortran/trans-openmp.cc @@ -6070,6 +6070,8 @@ gfc_split_omp_clauses (gfc_code *code, = code->ext.omp_clauses->lists[OMP_LIST_MAP]; clausesa[GFC_OMP_SPLIT_TARGET].lists[OMP_LIST_IS_DEVICE_PTR] = code->ext.omp_clauses->lists[OMP_LIST_IS_DEVICE_PTR]; + clausesa[GFC_OMP_SPLIT_TARGET].lists[OMP_LIST_HAS_DEVICE_ADDR] + = code->ext.omp_clauses->lists[OMP_LIST_HAS_DEVICE_ADDR]; clausesa[GFC_OMP_SPLIT_TARGET].device = code->ext.omp_clauses->device; clausesa[GFC_OMP_SPLIT_TARGET].thread_limit diff --git a/libgomp/testsuite/libgomp.fortran/has_device_addr.f90 b/libgomp/testsuite/libgomp.fortran/has_device_addr.f90 new file mode 100644 index 00000000000..95cc7788f2d --- /dev/null +++ b/libgomp/testsuite/libgomp.fortran/has_device_addr.f90 @@ -0,0 +1,59 @@ +! { dg-additional-options "-fdump-tree-original" } + +! +! PR fortran/108558 +! + +! { dg-final { scan-tree-dump-times "#pragma omp target has_device_addr\\(x\\) has_device_addr\\(y\\)" 2 "original" } } +! { dg-final { scan-tree-dump-times "#pragma omp target data map\\(tofrom:x\\) map\\(tofrom:y\\)" 2 "original" } } +! { dg-final { scan-tree-dump-times "#pragma omp target data use_device_addr\\(x\\) use_device_addr\\(y\\)" 1 "original" } } +! { dg-final { scan-tree-dump-times "#pragma omp target update from\\(y\\)" 1 "original" } } +! { dg-final { scan-tree-dump-times "#pragma omp target data map\\(tofrom:x\\) map\\(tofrom:y\\) use_device_addr\\(x\\) use_device_addr\\(y\\)" 1 "original" } } +! { dg-final { scan-tree-dump-times "#pragma omp teams" 2 "original" } } +! { dg-final { scan-tree-dump-times "#pragma omp distribute" 2 "original" } } +! { dg-final { scan-tree-dump-times "#pragma omp parallel" 2 "original" } } +! { dg-final { scan-tree-dump-times "#pragma omp for nowait" 2 "original" } } + +module m +contains +subroutine vectorAdd(x, y, N) + implicit none + integer :: N + integer(4) :: x(N), y(N) + integer :: i + + !$omp target teams distribute parallel do has_device_addr(x, y) + do i = 1, N + y(i) = x(i) + y(i) + end do +end subroutine vectorAdd +end module m + +program main + use m + implicit none + integer, parameter :: N = 9876 + integer(4) :: x(N), y(N) + integer :: i + + x(:) = 1 + y(:) = 2 + + !$omp target data map(x, y) + !$omp target data use_device_addr(x, y) + call vectorAdd(x, y, N) + !$omp end target data + !$omp target update from(y) + if (any (y /= 3)) error stop + !$omp end target data + + x = 1 + y = 2 + !$omp target data map(x, y) use_device_addr(x, y) + !$omp target teams distribute parallel do has_device_addr(x, y) + do i = 1, N + y(i) = x(i) + y(i) + end do + !$omp end target data + if (any (y /= 3)) error stop +end program