SWDEV-444558 - SWDEV-444418 - Fix capturing of AQL packets when kernel arg size is 0

When graph doesn't have kernel nodes.

Change-Id: I6b3b476654d7eedc9ff0cec4b7269168aa115360
This commit is contained in:
Anusha GodavarthySurya
2024-02-05 10:34:58 +00:00
parent f964975db0
commit ca0b50c9ca
2 ha cambiato i file con 28 aggiunte e 24 eliminazioni
+23 -21
Vedi File
@@ -365,35 +365,38 @@ hipError_t GraphExec::CaptureAQLPackets() {
}
}
}
auto device = g_devices[ihipGetDevice()]->devices()[0];
if (device->info().largeBar_) {
// Pad kernel argument buffer with sentinal size bytes to do a readback later
kernArgSizeForGraph += sizeof(int);
kernarg_pool_graph_ =
reinterpret_cast<address>(device->deviceLocalAlloc(kernArgSizeForGraph));
device_kernarg_pool_ = true;
} else {
kernarg_pool_graph_ = reinterpret_cast<address>(
device->hostAlloc(kernArgSizeForGraph, 0, amd::Device::MemorySegment::kKernArg));
}
if (kernArgSizeForGraph != 0) {
if (device->info().largeBar_) {
// Pad kernel argument buffer with sentinal size bytes to do a readback later
kernArgSizeForGraph += sizeof(int);
kernarg_pool_graph_ =
reinterpret_cast<address>(device->deviceLocalAlloc(kernArgSizeForGraph));
device_kernarg_pool_ = true;
} else {
kernarg_pool_graph_ = reinterpret_cast<address>(
device->hostAlloc(kernArgSizeForGraph, 0, amd::Device::MemorySegment::kKernArg));
}
if (kernarg_pool_graph_ == nullptr) {
return hipErrorMemoryAllocation;
if (kernarg_pool_graph_ == nullptr) {
return hipErrorMemoryAllocation;
}
kernarg_pool_size_graph_ = kernArgSizeForGraph;
}
kernarg_pool_size_graph_ = kernArgSizeForGraph;
for (auto& node : topoOrder_) {
if (node->GetType() == hipGraphNodeTypeKernel) {
auto kernelNode = reinterpret_cast<hip::GraphKernelNode*>(node);
// From the kernel pool allocate the kern arg size required for the current kernel node.
address kernArgOffset = allocKernArg(kernelNode->GetKernargSegmentByteSize(),
kernelNode->GetKernargSegmentAlignment());
if (kernArgOffset == nullptr) {
return hipErrorMemoryAllocation;
address kernArgOffset = nullptr;
if (kernelNode->GetKernargSegmentByteSize()) {
kernArgOffset = allocKernArg(kernelNode->GetKernargSegmentByteSize(),
kernelNode->GetKernargSegmentAlignment());
if (kernArgOffset == nullptr) {
return hipErrorMemoryAllocation;
}
}
// Form GPU packet capture for the kernel node.
kernelNode->CaptureAndFormPacket(capture_stream_, kernArgOffset) ;
kernelNode->CaptureAndFormPacket(capture_stream_, kernArgOffset);
}
}
@@ -419,7 +422,6 @@ hipError_t GraphExec::CaptureAQLPackets() {
host_val++;
}
}
ResetQueueIndex();
}
return status;
+5 -3
Vedi File
@@ -597,9 +597,11 @@ struct GraphExec {
// Release the kernel arg memory.
auto device = g_devices[ihipGetDevice()]->devices()[0];
if (DEBUG_CLR_GRAPH_PACKET_CAPTURE) {
device->hostFree(kernarg_pool_graph_, kernarg_pool_size_graph_);
for (auto& element : kernarg_graph_) {
device->hostFree(element, kernarg_graph_size_);
if (kernarg_pool_size_graph_ != 0) {
device->hostFree(kernarg_pool_graph_, kernarg_pool_size_graph_);
for (auto& element : kernarg_graph_) {
device->hostFree(element, kernarg_graph_size_);
}
}
}
amd::ScopedLock lock(graphExecSetLock_);