From: Jakub Jelinek <jakub@redhat.com>
To: Tobias Burnus <tobias@codesourcery.com>
Cc: gcc-patches <gcc-patches@gcc.gnu.org>, fortran <fortran@gcc.gnu.org>
Subject: Re: [Patch] OpenMP/Fortran: Fix has_device_addr clause splitting [PR108558]
Date: Fri, 27 Jan 2023 10:25:26 +0100 [thread overview]
Message-ID: <Y9OYhpE0Lhu6mPQx@tucnak> (raw)
In-Reply-To: <eb57f55b-3b84-c853-3bab-731c5c6608c2@codesourcery.com>
On Fri, Jan 27, 2023 at 10:19:42AM +0100, Tobias Burnus wrote:
> Rather obvious fix. Hence, I intent to commit it later as obvious,
> unless there are any comments.
Yeah, this is obviously correct.
Have you checked the function if we don't miss other clauses in there
(e.g. compared to the C implementation)?
> 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.
>
> 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 87213de0918..5283d0ce5f3 100644
> --- a/gcc/fortran/trans-openmp.cc
> +++ b/gcc/fortran/trans-openmp.cc
> @@ -6205,6 +6205,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
Jakub
prev parent reply other threads:[~2023-01-27 9:25 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-27 9:19 Tobias Burnus
2023-01-27 9:25 ` Jakub Jelinek [this message]
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=Y9OYhpE0Lhu6mPQx@tucnak \
--to=jakub@redhat.com \
--cc=fortran@gcc.gnu.org \
--cc=gcc-patches@gcc.gnu.org \
--cc=tobias@codesourcery.com \
/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).