diff --git a/openmp/libomptarget/plugins/ve/src/rtl.cpp b/openmp/libomptarget/plugins/ve/src/rtl.cpp --- a/openmp/libomptarget/plugins/ve/src/rtl.cpp +++ b/openmp/libomptarget/plugins/ve/src/rtl.cpp @@ -38,6 +38,8 @@ #include "../../common/elf_common.c" +static bool isInit = true; + struct DynLibTy { char *FileName; uint64_t VeoLibHandle; @@ -129,6 +131,8 @@ } ~RTLDeviceInfoTy() { + isInit = false; + DP("Closing VEO contexts\n"); for (auto &ctx : Contexts) { if (ctx != NULL) { if (veo_context_close(ctx) != 0) { @@ -137,6 +141,7 @@ } } + DP("Destroying VEO process handles\n"); for (auto &hdl : ProcHandles) { if (hdl != NULL) { veo_proc_destroy(hdl); @@ -390,6 +395,10 @@ // De-allocate the data referenced by target ptr on the device. In case of // success, return zero. Otherwise, return an error code. int32_t __tgt_rtl_data_delete(int32_t ID, void *TargetPtr) { + if (!isInit) { + // Workaround for memory manager + return OFFLOAD_SUCCESS; + } int ret = veo_free_mem(DeviceInfo.ProcHandles[ID], (uint64_t)TargetPtr); if (ret != 0) {