Merge topic 'release-deadlock'

58fc4d826 Fix potential deadlock in distributed contour tree

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3024
This commit is contained in:
Gunther Weber 2023-05-16 21:02:04 +00:00 committed by Kitware Robot
commit 149a6c3a29
3 changed files with 11 additions and 25 deletions

@ -467,8 +467,12 @@ void HierarchicalAugmenter<FieldType>::RetrieveInAttachmentPoints()
template <typename FieldType>
void HierarchicalAugmenter<FieldType>::ReleaseSwapArrays()
{ // ReleaseSwapArrays()
this->OutData.ReleaseResources();
this->InData.ReleaseResources();
// Rather than explicitly delete the arrays, we are going to "forget" them and
// just release our reference count on them. If no one else is using them, the
// memory will actually be deleted. But if an array is being used, it will
// continue to be managed until it is not.
this->OutData = decltype(this->OutData){};
this->InData = decltype(this->InData){};
} // ReleaseSwapArrays()

@ -127,7 +127,10 @@ public:
blockData->HierarchicalAugmenter.PrepareOutAttachmentPoints(round);
// TODO/FIXME: Correct function? Correct round?
rp.enqueue(target, blockData->HierarchicalAugmenter.OutData);
// TODO/FIXME: Is it save to already release HierarchicalAugmenter.OutData (and InData) here. Don't we free the arrays before the other block had the chance to complete its rp.dequeue?
// Note: HierarchicalAugmenter.ReleaseSwapArrays() does not necessarily delete the
// arrays. Rather, it releases the reference to them. If, for example, the data
// for HierarchicalAugmenter.OutData is still in flight, the data will continue to
// exist until it is sent.
blockData->HierarchicalAugmenter.ReleaseSwapArrays();
}
}

@ -101,34 +101,13 @@ public:
}
/// Destructor
~HierarchicalAugmenterInOutData();
/// Clear all arrays
void ReleaseResources();
~HierarchicalAugmenterInOutData() = default;
/// Print contents fo this objects
std::string DebugPrint(std::string message, const char* fileName, long lineNum);
}; // class HierarchicalAugmenterInOutData
template <typename FieldType>
HierarchicalAugmenterInOutData<FieldType>::~HierarchicalAugmenterInOutData()
{
this->ReleaseResources();
}
// routine to release memory used for out arrays
template <typename FieldType>
void HierarchicalAugmenterInOutData<FieldType>::ReleaseResources()
{ // ReleaseResources()
this->GlobalRegularIds.ReleaseResources();
this->DataValues.ReleaseResources();
this->SupernodeIds.ReleaseResources();
this->Superparents.ReleaseResources();
this->SuperparentRounds.ReleaseResources();
this->WhichRounds.ReleaseResources();
} // ReleaseResources()
template <typename FieldType>
std::string HierarchicalAugmenterInOutData<FieldType>::DebugPrint(std::string message,
const char* fileName,