diff --git a/openmp/libomptarget/src/omptarget.cpp b/openmp/libomptarget/src/omptarget.cpp --- a/openmp/libomptarget/src/omptarget.cpp +++ b/openmp/libomptarget/src/omptarget.cpp @@ -927,6 +927,14 @@ return OFFLOAD_FAIL; } + if (Device.RTL->synchronize) { + rc = Device.RTL->synchronize(device_id, &AsyncInfo); + if (rc != OFFLOAD_SUCCESS) { + DP("Failed to synchronize.\n"); + return OFFLOAD_FAIL; + } + } + // Deallocate (first-)private arrays for (auto it : fpArrays) { int rt = Device.RTL->data_delete(Device.RTLDeviceID, it); @@ -944,8 +952,5 @@ return OFFLOAD_FAIL; } - if (Device.RTL->synchronize) - return Device.RTL->synchronize(device_id, &AsyncInfo); - return OFFLOAD_SUCCESS; }