// If we copied the struct to the host, we need to restore the pointer.
if (ArgTypes[I] & OMP_TGT_MAPTYPE_FROM) {
void **ShadowHstPtrAddr = (void **)Itr->first;
+ // Wait for device-to-host memcopies for whole struct to complete,
+ // before restoring the correct host pointer.
+ if (AsyncInfo.synchronize() != OFFLOAD_SUCCESS)
+ return OFFLOAD_FAIL;
*ShadowHstPtrAddr = Itr->second.HstPtrVal;
DP("Restoring original host pointer value " DPxMOD " for host "
"pointer " DPxMOD "\n",
auto CB = [&](ShadowPtrListTy::iterator &Itr) {
void **ShadowHstPtrAddr = (void **)Itr->first;
+ // Wait for device-to-host memcopies for whole struct to complete,
+ // before restoring the correct host pointer.
+ if (AsyncInfo.synchronize() != OFFLOAD_SUCCESS)
+ return OFFLOAD_FAIL;
*ShadowHstPtrAddr = Itr->second.HstPtrVal;
DP("Restoring original host pointer value " DPxMOD
" for host pointer " DPxMOD "\n",