SWDEV-313503 - Returns appropriate error code when destroyed exec graphs are launched
Change-Id: I3ca025494fd27f9ed0cd4534c740f7e19e1c66b3
Этот коммит содержится в:
коммит произвёл
Sourabh Betigeri
родитель
74beb4583c
Коммит
0ae70a4c8d
@@ -997,7 +997,7 @@ hipError_t ihipGraphLaunch(hipGraphExec_t graphExec, hipStream_t stream) {
|
||||
|
||||
hipError_t hipGraphLaunch(hipGraphExec_t graphExec, hipStream_t stream) {
|
||||
HIP_INIT_API(hipGraphLaunch, graphExec, stream);
|
||||
if (graphExec == nullptr || !hip::isValid(stream)) {
|
||||
if (graphExec == nullptr || !hip::isValid(stream) || !hipGraphExec::isGraphExecValid(graphExec)) {
|
||||
HIP_RETURN(hipErrorInvalidValue);
|
||||
}
|
||||
HIP_RETURN_DURATION(ihipGraphLaunch(graphExec, stream));
|
||||
|
||||
@@ -51,6 +51,8 @@ std::unordered_set<hipGraphNode*> hipGraphNode::nodeSet_;
|
||||
amd::Monitor hipGraphNode::nodeSetLock_{"Guards global node set"};
|
||||
std::unordered_set<ihipGraph*> ihipGraph::graphSet_;
|
||||
amd::Monitor ihipGraph::graphSetLock_{"Guards global graph set"};
|
||||
std::unordered_set<hipGraphExec*> hipGraphExec::graphExecSet_;
|
||||
amd::Monitor hipGraphExec::graphExecSetLock_{"Guards global exec graph set"};
|
||||
|
||||
hipError_t hipGraphMemcpyNode1D::ValidateParams(void* dst, const void* src, size_t count,
|
||||
hipMemcpyKind kind) {
|
||||
@@ -673,6 +675,14 @@ ihipGraph* ihipGraph::clone() const{
|
||||
return clone(clonedNodes);
|
||||
}
|
||||
|
||||
bool hipGraphExec::isGraphExecValid(hipGraphExec* pGraphExec) {
|
||||
amd::ScopedLock lock(graphExecSetLock_);
|
||||
if (graphExecSet_.find(pGraphExec) == graphExecSet_.end()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
hipError_t hipGraphExec::CreateQueues(size_t numQueues) {
|
||||
parallelQueues_.reserve(numQueues);
|
||||
for (size_t i = 0; i < numQueues; i++) {
|
||||
|
||||
@@ -290,6 +290,8 @@ struct hipGraphExec {
|
||||
uint currentQueueIndex_;
|
||||
std::unordered_map<Node, Node> clonedNodes_;
|
||||
amd::Command* lastEnqueuedCommand_;
|
||||
static std::unordered_set<hipGraphExec*> graphExecSet_;
|
||||
static amd::Monitor graphExecSetLock_ ;
|
||||
|
||||
public:
|
||||
hipGraphExec(std::vector<Node>& levelOrder, std::vector<std::vector<Node>>& lists,
|
||||
@@ -300,7 +302,10 @@ struct hipGraphExec {
|
||||
nodeWaitLists_(nodeWaitLists),
|
||||
clonedNodes_(clonedNodes),
|
||||
lastEnqueuedCommand_(nullptr),
|
||||
currentQueueIndex_(0) {}
|
||||
currentQueueIndex_(0) {
|
||||
amd::ScopedLock lock(graphExecSetLock_);
|
||||
graphExecSet_.insert(this);
|
||||
}
|
||||
|
||||
~hipGraphExec() {
|
||||
// new commands are launched for every launch they are destroyed as and when command is
|
||||
@@ -309,6 +314,8 @@ struct hipGraphExec {
|
||||
queue->release();
|
||||
}
|
||||
for (auto it = clonedNodes_.begin(); it != clonedNodes_.end(); it++) delete it->second;
|
||||
amd::ScopedLock lock(graphExecSetLock_);
|
||||
graphExecSet_.erase(this);
|
||||
}
|
||||
|
||||
Node GetClonedNode(Node node) {
|
||||
@@ -321,6 +328,9 @@ struct hipGraphExec {
|
||||
return clonedNode;
|
||||
}
|
||||
|
||||
// check executable graphs validity
|
||||
static bool isGraphExecValid(hipGraphExec* pGraphExec);
|
||||
|
||||
std::vector<Node>& GetNodes() { return levelOrder_; }
|
||||
|
||||
amd::HostQueue* GetAvailableQueue() { return parallelQueues_[currentQueueIndex_++]; }
|
||||
|
||||
Ссылка в новой задаче
Block a user