diff --git a/openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp b/openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp --- a/openmp/libomptarget/plugins/amdgpu/impl/atmi.cpp +++ b/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 diff --git a/openmp/libomptarget/plugins/amdgpu/impl/rt.h b/openmp/libomptarget/plugins/amdgpu/impl/rt.h --- a/openmp/libomptarget/plugins/amdgpu/impl/rt.h +++ b/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 HSAExecutables; }; } // namespace core diff --git a/openmp/libomptarget/plugins/amdgpu/impl/system.cpp b/openmp/libomptarget/plugins/amdgpu/impl/system.cpp --- a/openmp/libomptarget/plugins/amdgpu/impl/system.cpp +++ b/openmp/libomptarget/plugins/amdgpu/impl/system.cpp @@ -134,8 +134,6 @@ std::vector atl_gpu_kernarg_pools; hsa_region_t atl_cpu_kernarg_region; -static std::vector g_executables; - std::map KernelNameMap; std::vector> KernelInfoTable; std::vector> 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;