public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* libgomp: Provide prototypes for functions implemented by libgomp plugins
@ 2017-01-27  9:29 Thomas Schwinge
  2017-01-27  9:40 ` Jakub Jelinek
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Schwinge @ 2017-01-27  9:29 UTC (permalink / raw)
  To: Jakub Jelinek, gcc-patches

Hi!

During development, I had been changing the libgomp plugin API, which
should have caused build failures in unmodified plugins -- but it didn't.
Here is patch to address that.  OK for trunk?  Should this also go into
release branches?

commit 01828b7ec25f2087548b5c75568b545aa0d16c3b
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Thu Jan 26 21:03:57 2017 +0100

    libgomp: Provide prototypes for functions implemented by libgomp plugins
    
            libgomp/
            * libgomp-plugin.h: #include <stdbool.h>.  Add prototypes for
            GOMP_OFFLOAD_get_name, GOMP_OFFLOAD_get_caps,
            GOMP_OFFLOAD_get_type, GOMP_OFFLOAD_get_num_devices,
            GOMP_OFFLOAD_init_device, GOMP_OFFLOAD_fini_device,
            GOMP_OFFLOAD_version, GOMP_OFFLOAD_load_image,
            GOMP_OFFLOAD_unload_image, GOMP_OFFLOAD_alloc, GOMP_OFFLOAD_free,
            GOMP_OFFLOAD_dev2host, GOMP_OFFLOAD_host2dev,
            GOMP_OFFLOAD_dev2dev, GOMP_OFFLOAD_can_run, GOMP_OFFLOAD_run,
            GOMP_OFFLOAD_async_run, GOMP_OFFLOAD_openacc_exec,
            GOMP_OFFLOAD_openacc_register_async_cleanup,
            GOMP_OFFLOAD_openacc_async_test,
            GOMP_OFFLOAD_openacc_async_test_all,
            GOMP_OFFLOAD_openacc_async_wait,
            GOMP_OFFLOAD_openacc_async_wait_async,
            GOMP_OFFLOAD_openacc_async_wait_all,
            GOMP_OFFLOAD_openacc_async_wait_all_async,
            GOMP_OFFLOAD_openacc_async_set_async,
            GOMP_OFFLOAD_openacc_create_thread_data,
            GOMP_OFFLOAD_openacc_destroy_thread_data,
            GOMP_OFFLOAD_openacc_get_current_device,
            GOMP_OFFLOAD_openacc_get_current_context,
            GOMP_OFFLOAD_openacc_get_stream, GOMP_OFFLOAD_openacc_set_stream.
            * libgomp.h (struct acc_dispatch_t, struct gomp_device_descr): Use
            these.
            * plugin/plugin-hsa.c (GOMP_OFFLOAD_load_image)
            (GOMP_OFFLOAD_unload_image): Fix argument types.
            liboffloadmic/
            * plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_get_type): Fix
            return type.
            (GOMP_OFFLOAD_load_image): Fix argument types.
---
 libgomp/libgomp-plugin.h                         | 43 ++++++++++++++--
 libgomp/libgomp.h                                | 65 ++++++++++++------------
 libgomp/plugin/plugin-hsa.c                      |  4 +-
 liboffloadmic/plugin/libgomp-plugin-intelmic.cpp |  4 +-
 4 files changed, 76 insertions(+), 40 deletions(-)

diff --git libgomp/libgomp-plugin.h libgomp/libgomp-plugin.h
index 107117b..de362ae 100644
--- libgomp/libgomp-plugin.h
+++ libgomp/libgomp-plugin.h
@@ -1,4 +1,6 @@
-/* Copyright (C) 2014-2017 Free Software Foundation, Inc.
+/* The libgomp plugin API.
+
+   Copyright (C) 2014-2017 Free Software Foundation, Inc.
 
    Contributed by Mentor Embedded.
 
@@ -24,11 +26,10 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-/* An interface to various libgomp-internal functions for use by plugins.  */
-
 #ifndef LIBGOMP_PLUGIN_H
 #define LIBGOMP_PLUGIN_H 1
 
+#include <stdbool.h>
 #include <stddef.h>
 #include <stdint.h>
 
@@ -73,6 +74,42 @@ extern void GOMP_PLUGIN_error (const char *, ...)
 extern void GOMP_PLUGIN_fatal (const char *, ...)
 	__attribute__ ((noreturn, format (printf, 1, 2)));
 
+/* Prototypes for functions implemented by libgomp plugins.  */
+extern const char *GOMP_OFFLOAD_get_name (void);
+extern unsigned int GOMP_OFFLOAD_get_caps (void);
+extern int GOMP_OFFLOAD_get_type (void);
+extern int GOMP_OFFLOAD_get_num_devices (void);
+extern bool GOMP_OFFLOAD_init_device (int);
+extern bool GOMP_OFFLOAD_fini_device (int);
+extern unsigned GOMP_OFFLOAD_version (void);
+extern int GOMP_OFFLOAD_load_image (int, unsigned, const void *,
+				    struct addr_pair **);
+extern bool GOMP_OFFLOAD_unload_image (int, unsigned, const void *);
+extern void *GOMP_OFFLOAD_alloc (int, size_t);
+extern bool GOMP_OFFLOAD_free (int, void *);
+extern bool GOMP_OFFLOAD_dev2host (int, void *, const void *, size_t);
+extern bool GOMP_OFFLOAD_host2dev (int, void *, const void *, size_t);
+extern bool GOMP_OFFLOAD_dev2dev (int, void *, const void *, size_t);
+extern bool GOMP_OFFLOAD_can_run (void *);
+extern void GOMP_OFFLOAD_run (int, void *, void *, void **);
+extern void GOMP_OFFLOAD_async_run (int, void *, void *, void **, void *);
+extern void GOMP_OFFLOAD_openacc_exec (void (*) (void *), size_t, void **,
+				       void **, int, unsigned *, void *);
+extern void GOMP_OFFLOAD_openacc_register_async_cleanup (void *, int);
+extern int GOMP_OFFLOAD_openacc_async_test (int);
+extern int GOMP_OFFLOAD_openacc_async_test_all (void);
+extern void GOMP_OFFLOAD_openacc_async_wait (int);
+extern void GOMP_OFFLOAD_openacc_async_wait_async (int, int);
+extern void GOMP_OFFLOAD_openacc_async_wait_all (void);
+extern void GOMP_OFFLOAD_openacc_async_wait_all_async (int);
+extern void GOMP_OFFLOAD_openacc_async_set_async (int);
+extern void *GOMP_OFFLOAD_openacc_create_thread_data (int);
+extern void GOMP_OFFLOAD_openacc_destroy_thread_data (void *);
+extern void *GOMP_OFFLOAD_openacc_get_current_device (void);
+extern void *GOMP_OFFLOAD_openacc_get_current_context (void);
+extern void *GOMP_OFFLOAD_openacc_get_stream (int);
+extern int GOMP_OFFLOAD_openacc_set_stream (int, void *);
+
 #ifdef __cplusplus
 }
 #endif
diff --git libgomp/libgomp.h libgomp/libgomp.h
index 78d8adc..eaa2303 100644
--- libgomp/libgomp.h
+++ libgomp/libgomp.h
@@ -882,31 +882,30 @@ typedef struct acc_dispatch_t
   struct target_mem_desc *data_environ;
 
   /* Execute.  */
-  void (*exec_func) (void (*) (void *), size_t, void **, void **, int,
-		     unsigned *, void *);
+  typeof (GOMP_OFFLOAD_openacc_exec) *exec_func;
 
   /* Async cleanup callback registration.  */
-  void (*register_async_cleanup_func) (void *, int);
+  typeof (GOMP_OFFLOAD_openacc_register_async_cleanup) *register_async_cleanup_func;
 
   /* Asynchronous routines.  */
-  int (*async_test_func) (int);
-  int (*async_test_all_func) (void);
-  void (*async_wait_func) (int);
-  void (*async_wait_async_func) (int, int);
-  void (*async_wait_all_func) (void);
-  void (*async_wait_all_async_func) (int);
-  void (*async_set_async_func) (int);
+  typeof (GOMP_OFFLOAD_openacc_async_test) *async_test_func;
+  typeof (GOMP_OFFLOAD_openacc_async_test_all) *async_test_all_func;
+  typeof (GOMP_OFFLOAD_openacc_async_wait) *async_wait_func;
+  typeof (GOMP_OFFLOAD_openacc_async_wait_async) *async_wait_async_func;
+  typeof (GOMP_OFFLOAD_openacc_async_wait_all) *async_wait_all_func;
+  typeof (GOMP_OFFLOAD_openacc_async_wait_all_async) *async_wait_all_async_func;
+  typeof (GOMP_OFFLOAD_openacc_async_set_async) *async_set_async_func;
 
   /* Create/destroy TLS data.  */
-  void *(*create_thread_data_func) (int);
-  void (*destroy_thread_data_func) (void *);
+  typeof (GOMP_OFFLOAD_openacc_create_thread_data) *create_thread_data_func;
+  typeof (GOMP_OFFLOAD_openacc_destroy_thread_data) *destroy_thread_data_func;
 
   /* NVIDIA target specific routines.  */
   struct {
-    void *(*get_current_device_func) (void);
-    void *(*get_current_context_func) (void);
-    void *(*get_stream_func) (int);
-    int (*set_stream_func) (int, void *);
+    typeof (GOMP_OFFLOAD_openacc_get_current_device) *get_current_device_func;
+    typeof (GOMP_OFFLOAD_openacc_get_current_context) *get_current_context_func;
+    typeof (GOMP_OFFLOAD_openacc_get_stream) *get_stream_func;
+    typeof (GOMP_OFFLOAD_openacc_set_stream) *set_stream_func;
   } cuda;
 } acc_dispatch_t;
 
@@ -940,23 +939,23 @@ struct gomp_device_descr
   enum offload_target_type type;
 
   /* Function handlers.  */
-  const char *(*get_name_func) (void);
-  unsigned int (*get_caps_func) (void);
-  int (*get_type_func) (void);
-  int (*get_num_devices_func) (void);
-  bool (*init_device_func) (int);
-  bool (*fini_device_func) (int);
-  unsigned (*version_func) (void);
-  int (*load_image_func) (int, unsigned, const void *, struct addr_pair **);
-  bool (*unload_image_func) (int, unsigned, const void *);
-  void *(*alloc_func) (int, size_t);
-  bool (*free_func) (int, void *);
-  bool (*dev2host_func) (int, void *, const void *, size_t);
-  bool (*host2dev_func) (int, void *, const void *, size_t);
-  bool (*dev2dev_func) (int, void *, const void *, size_t);
-  bool (*can_run_func) (void *);
-  void (*run_func) (int, void *, void *, void **);
-  void (*async_run_func) (int, void *, void *, void **, void *);
+  typeof (GOMP_OFFLOAD_get_name) *get_name_func;
+  typeof (GOMP_OFFLOAD_get_caps) *get_caps_func;
+  typeof (GOMP_OFFLOAD_get_type) *get_type_func;
+  typeof (GOMP_OFFLOAD_get_num_devices) *get_num_devices_func;
+  typeof (GOMP_OFFLOAD_init_device) *init_device_func;
+  typeof (GOMP_OFFLOAD_fini_device) *fini_device_func;
+  typeof (GOMP_OFFLOAD_version) *version_func;
+  typeof (GOMP_OFFLOAD_load_image) *load_image_func;
+  typeof (GOMP_OFFLOAD_unload_image) *unload_image_func;
+  typeof (GOMP_OFFLOAD_alloc) *alloc_func;
+  typeof (GOMP_OFFLOAD_free) *free_func;
+  typeof (GOMP_OFFLOAD_dev2host) *dev2host_func;
+  typeof (GOMP_OFFLOAD_host2dev) *host2dev_func;
+  typeof (GOMP_OFFLOAD_dev2dev) *dev2dev_func;
+  typeof (GOMP_OFFLOAD_can_run) *can_run_func;
+  typeof (GOMP_OFFLOAD_run) *run_func;
+  typeof (GOMP_OFFLOAD_async_run) *async_run_func;
 
   /* Splay tree containing information about mapped memory regions.  */
   struct splay_tree_s mem_map;
diff --git libgomp/plugin/plugin-hsa.c libgomp/plugin/plugin-hsa.c
index 9757fc6..9cc243d 100644
--- libgomp/plugin/plugin-hsa.c
+++ libgomp/plugin/plugin-hsa.c
@@ -891,7 +891,7 @@ init_basic_kernel_info (struct kernel_info *kernel,
    in TARGET_TABLE.  */
 
 int
-GOMP_OFFLOAD_load_image (int ord, unsigned version, void *target_data,
+GOMP_OFFLOAD_load_image (int ord, unsigned version, const void *target_data,
 			 struct addr_pair **target_table)
 {
   if (GOMP_VERSION_DEV (version) > GOMP_VERSION_HSA)
@@ -1726,7 +1726,7 @@ destroy_module (struct module_info *module)
    TRUE on success.  */
 
 bool
-GOMP_OFFLOAD_unload_image (int n, unsigned version, void *target_data)
+GOMP_OFFLOAD_unload_image (int n, unsigned version, const void *target_data)
 {
   if (GOMP_VERSION_DEV (version) > GOMP_VERSION_HSA)
     {
diff --git liboffloadmic/plugin/libgomp-plugin-intelmic.cpp liboffloadmic/plugin/libgomp-plugin-intelmic.cpp
index 26d68b4..d1678d0 100644
--- liboffloadmic/plugin/libgomp-plugin-intelmic.cpp
+++ liboffloadmic/plugin/libgomp-plugin-intelmic.cpp
@@ -159,7 +159,7 @@ GOMP_OFFLOAD_get_caps (void)
   return res;
 }
 
-extern "C" enum offload_target_type
+extern "C" int
 GOMP_OFFLOAD_get_type (void)
 {
   enum offload_target_type res = OFFLOAD_TARGET_TYPE_INTEL_MIC;
@@ -345,7 +345,7 @@ GOMP_OFFLOAD_version (void)
 
 extern "C" int
 GOMP_OFFLOAD_load_image (int device, const unsigned version,
-			 void *target_image, addr_pair **result)
+			 const void *target_image, addr_pair **result)
 {
   TRACE ("(device = %d, target_image = %p)", device, target_image);
 


Grüße
 Thomas

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: libgomp: Provide prototypes for functions implemented by libgomp plugins
  2017-01-27  9:29 libgomp: Provide prototypes for functions implemented by libgomp plugins Thomas Schwinge
@ 2017-01-27  9:40 ` Jakub Jelinek
  2017-01-31 14:53   ` Thomas Schwinge
  0 siblings, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2017-01-27  9:40 UTC (permalink / raw)
  To: Thomas Schwinge; +Cc: gcc-patches

On Fri, Jan 27, 2017 at 10:19:18AM +0100, Thomas Schwinge wrote:
> During development, I had been changing the libgomp plugin API, which
> should have caused build failures in unmodified plugins -- but it didn't.
> Here is patch to address that.  OK for trunk?  Should this also go into
> release branches?
> 
> commit 01828b7ec25f2087548b5c75568b545aa0d16c3b
> Author: Thomas Schwinge <thomas@codesourcery.com>
> Date:   Thu Jan 26 21:03:57 2017 +0100
> 
>     libgomp: Provide prototypes for functions implemented by libgomp plugins
>     
>             libgomp/
>             * libgomp-plugin.h: #include <stdbool.h>.

For the prototypes, just use
	(GOMP_OFFLOAD_get_name, GOMP_OFFLOAD_get_caps,
	....
	GOMP_OFFLOAD_openacc_set_stream): New prototype.

> --- libgomp/libgomp.h
> +++ libgomp/libgomp.h
> @@ -882,31 +882,30 @@ typedef struct acc_dispatch_t
>    struct target_mem_desc *data_environ;
>  
>    /* Execute.  */
> -  void (*exec_func) (void (*) (void *), size_t, void **, void **, int,
> -		     unsigned *, void *);
> +  typeof (GOMP_OFFLOAD_openacc_exec) *exec_func;

Please use __typeof instead of typeof, that is the keyword spelling rest of
libgomp uses.
>  
>    /* Async cleanup callback registration.  */
> -  void (*register_async_cleanup_func) (void *, int);
> +  typeof (GOMP_OFFLOAD_openacc_register_async_cleanup) *register_async_cleanup_func;

Many lines are too long, plus adding 2 __s might make some just below limit
lines over it.  Please use
  __typeof (GOMP_OFFLOAD_openacc_register_async_cleanup)
    *register_async_cleanup_func;
in that case.

Ok with those changes for trunk, please leave release branches as is.

	Jakub

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: libgomp: Provide prototypes for functions implemented by libgomp plugins
  2017-01-27  9:40 ` Jakub Jelinek
