SWDEV-460770 - Handle Graph Exec release

Handle GraphExec instance is destroyed before async launch completes
GraphExec instance is destroyed after async launch completes
GraphExec instance is destroyed without a launch

Change-Id: I45a7c82295fea916c7559bd8f796df710513aea1


[ROCm/clr commit: bf4d10ff61]
This commit is contained in:
Anusha GodavarthySurya authored and Maneesh Gupta committed 2024-05-28 06:28:17 +00:00
1 parent 3a67addd48
commit 085703c225
7 files changed
+64 -8

No files matched your search

+11 -1
View File
@@ -27,6 +27,8 @@
#include "hip_mempool_impl.hpp"
namespace hip {
extern std::unordered_map<GraphExec*, std::pair<hip::Stream*, bool>> GraphExecStatus_;
extern amd::Monitor GraphExecStatusLock_;
std::vector<hip::Stream*> g_captureStreams;
amd::Monitor g_captureStreamsLock{"StreamCaptureGlobalList"};
@@ -1396,8 +1398,16 @@ hipError_t hipGraphExecDestroy(hipGraphExec_t pGraphExec) {
if (pGraphExec == nullptr) {
HIP_RETURN(hipErrorInvalidValue);
}
amd::ScopedLock lock(GraphExecStatusLock_);
hip::GraphExec* ge = reinterpret_cast<hip::GraphExec*>(pGraphExec);
delete ge;
// bool found = false;
if (GraphExecStatus_.find(ge) == GraphExecStatus_.end()) {
ge->release();
} else {
// graph execution is under progress. destroy graphExec during next sync point
auto pair = GraphExecStatus_[ge];
GraphExecStatus_[ge] = std::make_pair(pair.first, true);
}
HIP_RETURN(hipSuccess);
}