]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Restore 'GOMP_offload_unregister_ver' functionality
authorThomas Schwinge <thomas@codesourcery.com>
Thu, 7 Jul 2022 06:54:11 +0000 (08:54 +0200)
committerTobias Burnus <tobias@codesourcery.com>
Thu, 7 Jul 2022 06:54:11 +0000 (08:54 +0200)
The recent commit 683f11843974f0bdf42f79cdcbb0c2b43c7b81b0
"OpenMP: Move omp requires checks to libgomp" changed the
'GOMP_offload_register_ver' interface but didn't change
'GOMP_offload_unregister_ver' accordingly, so we're no longer
actually unregistering.

gcc/
* config/gcn/mkoffload.cc (process_obj): Clarify 'target_data' ->
'[...]_data'.
* config/nvptx/mkoffload.cc (process): Likewise.
libgomp/
* target.c (GOMP_offload_register_ver): Clarify 'target_data' ->
'data'.
(GOMP_offload_unregister_ver): Likewise.  Fix up 'target_data'.

(cherry picked from commit 3f05e03d6cfdf723ca0556318b6a9aa37be438e7)

gcc/ChangeLog.omp
gcc/config/gcn/mkoffload.cc
gcc/config/nvptx/mkoffload.cc
libgomp/ChangeLog.omp
libgomp/target.c

index f2e1e68eb512ca1f9a9df88f52c31f1ab96962c2..655cb0175d4e8aa3a34e927fcd292ae12f4cf0d2 100644 (file)
@@ -1,3 +1,12 @@
+2022-07-07  Tobias Burnus  <tobias@codesourcery.com>
+
+       Backport from mainline:
+       2022-07-06  Thomas Schwinge  <thomas@codesourcery.com>
+
+       * config/gcn/mkoffload.cc (process_obj): Clarify 'target_data' ->
+       '[...]_data'.
+       * config/nvptx/mkoffload.cc (process): Likewise.
+
 2022-07-07  Tobias Burnus  <tobias@codesourcery.com>
 
        Backport from mainline:
