]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libgomp: Prepare for reverse offload fn lookup
authorTobias Burnus <tobias@codesourcery.com>
Fri, 9 Sep 2022 15:37:09 +0000 (17:37 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Fri, 9 Sep 2022 15:37:09 +0000 (17:37 +0200)
Prepare for reverse-offloading function-pointer lookup by passing
a rev_fn_table argument to GOMP_OFFLOAD_load_image.

The argument will be NULL, unless GOMP_REQUIRES_REVERSE_OFFLOAD is
requested and devices not supported it, are filtered out.
(Up to and including this commit, no non-host device claims such
support and the caller currently always passes NULL.)

libgomp/ChangeLog:

* libgomp-plugin.h (GOMP_OFFLOAD_load_image): Add
'uint64_t **rev_fn_table' argument.
* oacc-host.c (host_load_image): Likewise.
* plugin/plugin-gcn.c (GOMP_OFFLOAD_load_image): Likewise;
currently unused.
* plugin/plugin-nvptx.c (GOMP_OFFLOAD_load_image): Likewise.
* target.c (gomp_load_image_to_device): Update call but pass
NULL for now.

liboffloadmic/ChangeLog:

* plugin/libgomp-plugin-intelmic.cpp (GOMP_OFFLOAD_load_image):
Add (unused) uint64_t **rev_fn_table argument.

libgomp/libgomp-plugin.h
libgomp/oacc-host.c
libgomp/plugin/plugin-gcn.c
libgomp/plugin/plugin-nvptx.c
libgomp/target.c
liboffloadmic/plugin/libgomp-plugin-intelmic.cpp

index 71a307f47eb082bffafa70dd0e59d1be73a78117..6ab5ac6365fe5a88b091184a3855b52e8d84b7b0 100644 (file)
@@ -130,7 +130,7 @@ 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 **);
+                                   struct addr_pair **, uint64_t **);
 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 *);
index eb11b9cf16a90780c2796a82614d58c05640245a..4e3971ae1a9cd95dfb0ad6fd113f32acb410bdaa 100644 (file)
@@ -81,7 +81,8 @@ static int
 host_load_image (int n __attribute__ ((unused)),
                 unsigned v __attribute__ ((unused)),
                 const void *t __attribute__ ((unused)),
-                struct addr_pair **r __attribute__ ((unused)))
+                struct addr_pair **r __attribute__ ((unused)),
+                uint64_t **f __attribute__ ((unused)))
 {
   return 0;
 }
index 957455a3891978b5ff41ca3e84b77f3525aef596..6c77f896f886b788be29b20d7bfb334a5d80a80b 100644 (file)
@@ -3346,11 +3346,14 @@ GOMP_OFFLOAD_init_device (int n)
 
 /* Load GCN object-code module described by struct gcn_image_desc in
    TARGET_DATA and return references to kernel descriptors in TARGET_TABLE.
-   If there are any constructors then run them.  */
+   If there are any constructors then run them.  If not NULL, REV_FN_TABLE will
+   contain the on-device addresses of the functions for reverse offload.  To be
+   freed by the caller.  */
 
 int
 GOMP_OFFLOAD_load_image (int ord, unsigned version, const void *target_data,
-                        struct addr_pair **target_table)
+                        struct addr_pair **target_table,
+                        uint64_t **rev_fn_table __attribute__((unused)))
 {
   if (GOMP_VERSION_DEV (version) != GOMP_VERSION_GCN)
     {
index a12f1ac075a25b561f35d4639c896c6edf694de7..044bb9c09a61ba3be5de9083c77df8eebb4d030d 100644 (file)
@@ -1266,11 +1266,14 @@ nvptx_set_clocktick (CUmodule module, struct ptx_device *dev)
 }
 
 /* Load the (partial) program described by TARGET_DATA to device
-   number ORD.  Allocate and return TARGET_TABLE.  */
+   number ORD.  Allocate and return TARGET_TABLE.  If not NULL, REV_FN_TABLE
+   will contain the on-device addresses of the functions for reverse offload.
+   To be freed by the caller.  */
 
 int
 GOMP_OFFLOAD_load_image (int ord, unsigned version, const void *target_data,
-                        struct addr_pair **target_table)
+                        struct addr_pair **target_table,
+                        uint64_t **rev_fn_table __attribute__((unused)))
 {
   CUmodule module;
   const char *const *var_names;
index fbc2827d0381d2eebb87e157c854294993f0c056..57634839c8fd70e9d1a0f2e60622bd99d24a431b 100644 (file)
@@ -2196,7 +2196,7 @@ gomp_load_image_to_device (struct gomp_device_descr *devicep, unsigned version,
 
   num_target_entries
     = devicep->load_image_func (devicep->target_id, version,
-                               target_data, &target_table);
+                               target_data, &target_table, NULL);
 
   if (num_target_entries != num_funcs + num_vars
       /* "+1" due to the additional ICV struct.  */
index 33bae0650b41c6fffe0036f8b1bf4c0ddc531c64..7be27f0459db06a37c93427eec820f9f866c0671 100644 (file)
@@ -349,7 +349,8 @@ GOMP_OFFLOAD_version (void)
 
 extern "C" int
 GOMP_OFFLOAD_load_image (int device, const unsigned version,
-                        const void *target_image, addr_pair **result)
+                        const void *target_image, addr_pair **result,
+                        uint64_t ** /* rev_fn_table */)
 {
   TRACE ("(device = %d, target_image = %p)", device, target_image);