From 65d3357dbcc66dbf933bf423a822f5f952bda4fe Mon Sep 17 00:00:00 2001 From: Ajay Date: Thu, 19 May 2022 23:13:23 +0000 Subject: [PATCH] SWDEV-337331 - graph feature on Windows Fixes for hipGraphInstantiate OutofMemory issue and soft hang of hipStreamSynchronize. Change-Id: Ic2bb97582c5978ef2e4eb3a1b124483aa412838e [ROCm/clr commit: c06bfa6befddeb92745c343f0e270ab0d6b91566] --- .../clr/hipamd/src/hip_graph_internal.cpp | 20 ++++++++++--------- .../clr/hipamd/src/hip_graph_internal.hpp | 11 +++++----- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/projects/clr/hipamd/src/hip_graph_internal.cpp b/projects/clr/hipamd/src/hip_graph_internal.cpp index 517cab3e96..e6d2afc52e 100644 --- a/projects/clr/hipamd/src/hip_graph_internal.cpp +++ b/projects/clr/hipamd/src/hip_graph_internal.cpp @@ -689,7 +689,8 @@ hipError_t hipGraphExec::CreateQueues(size_t numQueues) { cl_command_queue_properties properties = (callbacks_table.is_enabled() || HIP_FORCE_QUEUE_PROFILING) ? CL_QUEUE_PROFILING_ENABLE : 0; queue = new amd::HostQueue(*hip::getCurrentDevice()->asContext(), - *hip::getCurrentDevice()->devices()[0], properties); + *hip::getCurrentDevice()->devices()[0], properties, + amd::CommandQueue::RealTimeDisabled, amd::CommandQueue::Priority::Normal); bool result = (queue != nullptr) ? queue->create() : false; // Create a host queue @@ -716,7 +717,8 @@ hipError_t hipGraphExec::Init() { hipError_t FillCommands(std::vector>& parallelLists, std::unordered_map>& nodeWaitLists, - std::vector& levelOrder, amd::Command*& rootCommand, + std::vector& levelOrder, + std::vector& rootCommands, amd::Command*& endCommand, amd::HostQueue* queue) { hipError_t status; for (auto& node : levelOrder) { @@ -739,13 +741,14 @@ hipError_t FillCommands(std::vector>& parallelLists, first = false; continue; } - rootCommand = new amd::Marker(*queue, false, {}); + amd::Command* rootCommand = new amd::Marker(*queue, false, {}); amd::Command::EventWaitList waitList; waitList.push_back(rootCommand); if (!singleList.empty()) { auto commands = singleList[0]->GetCommands(); if (!commands.empty()) { commands[0]->updateEventWaitList(waitList); + rootCommands.push_back(rootCommand); } } } @@ -794,17 +797,16 @@ hipError_t hipGraphExec::Run(hipStream_t stream) { return hipErrorInvalidResourceHandle; } UpdateQueue(parallelLists_, queue, this); - amd::Command* rootCommand = nullptr; + std::vector rootCommands; amd::Command* endCommand = nullptr; status = - FillCommands(parallelLists_, nodeWaitLists_, levelOrder_, rootCommand, endCommand, queue); + FillCommands(parallelLists_, nodeWaitLists_, levelOrder_, rootCommands, endCommand, queue); if (status != hipSuccess) { return status; } - - if (rootCommand != nullptr) { - rootCommand->enqueue(); - rootCommand->release(); + for (auto& cmd : rootCommands) { + cmd->enqueue(); + cmd->release(); } for (auto& node : levelOrder_) { node->EnqueueCommands(stream); diff --git a/projects/clr/hipamd/src/hip_graph_internal.hpp b/projects/clr/hipamd/src/hip_graph_internal.hpp index 6477235799..55d53cb910 100644 --- a/projects/clr/hipamd/src/hip_graph_internal.hpp +++ b/projects/clr/hipamd/src/hip_graph_internal.hpp @@ -37,7 +37,8 @@ typedef hipGraphNode* Node; hipError_t ihipValidateKernelParams(const hipKernelNodeParams* pNodeParams); hipError_t FillCommands(std::vector>& parallelLists, std::unordered_map>& nodeWaitLists, - std::vector& levelOrder, amd::Command*& rootCommand, + std::vector& levelOrder, + std::vector& rootCommands, amd::Command*& endCommand, amd::HostQueue* queue); void UpdateQueue(std::vector>& parallelLists, amd::HostQueue*& queue, hipGraphExec* ptr); @@ -394,12 +395,12 @@ struct hipChildGraphNode : public hipGraphNode { return status; } commands_.reserve(2); - amd::Command* rootCommand = nullptr; + std::vector rootCommands; amd::Command* endCommand = nullptr; - status = FillCommands(parallelLists_, nodeWaitLists_, childGraphlevelOrder_, rootCommand, + status = FillCommands(parallelLists_, nodeWaitLists_, childGraphlevelOrder_, rootCommands, endCommand, queue); - if (rootCommand != nullptr) { - commands_.push_back(rootCommand); + for (auto& cmd : rootCommands) { + commands_.push_back(cmd); } if (endCommand != nullptr) { commands_.push_back(endCommand);