This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [gomp4] libgomp updates


Hi!

On Wed, 17 Dec 2014 23:31:56 +0100, I wrote:
> On Wed, 17 Dec 2014 23:24:17 +0100, I wrote:
> > Committed to gomp-4_0-branch in r218839:
> > 
> > commit 1c4f05a68c6d0d5b6137bb6d85a293d16727b389
> > Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
> > Date:   Wed Dec 17 22:23:02 2014 +0000
> > 
> >     libgomp updates.
> 
> This has broken libgomp/libgomp_target.h usage from liboffloadmic/plugin.
> Committed to gomp-4_0-branch in r218841:
> 
> commit db16ceabfcaaa6c9e41c01e289201e6a9fbe3b26
> Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
> Date:   Wed Dec 17 22:30:30 2014 +0000
> 
>     libgomp: Again make libgomp_target.h safe to use "from outside".
>     
>     	libgomp/
>     	* libgomp_g.h: Move internal stuff from here...
>     	* libgomp_target.h: ..., and here...
>     	* libgomp.h: ... into here.

> --- libgomp/libgomp.h
> +++ libgomp/libgomp.h

> +#define TARGET_CAP_SHARED_MEM	1
> +#define TARGET_CAP_NATIVE_EXEC	2
> +#define TARGET_CAP_OPENMP_400	4
> +#define TARGET_CAP_OPENACC_200	8

> --- libgomp/libgomp_target.h
> +++ libgomp/libgomp_target.h

> -#define TARGET_CAP_SHARED_MEM	1
> -#define TARGET_CAP_NATIVE_EXEC	2
> -#define TARGET_CAP_OPENMP_400	4
> -#define TARGET_CAP_OPENACC_200	8

Those are actually part of the libgomp/plugin interface; committed to
gomp-4_0-branch in r219020:

commit 5932be162d00a1a8c27ec612255c01a57327a942
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Mon Dec 22 16:47:08 2014 +0000

    libgomp: GOMP_OFFLOAD_* are part of the libgomp/plugin interface.
    
    	libgomp/
    	* libgomp.h (TARGET_CAP_SHARED_MEM, TARGET_CAP_NATIVE_EXEC)
    	(TARGET_CAP_OPENMP_400, TARGET_CAP_OPENACC_200): Remove, and
    	instead...
    	* libgomp_target.h (GOMP_OFFLOAD_CAP_SHARED_MEM)
    	(GOMP_OFFLOAD_CAP_NATIVE_EXEC, GOMP_OFFLOAD_CAP_OPENMP_400)
    	(GOMP_OFFLOAD_CAP_OPENACC_200): ... add these new definitions.
    	Change all users.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@219020 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog.gomp        |  8 ++++++++
 libgomp/libgomp.h             |  5 -----
 libgomp/libgomp_target.h      |  6 ++++++
 libgomp/oacc-host.c           |  5 +++--
 libgomp/oacc-mem.c            |  2 +-
 libgomp/oacc-parallel.c       |  8 ++++----
 libgomp/plugin/plugin-host.c  | 25 +++++++++++++------------
 libgomp/plugin/plugin-nvptx.c | 25 ++++++++++++-------------
 libgomp/target.c              | 26 +++++++++++++++-----------
 9 files changed, 62 insertions(+), 48 deletions(-)

diff --git libgomp/ChangeLog.gomp libgomp/ChangeLog.gomp
index a36ec1f..898040d 100644
--- libgomp/ChangeLog.gomp
+++ libgomp/ChangeLog.gomp
@@ -1,5 +1,13 @@
 2014-12-22  Thomas Schwinge  <thomas@codesourcery.com>
 
+	* libgomp.h (TARGET_CAP_SHARED_MEM, TARGET_CAP_NATIVE_EXEC)
+	(TARGET_CAP_OPENMP_400, TARGET_CAP_OPENACC_200): Remove, and
+	instead...
+	* libgomp_target.h (GOMP_OFFLOAD_CAP_SHARED_MEM)
+	(GOMP_OFFLOAD_CAP_NATIVE_EXEC, GOMP_OFFLOAD_CAP_OPENMP_400)
+	(GOMP_OFFLOAD_CAP_OPENACC_200): ... add these new definitions.
+	Change all users.
+
 	* plugin/plugin-nvptx.c (GOMP_OFFLOAD_get_name): Return "nvptx".
 	* oacc-init.c (resolve_device): Update for that using...
 	(get_openacc_name): ... this new function.