@ 2017-01-31 14:53   ` Thomas Schwinge
  2017-02-02 12:23     ` libgomp: Normalize the names of a few functions of the libgomp plugin API (was: libgomp: Provide prototypes for functions implemented by libgomp plugins) Thomas Schwinge
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Schwinge @ 2017-01-31 14:53 UTC (permalink / raw)
  To: Jakub Jelinek, gcc-patches

Hi!

On Fri, 27 Jan 2017 10:28:42 +0100, Jakub Jelinek <jakub@redhat.com> wrote:
> On Fri, Jan 27, 2017 at 10:19:18AM +0100, Thomas Schwinge wrote:
> > During development, I had been changing the libgomp plugin API, which
> > should have caused build failures in unmodified plugins -- but it didn't.
> > Here is patch to address that.  OK for trunk?  Should this also go into
> > release branches?

> For the prototypes, just use
> 	(GOMP_OFFLOAD_get_name, GOMP_OFFLOAD_get_caps,
> 	....
> 	GOMP_OFFLOAD_openacc_set_stream): New prototype.

Well, even if regularly done that way, it's not technically quite right:
I'm not modifying "GOMP_OFFLOAD_get_name" et al., but instead I'm adding
them (modifying the "top level" scope).  But, I changed that anyway.

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

> > -  void (*exec_func) (void (*) (void *), size_t, void **, void **, int,
> > -		     unsigned *, void *);
> > +  typeof (GOMP_OFFLOAD_openacc_exec) *exec_func;
> 
> Please use __typeof instead of typeof, that is the keyword spelling rest of
> libgomp uses.

ACK.

> > -  void (*register_async_cleanup_func) (void *, int);
> > +  typeof (GOMP_OFFLOAD_openacc_register_async_cleanup) *register_async_cleanup_func;
> 
> Many lines are too long, plus adding 2 __s might make some just below limit
> lines over it.  Please use
>   __typeof (GOMP_OFFLOAD_openacc_register_async_cleanup)
>     *register_async_cleanup_func;
> in that case.

Ugly, but I guess we still have this 80 columns limit...  ;-)

> Ok with those changes for trunk, please leave release branches as is.

Thanks for the review; committed to trunk in r245062:

commit 468af399108a74c00c9d16cbe02a780aea1b2987
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Tue Jan 31 14:32:58 2017 +0000

    libgomp: Provide prototypes for functions implemented by libgomp plugins
    
            libgomp/
            * libgomp-plugin.h: #include <stdbool.h>.
            (GOMP_OFFLOAD_get_name, GOMP_OFFLOAD_get_caps)
            (GOMP_OFFLOAD_get_type, GOMP_OFFLOAD_get_num_devices)
            (GOMP_OFFLOAD_init_device, GOMP_OFFLOAD_fini_device)
            (GOMP_OFFLOAD_version, GOMP_OFFLOAD_load_image)
            (GOMP_OFFLOAD_unload_image, GOMP_OFFLOAD_alloc, GOMP_OFFLOAD_free)
            (GOMP_OFFLOAD_dev2host, GOMP_OFFLOAD_host2dev)
            (GOMP_OFFLOAD_dev2dev, GOMP_OFFLOAD_can_run, GOMP_OFFLOAD_run)
            (GOMP_OFFLOAD_async_run, GOMP_OFFLOAD_openacc_parallel)
            (GOMP_OFFLOAD_openacc_register_async_cleanup)
            (GOMP_OFFLOAD_openacc_async_test)
            (GOMP_OFFLOAD_openacc_async_test_all)
            (GOMP_OFFLOAD_openacc_async_wait)
            (GOMP_OFFLOAD_openacc_async_wait_async)
            (GOMP_OFFLOAD_openacc_async_wait_all)
            (GOMP_OFFLOAD_openacc_async_wait_all_async)
            (GOMP_OFFLOAD_openacc_async_set_async)
            (GOMP_OFFLOAD_openacc_create_thread_data)
            (GOMP_OFFLOAD_openacc_destroy_thread_data)
            (GOMP_OFFLOAD_openacc_get_current_cuda_device)
            (GOMP_OFFLOAD_openacc_get_current_cuda_context)
            (GOMP_OFFLOAD_openacc_get_cuda_stream)
            (GOMP_OFFLOAD_openacc_set_cuda_stream): New prototypes.
            * libgomp.h (struct acc_dispatch_t, struct gomp_device_descr): Use
            these.
            * plugin/plugin-hsa.c (GOMP_OFFLOAD_load_image)
            (GOMP_OFFLOAD_unload_image): Fix argument types.
            liboffloadmic/
            * plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_get_type): Fix
            return type.
            (GOMP_OFFLOAD_load_image): Fix argument types.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@245062 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog                                | 30 ++++++++++
 libgomp/libgomp-plugin.h                         | 43 ++++++++++++++-
 libgomp/libgomp.h                                | 70 +++++++++++++-----------
 libgomp/plugin/plugin-hsa.c                      |  4 +-
 liboffloadmic/ChangeLog                          | 12 ++++
 liboffloadmic/plugin/libgomp-plugin-intelmic.cpp |  4 +-
 6 files changed, 123 insertions(+), 40 deletions(-)

