public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc r12-1362] Extract 'goacc_enter_exit_data_internal' from 'libgomp/oacc-mem.c:GOACC_enter_exit_data'
@ 2021-06-10 11:40 Thomas Schwinge
  0 siblings, 0 replies; only message in thread
From: Thomas Schwinge @ 2021-06-10 11:40 UTC (permalink / raw)
  To: gcc-cvs

https://gcc.gnu.org/g:7999363961dc6feeb0976cc6d85ea91a120d0e1d

commit r12-1362-g7999363961dc6feeb0976cc6d85ea91a120d0e1d
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Tue Jun 8 17:39:25 2021 +0200

    Extract 'goacc_enter_exit_data_internal' from 'libgomp/oacc-mem.c:GOACC_enter_exit_data'
    
            libgomp/
            * oacc-mem.c (goacc_enter_exit_data_internal): New function,
            extracted from...
            (GOACC_enter_exit_data): ... here.
            (GOACC_declare): Use it.
    
    Co-Authored-By: Andrew Stubbs <ams@codesourcery.com>

Diff:
---
 libgomp/oacc-mem.c | 130 ++++++++++++++++++++++++++---------------------------
 1 file changed, 65 insertions(+), 65 deletions(-)

diff --git a/libgomp/oacc-mem.c b/libgomp/oacc-mem.c
index 056600aca52..f6173b91fdd 100644
--- a/libgomp/oacc-mem.c
+++ b/libgomp/oacc-mem.c
@@ -1320,56 +1320,22 @@ goacc_exit_data_internal (struct gomp_device_descr *acc_dev, size_t mapnum,
   gomp_mutex_unlock (&acc_dev->lock);
 }
 
-void
-GOACC_enter_exit_data (int flags_m, size_t mapnum, void **hostaddrs,
-		       size_t *sizes, unsigned short *kinds, int async,
-		       int num_waits, ...)
+static void
+goacc_enter_exit_data_internal (int flags_m, size_t mapnum, void **hostaddrs,
+				size_t *sizes, unsigned short *kinds,
+				bool data_enter, int async, int num_waits,
+				va_list *ap)
 {
   int flags = GOACC_FLAGS_UNMARSHAL (flags_m);
 
   struct goacc_thread *thr;
   struct gomp_device_descr *acc_dev;
-  bool data_enter = false;
-  size_t i;
 
   goacc_lazy_initialize ();
 
   thr = goacc_thread ();
   acc_dev = thr->dev;
 
-  /* Determine if this is an "acc enter data".  */
-  for (i = 0; i < mapnum; ++i)
-    {
-      unsigned char kind = kinds[i] & 0xff;
-
-      if (kind == GOMP_MAP_POINTER
-	  || kind == GOMP_MAP_TO_PSET
-	  || kind == GOMP_MAP_STRUCT)
-	continue;
-
-      if (kind == GOMP_MAP_FORCE_ALLOC
-	  || kind == GOMP_MAP_FORCE_PRESENT
-	  || kind == GOMP_MAP_ATTACH
-	  || kind == GOMP_MAP_FORCE_TO
-	  || kind == GOMP_MAP_TO
-	  || kind == GOMP_MAP_ALLOC)
-	{
-	  data_enter = true;
-	  break;
-	}
-
-      if (kind == GOMP_MAP_RELEASE
-	  || kind == GOMP_MAP_DELETE
-	  || kind == GOMP_MAP_DETACH
-	  || kind == GOMP_MAP_FORCE_DETACH
-	  || kind == GOMP_MAP_FROM
-	  || kind == GOMP_MAP_FORCE_FROM)
-	break;
-
-      gomp_fatal (">>>> GOACC_enter_exit_data UNHANDLED kind 0x%.2x",
-		      kind);
-    }
-
   bool profiling_p = GOACC_PROFILING_DISPATCH_P (true);
 
   acc_prof_info prof_info;
@@ -1433,13 +1399,7 @@ GOACC_enter_exit_data (int flags_m, size_t mapnum, void **hostaddrs,
     }
 
   if (num_waits)
-    {
-      va_list ap;
-
-      va_start (ap, num_waits);
-      goacc_wait (async, num_waits, &ap);
-      va_end (ap);
-    }
+    goacc_wait (async, num_waits, ap);
 
   goacc_aq aq = get_goacc_asyncqueue (async);
 
@@ -1462,6 +1422,52 @@ GOACC_enter_exit_data (int flags_m, size_t mapnum, void **hostaddrs,
     }
 }
 