index 5741d0a917b379184b74de91ca80acfbea52c487..29aa473239c173564e856647ee86694a6a19c7fa 100644 (file)
@@ -731,13 +731,13 @@ process_obj (FILE *in, FILE *cfile, uint32_t omp_requires)
           len);
 
   fprintf (cfile,
-          "static const struct gcn_image_desc {\n"
+          "static const struct gcn_data {\n"
           "  uintptr_t omp_requires_mask;\n"
           "  const struct gcn_image *gcn_image;\n"
           "  unsigned kernel_count;\n"
           "  const struct hsa_kernel_description *kernel_infos;\n"
           "  unsigned global_variable_count;\n"
-          "} target_data = {\n"
+          "} gcn_data = {\n"
           "  %d,\n"
           "  &gcn_image,\n"
           "  sizeof (gcn_kernels) / sizeof (gcn_kernels[0]),\n"
@@ -762,7 +762,7 @@ process_obj (FILE *in, FILE *cfile, uint32_t omp_requires)
   fprintf (cfile, "static __attribute__((constructor)) void init (void)\n"
           "{\n"
           "  GOMP_offload_register_ver (%#x, __OFFLOAD_TABLE__,"
-          " %d/*GCN*/, &target_data);\n"
+          " %d/*GCN*/, &gcn_data);\n"
           "};\n",
           GOMP_VERSION_PACK (GOMP_VERSION, GOMP_VERSION_GCN),
           GOMP_DEVICE_GCN);
@@ -770,7 +770,7 @@ process_obj (FILE *in, FILE *cfile, uint32_t omp_requires)
   fprintf (cfile, "static __attribute__((destructor)) void fini (void)\n"
           "{\n"
           "  GOMP_offload_unregister_ver (%#x, __OFFLOAD_TABLE__,"
-          " %d/*GCN*/, &target_data);\n"
+          " %d/*GCN*/, &gcn_data);\n"
           "};\n",
           GOMP_VERSION_PACK (GOMP_VERSION, GOMP_VERSION_GCN),
           GOMP_DEVICE_GCN);
index d8c81eb05473994cccc1670092640db0a83e9131..0fa5f4423bf881272429b81546b677573e7831ac 100644 (file)
@@ -310,7 +310,7 @@ process (FILE *in, FILE *out, uint32_t omp_requires)
   fprintf (out, "\n};\n\n");
 
   fprintf (out,
-          "static const struct nvptx_tdata {\n"
+          "static const struct nvptx_data {\n"
           "  uintptr_t omp_requires_mask;\n"
           "  const struct ptx_obj *ptx_objs;\n"
           "  unsigned ptx_num;\n"
@@ -318,7 +318,7 @@ process (FILE *in, FILE *out, uint32_t omp_requires)
           "  unsigned var_num;\n"
           "  const struct nvptx_fn *fn_names;\n"
           "  unsigned fn_num;\n"
-          "} target_data = {\n"
+          "} nvptx_data = {\n"
           "  %d, ptx_objs, sizeof (ptx_objs) / sizeof (ptx_objs[0]),\n"
           "  var_mappings,"
           "  sizeof (var_mappings) / sizeof (var_mappings[0]),\n"
@@ -344,7 +344,7 @@ process (FILE *in, FILE *out, uint32_t omp_requires)
   fprintf (out, "static __attribute__((constructor)) void init (void)\n"
           "{\n"
           "  GOMP_offload_register_ver (%#x, __OFFLOAD_TABLE__,"
-          " %d/*NVIDIA_PTX*/, &target_data);\n"
+          " %d/*NVIDIA_PTX*/, &nvptx_data);\n"
           "};\n",
           GOMP_VERSION_PACK (GOMP_VERSION, GOMP_VERSION_NVIDIA_PTX),
           GOMP_DEVICE_NVIDIA_PTX);
@@ -352,7 +352,7 @@ process (FILE *in, FILE *out, uint32_t omp_requires)
   fprintf (out, "static __attribute__((destructor)) void fini (void)\n"
           "{\n"
           "  GOMP_offload_unregister_ver (%#x, __OFFLOAD_TABLE__,"
-          " %d/*NVIDIA_PTX*/, &target_data);\n"
+          " %d/*NVIDIA_PTX*/, &nvptx_data);\n"
           "};\n",
           GOMP_VERSION_PACK (GOMP_VERSION, GOMP_VERSION_NVIDIA_PTX),
           GOMP_DEVICE_NVIDIA_PTX);
index 506f8f55944ee93ff0402e8aa9362384e5eb5706..ab3dce720778aef49554f33600095adacff6a149 100644 (file)
@@ -1,3 +1,12 @@
+2022-07-07  Tobias Burnus  <tobias@codesourcery.com>
+
+       Backport from mainline:
+       2022-07-06  Thomas Schwinge  <thomas@codesourcery.com>
+
+       * target.c (GOMP_offload_register_ver): Clarify 'target_data' ->
+       'data'.
+       (GOMP_offload_unregister_ver): Likewise.  Fix up 'target_data'.
+
 2022-07-05  Tobias Burnus  <tobias@codesourcery.com>
 
        Backport from mainline:
index 0c5f83b9273322b5e178e3bf2f8e52d0890ca0ee..c88df2cec0edb73400583a9e14d103fb42d39a88 100644 (file)
@@ -2524,23 +2524,29 @@ gomp_requires_to_name (char *buf, size_t size, int requires_mask)
 
 /* This function should be called from every offload image while loading.
    It gets the descriptor of the host func and var tables HOST_TABLE, TYPE of
-   the target, and TARGET_DATA needed by target plugin.  */
+   the target, and DATA.  */
 
 void
 GOMP_offload_register_ver (unsigned version, const void *host_table,
-                          int target_type, const void *target_data)
+                          int target_type, const void *data)
 {
   int i;
-  int omp_req = 0;
 
   if (GOMP_VERSION_LIB (version) > GOMP_VERSION)
     gomp_fatal ("Library too old for offload (version %u < %u)",
                GOMP_VERSION, GOMP_VERSION_LIB (version));
 
+  int omp_req;
+  const void *target_data;
   if (GOMP_VERSION_LIB (version) > 1)
     {
-      omp_req = (int) (size_t) ((void **) target_data)[0];
-      target_data = &((void **) target_data)[1];
+      omp_req = (int) (size_t) ((void **) data)[0];
+      target_data = &((void **) data)[1];
+    }
+  else
+    {
+      omp_req = 0;
+      target_data = data;
     }
 
   gomp_mutex_lock (&register_lock);
@@ -2603,14 +2609,24 @@ GOMP_offload_register (const void *host_table, int target_type,
 
 /* This function should be called from every offload image while unloading.
    It gets the descriptor of the host func and var tables HOST_TABLE, TYPE of
-   the target, and TARGET_DATA needed by target plugin.  */
+   the target, and DATA.  */
 
 void
 GOMP_offload_unregister_ver (unsigned version, const void *host_table,
-                            int target_type, const void *target_data)
+                            int target_type, const void *data)
 {
   int i;
 
+  if (GOMP_VERSION_LIB (version) > GOMP_VERSION)
+    gomp_fatal ("Library too old for offload (version %u < %u)",
+               GOMP_VERSION, GOMP_VERSION_LIB (version));
+
+  const void *target_data;
+  if (GOMP_VERSION_LIB (version) > 1)
+    target_data = &((void **) data)[1];
+  else
+    target_data = data;
+
   gomp_mutex_lock (&register_lock);
 
   /* Unload image from all initialized devices.  */