[Openmp-commits] [openmp] cc8661a - [AMDGPU][Libomptarget] Delete g_atmi_initialized

Pushpinder Singh via Openmp-commits openmp-commits at lists.llvm.org
Wed May 26 03:47:05 PDT 2021


Author: Pushpinder Singh
Date: 2021-05-26T10:46:54Z
New Revision: cc8661ac4a20fbbf654187c8072b226b2700d708

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

LOG: [AMDGPU][Libomptarget] Delete g_atmi_initialized

This patch drops g_atmi_initialized and inlines the Initialize &
Finalize methods from Runtime class.

Reviewed By: JonChesterfield

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/plugins/amdgpu/impl/atmi_interop_hsa.cpp b/openmp/libomptarget/plugins/amdgpu/impl/atmi_interop_hsa.cpp
index dc563ee40f7b..dde2f18bea04 100644
--- a/openmp/libomptarget/plugins/amdgpu/impl/atmi_interop_hsa.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/impl/atmi_interop_hsa.cpp
@@ -6,8 +6,6 @@
 #include "atmi_interop_hsa.h"
 #include "internal.h"
 
-using core::atl_is_atmi_initialized;
-
 atmi_status_t atmi_interop_hsa_get_symbol_info(
     const std::map<std::string, atl_symbol_info_t> &SymbolInfoTable,
     atmi_mem_place_t place, const char *symbol, void **var_addr,
@@ -21,8 +19,6 @@ atmi_status_t atmi_interop_hsa_get_symbol_info(
      atmi_memcpy(signal, host_add, var_addr, var_size);
   */
 
-  if (!atl_is_atmi_initialized())
-    return ATMI_STATUS_ERROR;
   atmi_machine_t *machine = atmi_machine_get_info();
   if (!symbol || !var_addr || !var_size || !machine)
     return ATMI_STATUS_ERROR;
@@ -57,8 +53,6 @@ atmi_status_t atmi_interop_hsa_get_kernel_info(
                                   &val);
   */
 
-  if (!atl_is_atmi_initialized())
-    return ATMI_STATUS_ERROR;
   atmi_machine_t *machine = atmi_machine_get_info();
   if (!kernel_name || !value || !machine)
     return ATMI_STATUS_ERROR;

diff  --git a/openmp/libomptarget/plugins/amdgpu/impl/system.cpp b/openmp/libomptarget/plugins/amdgpu/impl/system.cpp
index ac171022bad4..08168da9e838 100644
--- a/openmp/libomptarget/plugins/amdgpu/impl/system.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/impl/system.cpp
@@ -146,8 +146,6 @@ ATLMachine g_atl_machine;
 
 std::vector<hsa_amd_memory_pool_t> atl_gpu_kernarg_pools;
 
-bool g_atmi_initialized = false;
-
 /*
    atlc is all internal global values.
    The structure atl_context_t is defined in atl_internal.h
@@ -163,18 +161,6 @@ atmi_machine_t *Runtime::GetMachineInfo() {
   return &g_atmi_machine;
 }
 
-static void atl_set_atmi_initialized() {
-  // FIXME: thread safe? locks?
-  g_atmi_initialized = true;
-}
-
-static void atl_reset_atmi_initialized() {
-  // FIXME: thread safe? locks?
-  g_atmi_initialized = false;
-}
-
-bool atl_is_atmi_initialized() { return g_atmi_initialized; }
-
 hsa_status_t allow_access_to_all_gpu_agents(void *ptr) {
   std::vector<ATLGPUProcessor> &gpu_procs =
       g_atl_machine.processors<ATLGPUProcessor>();
@@ -186,26 +172,18 @@ hsa_status_t allow_access_to_all_gpu_agents(void *ptr) {
 }
 
 atmi_status_t Runtime::Initialize() {
-  atmi_devtype_t devtype = ATMI_DEVTYPE_GPU;
-  if (atl_is_atmi_initialized())
-    return ATMI_STATUS_SUCCESS;
-
-  if (devtype == ATMI_DEVTYPE_ALL || devtype & ATMI_DEVTYPE_GPU) {
-    atmi_status_t rc = atl_init_gpu_context();
-    if (rc != ATMI_STATUS_SUCCESS) {
-      printf("[%s:%d] %s failed: %s\n", __FILE__, __LINE__, "GPU context init",
-             get_atmi_error_string(atl_init_gpu_context()));
-      return rc;
-    }
+  atmi_status_t rc = atl_init_gpu_context();
+  if (rc != ATMI_STATUS_SUCCESS) {
+    printf("[%s:%d] %s failed: %s\n", __FILE__, __LINE__, "GPU context init",
+           get_atmi_error_string(atl_init_gpu_context()));
+    return rc;
   }
 
-  atl_set_atmi_initialized();
   return ATMI_STATUS_SUCCESS;
 }
 
 atmi_status_t Runtime::Finalize() {
   atmi_status_t rc = ATMI_STATUS_SUCCESS;
-  atl_reset_atmi_initialized();
   hsa_status_t err = hsa_shut_down();
   if (err != HSA_STATUS_SUCCESS) {
     printf("[%s:%d] %s failed: %s\n", __FILE__, __LINE__, "Shutting down HSA",


        


More information about the Openmp-commits mailing list