[Openmp-commits] [PATCH] D102691: [AMDGPU][Libomptarget] Remove global KernelNameMap

Pushpinder Singh via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Fri May 21 01:04:42 PDT 2021


pdhaliwal updated this revision to Diff 346946.
pdhaliwal added a comment.

Added check for .kd in symbol name.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D102691/new/

https://reviews.llvm.org/D102691

Files:
  openmp/libomptarget/plugins/amdgpu/impl/system.cpp


Index: openmp/libomptarget/plugins/amdgpu/impl/system.cpp
===================================================================
--- openmp/libomptarget/plugins/amdgpu/impl/system.cpp
+++ openmp/libomptarget/plugins/amdgpu/impl/system.cpp
@@ -132,7 +132,6 @@
 
 std::vector<hsa_amd_memory_pool_t> atl_gpu_kernarg_pools;
 
-std::map<std::string, std::string> KernelNameMap;
 std::vector<std::map<std::string, atl_kernel_info_t>> KernelInfoTable;
 std::vector<std::map<std::string, atl_symbol_info_t>> SymbolInfoTable;
 
@@ -868,6 +867,16 @@
       return HSA_STATUS_ERROR_INVALID_CODE_OBJECT;
     }
 
+    // Make sure that kernelName + ".kd" == symbolName
+    size_t Found = symbolName.find(kernelName);
+    if (Found == std::string::npos ||
+        symbolName.length() != kernelName.length() + 3 ||
+        symbolName.find(".kd", kernelName.length()) == std::string::npos) {
+      printf("[%s:%d] Kernel name mismatching symbol: %s != %s + .kd\n",
+             __FILE__, __LINE__, symbolName.c_str(), kernelName.c_str());
+      return HSA_STATUS_ERROR_INVALID_CODE_OBJECT;
+    }
+
     atl_kernel_info_t info = {0, 0, 0, 0, 0, 0, 0, 0, 0, {}, {}, {}};
 
     uint64_t sgpr_count, vgpr_count, sgpr_spill_count, vgpr_spill_count;
@@ -922,7 +931,6 @@
     // create a map from symbol to name
     DEBUG_PRINT("Kernel symbol %s; Name: %s; Size: %lu\n", symbolName.c_str(),
                 kernelName.c_str(), kernel_segment_size);
-    KernelNameMap[symbolName] = kernelName;
 
     bool hasHiddenArgs = false;
     if (kernel_segment_size > 0) {
@@ -1027,16 +1035,11 @@
              "Symbol info extraction", get_error_string(err));
       return err;
     }
-    name[name_length] = 0;
+    // remove the suffix .kd from symbol name.
+    name[name_length - 3] = 0;
 
-    if (KernelNameMap.find(std::string(name)) == KernelNameMap.end()) {
-      // did not find kernel name in the kernel map; this can happen only
-      // if the ROCr API for getting symbol info (name) is different from
-      // the comgr method of getting symbol info
-      return HSA_STATUS_ERROR;
-    }
     atl_kernel_info_t info;
-    std::string kernelName = KernelNameMap[std::string(name)];
+    std::string kernelName(name);
     // by now, the kernel info table should already have an entry
     // because the non-ROCr custom code object parsing is called before
     // iterating over the code object symbols using ROCr


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102691.346946.patch
Type: text/x-patch
Size: 2413 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210521/4cbb83ed/attachment.bin>


More information about the Openmp-commits mailing list