diff --git libgomp/ChangeLog libgomp/ChangeLog
index b4e7d6e..829a30f 100644
--- libgomp/ChangeLog
+++ libgomp/ChangeLog
@@ -1,3 +1,33 @@
+2017-01-31  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* libgomp-plugin.h: #include <stdbool.h>.
+	(GOMP_OFFLOAD_get_name, GOMP_OFFLOAD_get_caps)
+	(GOMP_OFFLOAD_get_type, GOMP_OFFLOAD_get_num_devices)
+	(GOMP_OFFLOAD_init_device, GOMP_OFFLOAD_fini_device)
+	(GOMP_OFFLOAD_version, GOMP_OFFLOAD_load_image)
+	(GOMP_OFFLOAD_unload_image, GOMP_OFFLOAD_alloc, GOMP_OFFLOAD_free)
+	(GOMP_OFFLOAD_dev2host, GOMP_OFFLOAD_host2dev)
+	(GOMP_OFFLOAD_dev2dev, GOMP_OFFLOAD_can_run, GOMP_OFFLOAD_run)
+	(GOMP_OFFLOAD_async_run, GOMP_OFFLOAD_openacc_parallel)
+	(GOMP_OFFLOAD_openacc_register_async_cleanup)
+	(GOMP_OFFLOAD_openacc_async_test)
+	(GOMP_OFFLOAD_openacc_async_test_all)
+	(GOMP_OFFLOAD_openacc_async_wait)
+	(GOMP_OFFLOAD_openacc_async_wait_async)
+	(GOMP_OFFLOAD_openacc_async_wait_all)
+	(GOMP_OFFLOAD_openacc_async_wait_all_async)
+	(GOMP_OFFLOAD_openacc_async_set_async)
+	(GOMP_OFFLOAD_openacc_create_thread_data)
+	(GOMP_OFFLOAD_openacc_destroy_thread_data)
+	(GOMP_OFFLOAD_openacc_get_current_cuda_device)
+	(GOMP_OFFLOAD_openacc_get_current_cuda_context)
+	(GOMP_OFFLOAD_openacc_get_cuda_stream)
+	(GOMP_OFFLOAD_openacc_set_cuda_stream): New prototypes.
+	* libgomp.h (struct acc_dispatch_t, struct gomp_device_descr): Use
+	these.
+	* plugin/plugin-hsa.c (GOMP_OFFLOAD_load_image)
+	(GOMP_OFFLOAD_unload_image): Fix argument types.
+
 2017-01-26  Jakub Jelinek  <jakub@redhat.com>
 
 	* testsuite/lib/libgomp.exp
diff --git libgomp/libgomp-plugin.h libgomp/libgomp-plugin.h
index 107117b..fba45ee 100644
--- libgomp/libgomp-plugin.h
+++ libgomp/libgomp-plugin.h
@@ -1,4 +1,6 @@
-/* Copyright (C) 2014-2017 Free Software Foundation, Inc.
+/* The libgomp plugin API.
+
+   Copyright (C) 2014-2017 Free Software Foundation, Inc.
 
    Contributed by Mentor Embedded.
 
@@ -24,11 +26,10 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-/* An interface to various libgomp-internal functions for use by plugins.  */
-
 #ifndef LIBGOMP_PLUGIN_H
 #define LIBGOMP_PLUGIN_H 1
 
+#include <stdbool.h>
 #include <stddef.h>
 #include <stdint.h>
 
@@ -73,6 +74,42 @@ extern void GOMP_PLUGIN_error (const char *, ...)
 extern void GOMP_PLUGIN_fatal (const char *, ...)
 	__attribute__ ((noreturn, format (printf, 1, 2)));
 
+/* Prototypes for functions implemented by libgomp plugins.  */
+extern const char *GOMP_OFFLOAD_get_name (void);
+extern unsigned int GOMP_OFFLOAD_get_caps (void);
+extern int GOMP_OFFLOAD_get_type (void);
+extern int GOMP_OFFLOAD_get_num_devices (void);
+extern bool GOMP_OFFLOAD_init_device (int);
+extern bool GOMP_OFFLOAD_fini_device (int);
+extern unsigned GOMP_OFFLOAD_version (void);
+extern int GOMP_OFFLOAD_load_image (int, unsigned, const void *,
+				    struct addr_pair **);
+extern bool GOMP_OFFLOAD_unload_image (int, unsigned, const void *);
+extern void *GOMP_OFFLOAD_alloc (int, size_t);
+extern bool GOMP_OFFLOAD_free (int, void *);
+extern bool GOMP_OFFLOAD_dev2host (int, void *, const void *, size_t);
+extern bool GOMP_OFFLOAD_host2dev (int, void *, const void *, size_t);
+extern bool GOMP_OFFLOAD_dev2dev (int, void *, const void *, size_t);
+extern bool GOMP_OFFLOAD_can_run (void *);
+extern void GOMP_OFFLOAD_run (int, void *, void *, void **);
+extern void GOMP_OFFLOAD_async_run (int, void *, void *, void **, void *);
+extern void GOMP_OFFLOAD_openacc_parallel (void (*) (void *), size_t, void **,
+					   void **, int, unsigned *, void *);
+extern void GOMP_OFFLOAD_openacc_register_async_cleanup (void *, int);
+extern int GOMP_OFFLOAD_openacc_async_test (int);
+extern int GOMP_OFFLOAD_openacc_async_test_all (void);
+extern void GOMP_OFFLOAD_openacc_async_wait (int);
+extern void GOMP_OFFLOAD_openacc_async_wait_async (int, int);
+extern void GOMP_OFFLOAD_openacc_async_wait_all (void);
+extern void GOMP_OFFLOAD_openacc_async_wait_all_async (int);
+extern void GOMP_OFFLOAD_openacc_async_set_async (int);
+extern void *GOMP_OFFLOAD_openacc_create_thread_data (int);
+extern void GOMP_OFFLOAD_openacc_destroy_thread_data (void *);
+extern void *GOMP_OFFLOAD_openacc_get_current_cuda_device (void);
+extern void *GOMP_OFFLOAD_openacc_get_current_cuda_context (void);
+extern void *GOMP_OFFLOAD_openacc_get_cuda_stream (int);
+extern int GOMP_OFFLOAD_openacc_set_cuda_stream (int, void *);
+
 #ifdef __cplusplus
 }
 #endif
diff --git libgomp/libgomp.h libgomp/libgomp.h
index 78d8adc..6dfe9aa 100644
--- libgomp/libgomp.h
+++ libgomp/libgomp.h
@@ -882,31 +882,35 @@ typedef struct acc_dispatch_t
   struct target_mem_desc *data_environ;
 
   /* Execute.  */
-  void (*exec_func) (void (*) (void *), size_t, void **, void **, int,
-		     unsigned *, void *);
+  __typeof (GOMP_OFFLOAD_openacc_parallel) *exec_func;
 
   /* Async cleanup callback registration.  */
-  void (*register_async_cleanup_func) (void *, int);
+  __typeof (GOMP_OFFLOAD_openacc_register_async_cleanup)
+    *register_async_cleanup_func;
 
   /* Asynchronous routines.  */
-  int (*async_test_func) (int);
-  int (*async_test_all_func) (void);
-  void (*async_wait_func) (int);
-  void (*async_wait_async_func) (int, int);
-  void (*async_wait_all_func) (void);
-  void (*async_wait_all_async_func) (int);
-  void (*async_set_async_func) (int);
+  __typeof (GOMP_OFFLOAD_openacc_async_test) *async_test_func;
+  __typeof (GOMP_OFFLOAD_openacc_async_test_all) *async_test_all_func;
+  __typeof (GOMP_OFFLOAD_openacc_async_wait) *async_wait_func;
+  __typeof (GOMP_OFFLOAD_openacc_async_wait_async) *async_wait_async_func;
+  __typeof (GOMP_OFFLOAD_openacc_async_wait_all) *async_wait_all_func;
+  __typeof (GOMP_OFFLOAD_openacc_async_wait_all_async)
+    *async_wait_all_async_func;
+  __typeof (GOMP_OFFLOAD_openacc_async_set_async) *async_set_async_func;
 
   /* Create/destroy TLS data.  */
-  void *(*create_thread_data_func) (int);
-  void (*destroy_thread_data_func) (void *);
+  __typeof (GOMP_OFFLOAD_openacc_create_thread_data) *create_thread_data_func;
+  __typeof (GOMP_OFFLOAD_openacc_destroy_thread_data)
+    *destroy_thread_data_func;
 
   /* NVIDIA target specific routines.  */
   struct {
-    void *(*get_current_device_func) (void);
-    void *(*get_current_context_func) (void);
-    void *(*get_stream_func) (int);
-    int (*set_stream_func) (int, void *);
+    __typeof (GOMP_OFFLOAD_openacc_get_current_cuda_device)
+      *get_current_device_func;
+    __typeof (GOMP_OFFLOAD_openacc_get_current_cuda_context)
+      *get_current_context_func;
+    __typeof (GOMP_OFFLOAD_openacc_get_cuda_stream) *get_stream_func;
+    __typeof (GOMP_OFFLOAD_openacc_set_cuda_stream) *set_stream_func;
   } cuda;
 } acc_dispatch_t;
 
@@ -940,23 +944,23 @@ struct gomp_device_descr
   enum offload_target_type type;
 
   /* Function handlers.  */
-  const char *(*get_name_func) (void);
-  unsigned int (*get_caps_func) (void);
-  int (*get_type_func) (void);
-  int (*get_num_devices_func) (void);
-  bool (*init_device_func) (int);
-  bool (*fini_device_func) (int);
-  unsigned (*version_func) (void);
-  int (*load_image_func) (int, unsigned, const void *, struct addr_pair **);
-  bool (*unload_image_func) (int, unsigned, const void *);
-  void *(*alloc_func) (int, size_t);
-  bool (*free_func) (int, void *);
-  bool (*dev2host_func) (int, void *, const void *, size_t);
-  bool (*host2dev_func) (int, void *, const void *, size_t);
-  bool (*dev2dev_func) (int, void *, const void *, size_t);
-  bool (*can_run_func) (void *);
-  void (*run_func) (int, void *, void *, void **);
-  void (*async_run_func) (int, void *, void *, void **, void *);
+  __typeof (GOMP_OFFLOAD_get_name) *get_name_func;
+  __typeof (GOMP_OFFLOAD_get_caps) *get_caps_func;
+  __typeof (GOMP_OFFLOAD_get_type) *get_type_func;
+  __typeof (GOMP_OFFLOAD_get_num_devices) *get_num_devices_func;
+  __typeof (GOMP_OFFLOAD_init_device) *init_device_func;
+  __typeof (GOMP_OFFLOAD_fini_device) *fini_device_func;
+  __typeof (GOMP_OFFLOAD_version) *version_func;
+  __typeof (GOMP_OFFLOAD_load_image) *load_image_func;
+  __typeof (GOMP_OFFLOAD_unload_image) *unload_image_func;
+  __typeof (GOMP_OFFLOAD_alloc) *alloc_func;
+  __typeof (GOMP_OFFLOAD_free) *free_func;
+  __typeof (GOMP_OFFLOAD_dev2host) *dev2host_func;
+  __typeof (GOMP_OFFLOAD_host2dev) *host2dev_func;
+  __typeof (GOMP_OFFLOAD_dev2dev) *dev2dev_func;
+  __typeof (GOMP_OFFLOAD_can_run) *can_run_func;
+  __typeof (GOMP_OFFLOAD_run) *run_func;
+  __typeof (GOMP_OFFLOAD_async_run) *async_run_func;
 
   /* Splay tree containing information about mapped memory regions.  */
   struct splay_tree_s mem_map;
