SWDEV-422207 - Report kernel names for activity profiling

- Report kernel names for optimized graph path
- Refactor code so that we store profiling info in Accumulate command

Change-Id: Ib97735a0239aeb9fc3a50a4bb7126dd0bcadc8af


[ROCm/clr commit: b056686607]
This commit is contained in:
Saleel Kudchadker
2023-11-15 04:27:56 +00:00
parent 153bb15f46
commit cb9a715e04
5 changed files with 55 additions and 21 deletions
@@ -551,6 +551,7 @@ hipError_t GraphExec::Run(hipStream_t stream) {
for (int i = 0; i < topoOrder_.size() - 1; i++) {
if (DEBUG_CLR_GRAPH_PACKET_CAPTURE && topoOrder_[i]->GetType() == hipGraphNodeTypeKernel) {
hip_stream->vdev()->dispatchAqlPacket(topoOrder_[i]->GetAqlPacket(), accumulate);
accumulate->addKernelName(topoOrder_[i]->GetKernelName());
} else {
topoOrder_[i]->SetStream(hip_stream, this);
status = topoOrder_[i]->CreateCommand(topoOrder_[i]->GetQueue());
@@ -561,6 +562,8 @@ hipError_t GraphExec::Run(hipStream_t stream) {
// If last captured packet is kernel, optimize to detect completion of last kernel
// This saves on extra packet submitted to determine end of graph
if (DEBUG_CLR_GRAPH_PACKET_CAPTURE && topoOrder_.back()->GetType() == hipGraphNodeTypeKernel) {
// Add the last kernel node name to the accumulate command
accumulate->addKernelName(topoOrder_.back()->GetKernelName());
accumulate->enqueue();
accumulate->release();
isLastPacketKernel = true;
@@ -183,6 +183,7 @@ struct GraphNode : public hipGraphNodeDOTAttribute {
static amd::Monitor nodeSetLock_;
unsigned int isEnabled_;
uint8_t gpuPacket_[64]; //!< GPU Packet to enqueue during graph launch
std::string capturedKernelName_;
public:
GraphNode(hipGraphNodeType type, std::string style = "", std::string shape = "",
@@ -232,7 +233,10 @@ struct GraphNode : public hipGraphNodeDOTAttribute {
}
// Return gpu packet address to update with actual packet under capture.
uint8_t* GetAqlPacket() { return gpuPacket_; }
hip::Stream* GetQueue() { return stream_; }
void SetKernelName(std::string kernelName) { capturedKernelName_ = kernelName; }
const std::string& GetKernelName() const { return capturedKernelName_; }
hip::Stream* GetQueue() const { return stream_; }
virtual void SetStream(hip::Stream* stream, GraphExec* ptr = nullptr) {
stream_ = stream;
@@ -805,8 +809,11 @@ class GraphKernelNode : public GraphNode {
reinterpret_cast<amd::NDRangeKernelCommand*>(command)->setCapturingState(
true, GetAqlPacket(), kernArgOffset);
// Enqueue command to capture GPU Packet. Packet is not sent to hardware queue.
// Enqueue command to capture GPU Packet. The packet is not submitted to the device.
// The packet is stored in gpuPacket_ and submitted during graph launch.
command->submit(*(command->queue())->vdev());
// Need to ensure if the command is NDRangeKernelCommand if we capture non kernel nodes
SetKernelName(reinterpret_cast<amd::NDRangeKernelCommand*>(command)->kernel().name());
command->release();
}
}