[gcc/devel/omp/gcc-12] openmp: Fix up get-mapped-ptr-1.{c,f90} tests
Tobias Burnus
burnus@gcc.gnu.org
Tue Jul 5 10:32:14 GMT 2022
https://gcc.gnu.org/g:11b4126ce10d1d708dc6866faa50f0bf4f546de8
commit 11b4126ce10d1d708dc6866faa50f0bf4f546de8
Author: Jakub Jelinek <jakub@redhat.com>
Date: Tue Jul 5 11:27:03 2022 +0200
openmp: Fix up get-mapped-ptr-1.{c,f90} tests
On Tue, Jun 14, 2022 at 06:41:37PM +0200, Thomas Schwinge wrote:
> In an offloading configuration, I'm seeing:
>
> PASS: libgomp.fortran/get-mapped-ptr-1.f90 -O (test for excess errors)
> [-PASS:-]{+FAIL:+} libgomp.fortran/get-mapped-ptr-1.f90 -O execution test
>
> Does that one need similar treatment?
I assume not just that but libgomp.c-c++-common/get-mapped-ptr-1.c too?
It both needs the same treatment, and in the get-mapped-ptr-1.c
case there is even UB, while the Fortran version was using c_loc (q)
as the host pointer, in C/C++ it was using q which was value of
uninitialized pointer.
2022-06-15 Jakub Jelinek <jakub@redhat.com>
* testsuite/libgomp.c-c++-common/get-mapped-ptr-1.c (main): Initialize
q to ddress of an automatic variable. Use -5 instead of -1 in
omp_get_mapped_ptr call. Add test with omp_initial_device.
* testsuite/libgomp.fortran/get-mapped-ptr-1.f90 (main): Use -5 instead
of -1 in omp_get_mapped_ptr call. Add test with omp_initial_device.
Renumber stop arguments afterwards.
(cherry picked from commit 7bfb3f488a7ec58109a859c66bf4eddc6354065b)
Diff:
---
libgomp/ChangeLog.omp | 12 ++++++++++++
libgomp/testsuite/libgomp.c-c++-common/get-mapped-ptr-1.c | 10 ++++++++--
libgomp/testsuite/libgomp.fortran/get-mapped-ptr-1.f90 | 12 ++++++++----
3 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index 6bc07725af1..cfb47039178 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,3 +1,15 @@
+2022-07-05 Tobias Burnus <tobias@codesourcery.com>
+
+ Backport from mainline:
+ 2022-06-15 Jakub Jelinek <jakub@redhat.com>
+
+ * testsuite/libgomp.c-c++-common/get-mapped-ptr-1.c (main): Initialize
+ q to ddress of an automatic variable. Use -5 instead of -1 in
+ omp_get_mapped_ptr call. Add test with omp_initial_device.
+ * testsuite/libgomp.fortran/get-mapped-ptr-1.f90 (main): Use -5 instead
+ of -1 in omp_get_mapped_ptr call. Add test with omp_initial_device.
+ Renumber stop arguments afterwards.
+
2022-07-05 Tobias Burnus <tobias@codesourcery.com>
Backport from mainline:
diff --git a/libgomp/testsuite/libgomp.c-c++-common/get-mapped-ptr-1.c b/libgomp/testsuite/libgomp.c-c++-common/get-mapped-ptr-1.c
index 97a60ca9541..4708ae86bfe 100644
--- a/libgomp/testsuite/libgomp.c-c++-common/get-mapped-ptr-1.c
+++ b/libgomp/testsuite/libgomp.c-c++-common/get-mapped-ptr-1.c
@@ -6,7 +6,10 @@ main ()
{
int d = omp_get_default_device ();
int id = omp_get_initial_device ();
- void *p , *q;
+ int x;
+ void *p, *q;
+
+ q = (void *) &x;
if (d < 0 || d >= omp_get_num_devices ())
d = id;
@@ -18,7 +21,7 @@ main ()
if (omp_target_associate_ptr (q, p, sizeof (int), 0, d) != 0)
return 0;
- if (omp_get_mapped_ptr (q, -1) != NULL)
+ if (omp_get_mapped_ptr (q, -5) != NULL)
abort ();
if (omp_get_mapped_ptr (q, omp_get_num_devices () + 1) != NULL)
@@ -27,6 +30,9 @@ main ()
if (omp_get_mapped_ptr (q, id) != q)
abort ();
+ if (omp_get_mapped_ptr (q, omp_initial_device) != q)
+ abort ();
+
if (omp_get_mapped_ptr (q, d) != p)
abort ();
diff --git a/libgomp/testsuite/libgomp.fortran/get-mapped-ptr-1.f90 b/libgomp/testsuite/libgomp.fortran/get-mapped-ptr-1.f90
index de05179ce9f..9b6334f50d8 100644
--- a/libgomp/testsuite/libgomp.fortran/get-mapped-ptr-1.f90
+++ b/libgomp/testsuite/libgomp.fortran/get-mapped-ptr-1.f90
@@ -19,7 +19,7 @@ program main
if (omp_target_associate_ptr (c_loc (q), p, c_sizeof (q), &
0_c_size_t, d) == 0) then
- if(c_associated (omp_get_mapped_ptr (c_loc (q), -1))) &
+ if(c_associated (omp_get_mapped_ptr (c_loc (q), -5))) &
stop 1
if(c_associated (omp_get_mapped_ptr (c_loc (q), &
@@ -29,14 +29,18 @@ program main
if(.not. c_associated (omp_get_mapped_ptr (c_loc (q), id), c_loc (q))) &
stop 3
- if(.not. c_associated (omp_get_mapped_ptr (c_loc (q), d), p)) &
+ if(.not. c_associated (omp_get_mapped_ptr (c_loc (q), omp_initial_device), &
+ c_loc (q))) &
stop 4
- if (omp_target_disassociate_ptr (c_loc (q), d) /= 0) &
+ if(.not. c_associated (omp_get_mapped_ptr (c_loc (q), d), p)) &
stop 5
- if(c_associated (omp_get_mapped_ptr (c_loc (q), d))) &
+ if (omp_target_disassociate_ptr (c_loc (q), d) /= 0) &
stop 6
+
+ if(c_associated (omp_get_mapped_ptr (c_loc (q), d))) &
+ stop 7
end if
call omp_target_free (p, d)
More information about the Gcc-cvs
mailing list