Hi!

On Tue, 11 Nov 2014 13:53:23 +0000, Julian Brown <jul...@codesourcery.com> 
wrote:
> On Tue, 23 Sep 2014 19:19:31 +0100
> Julian Brown <jul...@codesourcery.com> wrote:
> > This patch contains the bulk of the OpenACC 2.0 runtime support,
> > building around, or on top of, the OpenMP 4.0 support (as previously
> > posted or already extant upstream) where we could. [...]
> 
> Here is a new version of the OpenACC support patch for libgomp, [...]

>     libgomp/

>     * libgomp_target.h [...]
>     (struct gomp_device_descr): Move here. Add offload_regions_registered,
>     openacc dispatch functions, target_data.

>     * target.c [...]
>     (splay_tree_key_s, gomp_device_descr): Don't declare here.

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

> +/* This structure describes accelerator device.
> +   It contains name of the corresponding libgomp plugin, function handlers 
> for
> +   interaction with the device, ID-number of the device, and information 
> about
> +   mapped memory.  */
> +struct gomp_device_descr
> +{
> [...]
> +  /* Extra information required for a device instance by a given target.  */
> +  void *target_data;
> +};

Committed to gomp-4_0-branch in r219024:

commit 095199060ff07ddfd0fb5d5c9fecabfe80ed8eed
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Mon Dec 22 17:57:50 2014 +0000

    libgomp: Move target_data member from struct gomp_device_descr into struct 
acc_dispatch_t.
    
    It is only used with struct acc_dispatch_t's open_device_func and
    close_device_func, so specific to OpenACC support.
    
        libgomp/
        * libgomp.h (struct gomp_device_descr): Move target_data member...
        (struct acc_dispatch_t): ... into here.  Change all users.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@219024 
138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog.gomp |  3 +++
 libgomp/libgomp.h      |  6 +++---
 libgomp/oacc-init.c    | 11 ++++++-----
 libgomp/target.c       |  2 +-
 4 files changed, 13 insertions(+), 9 deletions(-)

diff --git libgomp/ChangeLog.gomp libgomp/ChangeLog.gomp
index 3aa9bf4..4eac98c 100644
--- libgomp/ChangeLog.gomp
+++ libgomp/ChangeLog.gomp
@@ -1,5 +1,8 @@
 2014-12-22  Thomas Schwinge  <tho...@codesourcery.com>
 
+       * libgomp.h (struct gomp_device_descr): Move target_data member...
+       (struct acc_dispatch_t): ... into here.  Change all users.
+
        * target.c (GOMP_target_update): To initialize, call
        gomp_init_dev_tables instead of gomp_init_device.
 
diff --git libgomp/libgomp.h libgomp/libgomp.h
index 866f6ca..ec3c52e 100644
--- libgomp/libgomp.h
+++ libgomp/libgomp.h
@@ -684,6 +684,9 @@ typedef struct acc_dispatch_t
      happen out-of-order with respect to mapping.  */
   struct target_mem_desc *data_environ;
 
+  /* Extra information required for a device instance by a given target.  */
+  void *target_data;
+
   /* Open or close a device instance.  */
   void *(*open_device_func) (int n);
   int (*close_device_func) (void *h);
@@ -769,9 +772,6 @@ struct gomp_device_descr
 
   /* Memory-mapping info for this device instance.  */
   struct gomp_memory_mapping mem_map;
-
-  /* Extra information required for a device instance by a given target.  */
-  void *target_data;
 };
 
 extern void gomp_acc_insert_pointer (size_t, void **, size_t *, void *);
diff --git libgomp/oacc-init.c libgomp/oacc-init.c
index ff51856..06039b3 100644
--- libgomp/oacc-init.c
+++ libgomp/oacc-init.c
@@ -279,11 +279,11 @@ lazy_open (int ord)
   thr->saved_bound_dev = NULL;
   thr->mapped_data = NULL;
 
-  if (!acc_dev->target_data)
-    acc_dev->target_data = acc_dev->openacc.open_device_func (ord);
+  if (!acc_dev->openacc.target_data)
+    acc_dev->openacc.target_data = acc_dev->openacc.open_device_func (ord);
 
   thr->target_tls
-    = acc_dev->openacc.create_thread_data_func (acc_dev->target_data);
+    = acc_dev->openacc.create_thread_data_func (acc_dev->openacc.target_data);
 
   acc_dev->openacc.async_set_async_func (acc_async_sync);
 
@@ -344,10 +344,11 @@ acc_shutdown_1 (acc_device_t d)
 
       if (walk->dev)
        {
-          if (walk->dev->openacc.close_device_func (walk->dev->target_data) < 
0)
+         void *target_data = walk->dev->openacc.target_data;
+         if (walk->dev->openacc.close_device_func (target_data) < 0)
            gomp_fatal ("failed to close device");
 
-         walk->dev->target_data = NULL;
+         walk->dev->openacc.target_data = target_data = NULL;
 
          gomp_free_memmap (walk->dev);
 
diff --git libgomp/target.c libgomp/target.c
index 8517a84..bf719f8 100644
--- libgomp/target.c
+++ libgomp/target.c
@@ -1106,8 +1106,8 @@ gomp_target_init (void)
                current_device.offload_regions_registered = false;
                current_device.mem_map.splay_tree.root = NULL;
                current_device.mem_map.is_initialized = false;
-               current_device.target_data = NULL;
                current_device.openacc.data_environ = NULL;
+               current_device.openacc.target_data = NULL;
                for (i = 0; i < new_num_devices; i++)
                  {
                    current_device.id = num_devices + 1;


Grüße,
 Thomas

Attachment: signature.asc
Description: PGP signature

Reply via email to