SWDEV-467102 - Hidden heap init for graph capture
If the graph has kernels that does device side allocation, during packet capture, heap is
allocated because heap pointer has to be added to the AQL packet, and initialized during
graph launch.
Handle race with wait when 2 kernels with device heap are enqueued on multiple streams.
Change-Id: I45933b77fcaf7bc8fdf1bc906462e32b5d8d3688
[ROCm/clr commit: 57156c524d]
This commit is contained in:
1 parent
c8bc9e3f2e
commit
291f079669
9 files changed
+57
-17
No files matched your search
@@ -358,8 +358,7 @@ void GetKernelArgSizeForGraph(std::vector<std::vector<Node>>& parallelLists,
|
||||
// arg size required for all graph kernel nodes to allocate
|
||||
for (const auto& list : parallelLists) {
|
||||
for (auto& node : list) {
|
||||
if (node->GetType() == hipGraphNodeTypeKernel &&
|
||||
!reinterpret_cast<hip::GraphKernelNode*>(node)->HasHiddenHeap()) {
|
||||
if (node->GetType() == hipGraphNodeTypeKernel) {
|
||||
kernArgSizeForGraph += reinterpret_cast<hip::GraphKernelNode*>(node)->GetKerArgSize();
|
||||
} else if (node->GetType() == hipGraphNodeTypeGraph) {
|
||||
auto& childParallelLists = reinterpret_cast<hip::ChildGraphNode*>(node)->GetParallelLists();
|
||||
@@ -375,8 +374,13 @@ hipError_t AllocKernelArgForGraph(std::vector<hip::Node>& topoOrder, hip::Stream
|
||||
hip::GraphExec* graphExec) {
|
||||
hipError_t status = hipSuccess;
|
||||
for (auto& node : topoOrder) {
|
||||
if (node->GetType() == hipGraphNodeTypeKernel &&
|
||||
!reinterpret_cast<hip::GraphKernelNode*>(node)->HasHiddenHeap()) {
|
||||
if (node->GetType() == hipGraphNodeTypeKernel) {
|
||||
// Check if graph requires hidden heap and set as part of graphExec param.
|
||||
static bool initialized = false;
|
||||
if (!initialized && reinterpret_cast<hip::GraphKernelNode*>(node)->HasHiddenHeap()) {
|
||||
graphExec->SetHiddenHeap();
|
||||
initialized = true;
|
||||
}
|
||||
auto kernelNode = reinterpret_cast<hip::GraphKernelNode*>(node);
|
||||
// From the kernel pool allocate the kern arg size required for the current kernel node.
|
||||
address kernArgOffset = nullptr;
|
||||
@@ -591,8 +595,7 @@ hipError_t EnqueueGraphWithSingleList(std::vector<hip::Node>& topoOrder, hip::St
|
||||
accumulate = new amd::AccumulateCommand(*hip_stream, {}, nullptr);
|
||||
}
|
||||
for (int i = 0; i < topoOrder.size(); i++) {
|
||||
if (DEBUG_CLR_GRAPH_PACKET_CAPTURE && topoOrder[i]->GetType() == hipGraphNodeTypeKernel &&
|
||||
!reinterpret_cast<hip::GraphKernelNode*>(topoOrder[i])->HasHiddenHeap()) {
|
||||
if (DEBUG_CLR_GRAPH_PACKET_CAPTURE && topoOrder[i]->GetType() == hipGraphNodeTypeKernel) {
|
||||
if (topoOrder[i]->GetEnabled()) {
|
||||
hip_stream->vdev()->dispatchAqlPacket(topoOrder[i]->GetAqlPacket(),
|
||||
topoOrder[i]->GetKernelName(),
|
||||
@@ -640,6 +643,16 @@ hipError_t GraphExec::Run(hipStream_t stream) {
|
||||
|
||||
if (parallelLists_.size() == 1 &&
|
||||
instantiateDeviceId_ == hip_stream->DeviceId()) {
|
||||
if (DEBUG_CLR_GRAPH_PACKET_CAPTURE) {
|
||||
// If the graph has kernels that does device side allocation, during packet capture, heap is
|
||||
// allocated because heap pointer has to be added to the AQL packet, and initialized during
|
||||
// graph launch.
|
||||
static bool initialized = false;
|
||||
if (!initialized && HasHiddenHeap()) {
|
||||
hip_stream->vdev()->HiddenHeapInit();
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
status = EnqueueGraphWithSingleList(topoOrder_, hip_stream, this);
|
||||
} else if (parallelLists_.size() == 1 &&
|
||||
instantiateDeviceId_ != hip_stream->DeviceId()) {
|
||||
|
||||
Reference in new issue
Block a user