[Openmp-commits] [openmp] d642156 - [libomptarget][nfc] Hoist hsa_init into rtl.cpp

Jon Chesterfield via Openmp-commits openmp-commits at lists.llvm.org
Thu Sep 9 08:09:41 PDT 2021


Author: Jon Chesterfield
Date: 2021-09-09T16:09:34+01:00
New Revision: d642156f8f72a7798a4d890f8c702274ac337cd7

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

LOG: [libomptarget][nfc] Hoist hsa_init into rtl.cpp

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/plugins/amdgpu/impl/system.cpp b/openmp/libomptarget/plugins/amdgpu/impl/system.cpp
index fd10bef39099a..8682fede569db 100644
--- a/openmp/libomptarget/plugins/amdgpu/impl/system.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/impl/system.cpp
@@ -177,12 +177,7 @@ hsa_status_t callbackEvent(const hsa_amd_event_t *event, void *data) {
 }
 
 hsa_status_t atl_init_gpu_context() {
-  hsa_status_t err;
-  err = hsa_init();
-  if (err != HSA_STATUS_SUCCESS)
-    return HSA_STATUS_ERROR;
-
-  err = hsa_amd_register_system_event_handler(callbackEvent, NULL);
+  hsa_status_t err = hsa_amd_register_system_event_handler(callbackEvent, NULL);
   if (err != HSA_STATUS_SUCCESS) {
     printf("[%s:%d] %s failed: %s\n", __FILE__, __LINE__,
            "Registering the system for memory faults", get_error_string(err));

diff  --git a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
index bbf73b1c3a3c1..82bbbad6172cc 100644
--- a/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
+++ b/openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
@@ -691,7 +691,10 @@ class RTLDeviceInfoTy {
       print_kernel_trace = 0;
 
     DP("Start initializing " GETNAME(TARGET_NAME) "\n");
-    hsa_status_t err = core::atl_init_gpu_context();
+    hsa_status_t err = hsa_init();
+    if (err == HSA_STATUS_SUCCESS) {
+      err = core::atl_init_gpu_context();
+    }
     if (err == HSA_STATUS_SUCCESS) {
       HSAInitializeSucceeded = true;
     } else {


        


More information about the Openmp-commits mailing list