[Openmp-commits] [openmp] 486110e - [AMDGPU][Libomptarget] Remove global KernelNameMap

Pushpinder Singh via Openmp-commits openmp-commits at lists.llvm.org
Mon May 24 01:46:19 PDT 2021


Author: Pushpinder Singh
Date: 2021-05-24T08:46:08Z
New Revision: 486110eb413446dfa835d880bfd1c0d6bbe9f120

URL: https://github.com/llvm/llvm-project/commit/486110eb413446dfa835d880bfd1c0d6bbe9f120
DIFF: https://github.com/llvm/llvm-project/commit/486110eb413446dfa835d880bfd1c0d6bbe9f120.diff

LOG: [AMDGPU][Libomptarget] Remove global KernelNameMap

KernelNameMap contains entries like "key.kd" => key which clearly
could be replaced by simple logic of removing suffix from the key.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D102691

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/plugins/amdgpu/impl/system.cpp b/openmp/libomptarget/plugins/amdgpu/impl/system.cpp
index 3998cbddecc26..92b7d72cfbcf7 100644
--- a/openmp/libomptarget/plugins/amdgpu/impl/system.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/impl/system.cpp
@@ -132,7 +132,6 @@ ATLMachine g_atl_machine;
 
 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,13 @@ static hsa_status_t get_code_object_custom_metadata(void *binary,
       return HSA_STATUS_ERROR_INVALID_CODE_OBJECT;
     }
 
+    // Make sure that kernelName + ".kd" == symbolName
+    if ((kernelName + ".kd") != symbolName) {
+      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;
@@ -919,11 +925,6 @@ static hsa_status_t get_code_object_custom_metadata(void *binary,
       return HSA_STATUS_ERROR_INVALID_CODE_OBJECT;
     }
 
-    // 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) {
       uint64_t argsSize;
@@ -1027,16 +1028,11 @@ static hsa_status_t populate_InfoTables(hsa_executable_t executable,
              "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 
diff erent 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


        


More information about the Openmp-commits mailing list