public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Tobias Burnus <burnus@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc/devel/omp/gcc-11] libgomp/testsuite: Improve omp_get_device_num() tests
Date: Sun, 27 Feb 2022 21:35:34 +0000 (GMT)	[thread overview]
Message-ID: <20220227213534.E8F613858C39@sourceware.org> (raw)

https://gcc.gnu.org/g:741b4cd5d011e60f30c757d2438d0254b5616f56

commit 741b4cd5d011e60f30c757d2438d0254b5616f56
Author: Tobias Burnus <tobias@codesourcery.com>
Date:   Tue Jan 4 14:58:06 2022 +0100

    libgomp/testsuite: Improve omp_get_device_num() tests
    
    Related to r12-6208-gebc853deb7cc0487de9ef6e891a007ba853d1933
    "libgomp: Fix GOMP_DEVICE_NUM_VAR stringification during offload image load"
    
    That commit fixed an issue with omp_get_device_num() on gcn/nvptx that
    resulted in having always the value 0.
    This commit modifies the tests to iterate over all devices such that on a
    multi-nonhost-device system it had detected that always-zero issue.
    
    libgomp/ChangeLog:
    
            * testsuite/libgomp.c-c++-common/target-45.c: Iterate over all devices.
            * testsuite/libgomp.fortran/target10.f90: Likewise.
    
    (cherry picked from commit be661959a6b6d8f9c3c8608a746789e7b2ec3ca4)

Diff:
---
 libgomp/ChangeLog.omp                              |  8 +++++++
 libgomp/testsuite/libgomp.c-c++-common/target-45.c | 28 +++++++++++++---------
 libgomp/testsuite/libgomp.fortran/target10.f90     | 18 +++++++-------
 3 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index f8a2ff30f15..f03b4315ae1 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,3 +1,11 @@
+2022-02-27  Tobias Burnus  <tobias@codesourcery.com>
+
+	Backported from master:
+	2022-01-04 Tobias Burnus  <tobias@codesourcery.com>
+
+	* testsuite/libgomp.c-c++-common/target-45.c: Iterate over all devices.
+	* testsuite/libgomp.fortran/target10.f90: Likewise.
+
 2022-02-27  Tobias Burnus  <tobias@codesourcery.com>
 
 	Backported from master:
diff --git a/libgomp/testsuite/libgomp.c-c++-common/target-45.c b/libgomp/testsuite/libgomp.c-c++-common/target-45.c
index ec0d202e51c..03653f2fd50 100644
--- a/libgomp/testsuite/libgomp.c-c++-common/target-45.c
+++ b/libgomp/testsuite/libgomp.c-c++-common/target-45.c
@@ -14,17 +14,23 @@ int main (void)
   int device_num;
   int initial_device;
 
-  #pragma omp target map(from: device_num, initial_device)
-  {
-    initial_device = omp_is_initial_device ();
-    device_num = omp_get_device_num ();
-  }
-
-  if (initial_device && host_device_num != device_num)
-    abort ();
-
-  if (!initial_device && host_device_num == device_num)
-    abort ();
+  for (int i = 0; i <= omp_get_num_devices (); i++)
+    {
+      #pragma omp target map(from: device_num, initial_device) device(i)
+	{
+	  initial_device = omp_is_initial_device ();
+	  device_num = omp_get_device_num ();
+	}
+
+      if (i != device_num)
+	abort ();
+
+      if (initial_device && host_device_num != device_num)
+	abort ();
+
+      if (!initial_device && host_device_num == device_num)
+	abort ();
+    }
 
   return 0;
 }
diff --git a/libgomp/testsuite/libgomp.fortran/target10.f90 b/libgomp/testsuite/libgomp.fortran/target10.f90
index 0b939ad7a0d..edfd3514aac 100644
--- a/libgomp/testsuite/libgomp.fortran/target10.f90
+++ b/libgomp/testsuite/libgomp.fortran/target10.f90
@@ -3,18 +3,20 @@
 program main
   use omp_lib
   implicit none
-  integer :: device_num, host_device_num
+  integer :: device_num, host_device_num, i
   logical :: initial_device
 
   host_device_num = omp_get_device_num ()
   if (host_device_num .ne. omp_get_initial_device ()) stop 1
 
-  !$omp target map(from: device_num, initial_device)
-  initial_device = omp_is_initial_device ()
-  device_num = omp_get_device_num ()
-  !$omp end target
-
-  if (initial_device .and. (host_device_num .ne. device_num)) stop 2
-  if ((.not. initial_device) .and. (host_device_num .eq. device_num)) stop 3
+  do i = 0, omp_get_num_devices ()
+    !$omp target map(from: device_num, initial_device) device(i)
+      initial_device = omp_is_initial_device ()
+      device_num = omp_get_device_num ()
+    !$omp end target
+    if (i /= device_num) stop 2
+    if (initial_device .and. (host_device_num .ne. device_num)) stop 3
+    if ((.not. initial_device) .and. (host_device_num .eq. device_num)) stop 4
+  end do
 
 end program main


                 reply	other threads:[~2022-02-27 21:35 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20220227213534.E8F613858C39@sourceware.org \
    --to=burnus@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /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).