+void
+GOACC_enter_exit_data (int flags_m, size_t mapnum, void **hostaddrs,
+		       size_t *sizes, unsigned short *kinds, int async,
+		       int num_waits, ...)
+{
+  /* Determine if this is an OpenACC "enter data".  */
+  bool data_enter = false;
+  for (size_t i = 0; i < mapnum; ++i)
+    {
+      unsigned char kind = kinds[i] & 0xff;
+
+      if (kind == GOMP_MAP_POINTER
+	  || kind == GOMP_MAP_TO_PSET
+	  || kind == GOMP_MAP_STRUCT)
+	continue;
+
+      if (kind == GOMP_MAP_FORCE_ALLOC
+	  || kind == GOMP_MAP_FORCE_PRESENT
+	  || kind == GOMP_MAP_ATTACH
+	  || kind == GOMP_MAP_FORCE_TO
+	  || kind == GOMP_MAP_TO
+	  || kind == GOMP_MAP_ALLOC)
+	{
+	  data_enter = true;
+	  break;
+	}
+
+      if (kind == GOMP_MAP_RELEASE
+	  || kind == GOMP_MAP_DELETE
+	  || kind == GOMP_MAP_DETACH
+	  || kind == GOMP_MAP_FORCE_DETACH
+	  || kind == GOMP_MAP_FROM
+	  || kind == GOMP_MAP_FORCE_FROM)
+	break;
+
+      gomp_fatal (">>>> GOACC_enter_exit_data UNHANDLED kind 0x%.2x",
+		      kind);
+    }
+
+  va_list ap;
+  va_start (ap, num_waits);
+  goacc_enter_exit_data_internal (flags_m, mapnum, hostaddrs, sizes, kinds,
+				  data_enter, async, num_waits, &ap);
+  va_end (ap);
+}
+
 void
 GOACC_declare (int flags_m, size_t mapnum,
 	       void **hostaddrs, size_t *sizes, unsigned short *kinds)
@@ -1475,34 +1481,28 @@ GOACC_declare (int flags_m, size_t mapnum,
 
       switch (kind)
 	{
+	case GOMP_MAP_ALLOC:
+	  if (acc_is_present (hostaddrs[i], sizes[i]))
+	    continue;
+	  /* FALLTHRU */
 	case GOMP_MAP_FORCE_ALLOC:
-	case GOMP_MAP_FORCE_FROM:
+	case GOMP_MAP_TO:
 	case GOMP_MAP_FORCE_TO:
+	  goacc_enter_exit_data_internal (flags_m, 1, &hostaddrs[i], &sizes[i],
+					  &kinds[i], true, GOMP_ASYNC_SYNC, 0, NULL);
+	  break;
+
+	case GOMP_MAP_FROM:
+	case GOMP_MAP_FORCE_FROM:
 	case GOMP_MAP_RELEASE:
 	case GOMP_MAP_DELETE:
-	  GOACC_enter_exit_data (flags_m, 1, &hostaddrs[i], &sizes[i],
-				 &kinds[i], GOMP_ASYNC_SYNC, 0);
+	  goacc_enter_exit_data_internal (flags_m, 1, &hostaddrs[i], &sizes[i],
+					  &kinds[i], false, GOMP_ASYNC_SYNC, 0, NULL);
 	  break;
 
 	case GOMP_MAP_FORCE_DEVICEPTR:
 	  break;
 
-	case GOMP_MAP_ALLOC:
-	  if (!acc_is_present (hostaddrs[i], sizes[i]))
-	    GOACC_enter_exit_data (flags_m, 1, &hostaddrs[i], &sizes[i],
-				   &kinds[i], GOMP_ASYNC_SYNC, 0);
-	  break;
-
-	case GOMP_MAP_TO:
-	  GOACC_enter_exit_data (flags_m, 1, &hostaddrs[i], &sizes[i],
-				 &kinds[i], GOMP_ASYNC_SYNC, 0);
-	  break;
-
-	case GOMP_MAP_FROM:
-	  GOACC_enter_exit_data (flags_m, 1, &hostaddrs[i], &sizes[i],
-				 &kinds[i], GOMP_ASYNC_SYNC, 0);
-	  break;
-
 	case GOMP_MAP_FORCE_PRESENT:
 	  if (!acc_is_present (hostaddrs[i], sizes[i]))
 	    gomp_fatal ("[%p,%ld] is not mapped", hostaddrs[i],


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-06-10 11:40 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-10 11:40 [gcc r12-1362] Extract 'goacc_enter_exit_data_internal' from 'libgomp/oacc-mem.c:GOACC_enter_exit_data' Thomas Schwinge

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).