[AMDGPU][Libomptarget][NFC] Remove atmi_place_t
authorPushpinder Singh <Pushpinder.Singh@amd.com>
Wed, 2 Jun 2021 07:22:40 +0000 (07:22 +0000)
committerPushpinder Singh <Pushpinder.Singh@amd.com>
Wed, 2 Jun 2021 10:35:28 +0000 (10:35 +0000)
atmi_place_t has been replaced with int DeviceId.

Reviewed By: JonChesterfield

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

openmp/libomptarget/plugins/amdgpu/impl/atmi.h
openmp/libomptarget/plugins/amdgpu/impl/atmi_runtime.h
openmp/libomptarget/plugins/amdgpu/impl/machine.h
openmp/libomptarget/plugins/amdgpu/impl/rt.h
openmp/libomptarget/plugins/amdgpu/impl/system.cpp
openmp/libomptarget/plugins/amdgpu/src/rtl.cpp

index c1386f115aba3641fa3910573a169d953e581057..45e64060e645f62ac2e93d8438777ebb7320d53d 100644 (file)
@@ -39,25 +39,6 @@ typedef enum atmi_memtype_s {
  *  @{
  */
 
-/**
- * @brief ATMI Compute Place
- */
-typedef struct atmi_place_s {
-  /**
-   * The node in a cluster where computation should occur.
-   * Default is node_id = 0 for local computations.
-   */
-  unsigned int node_id;
-  /**
-   * Device type: CPU, GPU or DSP
-   */
-  atmi_devtype_t type;
-  /**
-   * The device ordinal number ordered by runtime; -1 for any
-   */
-  int device_id;
-} atmi_place_t;
-
 /**
  * @brief ATMI Memory Space/region Structure
  */
index c180ec7092649ef9476f52c4a069d723f1f334f6..1d7dee118628e4829f140f793395f7d908f8eb14 100644 (file)
@@ -51,7 +51,7 @@ extern "C" {
  *
  */
 hsa_status_t atmi_module_register_from_memory_to_place(
-    void *module_bytes, size_t module_size, atmi_place_t place,
+    void *module_bytes, size_t module_size, int DeviceId,
     hsa_status_t (*on_deserialized_data)(void *data, size_t size,
                                          void *cb_state),
     void *cb_state);
index 9250c3b7c66376f9dbae100b4d37d29f5ad14cfa..6c3293e300141900329508e425faab7ac8c2f8bd 100644 (file)
@@ -79,8 +79,7 @@ hsa_amd_memory_pool_t get_memory_pool(const ATLProcessor &proc,
                                       const int mem_id);
 
 extern ATLMachine g_atl_machine;
-template <typename T> T &get_processor(atmi_place_t place) {
-  int dev_id = place.device_id;
+template <typename T> T &get_processor(int dev_id) {
   if (dev_id == -1) {
     // user is asking runtime to pick a device
     // best device of this type? pick 0 for now
index fb33db98f5639910fd8fa35365f843007a9abdec..d1e1a9d5ce1d874433ebcc2cb610c63574838d8c 100644 (file)
@@ -51,7 +51,7 @@ public:
 
   // modules
   static hsa_status_t RegisterModuleFromMemory(
-      void *, size_t, atmi_place_t,
+      void *, size_t, int DeviceId,
       hsa_status_t (*on_deserialized_data)(void *data, size_t size,
                                            void *cb_state),
       void *cb_state, std::vector<hsa_executable_t> &HSAExecutables);
index cbea4ac5997c0f785cffa967ab56149887aecd9f..14a29b93128a09c437fc912baeca7784ed6249cf 100644 (file)
@@ -491,8 +491,7 @@ void init_tasks() {
   std::vector<hsa_agent_t> gpu_agents;
   int gpu_count = g_atl_machine.processorCount<ATLGPUProcessor>();
   for (int gpu = 0; gpu < gpu_count; gpu++) {
-    atmi_place_t place = ATMI_PLACE_GPU(0, gpu);
-    ATLGPUProcessor &proc = get_processor<ATLGPUProcessor>(place);
+    ATLGPUProcessor &proc = get_processor<ATLGPUProcessor>(gpu);
     gpu_agents.push_back(proc.agent());
   }
   atlc.g_tasks_initialized = true;
@@ -1069,16 +1068,15 @@ populate_InfoTables(hsa_executable_symbol_t symbol, int gpu,
 hsa_status_t RegisterModuleFromMemory(
     std::map<std::string, atl_kernel_info_t> &KernelInfoTable,
     std::map<std::string, atl_symbol_info_t> &SymbolInfoTable,
-    void *module_bytes, size_t module_size, atmi_place_t place,
+    void *module_bytes, size_t module_size, int gpu,
     hsa_status_t (*on_deserialized_data)(void *data, size_t size,
                                          void *cb_state),
     void *cb_state, std::vector<hsa_executable_t> &HSAExecutables) {
   hsa_status_t err;
-  int gpu = place.device_id;
   assert(gpu >= 0);
 
   DEBUG_PRINT("Trying to load module to GPU-%d\n", gpu);
-  ATLGPUProcessor &proc = get_processor<ATLGPUProcessor>(place);
+  ATLGPUProcessor &proc = get_processor<ATLGPUProcessor>(gpu);
   hsa_agent_t agent = proc.agent();
   hsa_executable_t executable = {0};
   hsa_profile_t agent_profile;
index c464f0449921ecb69a90e5d367c135ea561543bc..344c1be00f1cc4d53b4498dcdca51a61126addcf 100644 (file)
@@ -90,7 +90,7 @@ namespace core {
 hsa_status_t RegisterModuleFromMemory(
     std::map<std::string, atl_kernel_info_t> &KernelInfo,
     std::map<std::string, atl_symbol_info_t> &SymbolInfoTable, void *, size_t,
-    atmi_place_t,
+    int DeviceId,
     hsa_status_t (*on_deserialized_data)(void *data, size_t size,
                                          void *cb_state),
     void *cb_state, std::vector<hsa_executable_t> &HSAExecutables);
@@ -242,11 +242,6 @@ struct KernelTy {
 /// FIXME: we may need this to be per device and per library.
 std::list<KernelTy> KernelsList;
 
-// ATMI API to get gpu and gpu memory place
-static atmi_place_t get_gpu_place(int device_id) {
-  return ATMI_PLACE_GPU(0, device_id);
-}
-
 static std::vector<hsa_agent_t> find_gpu_agents() {
   std::vector<hsa_agent_t> res;
 
@@ -1025,14 +1020,14 @@ template <typename C>
 hsa_status_t module_register_from_memory_to_place(
     std::map<std::string, atl_kernel_info_t> &KernelInfoTable,
     std::map<std::string, atl_symbol_info_t> &SymbolInfoTable,
-    void *module_bytes, size_t module_size, atmi_place_t place, C cb,
+    void *module_bytes, size_t module_size, int DeviceId, C cb,
     std::vector<hsa_executable_t> &HSAExecutables) {
   auto L = [](void *data, size_t size, void *cb_state) -> hsa_status_t {
     C *unwrapped = static_cast<C *>(cb_state);
     return (*unwrapped)(data, size);
   };
   return core::RegisterModuleFromMemory(
-      KernelInfoTable, SymbolInfoTable, module_bytes, module_size, place, L,
+      KernelInfoTable, SymbolInfoTable, module_bytes, module_size, DeviceId, L,
       static_cast<void *>(&cb), HSAExecutables);
 }
 } // namespace
@@ -1239,8 +1234,7 @@ __tgt_target_table *__tgt_rtl_load_binary_locked(int32_t device_id,
     auto &KernelInfo = DeviceInfo.KernelInfoTable[device_id];
     auto &SymbolInfo = DeviceInfo.SymbolInfoTable[device_id];
     hsa_status_t err = module_register_from_memory_to_place(
-        KernelInfo, SymbolInfo, (void *)image->ImageStart, img_size,
-        get_gpu_place(device_id),
+        KernelInfo, SymbolInfo, (void *)image->ImageStart, img_size, device_id,
         [&](void *data, size_t size) {
           if (image_contains_symbol(data, size, "needs_hostcall_buffer")) {
             __atomic_store_n(&DeviceInfo.hostcall_required, true,