diff --git libgomp/plugin/plugin-hsa.c libgomp/plugin/plugin-hsa.c
index 9757fc6..9cc243d 100644
--- libgomp/plugin/plugin-hsa.c
+++ libgomp/plugin/plugin-hsa.c
@@ -891,7 +891,7 @@ init_basic_kernel_info (struct kernel_info *kernel,
    in TARGET_TABLE.  */
 
 int
-GOMP_OFFLOAD_load_image (int ord, unsigned version, void *target_data,
+GOMP_OFFLOAD_load_image (int ord, unsigned version, const void *target_data,
 			 struct addr_pair **target_table)
 {
   if (GOMP_VERSION_DEV (version) > GOMP_VERSION_HSA)
@@ -1726,7 +1726,7 @@ destroy_module (struct module_info *module)
    TRUE on success.  */
 
 bool
-GOMP_OFFLOAD_unload_image (int n, unsigned version, void *target_data)
+GOMP_OFFLOAD_unload_image (int n, unsigned version, const void *target_data)
 {
   if (GOMP_VERSION_DEV (version) > GOMP_VERSION_HSA)
     {
diff --git liboffloadmic/ChangeLog liboffloadmic/ChangeLog
index 3d8ad67..c9aa32c 100644
--- liboffloadmic/ChangeLog
+++ liboffloadmic/ChangeLog
@@ -1,3 +1,9 @@
+2017-01-31  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_get_type): Fix
+	return type.
+	(GOMP_OFFLOAD_load_image): Fix argument types.
+
 2017-01-21  Jakub Jelinek  <jakub@redhat.com>
 
 	PR other/79046
@@ -630,3 +636,9 @@
 	* runtime/orsl-lite/lib/orsl-lite.c: Ditto.
 	* runtime/orsl-lite/version.txt: Ditto.
 	* runtime/use_mpss2.txt: Ditto.
+\f
+Copyright (C) 2014-2017 Free Software Foundation, Inc.
+
+Copying and distribution of this file, with or without modification,
+are permitted in any medium without royalty provided the copyright
+notice and this notice are preserved.
diff --git liboffloadmic/plugin/libgomp-plugin-intelmic.cpp liboffloadmic/plugin/libgomp-plugin-intelmic.cpp
index 26d68b4..d1678d0 100644
--- liboffloadmic/plugin/libgomp-plugin-intelmic.cpp
+++ liboffloadmic/plugin/libgomp-plugin-intelmic.cpp
@@ -159,7 +159,7 @@ GOMP_OFFLOAD_get_caps (void)
   return res;
 }
 
-extern "C" enum offload_target_type
+extern "C" int
 GOMP_OFFLOAD_get_type (void)
 {
   enum offload_target_type res = OFFLOAD_TARGET_TYPE_INTEL_MIC;
@@ -345,7 +345,7 @@ GOMP_OFFLOAD_version (void)
 
 extern "C" int
 GOMP_OFFLOAD_load_image (int device, const unsigned version,
-			 void *target_image, addr_pair **result)
+			 const void *target_image, addr_pair **result)
 {
   TRACE ("(device = %d, target_image = %p)", device, target_image);
 


Committed to gomp-4_0-branch in r245063:

commit 0948da44dab2b03e3ed92e739ae032afed4dbe83
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Tue Jan 31 14:37:19 2017 +0000

    libgomp: Provide prototypes for functions implemented by libgomp plugins
    
    Backport from trunk r245062:
    
            libgomp/
            * libgomp-plugin.h: #include <stdbool.h>.
            (GOMP_OFFLOAD_get_name, GOMP_OFFLOAD_get_caps)
            (GOMP_OFFLOAD_get_type, GOMP_OFFLOAD_get_num_devices)
            (GOMP_OFFLOAD_init_device, GOMP_OFFLOAD_fini_device)
            (GOMP_OFFLOAD_version, GOMP_OFFLOAD_load_image)
            (GOMP_OFFLOAD_unload_image, GOMP_OFFLOAD_alloc, GOMP_OFFLOAD_free)
            (GOMP_OFFLOAD_dev2host, GOMP_OFFLOAD_host2dev)
            (GOMP_OFFLOAD_dev2dev, GOMP_OFFLOAD_can_run, GOMP_OFFLOAD_run)
            (GOMP_OFFLOAD_async_run, GOMP_OFFLOAD_openacc_parallel)
            (GOMP_OFFLOAD_openacc_register_async_cleanup)
            (GOMP_OFFLOAD_openacc_async_test)
            (GOMP_OFFLOAD_openacc_async_test_all)
            (GOMP_OFFLOAD_openacc_async_wait)
            (GOMP_OFFLOAD_openacc_async_wait_async)
            (GOMP_OFFLOAD_openacc_async_wait_all)
            (GOMP_OFFLOAD_openacc_async_wait_all_async)
            (GOMP_OFFLOAD_openacc_async_set_async)
            (GOMP_OFFLOAD_openacc_create_thread_data)
            (GOMP_OFFLOAD_openacc_destroy_thread_data)
            (GOMP_OFFLOAD_openacc_get_current_cuda_device)
            (GOMP_OFFLOAD_openacc_get_current_cuda_context)
            (GOMP_OFFLOAD_openacc_get_cuda_stream)
            (GOMP_OFFLOAD_openacc_set_cuda_stream): New prototypes.
            * libgomp.h (struct acc_dispatch_t, struct gomp_device_descr): Use
            these.
            * plugin/plugin-hsa.c (GOMP_OFFLOAD_load_image)
            (GOMP_OFFLOAD_unload_image): Fix argument types.
            liboffloadmic/
            * plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_get_type): Fix
            return type.
            (GOMP_OFFLOAD_load_image): Fix argument types.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@245063 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog.gomp                           | 33 +++++++++++
 libgomp/libgomp-plugin.h                         | 43 ++++++++++++++-
 libgomp/libgomp.h                                | 70 +++++++++++++-----------
 libgomp/plugin/plugin-hsa.c                      |  4 +-
 liboffloadmic/ChangeLog.gomp                     |  9 +++
 liboffloadmic/plugin/libgomp-plugin-intelmic.cpp |  4 +-
 6 files changed, 123 insertions(+), 40 deletions(-)

diff --git libgomp/ChangeLog.gomp libgomp/ChangeLog.gomp
index bc006cc..78f64207 100644
--- libgomp/ChangeLog.gomp
+++ libgomp/ChangeLog.gomp
@@ -1,3 +1,36 @@
+2017-01-31  Thomas Schwinge  <thomas@codesourcery.com>
+
+	Backport from trunk r245062:
+	2017-01-31  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* libgomp-plugin.h: #include <stdbool.h>.
+	(GOMP_OFFLOAD_get_name, GOMP_OFFLOAD_get_caps)
+	(GOMP_OFFLOAD_get_type, GOMP_OFFLOAD_get_num_devices)
+	(GOMP_OFFLOAD_init_device, GOMP_OFFLOAD_fini_device)
+	(GOMP_OFFLOAD_version, GOMP_OFFLOAD_load_image)
+	(GOMP_OFFLOAD_unload_image, GOMP_OFFLOAD_alloc, GOMP_OFFLOAD_free)
+	(GOMP_OFFLOAD_dev2host, GOMP_OFFLOAD_host2dev)
+	(GOMP_OFFLOAD_dev2dev, GOMP_OFFLOAD_can_run, GOMP_OFFLOAD_run)
+	(GOMP_OFFLOAD_async_run, GOMP_OFFLOAD_openacc_parallel)
+	(GOMP_OFFLOAD_openacc_register_async_cleanup)
+	(GOMP_OFFLOAD_openacc_async_test)
+	(GOMP_OFFLOAD_openacc_async_test_all)
+	(GOMP_OFFLOAD_openacc_async_wait)
+	(GOMP_OFFLOAD_openacc_async_wait_async)
+	(GOMP_OFFLOAD_openacc_async_wait_all)
+	(GOMP_OFFLOAD_openacc_async_wait_all_async)
+	(GOMP_OFFLOAD_openacc_async_set_async)
+	(GOMP_OFFLOAD_openacc_create_thread_data)
+	(GOMP_OFFLOAD_openacc_destroy_thread_data)
+	(GOMP_OFFLOAD_openacc_get_current_cuda_device)
+	(GOMP_OFFLOAD_openacc_get_current_cuda_context)
+	(GOMP_OFFLOAD_openacc_get_cuda_stream)
+	(GOMP_OFFLOAD_openacc_set_cuda_stream): New prototypes.
+	* libgomp.h (struct acc_dispatch_t, struct gomp_device_descr): Use
+	these.
+	* plugin/plugin-hsa.c (GOMP_OFFLOAD_load_image)
+	(GOMP_OFFLOAD_unload_image): Fix argument types.
+
 2017-01-27  Cesar Philippidis  <cesar@codesourcery.com>
 
 	* testsuite/libgomp.oacc-fortran/deviceptr-1.f90: Add -foffload-force.
diff --git libgomp/libgomp-plugin.h libgomp/libgomp-plugin.h
index 53f9248..fba45ee 100644
--- libgomp/libgomp-plugin.h
+++ libgomp/libgomp-plugin.h
@@ -1,4 +1,6 @@
-/* Copyright (C) 2014-2016 Free Software Foundation, Inc.
+/* The libgomp plugin API.
+
+   Copyright (C) 2014-2017 Free Software Foundation, Inc.
 
    Contributed by Mentor Embedded.
 
@@ -24,11 +26,10 @@
    see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
    <http://www.gnu.org/licenses/>.  */
 
-/* An interface to various libgomp-internal functions for use by plugins.  */
-
 #ifndef LIBGOMP_PLUGIN_H
 #define LIBGOMP_PLUGIN_H 1
 
+#include <stdbool.h>
 #include <stddef.h>
 #include <stdint.h>
 
@@ -73,6 +74,42 @@ extern void GOMP_PLUGIN_error (const char *, ...)
 extern void GOMP_PLUGIN_fatal (const char *, ...)
 	__attribute__ ((noreturn, format (printf, 1, 2)));
 
+/* Prototypes for functions implemented by libgomp plugins.  */
+extern const char *GOMP_OFFLOAD_get_name (void);
+extern unsigned int GOMP_OFFLOAD_get_caps (void);
+extern int GOMP_OFFLOAD_get_type (void);
+extern int GOMP_OFFLOAD_get_num_devices (void);
+extern bool GOMP_OFFLOAD_init_device (int);
+extern bool GOMP_OFFLOAD_fini_device (int);
+extern unsigned GOMP_OFFLOAD_version (void);
+extern int GOMP_OFFLOAD_load_image (int, unsigned, const void *,
+				    struct addr_pair **);
+extern bool GOMP_OFFLOAD_unload_image (int, unsigned, const void *);
+extern void *GOMP_OFFLOAD_alloc (int, size_t);
+extern bool GOMP_OFFLOAD_free (int, void *);
+extern bool GOMP_OFFLOAD_dev2host (int, void *, const void *, size_t);
+extern bool GOMP_OFFLOAD_host2dev (int, void *, const void *, size_t);
+extern bool GOMP_OFFLOAD_dev2dev (int, void *, const void *, size_t);
+extern bool GOMP_OFFLOAD_can_run (void *);
+extern void GOMP_OFFLOAD_run (int, void *, void *, void **);
+extern void GOMP_OFFLOAD_async_run (int, void *, void *, void **, void *);
+extern void GOMP_OFFLOAD_openacc_parallel (void (*) (void *), size_t, void **,
+					   void **, int, unsigned *, void *);
+extern void GOMP_OFFLOAD_openacc_register_async_cleanup (void *, int);
+extern int GOMP_OFFLOAD_openacc_async_test (int);
+extern int GOMP_OFFLOAD_openacc_async_test_all (void);
+extern void GOMP_OFFLOAD_openacc_async_wait (int);
+extern void GOMP_OFFLOAD_openacc_async_wait_async (int, int);
+extern void GOMP_OFFLOAD_openacc_async_wait_all (void);
+extern void GOMP_OFFLOAD_openacc_async_wait_all_async (int);
+extern void GOMP_OFFLOAD_openacc_async_set_async (int);
+extern void *GOMP_OFFLOAD_openacc_create_thread_data (int);
+extern void GOMP_OFFLOAD_openacc_destroy_thread_data (void *);
+extern void *GOMP_OFFLOAD_openacc_get_current_cuda_device (void);
+extern void *GOMP_OFFLOAD_openacc_get_current_cuda_context (void);
+extern void *GOMP_OFFLOAD_openacc_get_cuda_stream (int);
+extern int GOMP_OFFLOAD_openacc_set_cuda_stream (int, void *);
+
 #ifdef __cplusplus
 }
 #endif
diff --git libgomp/libgomp.h libgomp/libgomp.h
index e39ebc6..3896022 100644
--- libgomp/libgomp.h
+++ libgomp/libgomp.h
@@ -866,31 +866,35 @@ typedef struct acc_dispatch_t
   struct target_mem_desc *data_environ;
 
   /* Execute.  */
-  void (*exec_func) (void (*) (void *), size_t, void **, void **, int,
-		     unsigned *, void *);
+  __typeof (GOMP_OFFLOAD_openacc_parallel) *exec_func;
 
   /* Async cleanup callback registration.  */
-  void (*register_async_cleanup_func) (void *, int);
+  __typeof (GOMP_OFFLOAD_openacc_register_async_cleanup)
+    *register_async_cleanup_func;
 
   /* Asynchronous routines.  */
-  int (*async_test_func) (int);
-  int (*async_test_all_func) (void);
-  void (*async_wait_func) (int);
-  void (*async_wait_async_func) (int, int);
-  void (*async_wait_all_func) (void);
-  void (*async_wait_all_async_func) (int);
-  void (*async_set_async_func) (int);
+  __typeof (GOMP_OFFLOAD_openacc_async_test) *async_test_func;
+  __typeof (GOMP_OFFLOAD_openacc_async_test_all) *async_test_all_func;
+  __typeof (GOMP_OFFLOAD_openacc_async_wait) *async_wait_func;
+  __typeof (GOMP_OFFLOAD_openacc_async_wait_async) *async_wait_async_func;
+  __typeof (GOMP_OFFLOAD_openacc_async_wait_all) *async_wait_all_func;
+  __typeof (GOMP_OFFLOAD_openacc_async_wait_all_async)
+    *async_wait_all_async_func;
+  __typeof (GOMP_OFFLOAD_openacc_async_set_async) *async_set_async_func;
 
   /* Create/destroy TLS data.  */
-  void *(*create_thread_data_func) (int);
-  void (*destroy_thread_data_func) (void *);
+  __typeof (GOMP_OFFLOAD_openacc_create_thread_data) *create_thread_data_func;
+  __typeof (GOMP_OFFLOAD_openacc_destroy_thread_data)
+    *destroy_thread_data_func;
 
   /* NVIDIA target specific routines.  */
   struct {
-    void *(*get_current_device_func) (void);
-    void *(*get_current_context_func) (void);
-    void *(*get_stream_func) (int);
-    int (*set_stream_func) (int, void *);
+    __typeof (GOMP_OFFLOAD_openacc_get_current_cuda_device)
+      *get_current_device_func;
+    __typeof (GOMP_OFFLOAD_openacc_get_current_cuda_context)
+      *get_current_context_func;
+    __typeof (GOMP_OFFLOAD_openacc_get_cuda_stream) *get_stream_func;
+    __typeof (GOMP_OFFLOAD_openacc_set_cuda_stream) *set_stream_func;
   } cuda;
 } acc_dispatch_t;
 
@@ -924,23 +928,23 @@ struct gomp_device_descr
   enum offload_target_type type;
 
   /* Function handlers.  */
-  const char *(*get_name_func) (void);
-  unsigned int (*get_caps_func) (void);
-  int (*get_type_func) (void);
-  int (*get_num_devices_func) (void);
-  bool (*init_device_func) (int);
-  bool (*fini_device_func) (int);
-  unsigned (*version_func) (void);
-  int (*load_image_func) (int, unsigned, const void *, struct addr_pair **);
-  bool (*unload_image_func) (int, unsigned, const void *);
-  void *(*alloc_func) (int, size_t);
-  bool (*free_func) (int, void *);
-  bool (*dev2host_func) (int, void *, const void *, size_t);
-  bool (*host2dev_func) (int, void *, const void *, size_t);
-  bool (*dev2dev_func) (int, void *, const void *, size_t);
-  bool (*can_run_func) (void *);
-  void (*run_func) (int, void *, void *, void **);
-  void (*async_run_func) (int, void *, void *, void **, void *);
+  __typeof (GOMP_OFFLOAD_get_name) *get_name_func;
+  __typeof (GOMP_OFFLOAD_get_caps) *get_caps_func;
+  __typeof (GOMP_OFFLOAD_get_type) *get_type_func;
+  __typeof (GOMP_OFFLOAD_get_num_devices) *get_num_devices_func;
+  __typeof (GOMP_OFFLOAD_init_device) *init_device_func;
+  __typeof (GOMP_OFFLOAD_fini_device) *fini_device_func;
+  __typeof (GOMP_OFFLOAD_version) *version_func;
+  __typeof (GOMP_OFFLOAD_load_image) *load_image_func;
+  __typeof (GOMP_OFFLOAD_unload_image) *unload_image_func;
+  __typeof (GOMP_OFFLOAD_alloc) *alloc_func;
+  __typeof (GOMP_OFFLOAD_free) *free_func;
+  __typeof (GOMP_OFFLOAD_dev2host) *dev2host_func;
+  __typeof (GOMP_OFFLOAD_host2dev) *host2dev_func;
+  __typeof (GOMP_OFFLOAD_dev2dev) *dev2dev_func;
+  __typeof (GOMP_OFFLOAD_can_run) *can_run_func;
+  __typeof (GOMP_OFFLOAD_run) *run_func;
+  __typeof (GOMP_OFFLOAD_async_run) *async_run_func;
 
   /* Splay tree containing information about mapped memory regions.  */
   struct splay_tree_s mem_map;
diff --git libgomp/plugin/plugin-hsa.c libgomp/plugin/plugin-hsa.c
index bed8555..51f79e1 100644
--- libgomp/plugin/plugin-hsa.c
+++ libgomp/plugin/plugin-hsa.c
@@ -666,7 +666,7 @@ destroy_hsa_program (struct agent_info *agent)
    in TARGET_TABLE.  */
 
 int
-GOMP_OFFLOAD_load_image (int ord, unsigned version, void *target_data,
+GOMP_OFFLOAD_load_image (int ord, unsigned version, const void *target_data,
 			 struct addr_pair **target_table)
 {
   if (GOMP_VERSION_DEV (version) > GOMP_VERSION_HSA)
@@ -1455,7 +1455,7 @@ destroy_module (struct module_info *module)
    TRUE on success.  */
 
 bool
-GOMP_OFFLOAD_unload_image (int n, unsigned version, void *target_data)
+GOMP_OFFLOAD_unload_image (int n, unsigned version, const void *target_data)
 {
   if (GOMP_VERSION_DEV (version) > GOMP_VERSION_HSA)
     {
diff --git liboffloadmic/ChangeLog.gomp liboffloadmic/ChangeLog.gomp
index 10565cc..0488979 100644
--- liboffloadmic/ChangeLog.gomp
+++ liboffloadmic/ChangeLog.gomp
@@ -1,3 +1,12 @@
+2017-01-31  Thomas Schwinge  <thomas@codesourcery.com>
+
+	Backport from trunk r245062:
+	2017-01-31  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_get_type): Fix
+	return type.
+	(GOMP_OFFLOAD_load_image): Fix argument types.
+
 2016-11-16  Cesar Philippidis  <cesar@codesourcery.com>
 
 	Backport from trunk:
diff --git liboffloadmic/plugin/libgomp-plugin-intelmic.cpp liboffloadmic/plugin/libgomp-plugin-intelmic.cpp
index 7983532..e7ddb93 100644
--- liboffloadmic/plugin/libgomp-plugin-intelmic.cpp
+++ liboffloadmic/plugin/libgomp-plugin-intelmic.cpp
@@ -190,7 +190,7 @@ GOMP_OFFLOAD_get_caps (void)
   return res;
 }
 
-extern "C" enum offload_target_type
+extern "C" int
 GOMP_OFFLOAD_get_type (void)
 {
   enum offload_target_type res = OFFLOAD_TARGET_TYPE_INTEL_MIC;
@@ -376,7 +376,7 @@ GOMP_OFFLOAD_version (void)
 
 extern "C" int
 GOMP_OFFLOAD_load_image (int device, const unsigned version,
-			 void *target_image, addr_pair **result)
+			 const void *target_image, addr_pair **result)
 {
   TRACE ("(device = %d, target_image = %p)", device, target_image);
 


Grüße
 Thomas

^ permalink raw reply	[flat|nested] 6+ messages in thread

* libgomp: Normalize the names of a few functions of the libgomp plugin API (was: libgomp: Provide prototypes for functions implemented by libgomp plugins)
  2017-01-31 14:53   ` Thomas Schwinge
@ 2017-02-02 12:23     ` Thomas Schwinge
  2017-02-02 12:27       ` Jakub Jelinek
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Schwinge @ 2017-02-02 12:23 UTC (permalink / raw)
  To: Jakub Jelinek, gcc-patches

Hi!

On Tue, 31 Jan 2017 15:44:46 +0100, I wrote:
> --- libgomp/libgomp.h
> +++ libgomp/libgomp.h
> @@ -882,31 +882,35 @@ typedef struct acc_dispatch_t

> +  __typeof (GOMP_OFFLOAD_openacc_parallel) *exec_func;

As can be seen here, for a handful of functions, the name of the
implementation in the plugins ("GOMP_OFFLOAD_openacc_parallel") doesn't
match the name used in libgomp proper ("openacc.exec_func").  Here is a
patch to adjust these.  OK for trunk?  If not now, then in next stage 1?

commit 4dc0a9c9a6a1d67e298b254d9c1aa7592db5c763
Author: Thomas Schwinge <thomas@codesourcery.com>
Date:   Thu Jan 26 20:18:30 2017 +0100

    libgomp: Normalize the names of a few functions of the libgomp plugin API
    
            libgomp/
            * libgomp-plugin.h (GOMP_OFFLOAD_openacc_parallel): Rename to
            GOMP_OFFLOAD_openacc_exec.  Adjust all users.
            (GOMP_OFFLOAD_openacc_get_current_cuda_device): Rename to
            GOMP_OFFLOAD_openacc_cuda_get_current_device.  Adjust all users.
            (GOMP_OFFLOAD_openacc_get_current_cuda_context): Rename to
            GOMP_OFFLOAD_openacc_cuda_get_current_context.  Adjust all users.
            (GOMP_OFFLOAD_openacc_get_cuda_stream): Rename to
            GOMP_OFFLOAD_openacc_cuda_get_stream.  Adjust all users.
            (GOMP_OFFLOAD_openacc_set_cuda_stream): Rename to
            GOMP_OFFLOAD_openacc_cuda_set_stream.  Adjust all users.
---
 libgomp/ChangeLog             | 11 +++++++++++
 libgomp/libgomp-plugin.h      | 12 ++++++------
 libgomp/libgomp.h             | 10 +++++-----
 libgomp/plugin/plugin-nvptx.c | 14 +++++++-------
 libgomp/target.c              | 10 +++++-----
 5 files changed, 34 insertions(+), 23 deletions(-)

diff --git libgomp/ChangeLog libgomp/ChangeLog
[snipped]
diff --git libgomp/libgomp-plugin.h libgomp/libgomp-plugin.h
index fba45ee..ff81350 100644
--- libgomp/libgomp-plugin.h
+++ libgomp/libgomp-plugin.h
@@ -93,8 +93,8 @@ extern bool GOMP_OFFLOAD_dev2dev (int, void *, const void *, size_t);
 extern bool GOMP_OFFLOAD_can_run (void *);
 extern void GOMP_OFFLOAD_run (int, void *, void *, void **);
 extern void GOMP_OFFLOAD_async_run (int, void *, void *, void **, void *);
-extern void GOMP_OFFLOAD_openacc_parallel (void (*) (void *), size_t, void **,
-					   void **, int, unsigned *, void *);
+extern void GOMP_OFFLOAD_openacc_exec (void (*) (void *), size_t, void **,
+				       void **, int, unsigned *, void *);
 extern void GOMP_OFFLOAD_openacc_register_async_cleanup (void *, int);
 extern int GOMP_OFFLOAD_openacc_async_test (int);
 extern int GOMP_OFFLOAD_openacc_async_test_all (void);
@@ -105,10 +105,10 @@ extern void GOMP_OFFLOAD_openacc_async_wait_all_async (int);
 extern void GOMP_OFFLOAD_openacc_async_set_async (int);
 extern void *GOMP_OFFLOAD_openacc_create_thread_data (int);
 extern void GOMP_OFFLOAD_openacc_destroy_thread_data (void *);
-extern void *GOMP_OFFLOAD_openacc_get_current_cuda_device (void);
-extern void *GOMP_OFFLOAD_openacc_get_current_cuda_context (void);
-extern void *GOMP_OFFLOAD_openacc_get_cuda_stream (int);
-extern int GOMP_OFFLOAD_openacc_set_cuda_stream (int, void *);
+extern void *GOMP_OFFLOAD_openacc_cuda_get_current_device (void);
+extern void *GOMP_OFFLOAD_openacc_cuda_get_current_context (void);
+extern void *GOMP_OFFLOAD_openacc_cuda_get_stream (int);
+extern int GOMP_OFFLOAD_openacc_cuda_set_stream (int, void *);
 
 #ifdef __cplusplus
 }
diff --git libgomp/libgomp.h libgomp/libgomp.h
index 6dfe9aa..1769a48 100644
--- libgomp/libgomp.h
+++ libgomp/libgomp.h
@@ -882,7 +882,7 @@ typedef struct acc_dispatch_t
   struct target_mem_desc *data_environ;
 
   /* Execute.  */
-  __typeof (GOMP_OFFLOAD_openacc_parallel) *exec_func;
+  __typeof (GOMP_OFFLOAD_openacc_exec) *exec_func;
 
   /* Async cleanup callback registration.  */
   __typeof (GOMP_OFFLOAD_openacc_register_async_cleanup)
@@ -905,12 +905,12 @@ typedef struct acc_dispatch_t
 
   /* NVIDIA target specific routines.  */
   struct {
-    __typeof (GOMP_OFFLOAD_openacc_get_current_cuda_device)
+    __typeof (GOMP_OFFLOAD_openacc_cuda_get_current_device)
       *get_current_device_func;
-    __typeof (GOMP_OFFLOAD_openacc_get_current_cuda_context)
+    __typeof (GOMP_OFFLOAD_openacc_cuda_get_current_context)
       *get_current_context_func;
-    __typeof (GOMP_OFFLOAD_openacc_get_cuda_stream) *get_stream_func;
-    __typeof (GOMP_OFFLOAD_openacc_set_cuda_stream) *set_stream_func;
+    __typeof (GOMP_OFFLOAD_openacc_cuda_get_stream) *get_stream_func;
+    __typeof (GOMP_OFFLOAD_openacc_cuda_set_stream) *set_stream_func;
   } cuda;
 } acc_dispatch_t;
 
diff --git libgomp/plugin/plugin-nvptx.c libgomp/plugin/plugin-nvptx.c
index 4144218..0284c7f 100644
--- libgomp/plugin/plugin-nvptx.c
+++ libgomp/plugin/plugin-nvptx.c
@@ -1922,9 +1922,9 @@ GOMP_OFFLOAD_dev2dev (int ord, void *dst, const void *src, size_t n)
 void (*device_run) (int n, void *fn_ptr, void *vars) = NULL;
 
 void
-GOMP_OFFLOAD_openacc_parallel (void (*fn) (void *), size_t mapnum,
-			       void **hostaddrs, void **devaddrs,
-			       int async, unsigned *dims, void *targ_mem_desc)
+GOMP_OFFLOAD_openacc_exec (void (*fn) (void *), size_t mapnum,
+			   void **hostaddrs, void **devaddrs,
+			   int async, unsigned *dims, void *targ_mem_desc)
 {
   nvptx_exec (fn, mapnum, hostaddrs, devaddrs, async, dims, targ_mem_desc);
 }
@@ -2014,13 +2014,13 @@ GOMP_OFFLOAD_openacc_destroy_thread_data (void *data)
 }
 
 void *
-GOMP_OFFLOAD_openacc_get_current_cuda_device (void)
+GOMP_OFFLOAD_openacc_cuda_get_current_device (void)
 {
   return nvptx_get_current_cuda_device ();
 }
 
 void *
-GOMP_OFFLOAD_openacc_get_current_cuda_context (void)
+GOMP_OFFLOAD_openacc_cuda_get_current_context (void)
 {
   return nvptx_get_current_cuda_context ();
 }
@@ -2028,7 +2028,7 @@ GOMP_OFFLOAD_openacc_get_current_cuda_context (void)
 /* NOTE: This returns a CUstream, not a ptx_stream pointer.  */
 
 void *
-GOMP_OFFLOAD_openacc_get_cuda_stream (int async)
+GOMP_OFFLOAD_openacc_cuda_get_stream (int async)
 {
   return nvptx_get_cuda_stream (async);
 }
@@ -2036,7 +2036,7 @@ GOMP_OFFLOAD_openacc_get_cuda_stream (int async)
 /* NOTE: This takes a CUstream, not a ptx_stream pointer.  */
 
 int
-GOMP_OFFLOAD_openacc_set_cuda_stream (int async, void *stream)
+GOMP_OFFLOAD_openacc_cuda_set_stream (int async, void *stream)
 {
   return nvptx_set_cuda_stream (async, stream);
 }
diff --git libgomp/target.c libgomp/target.c
index 26d5aba..3dd119f 100644
--- libgomp/target.c
+++ libgomp/target.c
@@ -2399,7 +2399,7 @@ gomp_load_plugin_for_device (struct gomp_device_descr *device,
     }
   if (device->capabilities & GOMP_OFFLOAD_CAP_OPENACC_200)
     {
-      if (!DLSYM_OPT (openacc.exec, openacc_parallel)
+      if (!DLSYM_OPT (openacc.exec, openacc_exec)
 	  || !DLSYM_OPT (openacc.register_async_cleanup,
 			 openacc_register_async_cleanup)
 	  || !DLSYM_OPT (openacc.async_test, openacc_async_test)
@@ -2423,11 +2423,11 @@ gomp_load_plugin_for_device (struct gomp_device_descr *device,
 
       unsigned cuda = 0;
       cuda += DLSYM_OPT (openacc.cuda.get_current_device,
-			 openacc_get_current_cuda_device);
+			 openacc_cuda_get_current_device);
       cuda += DLSYM_OPT (openacc.cuda.get_current_context,
-			 openacc_get_current_cuda_context);
-      cuda += DLSYM_OPT (openacc.cuda.get_stream, openacc_get_cuda_stream);
-      cuda += DLSYM_OPT (openacc.cuda.set_stream, openacc_set_cuda_stream);
+			 openacc_cuda_get_current_context);
+      cuda += DLSYM_OPT (openacc.cuda.get_stream, openacc_cuda_get_stream);
+      cuda += DLSYM_OPT (openacc.cuda.set_stream, openacc_cuda_set_stream);
       if (cuda && cuda != 4)
 	{
 	  /* Make sure all the CUDA functions are there if any of them are.  */


Grüße
 Thomas

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: libgomp: Normalize the names of a few functions of the libgomp plugin API (was: libgomp: Provide prototypes for functions implemented by libgomp plugins)
  2017-02-02 12:23     ` libgomp: Normalize the names of a few functions of the libgomp plugin API (was: libgomp: Provide prototypes for functions implemented by libgomp plugins) Thomas Schwinge
@ 2017-02-02 12:27       ` Jakub Jelinek
  2017-02-02 14:19         ` libgomp: Normalize the names of a few functions of the libgomp plugin API Thomas Schwinge
  0 siblings, 1 reply; 6+ messages in thread
From: Jakub Jelinek @ 2017-02-02 12:27 UTC (permalink / raw)
  To: Thomas Schwinge; +Cc: gcc-patches

On Thu, Feb 02, 2017 at 01:22:37PM +0100, Thomas Schwinge wrote:
> Hi!
> 
> On Tue, 31 Jan 2017 15:44:46 +0100, I wrote:
> > --- libgomp/libgomp.h
> > +++ libgomp/libgomp.h
> > @@ -882,31 +882,35 @@ typedef struct acc_dispatch_t
> 
> > +  __typeof (GOMP_OFFLOAD_openacc_parallel) *exec_func;
> 
> As can be seen here, for a handful of functions, the name of the
> implementation in the plugins ("GOMP_OFFLOAD_openacc_parallel") doesn't
> match the name used in libgomp proper ("openacc.exec_func").  Here is a
> patch to adjust these.  OK for trunk?  If not now, then in next stage 1?

Ok for trunk now, otherwise we'd have to bump the plugin interface in GCC8, even
when we don't know if we'll need to do that.

	Jakub

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: libgomp: Normalize the names of a few functions of the libgomp plugin API
  2017-02-02 12:27       ` Jakub Jelinek
@ 2017-02-02 14:19         ` Thomas Schwinge
  0 siblings, 0 replies; 6+ messages in thread
From: Thomas Schwinge @ 2017-02-02 14:19 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

Hi!

On Thu, 2 Feb 2017 13:27:11 +0100, Jakub Jelinek <jakub@redhat.com> wrote:
> On Thu, Feb 02, 2017 at 01:22:37PM +0100, Thomas Schwinge wrote:
> > On Tue, 31 Jan 2017 15:44:46 +0100, I wrote:
> > > --- libgomp/libgomp.h
> > > +++ libgomp/libgomp.h
> > > @@ -882,31 +882,35 @@ typedef struct acc_dispatch_t
> > 
> > > +  __typeof (GOMP_OFFLOAD_openacc_parallel) *exec_func;
> > 
> > As can be seen here, for a handful of functions, the name of the
> > implementation in the plugins ("GOMP_OFFLOAD_openacc_parallel") doesn't
> > match the name used in libgomp proper ("openacc.exec_func").  Here is a
> > patch to adjust these.  OK for trunk?  If not now, then in next stage 1?
> 
> Ok for trunk now

Thanks for the quick review!

> otherwise we'd have to bump the plugin interface in GCC8, even
> when we don't know if we'll need to do that.

I don't think that's actually a concern: this changes the libgomp <->
libgomp plugin interface only, for which versioning is not a concern.


Anyway, without changes committed to trunk in r245125:

commit 65caa53b3e767f1df02673f25f281926d11219a7
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Thu Feb 2 14:13:57 2017 +0000

    libgomp: Normalize the names of a few functions of the libgomp plugin API
    
            libgomp/
            * libgomp-plugin.h (GOMP_OFFLOAD_openacc_parallel): Rename to
            GOMP_OFFLOAD_openacc_exec.  Adjust all users.
            (GOMP_OFFLOAD_openacc_get_current_cuda_device): Rename to
            GOMP_OFFLOAD_openacc_cuda_get_current_device.  Adjust all users.
            (GOMP_OFFLOAD_openacc_get_current_cuda_context): Rename to
            GOMP_OFFLOAD_openacc_cuda_get_current_context.  Adjust all users.
            (GOMP_OFFLOAD_openacc_get_cuda_stream): Rename to
            GOMP_OFFLOAD_openacc_cuda_get_stream.  Adjust all users.
            (GOMP_OFFLOAD_openacc_set_cuda_stream): Rename to
            GOMP_OFFLOAD_openacc_cuda_set_stream.  Adjust all users.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@245125 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog             | 13 +++++++++++++
 libgomp/libgomp-plugin.h      | 12 ++++++------
 libgomp/libgomp.h             | 10 +++++-----
 libgomp/plugin/plugin-nvptx.c | 14 +++++++-------
 libgomp/target.c              | 10 +++++-----
 5 files changed, 36 insertions(+), 23 deletions(-)

diff --git libgomp/ChangeLog libgomp/ChangeLog
index 829a30f..5f05cdb 100644
--- libgomp/ChangeLog
+++ libgomp/ChangeLog
@@ -1,3 +1,16 @@
+2017-02-02  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* libgomp-plugin.h (GOMP_OFFLOAD_openacc_parallel): Rename to
+	GOMP_OFFLOAD_openacc_exec.  Adjust all users.
+	(GOMP_OFFLOAD_openacc_get_current_cuda_device): Rename to
+	GOMP_OFFLOAD_openacc_cuda_get_current_device.  Adjust all users.
+	(GOMP_OFFLOAD_openacc_get_current_cuda_context): Rename to
+	GOMP_OFFLOAD_openacc_cuda_get_current_context.  Adjust all users.
+	(GOMP_OFFLOAD_openacc_get_cuda_stream): Rename to
+	GOMP_OFFLOAD_openacc_cuda_get_stream.  Adjust all users.
+	(GOMP_OFFLOAD_openacc_set_cuda_stream): Rename to
+	GOMP_OFFLOAD_openacc_cuda_set_stream.  Adjust all users.
+
 2017-01-31  Thomas Schwinge  <thomas@codesourcery.com>
 
 	* libgomp-plugin.h: #include <stdbool.h>.
diff --git libgomp/libgomp-plugin.h libgomp/libgomp-plugin.h
index fba45ee..ff81350 100644
--- libgomp/libgomp-plugin.h
+++ libgomp/libgomp-plugin.h
@@ -93,8 +93,8 @@ extern bool GOMP_OFFLOAD_dev2dev (int, void *, const void *, size_t);
 extern bool GOMP_OFFLOAD_can_run (void *);
 extern void GOMP_OFFLOAD_run (int, void *, void *, void **);
 extern void GOMP_OFFLOAD_async_run (int, void *, void *, void **, void *);
-extern void GOMP_OFFLOAD_openacc_parallel (void (*) (void *), size_t, void **,
-					   void **, int, unsigned *, void *);
+extern void GOMP_OFFLOAD_openacc_exec (void (*) (void *), size_t, void **,
+				       void **, int, unsigned *, void *);
 extern void GOMP_OFFLOAD_openacc_register_async_cleanup (void *, int);
 extern int GOMP_OFFLOAD_openacc_async_test (int);
 extern int GOMP_OFFLOAD_openacc_async_test_all (void);
@@ -105,10 +105,10 @@ extern void GOMP_OFFLOAD_openacc_async_wait_all_async (int);
 extern void GOMP_OFFLOAD_openacc_async_set_async (int);
 extern void *GOMP_OFFLOAD_openacc_create_thread_data (int);
 extern void GOMP_OFFLOAD_openacc_destroy_thread_data (void *);
-extern void *GOMP_OFFLOAD_openacc_get_current_cuda_device (void);
-extern void *GOMP_OFFLOAD_openacc_get_current_cuda_context (void);
-extern void *GOMP_OFFLOAD_openacc_get_cuda_stream (int);
-extern int GOMP_OFFLOAD_openacc_set_cuda_stream (int, void *);
+extern void *GOMP_OFFLOAD_openacc_cuda_get_current_device (void);
+extern void *GOMP_OFFLOAD_openacc_cuda_get_current_context (void);
+extern void *GOMP_OFFLOAD_openacc_cuda_get_stream (int);
+extern int GOMP_OFFLOAD_openacc_cuda_set_stream (int, void *);
 
 #ifdef __cplusplus
 }
diff --git libgomp/libgomp.h libgomp/libgomp.h
index 6dfe9aa..1769a48 100644
--- libgomp/libgomp.h
+++ libgomp/libgomp.h
@@ -882,7 +882,7 @@ typedef struct acc_dispatch_t
   struct target_mem_desc *data_environ;
 
   /* Execute.  */
-  __typeof (GOMP_OFFLOAD_openacc_parallel) *exec_func;
+  __typeof (GOMP_OFFLOAD_openacc_exec) *exec_func;
 
   /* Async cleanup callback registration.  */
   __typeof (GOMP_OFFLOAD_openacc_register_async_cleanup)
@@ -905,12 +905,12 @@ typedef struct acc_dispatch_t
 
   /* NVIDIA target specific routines.  */
   struct {
-    __typeof (GOMP_OFFLOAD_openacc_get_current_cuda_device)
+    __typeof (GOMP_OFFLOAD_openacc_cuda_get_current_device)
       *get_current_device_func;
-    __typeof (GOMP_OFFLOAD_openacc_get_current_cuda_context)
+    __typeof (GOMP_OFFLOAD_openacc_cuda_get_current_context)
       *get_current_context_func;
-    __typeof (GOMP_OFFLOAD_openacc_get_cuda_stream) *get_stream_func;
-    __typeof (GOMP_OFFLOAD_openacc_set_cuda_stream) *set_stream_func;
+    __typeof (GOMP_OFFLOAD_openacc_cuda_get_stream) *get_stream_func;
+    __typeof (GOMP_OFFLOAD_openacc_cuda_set_stream) *set_stream_func;
   } cuda;
 } acc_dispatch_t;
 
diff --git libgomp/plugin/plugin-nvptx.c libgomp/plugin/plugin-nvptx.c
index 4144218..0284c7f 100644
--- libgomp/plugin/plugin-nvptx.c
+++ libgomp/plugin/plugin-nvptx.c
@@ -1922,9 +1922,9 @@ GOMP_OFFLOAD_dev2dev (int ord, void *dst, const void *src, size_t n)
 void (*device_run) (int n, void *fn_ptr, void *vars) = NULL;
 
 void
-GOMP_OFFLOAD_openacc_parallel (void (*fn) (void *), size_t mapnum,
-			       void **hostaddrs, void **devaddrs,
-			       int async, unsigned *dims, void *targ_mem_desc)
+GOMP_OFFLOAD_openacc_exec (void (*fn) (void *), size_t mapnum,
+			   void **hostaddrs, void **devaddrs,
+			   int async, unsigned *dims, void *targ_mem_desc)
 {
   nvptx_exec (fn, mapnum, hostaddrs, devaddrs, async, dims, targ_mem_desc);
 }
@@ -2014,13 +2014,13 @@ GOMP_OFFLOAD_openacc_destroy_thread_data (void *data)
 }
 
 void *
-GOMP_OFFLOAD_openacc_get_current_cuda_device (void)
+GOMP_OFFLOAD_openacc_cuda_get_current_device (void)
 {
   return nvptx_get_current_cuda_device ();
 }
 
 void *
-GOMP_OFFLOAD_openacc_get_current_cuda_context (void)
+GOMP_OFFLOAD_openacc_cuda_get_current_context (void)
 {
   return nvptx_get_current_cuda_context ();
 }
@@ -2028,7 +2028,7 @@ GOMP_OFFLOAD_openacc_get_current_cuda_context (void)
 /* NOTE: This returns a CUstream, not a ptx_stream pointer.  */
 
 void *
-GOMP_OFFLOAD_openacc_get_cuda_stream (int async)
+GOMP_OFFLOAD_openacc_cuda_get_stream (int async)
 {
   return nvptx_get_cuda_stream (async);
 }
@@ -2036,7 +2036,7 @@ GOMP_OFFLOAD_openacc_get_cuda_stream (int async)
 /* NOTE: This takes a CUstream, not a ptx_stream pointer.  */
 
 int
-GOMP_OFFLOAD_openacc_set_cuda_stream (int async, void *stream)
+GOMP_OFFLOAD_openacc_cuda_set_stream (int async, void *stream)
 {
   return nvptx_set_cuda_stream (async, stream);
 }
diff --git libgomp/target.c libgomp/target.c
index 26d5aba..3dd119f 100644
--- libgomp/target.c
+++ libgomp/target.c
@@ -2399,7 +2399,7 @@ gomp_load_plugin_for_device (struct gomp_device_descr *device,
     }
   if (device->capabilities & GOMP_OFFLOAD_CAP_OPENACC_200)
     {
-      if (!DLSYM_OPT (openacc.exec, openacc_parallel)
+      if (!DLSYM_OPT (openacc.exec, openacc_exec)
 	  || !DLSYM_OPT (openacc.register_async_cleanup,
 			 openacc_register_async_cleanup)
 	  || !DLSYM_OPT (openacc.async_test, openacc_async_test)
@@ -2423,11 +2423,11 @@ gomp_load_plugin_for_device (struct gomp_device_descr *device,
 
       unsigned cuda = 0;
       cuda += DLSYM_OPT (openacc.cuda.get_current_device,
-			 openacc_get_current_cuda_device);
+			 openacc_cuda_get_current_device);
       cuda += DLSYM_OPT (openacc.cuda.get_current_context,
-			 openacc_get_current_cuda_context);
-      cuda += DLSYM_OPT (openacc.cuda.get_stream, openacc_get_cuda_stream);
-      cuda += DLSYM_OPT (openacc.cuda.set_stream, openacc_set_cuda_stream);
+			 openacc_cuda_get_current_context);
+      cuda += DLSYM_OPT (openacc.cuda.get_stream, openacc_cuda_get_stream);
+      cuda += DLSYM_OPT (openacc.cuda.set_stream, openacc_cuda_set_stream);
       if (cuda && cuda != 4)
 	{
 	  /* Make sure all the CUDA functions are there if any of them are.  */


Backported to gomp-4_0-branch in r245126:

commit bc818cb3d8d8a5582aa35e667594102670a76c7a
Author: tschwinge <tschwinge@138bc75d-0d04-0410-961f-82ee72b054a4>
Date:   Thu Feb 2 14:15:17 2017 +0000

    libgomp: Normalize the names of a few functions of the libgomp plugin API
    
    Backport from trunk r245125:
    
            libgomp/
            * libgomp-plugin.h (GOMP_OFFLOAD_openacc_parallel): Rename to
            GOMP_OFFLOAD_openacc_exec.  Adjust all users.
            (GOMP_OFFLOAD_openacc_get_current_cuda_device): Rename to
            GOMP_OFFLOAD_openacc_cuda_get_current_device.  Adjust all users.
            (GOMP_OFFLOAD_openacc_get_current_cuda_context): Rename to
            GOMP_OFFLOAD_openacc_cuda_get_current_context.  Adjust all users.
            (GOMP_OFFLOAD_openacc_get_cuda_stream): Rename to
            GOMP_OFFLOAD_openacc_cuda_get_stream.  Adjust all users.
            (GOMP_OFFLOAD_openacc_set_cuda_stream): Rename to
            GOMP_OFFLOAD_openacc_cuda_set_stream.  Adjust all users.
    
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gomp-4_0-branch@245126 138bc75d-0d04-0410-961f-82ee72b054a4
---
 libgomp/ChangeLog.gomp        | 16 ++++++++++++++++
 libgomp/libgomp-plugin.h      | 12 ++++++------
 libgomp/libgomp.h             | 10 +++++-----
 libgomp/plugin/plugin-nvptx.c | 14 +++++++-------
 libgomp/target.c              | 10 +++++-----
 5 files changed, 39 insertions(+), 23 deletions(-)

diff --git libgomp/ChangeLog.gomp libgomp/ChangeLog.gomp
index 78f64207..17b10ef 100644
--- libgomp/ChangeLog.gomp
+++ libgomp/ChangeLog.gomp
@@ -1,3 +1,19 @@
+2017-02-02  Thomas Schwinge  <thomas@codesourcery.com>
+
+	Backport from trunk r245125:
+	2017-02-02  Thomas Schwinge  <thomas@codesourcery.com>
+
+	* libgomp-plugin.h (GOMP_OFFLOAD_openacc_parallel): Rename to
+	GOMP_OFFLOAD_openacc_exec.  Adjust all users.
+	(GOMP_OFFLOAD_openacc_get_current_cuda_device): Rename to
+	GOMP_OFFLOAD_openacc_cuda_get_current_device.  Adjust all users.
+	(GOMP_OFFLOAD_openacc_get_current_cuda_context): Rename to
+	GOMP_OFFLOAD_openacc_cuda_get_current_context.  Adjust all users.
+	(GOMP_OFFLOAD_openacc_get_cuda_stream): Rename to
+	GOMP_OFFLOAD_openacc_cuda_get_stream.  Adjust all users.
+	(GOMP_OFFLOAD_openacc_set_cuda_stream): Rename to
+	GOMP_OFFLOAD_openacc_cuda_set_stream.  Adjust all users.
+
 2017-01-31  Thomas Schwinge  <thomas@codesourcery.com>
 
 	Backport from trunk r245062:
diff --git libgomp/libgomp-plugin.h libgomp/libgomp-plugin.h
index fba45ee..ff81350 100644
--- libgomp/libgomp-plugin.h
+++ libgomp/libgomp-plugin.h
@@ -93,8 +93,8 @@ extern bool GOMP_OFFLOAD_dev2dev (int, void *, const void *, size_t);
 extern bool GOMP_OFFLOAD_can_run (void *);
 extern void GOMP_OFFLOAD_run (int, void *, void *, void **);
 extern void GOMP_OFFLOAD_async_run (int, void *, void *, void **, void *);
-extern void GOMP_OFFLOAD_openacc_parallel (void (*) (void *), size_t, void **,
-					   void **, int, unsigned *, void *);
+extern void GOMP_OFFLOAD_openacc_exec (void (*) (void *), size_t, void **,
+				       void **, int, unsigned *, void *);
 extern void GOMP_OFFLOAD_openacc_register_async_cleanup (void *, int);
 extern int GOMP_OFFLOAD_openacc_async_test (int);
 extern int GOMP_OFFLOAD_openacc_async_test_all (void);
@@ -105,10 +105,10 @@ extern void GOMP_OFFLOAD_openacc_async_wait_all_async (int);
 extern void GOMP_OFFLOAD_openacc_async_set_async (int);
 extern void *GOMP_OFFLOAD_openacc_create_thread_data (int);
 extern void GOMP_OFFLOAD_openacc_destroy_thread_data (void *);
-extern void *GOMP_OFFLOAD_openacc_get_current_cuda_device (void);
-extern void *GOMP_OFFLOAD_openacc_get_current_cuda_context (void);
-extern void *GOMP_OFFLOAD_openacc_get_cuda_stream (int);
-extern int GOMP_OFFLOAD_openacc_set_cuda_stream (int, void *);
+extern void *GOMP_OFFLOAD_openacc_cuda_get_current_device (void);
+extern void *GOMP_OFFLOAD_openacc_cuda_get_current_context (void);
+extern void *GOMP_OFFLOAD_openacc_cuda_get_stream (int);
+extern int GOMP_OFFLOAD_openacc_cuda_set_stream (int, void *);
 
 #ifdef __cplusplus
 }
diff --git libgomp/libgomp.h libgomp/libgomp.h
index 3896022..f4bfc06 100644
--- libgomp/libgomp.h
+++ libgomp/libgomp.h
@@ -866,7 +866,7 @@ typedef struct acc_dispatch_t
   struct target_mem_desc *data_environ;
 
   /* Execute.  */
-  __typeof (GOMP_OFFLOAD_openacc_parallel) *exec_func;
+  __typeof (GOMP_OFFLOAD_openacc_exec) *exec_func;
 
   /* Async cleanup callback registration.  */
   __typeof (GOMP_OFFLOAD_openacc_register_async_cleanup)
@@ -889,12 +889,12 @@ typedef struct acc_dispatch_t
 
   /* NVIDIA target specific routines.  */
   struct {
-    __typeof (GOMP_OFFLOAD_openacc_get_current_cuda_device)
+    __typeof (GOMP_OFFLOAD_openacc_cuda_get_current_device)
       *get_current_device_func;
-    __typeof (GOMP_OFFLOAD_openacc_get_current_cuda_context)
+    __typeof (GOMP_OFFLOAD_openacc_cuda_get_current_context)
       *get_current_context_func;
-    __typeof (GOMP_OFFLOAD_openacc_get_cuda_stream) *get_stream_func;
-    __typeof (GOMP_OFFLOAD_openacc_set_cuda_stream) *set_stream_func;
+    __typeof (GOMP_OFFLOAD_openacc_cuda_get_stream) *get_stream_func;
+    __typeof (GOMP_OFFLOAD_openacc_cuda_set_stream) *set_stream_func;
   } cuda;
 } acc_dispatch_t;
 
diff --git libgomp/plugin/plugin-nvptx.c libgomp/plugin/plugin-nvptx.c
index a05b399..79c58c6 100644
--- libgomp/plugin/plugin-nvptx.c
+++ libgomp/plugin/plugin-nvptx.c
@@ -1733,9 +1733,9 @@ GOMP_OFFLOAD_host2dev (int ord, void *dst, const void *src, size_t n)
 void (*device_run) (int n, void *fn_ptr, void *vars) = NULL;
 
 void
-GOMP_OFFLOAD_openacc_parallel (void (*fn) (void *), size_t mapnum,
-			       void **hostaddrs, void **devaddrs,
-			       int async, unsigned *dims, void *targ_mem_desc)
+GOMP_OFFLOAD_openacc_exec (void (*fn) (void *), size_t mapnum,
+			   void **hostaddrs, void **devaddrs,
+			   int async, unsigned *dims, void *targ_mem_desc)
 {
   nvptx_exec (fn, mapnum, hostaddrs, devaddrs, async, dims, targ_mem_desc);
 }
@@ -1825,13 +1825,13 @@ GOMP_OFFLOAD_openacc_destroy_thread_data (void *data)
 }
 
 void *
-GOMP_OFFLOAD_openacc_get_current_cuda_device (void)
+GOMP_OFFLOAD_openacc_cuda_get_current_device (void)
 {
   return nvptx_get_current_cuda_device ();
 }
 
 void *
-GOMP_OFFLOAD_openacc_get_current_cuda_context (void)
+GOMP_OFFLOAD_openacc_cuda_get_current_context (void)
 {
   return nvptx_get_current_cuda_context ();
 }
@@ -1839,7 +1839,7 @@ GOMP_OFFLOAD_openacc_get_current_cuda_context (void)
 /* NOTE: This returns a CUstream, not a ptx_stream pointer.  */
 
 void *
-GOMP_OFFLOAD_openacc_get_cuda_stream (int async)
+GOMP_OFFLOAD_openacc_cuda_get_stream (int async)
 {
   return nvptx_get_cuda_stream (async);
 }
@@ -1847,7 +1847,7 @@ GOMP_OFFLOAD_openacc_get_cuda_stream (int async)
 /* NOTE: This takes a CUstream, not a ptx_stream pointer.  */
 
 int
-GOMP_OFFLOAD_openacc_set_cuda_stream (int async, void *stream)
+GOMP_OFFLOAD_openacc_cuda_set_stream (int async, void *stream)
 {
   return nvptx_set_cuda_stream (async, stream);
 }
diff --git libgomp/target.c libgomp/target.c
index 590b7dd..6bfcd75 100644
--- libgomp/target.c
+++ libgomp/target.c
@@ -2855,7 +2855,7 @@ gomp_load_plugin_for_device (struct gomp_device_descr *device,
     }
   if (device->capabilities & GOMP_OFFLOAD_CAP_OPENACC_200)
     {
-      if (!DLSYM_OPT (openacc.exec, openacc_parallel)
+      if (!DLSYM_OPT (openacc.exec, openacc_exec)
 	  || !DLSYM_OPT (openacc.register_async_cleanup,
 			 openacc_register_async_cleanup)
 	  || !DLSYM_OPT (openacc.async_test, openacc_async_test)
@@ -2879,11 +2879,11 @@ gomp_load_plugin_for_device (struct gomp_device_descr *device,
 
       unsigned cuda = 0;
       cuda += DLSYM_OPT (openacc.cuda.get_current_device,
-			 openacc_get_current_cuda_device);
+			 openacc_cuda_get_current_device);
       cuda += DLSYM_OPT (openacc.cuda.get_current_context,
-			 openacc_get_current_cuda_context);
-      cuda += DLSYM_OPT (openacc.cuda.get_stream, openacc_get_cuda_stream);
-      cuda += DLSYM_OPT (openacc.cuda.set_stream, openacc_set_cuda_stream);
+			 openacc_cuda_get_current_context);
+      cuda += DLSYM_OPT (openacc.cuda.get_stream, openacc_cuda_get_stream);
+      cuda += DLSYM_OPT (openacc.cuda.set_stream, openacc_cuda_set_stream);
       if (cuda && cuda != 4)
 	{
 	  /* Make sure all the CUDA functions are there if any of them are.  */


Grüße
 Thomas

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-02-02 14:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-27  9:29 libgomp: Provide prototypes for functions implemented by libgomp plugins Thomas Schwinge
2017-01-27  9:40 ` Jakub Jelinek
2017-01-31 14:53   ` Thomas Schwinge
2017-02-02 12:23     ` libgomp: Normalize the names of a few functions of the libgomp plugin API (was: libgomp: Provide prototypes for functions implemented by libgomp plugins) Thomas Schwinge
2017-02-02 12:27       ` Jakub Jelinek
2017-02-02 14:19         ` libgomp: Normalize the names of a few functions of the libgomp plugin API 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).