SWDEV-386685 - return proper error

- if graph is already instantiated there cant be a second instance in
  case nodes are free or alloc

Signed-off-by: sdashmiz <shadi.dashmiz@amd.com>
Change-Id: I51e2ca8ade24799da96ed126a26c5ea3bad6f452
This commit is contained in:
sdashmiz
2023-03-06 14:29:39 -05:00
committed by Maneesh Gupta
parent 3a45a965e2
commit f6c36be185
2 changed files with 21 additions and 2 deletions
+11 -2
View File
@@ -1218,12 +1218,20 @@ hipError_t hipGraphAddChildGraphNode(hipGraphNode_t* pGraphNode, hipGraph_t grap
hipError_t ihipGraphInstantiate(hipGraphExec_t* pGraphExec, hipGraph_t graph,
uint64_t flags = 0) {
if (pGraphExec == nullptr || graph == nullptr) {
HIP_RETURN(hipErrorInvalidValue);
return hipErrorInvalidValue;
}
if (graph->IsGraphInstantiated() == true) {
for (auto node : graph->GetNodes()) {
if ((node->GetType() == hipGraphNodeTypeMemAlloc)
|| (node->GetType() == hipGraphNodeTypeMemFree)) {
return hipErrorNotSupported;
}
}
}
std::unordered_map<Node, Node> clonedNodes;
hipGraph_t clonedGraph = graph->clone(clonedNodes);
if (clonedGraph == nullptr) {
HIP_RETURN(hipErrorInvalidValue);
return hipErrorInvalidValue;
}
std::vector<std::vector<Node>> parallelLists;
std::unordered_map<Node, std::vector<Node>> nodeWaitLists;
@@ -1236,6 +1244,7 @@ hipError_t ihipGraphInstantiate(hipGraphExec_t* pGraphExec, hipGraph_t graph,
new hipGraphExec(levelOrder, parallelLists, nodeWaitLists, clonedNodes,
graphExeUserObj, flags);
if (*pGraphExec != nullptr) {
graph->SetGraphInstantiated(true);
return (*pGraphExec)->Init();
} else {
return hipErrorOutOfMemory;
+10
View File
@@ -398,6 +398,7 @@ struct ihipGraph {
hip::Device* device_; //!< HIP device object
hip::MemoryPool* mem_pool_; //!< Memory pool, associated with this graph
std::unordered_set<hipGraphNode*> capturedNodes_;
bool graphInstantiated_;
public:
ihipGraph(hip::Device* device, const ihipGraph* original = nullptr)
@@ -408,6 +409,7 @@ struct ihipGraph {
graphSet_.insert(this);
mem_pool_ = device->GetGraphMemoryPool();
mem_pool_->retain();
graphInstantiated_ = false;
}
~ihipGraph() {
@@ -529,6 +531,14 @@ struct ihipGraph {
void FreeAllMemory() {
mem_pool_->FreeAllMemory();
}
bool IsGraphInstantiated() const {
return graphInstantiated_;
}
void SetGraphInstantiated(bool graphInstantiate) {
graphInstantiated_ = graphInstantiate;
}
};
struct hipGraphExec {