[Openmp-commits] [PATCH] D102600: [AMDGPU][Libomptarget] Rename & move g_executables to private

Pushpinder Singh via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Mon May 17 01:25:44 PDT 2021


pdhaliwal created this revision.
pdhaliwal added reviewers: JonChesterfield, gregrodgers, ronlieb.
Herald added subscribers: kerbowa, t-tye, tpr, dstuttard, yaxunl, nhaehnle, jvesely, kzhuravl.
pdhaliwal requested review of this revision.
Herald added subscribers: openmp-commits, wdng.
Herald added a project: OpenMP.

This patch moves g_executables to private member of Runtime class
and is renamed to HSAExecutables following LLVM naming convention.

This movement required making Runtime::Initialize and Runtime::Finalize
non-static. Verified the correctness of this change by running
libomptarget tests on gfx906.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102600

Files:
  openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp
  openmp/libomptarget/plugins/amdgpu/impl/rt.h
  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
@@ -134,8 +134,6 @@
 std::vector<hsa_amd_memory_pool_t> atl_gpu_kernarg_pools;
 hsa_region_t atl_cpu_kernarg_region;
 
-static std::vector<hsa_executable_t> g_executables;
-
 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;
@@ -206,8 +204,8 @@
 atmi_status_t Runtime::Finalize() {
   hsa_status_t err;
 
-  for (uint32_t i = 0; i < g_executables.size(); i++) {
-    err = hsa_executable_destroy(g_executables[i]);
+  for (uint32_t i = 0; i < HSAExecutables.size(); i++) {
+    err = hsa_executable_destroy(HSAExecutables[i]);
     if (err != HSA_STATUS_SUCCESS) {
       printf("[%s:%d] %s failed: %s\n", __FILE__, __LINE__,
              "Destroying executable", get_error_string(err));
@@ -1269,7 +1267,7 @@
     }
 
     // save the executable and destroy during finalize
-    g_executables.push_back(executable);
+    HSAExecutables.push_back(executable);
     return ATMI_STATUS_SUCCESS;
   } else {
     return ATMI_STATUS_ERROR;
Index: openmp/libomptarget/plugins/amdgpu/impl/rt.h
===================================================================
--- openmp/libomptarget/plugins/amdgpu/impl/rt.h
+++ openmp/libomptarget/plugins/amdgpu/impl/rt.h
@@ -50,12 +50,12 @@
   }
 
   // init/finalize
-  static atmi_status_t Initialize();
-  static atmi_status_t Finalize();
+  atmi_status_t Initialize();
+  atmi_status_t Finalize();
   // machine info
   static atmi_machine_t *GetMachineInfo();
   // modules
-  static atmi_status_t RegisterModuleFromMemory(
+  atmi_status_t RegisterModuleFromMemory(
       void *, size_t, atmi_place_t,
       atmi_status_t (*on_deserialized_data)(void *data, size_t size,
                                             void *cb_state),
@@ -78,6 +78,9 @@
 protected:
   // variable to track environment variables
   Environment env_;
+
+private:
+  std::vector<hsa_executable_t> HSAExecutables;
 };
 
 } // namespace core
Index: openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp
===================================================================
--- openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp
+++ openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp
@@ -13,9 +13,11 @@
 /*
  * Initialize/Finalize
  */
-atmi_status_t atmi_init() { return core::Runtime::Initialize(); }
+atmi_status_t atmi_init() { return core::Runtime::getInstance().Initialize(); }
 
-atmi_status_t atmi_finalize() { return core::Runtime::Finalize(); }
+atmi_status_t atmi_finalize() {
+  return core::Runtime::getInstance().Finalize();
+}
 
 /*
  * Machine Info


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102600.345787.patch
Type: text/x-patch
Size: 2851 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210517/ca4e5492/attachment.bin>


More information about the Openmp-commits mailing list