]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libgomp: Fix GOMP_DEVICE_NUM_VAR stringification during offload image load
authorChung-Lin Tang <cltang@codesourcery.com>
Tue, 4 Jan 2022 09:26:23 +0000 (17:26 +0800)
committerChung-Lin Tang <cltang@codesourcery.com>
Tue, 4 Jan 2022 09:31:36 +0000 (17:31 +0800)
In the patch that implemented omp_get_device_num(), there was an error where
the stringification of GOMP_DEVICE_NUM_VAR, which is the macro expanding to
the actual symbol used, was erroneously using the STRINGX() macro in the
libgomp offload image symbol search, and expansion of the variable name
string through the additional layer of preprocessor symbol was not properly
achieved.

This patch fixes this by changing to properly use XSTRING(), also from
include/symcat.h.

libgomp/ChangeLog:

* plugin/plugin-gcn.c (GOMP_OFFLOAD_load_image): Change uses of STRINGX
into XSTRING when looking for GOMP_DEVICE_NUM_VAR in offload image.
* plugin/plugin-nvptx.c (GOMP_OFFLOAD_load_image): Likewise.

(cherry picked from commit fbb592407c9dd244b4cea086cbb90d7bd0bf60bb)

libgomp/plugin/plugin-gcn.c
libgomp/plugin/plugin-nvptx.c

index c760c172229a28a24e05093d700d2430f21a09cb..582c07929f90d697564a9dcce3aa585dff53798f 100644 (file)
@@ -3458,12 +3458,12 @@ GOMP_OFFLOAD_load_image (int ord, unsigned version, const void *target_data,
        }
     }
 
-  GCN_DEBUG ("Looking for variable %s\n", STRINGX (GOMP_DEVICE_NUM_VAR));
+  GCN_DEBUG ("Looking for variable %s\n", XSTRING (GOMP_DEVICE_NUM_VAR));
 
   hsa_status_t status;
   hsa_executable_symbol_t var_symbol;
   status = hsa_fns.hsa_executable_get_symbol_fn (agent->executable, NULL,
-                                                STRINGX (GOMP_DEVICE_NUM_VAR),
+                                                XSTRING (GOMP_DEVICE_NUM_VAR),
                                                 agent->id, 0, &var_symbol);
   if (status == HSA_STATUS_SUCCESS)
     {
index b7669cc1db27430c4f6287f7fd0e67bbdaafe2a3..61cf3ee639d1590b03476a0bed221582f99ad66d 100644 (file)
@@ -1382,7 +1382,7 @@ GOMP_OFFLOAD_load_image (int ord, unsigned version, const void *target_data,
   size_t device_num_varsize;
   CUresult r = CUDA_CALL_NOCHECK (cuModuleGetGlobal, &device_num_varptr,
                                  &device_num_varsize, module,
-                                 STRINGX (GOMP_DEVICE_NUM_VAR));
+                                 XSTRING (GOMP_DEVICE_NUM_VAR));
   if (r == CUDA_SUCCESS)
     {
       targ_tbl->start = (uintptr_t) device_num_varptr;