File tree Expand file tree Collapse file tree 1 file changed +12
-8
lines changed
offload/plugins-nextgen/common/src Expand file tree Collapse file tree 1 file changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -1337,19 +1337,23 @@ Error PinnedAllocationMapTy::unlockUnmappedHostBuffer(void *HstPtr) {
13371337
13381338Error GenericDeviceTy::synchronize (__tgt_async_info *AsyncInfo,
13391339 bool RemoveQueue) {
1340- std::lock_guard<std::mutex> AllocationGuard{AsyncInfo->Mutex };
1340+ SmallVector<void *, 2 > AllocsToDelete{};
1341+ {
1342+ std::lock_guard<std::mutex> AllocationGuard{AsyncInfo->Mutex };
13411343
1342- if (!AsyncInfo || !AsyncInfo->Queue )
1343- return Plugin::error (ErrorCode::INVALID_ARGUMENT,
1344- " invalid async info queue" );
1344+ if (!AsyncInfo || !AsyncInfo->Queue )
1345+ return Plugin::error (ErrorCode::INVALID_ARGUMENT,
1346+ " invalid async info queue" );
13451347
1346- if (auto Err = synchronizeImpl (*AsyncInfo, RemoveQueue))
1347- return Err;
1348+ if (auto Err = synchronizeImpl (*AsyncInfo, RemoveQueue))
1349+ return Err;
1350+
1351+ std::swap (AllocsToDelete, AsyncInfo->AssociatedAllocations );
1352+ }
13481353
1349- for (auto *Ptr : AsyncInfo-> AssociatedAllocations )
1354+ for (auto *Ptr : AllocsToDelete )
13501355 if (auto Err = dataDelete (Ptr, TargetAllocTy::TARGET_ALLOC_DEVICE))
13511356 return Err;
1352- AsyncInfo->AssociatedAllocations .clear ();
13531357
13541358 return Plugin::success ();
13551359}
You can’t perform that action at this time.
0 commit comments