diff --git libgomp/libgomp.h libgomp/libgomp.h
index 78de0b4..866f6ca 100644
--- libgomp/libgomp.h
+++ libgomp/libgomp.h
@@ -662,11 +662,6 @@ struct target_mem_desc {
   splay_tree_key list[];
 };
 
-#define TARGET_CAP_SHARED_MEM	1
-#define TARGET_CAP_NATIVE_EXEC	2
-#define TARGET_CAP_OPENMP_400	4
-#define TARGET_CAP_OPENACC_200	8
-
 /* Information about mapped memory regions (per device/context).  */
 
 struct gomp_memory_mapping
diff --git libgomp/libgomp_target.h libgomp/libgomp_target.h
index b6723fe..63083f3 100644
--- libgomp/libgomp_target.h
+++ libgomp/libgomp_target.h
@@ -25,6 +25,12 @@
 #ifndef LIBGOMP_TARGET_H
 #define LIBGOMP_TARGET_H 1
 
+/* Capabilities of offloading devices.  */
+#define GOMP_OFFLOAD_CAP_SHARED_MEM	(1 << 0)
+#define GOMP_OFFLOAD_CAP_NATIVE_EXEC	(1 << 1)
+#define GOMP_OFFLOAD_CAP_OPENMP_400	(1 << 2)
+#define GOMP_OFFLOAD_CAP_OPENACC_200	(1 << 3)
+
 /* Type of offload target device.  Keep in sync with include/gomp-constants.h.  */
 enum offload_target_type
 {
diff --git libgomp/oacc-host.c libgomp/oacc-host.c
index f1ec426..3b90259 100644
--- libgomp/oacc-host.c
+++ libgomp/oacc-host.c
@@ -35,8 +35,9 @@ static struct gomp_device_descr host_dispatch =
     .name = "host",
 
     .type = OFFLOAD_TARGET_TYPE_HOST,
-    .capabilities = TARGET_CAP_OPENACC_200 | TARGET_CAP_NATIVE_EXEC
-		    | TARGET_CAP_SHARED_MEM,
+    .capabilities = (GOMP_OFFLOAD_CAP_OPENACC_200
+		     | GOMP_OFFLOAD_CAP_NATIVE_EXEC
+		     | GOMP_OFFLOAD_CAP_SHARED_MEM),
     .id = 0,
 
     .is_initialized = false,
diff --git libgomp/oacc-mem.c libgomp/oacc-mem.c
index 7453020..8f7868e 100644
--- libgomp/oacc-mem.c
+++ libgomp/oacc-mem.c
@@ -259,7 +259,7 @@ acc_map_data (void *h, void *d, size_t s)
   struct goacc_thread *thr = goacc_thread ();
   struct gomp_device_descr *acc_dev = thr->dev;
 
-  if (acc_dev->capabilities & TARGET_CAP_SHARED_MEM)
+  if (acc_dev->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM)
     {
       if (d != h)
         gomp_fatal ("cannot map data on shared-memory system");
diff --git libgomp/oacc-parallel.c libgomp/oacc-parallel.c
index 888f20d..d430eb4 100644
--- libgomp/oacc-parallel.c
+++ libgomp/oacc-parallel.c
@@ -131,7 +131,7 @@ GOACC_parallel (int device, void (*fn) (void *), const void *offload_table,
 
   acc_dev->openacc.async_set_async_func (async);
 
-  if (!(acc_dev->capabilities & TARGET_CAP_NATIVE_EXEC))
+  if (!(acc_dev->capabilities & GOMP_OFFLOAD_CAP_NATIVE_EXEC))
     {
       k.host_start = (uintptr_t) fn;
       k.host_end = k.host_start + 1;
@@ -187,7 +187,7 @@ GOACC_data_start (int device, const void *offload_table, size_t mapnum,
   struct gomp_device_descr *acc_dev = thr->dev;
 
   /* Host fallback or 'do nothing'.  */
-  if ((acc_dev->capabilities & TARGET_CAP_SHARED_MEM)
+  if ((acc_dev->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM)
       || host_fallback)
     {
       tgt = gomp_map_vars (NULL, 0, NULL, NULL, NULL, NULL, true, false);
@@ -233,7 +233,7 @@ GOACC_enter_exit_data (int device, const void *offload_table, size_t mapnum,
   thr = goacc_thread ();
   acc_dev = thr->dev;
 
-  if ((acc_dev->capabilities & TARGET_CAP_SHARED_MEM)
+  if ((acc_dev->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM)
       || host_fallback)
     return;
 
@@ -445,7 +445,7 @@ GOACC_update (int device, const void *offload_table, size_t mapnum,
   struct goacc_thread *thr = goacc_thread ();
   struct gomp_device_descr *acc_dev = thr->dev;
 
-  if ((acc_dev->capabilities & TARGET_CAP_SHARED_MEM)
+  if ((acc_dev->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM)
       || host_fallback)
     return;
 
diff --git libgomp/plugin/plugin-host.c libgomp/plugin/plugin-host.c
index 8bca998..324e71b 100644
--- libgomp/plugin/plugin-host.c
+++ libgomp/plugin/plugin-host.c
@@ -70,29 +70,30 @@ GOMP_OFFLOAD_get_name (void)
 #endif
 }
 
-STATIC int
-GOMP_OFFLOAD_get_type (void)
-{
-#ifdef HOST_NONSHM_PLUGIN
-  return OFFLOAD_TARGET_TYPE_HOST_NONSHM;
-#else
-  return OFFLOAD_TARGET_TYPE_HOST;
-#endif
-}
-
 STATIC unsigned int
 GOMP_OFFLOAD_get_caps (void)
 {
-  unsigned int caps = TARGET_CAP_OPENACC_200 | TARGET_CAP_NATIVE_EXEC;
+  unsigned int caps = (GOMP_OFFLOAD_CAP_OPENACC_200
+		       | GOMP_OFFLOAD_CAP_NATIVE_EXEC);
 
 #ifndef HOST_NONSHM_PLUGIN
-  caps |= TARGET_CAP_SHARED_MEM;
+  caps |= GOMP_OFFLOAD_CAP_SHARED_MEM;
 #endif
 
   return caps;
 }
 
 STATIC int
+GOMP_OFFLOAD_get_type (void)
+{
+#ifdef HOST_NONSHM_PLUGIN
+  return OFFLOAD_TARGET_TYPE_HOST_NONSHM;
+#else
+  return OFFLOAD_TARGET_TYPE_HOST;
+#endif
+}
+
+STATIC int
 GOMP_OFFLOAD_get_num_devices (void)
 {
   return 1;
diff --git libgomp/plugin/plugin-nvptx.c libgomp/plugin/plugin-nvptx.c
index d423d3a..aaed04b 100644
--- libgomp/plugin/plugin-nvptx.c
+++ libgomp/plugin/plugin-nvptx.c
@@ -1483,25 +1483,24 @@ nvptx_set_cuda_stream (int async, void *stream)
 
 /* Plugin entry points.  */
 
-
-int
-GOMP_OFFLOAD_get_type (void)
-{
-  return OFFLOAD_TARGET_TYPE_NVIDIA_PTX;
-}
-
-unsigned int
-GOMP_OFFLOAD_get_caps (void)
-{
-  return TARGET_CAP_OPENACC_200;
-}
-
 const char *
 GOMP_OFFLOAD_get_name (void)
 {
   return "nvptx";
 }
 
+unsigned int
+GOMP_OFFLOAD_get_caps (void)
+{
+  return GOMP_OFFLOAD_CAP_OPENACC_200;
+}
+
+int
+GOMP_OFFLOAD_get_type (void)
+{
+  return OFFLOAD_TARGET_TYPE_NVIDIA_PTX;
+}
+
 int
 GOMP_OFFLOAD_get_num_devices (void)
 {
diff --git libgomp/target.c libgomp/target.c
index bdfec67..dadcc03 100644
--- libgomp/target.c
+++ libgomp/target.c
@@ -844,7 +844,8 @@ GOMP_target (int device, void (*fn) (void *), const void *offload_table,
   if (devicep != NULL && !devicep->is_initialized)
     gomp_init_dev_tables (devicep);
 
-  if (devicep == NULL || !(devicep->capabilities & TARGET_CAP_OPENMP_400))
+  if (devicep == NULL
+      || !(devicep->capabilities & GOMP_OFFLOAD_CAP_OPENMP_400))
     {
       /* Host fallback.  */
       struct gomp_thread old_thr, *thr = gomp_thread ();
@@ -863,7 +864,7 @@ GOMP_target (int device, void (*fn) (void *), const void *offload_table,
 
   void *fn_addr;
 
-  if (devicep->capabilities & TARGET_CAP_NATIVE_EXEC)
+  if (devicep->capabilities & GOMP_OFFLOAD_CAP_NATIVE_EXEC)
     fn_addr = (void *) fn;
   else
     {
@@ -909,7 +910,8 @@ GOMP_target_data (int device, const void *offload_table, size_t mapnum,
   if (devicep != NULL && !devicep->is_initialized)
     gomp_init_dev_tables (devicep);
 
-  if (devicep == NULL || !(devicep->capabilities & TARGET_CAP_OPENMP_400))
+  if (devicep == NULL
+      || !(devicep->capabilities & GOMP_OFFLOAD_CAP_OPENMP_400))
     {
       /* Host fallback.  */
       struct gomp_task_icv *icv = gomp_icv (false);
@@ -968,7 +970,7 @@ GOMP_target_update (int device, const void *offload_table, size_t mapnum,
     gomp_init_device (devicep);
   gomp_mutex_unlock (&mm->lock);
 
-  if (!(devicep->capabilities & TARGET_CAP_OPENMP_400))
+  if (!(devicep->capabilities & GOMP_OFFLOAD_CAP_OPENMP_400))
     return;
 
   gomp_update (devicep, &devicep->mem_map, mapnum, hostaddrs, sizes, kinds,
@@ -1050,9 +1052,9 @@ gomp_load_plugin_for_device (struct gomp_device_descr *device,
   DLSYM (dev2host);
   DLSYM (host2dev);
   device->capabilities = device->get_caps_func ();
-  if (device->capabilities & TARGET_CAP_OPENMP_400)
+  if (device->capabilities & GOMP_OFFLOAD_CAP_OPENMP_400)
     DLSYM (run);
-  if (device->capabilities & TARGET_CAP_OPENACC_200)
+  if (device->capabilities & GOMP_OFFLOAD_CAP_OPENACC_200)
     {
       optional_present = optional_total = 0;
       DLSYM_OPT (openacc.exec, openacc_parallel);
@@ -1071,7 +1073,8 @@ gomp_load_plugin_for_device (struct gomp_device_descr *device,
       DLSYM_OPT (openacc.async_set_async, openacc_async_set_async);
       DLSYM_OPT (openacc.create_thread_data, openacc_create_thread_data);
       DLSYM_OPT (openacc.destroy_thread_data, openacc_destroy_thread_data);
-      /* Require all the OpenACC handlers if we have TARGET_CAP_OPENACC_200.  */
+      /* Require all the OpenACC handlers if we have
+	 GOMP_OFFLOAD_CAP_OPENACC_200.  */
       if (optional_present != optional_total)
 	{
 	  err = "plugin missing OpenACC handler function";
@@ -1197,16 +1200,17 @@ gomp_target_init (void)
       }
     while (next);
 
-  /* Prefer a device with TARGET_CAP_OPENMP_400 for ICV default-device-var.  */
+  /* Prefer a device with GOMP_OFFLOAD_CAP_OPENMP_400 for ICV
+     default-device-var.  */
   if (num_devices > 1)
     {
       int d = gomp_icv (false)->default_device_var;
 
-      if (!(devices[d].capabilities & TARGET_CAP_OPENMP_400))
+      if (!(devices[d].capabilities & GOMP_OFFLOAD_CAP_OPENMP_400))
 	{
 	  for (i = 0; i < num_devices; i++)
 	    {
-	      if (devices[i].capabilities & TARGET_CAP_OPENMP_400)
+	      if (devices[i].capabilities & GOMP_OFFLOAD_CAP_OPENMP_400)
 		{
 		  struct gomp_device_descr device_tmp = devices[d];
 		  devices[d] = devices[i];
@@ -1230,7 +1234,7 @@ gomp_target_init (void)
       /* The 'devices' array can be moved (by the realloc call) until we have
 	 found all the plugins, so registering with the OpenACC runtime (which
 	 takes a copy of the pointer argument) must be delayed until now.  */
-      if (devices[i].capabilities & TARGET_CAP_OPENACC_200)
+      if (devices[i].capabilities & GOMP_OFFLOAD_CAP_OPENACC_200)
 	goacc_register (&devices[i]);
     }
 


GrÃÃe,
 Thomas

Attachment: pgpvKbyRO2Iww.pgp
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]